:root {
  --bg: #07120d;
  --bg-2: #0f1f17;
  --panel: rgba(15, 28, 21, 0.86);
  --panel-strong: rgba(12, 24, 18, 0.92);
  --line: rgba(148, 201, 166, 0.18);
  --text: #ecf4ee;
  --muted: #aac1b2;
  --accent: #82f4a9;
  --accent-deep: #29b871;
  --warn: #f6d08a;
  --danger: #f39d9d;
  --chip: rgba(126, 255, 171, 0.12);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Manrope, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 14% 0%, rgba(90, 220, 140, 0.2), transparent 40%),
    radial-gradient(circle at 80% 100%, rgba(40, 130, 90, 0.23), transparent 35%),
    linear-gradient(180deg, #07120d 0%, #06100b 40%, #040b08 100%);
  min-height: 100vh;
  overflow-x: hidden;
}
h1, h2, h3, h4, h5 {
  font-family: "Cormorant Garamond", Georgia, serif;
  letter-spacing: 0.01em;
}
.ambient { position: fixed; width: 42rem; height: 42rem; filter: blur(90px); opacity: .18; pointer-events: none; z-index: 0; }
.ambient-a { top: -15rem; left: -12rem; background: #5af2a4; }
.ambient-b { bottom: -16rem; right: -12rem; background: #1c7f57; }

.intro-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, rgba(4, 12, 9, 0.95), rgba(13, 36, 25, 0.94));
  transition: opacity .5s ease, visibility .5s ease;
}
.intro-screen.hidden { opacity: 0; visibility: hidden; }
.intro-card {
  width: min(720px, calc(100% - 2rem));
  border: 1px solid rgba(143, 235, 176, .28);
  border-radius: 26px;
  padding: 2rem;
  background: linear-gradient(160deg, rgba(10, 27, 18, .9), rgba(14, 38, 27, .75));
  box-shadow: var(--shadow);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.intro-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent 0 14px, rgba(255,255,255,.02) 14px 15px);
  pointer-events: none;
}
.intro-mark {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid rgba(130,244,169,.48);
}
.intro-tagline { color: var(--muted); margin-top: .4rem; }
.progress-bar { height: 9px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; margin: 1rem 0 1.2rem; }
.progress-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-deep)); transition: width .4s ease; }

.app-topbar, .app-shell, .footer, .mobile-actions { position: relative; z-index: 1; }
.app-topbar {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.2rem 1.2rem .8rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: end;
}
.menu-btn { display: none; }
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: .17em;
  font-size: .75rem;
  color: var(--accent);
}
.app-topbar h2 { margin: .2rem 0; font-size: clamp(1.7rem, 2.6vw, 2.7rem); line-height: .97; }
.subhead { margin: 0; max-width: 900px; color: var(--muted); }
.top-actions { display: flex; gap: .7rem; flex-wrap: wrap; }

.app-shell {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 1.2rem 5rem;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: .9rem;
}
.sidebar {
  position: sticky;
  top: .8rem;
  height: calc(100vh - 1.8rem);
  border-radius: 24px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: auto;
}
.sidebar-header { padding: 1rem; border-bottom: 1px solid var(--line); }
.sidebar-header h3 { margin: 0; font-size: 1.35rem; }
.nav-items { padding: .7rem; display: grid; gap: .45rem; }
.nav-item {
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.03);
  border-radius: 14px;
  padding: .6rem .7rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: .5rem;
  align-items: center;
}
.nav-item.active { border-color: rgba(130,244,169,.36); background: rgba(130,244,169,.12); }
.nav-item .chip { font-size: .7rem; border-radius: 999px; padding: .15rem .45rem; border: 1px solid rgba(255,255,255,.1); color: var(--muted); }
.sidebar-footer { padding: .85rem; border-top: 1px solid var(--line); }
.disclaimer-mini { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.45; }

.main-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(320px, .9fr) minmax(440px, 1.3fr);
  gap: .9rem;
  align-items: start;
}
.panel {
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  padding: .95rem;
}
.panel-header { padding: .25rem .2rem .8rem; }
.panel-header h3, .panel-header h4 { margin: 0; }
.panel-header p { margin: .2rem 0 0; color: var(--muted); }
.between { display: flex; justify-content: space-between; gap: .7rem; align-items: center; }
.mode-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; }

.grid { display: grid; gap: .75rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label, fieldset { display: flex; flex-direction: column; gap: .33rem; margin-bottom: .75rem; min-width: 0; }
label span, legend { font-size: .84rem; color: #cfe2d5; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 13px;
  background: rgba(255,255,255,.045);
  color: var(--text);
  padding: .74rem .86rem;
  font: inherit;
  outline: 0;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
}
input:focus, select:focus, textarea:focus { border-color: rgba(130,244,169,.45); background: rgba(255,255,255,.075); transform: translateY(-1px); }
fieldset { border-radius: 16px; border: 1px solid rgba(255,255,255,.08); padding: .75rem; }
fieldset label { margin-bottom: .38rem; flex-direction: row; align-items: center; color: var(--muted); }
input[type="checkbox"] { width: auto; margin: 0; accent-color: #6edd97; }
.preset-grid { display: grid; gap: .42rem; }
.preset-btn { text-align: left; border-radius: 12px; padding: .52rem .65rem; border: 1px solid rgba(255,255,255,.09); background: rgba(255,255,255,.04); color: var(--text); cursor: pointer; }
.preset-btn:hover { border-color: rgba(130,244,169,.32); }

.source-ingest .inline-toggle { flex-direction: row; align-items: center; color: var(--muted); }
.upload-placeholder {
  border: 1px dashed rgba(255,255,255,.18);
  border-radius: 12px;
  padding: .65rem;
  color: var(--muted);
}
.upload-placeholder input { margin-top: .35rem; }

button {
  border: 0;
  border-radius: 999px;
  padding: .72rem 1rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }
.primary { background: linear-gradient(120deg, var(--accent), var(--accent-deep)); color: #032313; box-shadow: 0 10px 26px rgba(41,184,113,.29); }
.ghost { background: rgba(255,255,255,.04); color: var(--text); border: 1px solid rgba(255,255,255,.09); }
.small { padding: .4rem .68rem; font-size: .82rem; }
.file-label { position: relative; overflow: hidden; }
.file-label input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.button-row { display: flex; flex-wrap: wrap; gap: .52rem; }
.button-row.compact button, .button-row.compact .file-label { padding: .55rem .8rem; font-size: .84rem; }

.badge-row { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: .65rem; }
.badge { border: 1px solid rgba(130,244,169,.34); background: var(--chip); color: #c9f4d9; border-radius: 999px; font-size: .75rem; padding: .28rem .55rem; }
.inputs-content, .snapshot {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 15px;
  padding: .75rem;
  margin-bottom: .8rem;
  background: rgba(255,255,255,.02);
}
.snapshot ul, .inputs-content ul { margin: .35rem 0 0; padding-left: 1rem; color: var(--muted); }
.chip-wrap { display: flex; flex-wrap: wrap; gap: .43rem; margin-bottom: 1rem; }
.chip { border-radius: 999px; padding: .25rem .58rem; font-size: .75rem; border: 1px solid rgba(255,255,255,.09); background: rgba(255,255,255,.04); color: var(--muted); }
.chip.warn { color: #f7da9e; border-color: rgba(246,208,138,.36); background: rgba(246,208,138,.12); }
.muted { color: var(--muted); font-size: .82rem; }

.loading-strip {
  margin: .3rem 0 .7rem;
  border-radius: 12px;
  padding: .58rem .74rem;
  background: rgba(130,244,169,.12);
  border: 1px solid rgba(130,244,169,.3);
  animation: pulse 1s ease-in-out infinite alternate;
}
.hidden { display: none !important; }
@keyframes pulse { from { opacity: .65; } to { opacity: 1; } }

.summary-card {
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  padding: .8rem;
  color: var(--muted);
}
.empty-state { font-style: italic; }
.subpanel { margin-top: .8rem; background: rgba(6, 18, 12, .7); }
.progress-shell { width: 100%; border-radius: 999px; height: 9px; background: rgba(255,255,255,.08); overflow: hidden; }
.progress-shell span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-deep)); }
.checklist-grid-mini { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .42rem; margin-top: .7rem; }
.check-item { border-radius: 11px; padding: .45rem .55rem; border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.02); font-size: .82rem; color: var(--muted); }
.check-item.complete { border-color: rgba(130,244,169,.36); color: #d8f5e4; background: rgba(130,244,169,.12); }

.template-library { display: grid; gap: .45rem; max-height: 300px; overflow: auto; }
.template-card {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: .62rem;
  background: rgba(255,255,255,.03);
}
.template-card h5 { margin: 0 0 .22rem; font-size: 1.02rem; }
.template-meta { color: var(--muted); font-size: .8rem; margin-bottom: .35rem; }
.search { max-width: 280px; }
.document-tabs { display: flex; flex-wrap: wrap; gap: .45rem; margin: .45rem 0 .65rem; }
.tab { border-radius: 999px; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.03); color: var(--muted); padding: .42rem .67rem; font-size: .8rem; cursor: pointer; }
.tab.active { border-color: rgba(130,244,169,.35); color: var(--text); background: rgba(130,244,169,.12); }
.document-output {
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.08);
  min-height: 420px;
  max-height: 980px;
  overflow: auto;
  padding: .75rem;
  background: rgba(255,255,255,.02);
}
.doc-card {
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  background: rgba(8, 20, 14, .82);
  margin-bottom: .7rem;
  overflow: hidden;
}
.doc-head { padding: .7rem .7rem .4rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.doc-head h4 { margin: 0; font-size: 1.2rem; }
.doc-tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .35rem; }
.doc-tag { font-size: .72rem; border-radius: 999px; padding: .2rem .5rem; background: rgba(130,244,169,.12); border: 1px solid rgba(130,244,169,.28); color: #cff2dc; }
.doc-section { padding: .65rem .7rem; }
.doc-summary { color: var(--muted); }
.doc-actions { display: flex; flex-wrap: wrap; gap: .42rem; margin-top: .55rem; }
.doc-actions button, .doc-actions select { padding: .43rem .58rem; border-radius: 10px; font-size: .78rem; }
.doc-editor {
  width: 100%;
  min-height: 220px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.09);
  background: rgba(255,255,255,.04);
  color: var(--text);
  padding: .6rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.5;
}
.reasoning {
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 11px;
  background: rgba(255,255,255,.02);
  color: var(--muted);
  padding: .48rem .58rem;
  font-size: .82rem;
}
.recommend-list { margin: .45rem 0 0; padding-left: 1rem; color: var(--muted); }
.cover-page {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 1.1rem;
  background: linear-gradient(160deg, rgba(13,28,20,.95), rgba(10,22,16,.85));
  margin-bottom: .8rem;
}
.cover-page h3 { margin: 0; font-size: 1.7rem; }
.cover-meta { margin-top: .55rem; color: var(--muted); display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .3rem; }
.placeholder { color: var(--muted); padding: .5rem; }

.footer { max-width: 1600px; margin: 0 auto; padding: 0 1.2rem 5.5rem; color: #94aa9b; }
.mobile-actions {
  position: fixed;
  bottom: .55rem;
  left: .5rem;
  right: .5rem;
  z-index: 4;
  display: none;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .5rem;
  padding: .45rem;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  backdrop-filter: blur(14px);
  background: rgba(7, 15, 11, .85);
}

@media (max-width: 1400px) {
  .main-grid { grid-template-columns: 1fr 1fr; }
  .insights-panel { grid-column: 1 / -1; }
}
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 1fr; }
  .main-grid { grid-template-columns: 1fr; }
  .menu-btn { display: inline-block; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(310px, 90vw);
    border-radius: 0 20px 20px 0;
    transform: translateX(-103%);
    transition: transform .25s ease;
    z-index: 10;
  }
  .sidebar.open { transform: translateX(0); }
}
@media (max-width: 760px) {
  .app-topbar { grid-template-columns: auto 1fr; }
  .top-actions { grid-column: span 2; }
  .mode-row, .grid.two, .grid.three { grid-template-columns: 1fr; }
  .checklist-grid-mini { grid-template-columns: 1fr; }
  .cover-meta { grid-template-columns: 1fr; }
  .mobile-actions { display: grid; }
}

@media print {
  body { background: #fff; color: #000; }
  .intro-screen, .ambient, .app-topbar, .sidebar, .intake-panel, .insights-panel, .document-tabs, .mobile-actions, .footer, .template-library, .search, .button-row, .doc-actions { display: none !important; }
  .app-shell, .main-grid { display: block; padding: 0; max-width: none; }
  .output-panel, .subpanel, .document-output, .summary-card, .doc-card, .cover-page { border: 0; box-shadow: none; background: #fff; color: #000; }
  .doc-editor { border: 0; background: #fff; color: #000; padding: 0; min-height: auto; }
  .doc-summary, .reasoning, .recommend-list, .muted { color: #333; border: 0; }
}
