:root {
  --bg: #f5efe6;
  --panel: #fff9f2;
  --ink: #1b1b1b;
  --muted: #56606b;
  --accent: #0f4c81;
  --accent-2: #d05c3b;
  --chip: #f0e2d6;
  --chip-border: #e2cbb8;
  --shadow: 0 24px 60px rgba(17, 30, 45, 0.12);
}

.toast-error {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #7b1d1d;
  color: #fde8e8;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  animation: fadeInDown 0.3s ease;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top right, #ffe8d2 0%, transparent 45%),
    radial-gradient(circle at 20% 20%, #e0f1ff 0%, transparent 40%),
    var(--bg);
  min-height: 100vh;
}

h1,
h2 {
  font-family: "Palatino Linotype", "Book Antiqua", serif;
}

.ambient {
  position: fixed;
  inset: 10% 12% auto auto;
  width: 280px;
  height: 280px;
  background: conic-gradient(from 140deg, #d05c3b, #f2cfa3, #0f4c81);
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.5;
  pointer-events: none;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 56px;
  animation: fadeUp 0.8s ease;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--accent);
  margin: 0 0 6px;
}

h1 {
  font-size: 40px;
  margin: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  height: 52px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(15, 76, 129, 0.18));
}

.subtitle {
  color: var(--muted);
  max-width: 420px;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 24px;
}

.panel {
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  animation: fadeUp 0.8s ease;
}

.panel:nth-child(2) {
  animation-delay: 0.1s;
}

h2 {
  margin: 18px 0 10px;
  font-size: 18px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

input,
textarea {
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: white;
}

textarea {
  resize: vertical;
}

.grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.list {
  display: grid;
  gap: 16px;
}

.card {
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 16px;
  border-radius: 14px;
  display: grid;
  gap: 12px;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 12px 24px rgba(15, 76, 129, 0.25);
}

.btn.ghost {
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.btn.mini {
  padding: 6px 12px;
  font-size: 12px;
}

.btn.danger {
  background: #f2d4c7;
  color: #7b2e19;
}

.btn.ai-suggest {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: white;
  font-size: 13px;
  margin-top: 8px;
  align-self: flex-start;
  letter-spacing: 0.02em;
}

.btn.ai-suggest:not(:disabled):hover {
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);
}

.btn.ai-suggest:disabled {
  opacity: 0.7;
  cursor: wait;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(17, 30, 45, 0.15);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-input {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chip {
  background: var(--chip);
  border: 1px solid var(--chip-border);
  padding: 6px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.chip-x {
  border: none;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}

.label {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 6px;
}

.latex {
  width: 100%;
  font-family: "Courier New", monospace;
  background: #0f1b2a;
  color: #e2f1ff;
  border: none;
  padding: 12px;
}

.log {
  background: #111722;
  color: #d5e2f0;
  padding: 12px;
  border-radius: 12px;
  min-height: 120px;
  overflow: auto;
}

.pdf iframe {
  width: 100%;
  height: 480px;
  border: none;
  border-radius: 12px;
  background: white;
}

.muted {
  color: var(--muted);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .grid.two,
  .row {
    grid-template-columns: 1fr;
  }
}
