:root {
  color-scheme: light;
  --bg: #f7f7f3;
  --surface: #ffffff;
  --surface-soft: #fbfbf8;
  --ink: #111719;
  --muted: #697478;
  --subtle: #8a9498;
  --line: rgba(17, 23, 25, 0.1);
  --line-strong: rgba(17, 23, 25, 0.16);
  --teal: #236f68;
  --red: #a84e45;
  --amber: #9a6a17;
  --shadow: 0 18px 58px rgba(17, 23, 25, 0.1);
  --shadow-soft: 0 10px 32px rgba(17, 23, 25, 0.07);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #ffffff 0%, var(--bg) 54%, #efefeb 100%);
  color: var(--ink);
  font-family: var(--font);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.hidden {
  display: none !important;
}

.app {
  min-height: 100vh;
  isolation: isolate;
}

.app-chrome {
  position: fixed;
  inset: 18px auto auto 50%;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(940px, calc(100vw - 28px));
  min-height: 64px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 44px rgba(17, 23, 25, 0.1);
  transform: translateX(-50%);
  backdrop-filter: blur(24px) saturate(1.05);
  -webkit-backdrop-filter: blur(24px) saturate(1.05);
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 218px;
  padding: 0 14px 0 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: var(--ink);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 900;
}

.brand-copy {
  display: grid;
  gap: 1px;
}

.brand-copy strong {
  font-size: 0.94rem;
  line-height: 1.1;
}

.brand-copy small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
}

.primary-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(84px, 1fr));
  gap: 4px;
  width: 100%;
}

.primary-nav button {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #596367;
  font-size: 0.88rem;
  font-weight: 850;
}

.primary-nav button:hover,
.primary-nav button.active {
  background: var(--ink);
  color: #ffffff;
}

.stage {
  width: min(1120px, calc(100vw - 44px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 126px 0 72px;
}

.upload-view {
  display: grid;
  justify-items: center;
  padding-top: clamp(24px, 8vh, 94px);
}

.hero-copy {
  display: grid;
  gap: 16px;
  width: min(800px, 100%);
  text-align: center;
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 950;
  letter-spacing: 0.13em;
  line-height: 1.2;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.hero-copy h1,
.brief-heading h1 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: clamp(2.45rem, 5vw, 5.05rem);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 0.98;
  text-wrap: balance;
}

.hero-subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.45vw, 1.2rem);
  font-weight: 720;
  line-height: 1.55;
}

.upload-card {
  display: grid;
  gap: 14px;
  width: min(900px, 100%);
  margin-top: clamp(34px, 6vh, 68px);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.file-drop {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 96px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface-soft);
  cursor: pointer;
}

.file-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.file-drop-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: var(--ink);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 950;
}

.file-drop strong,
.file-drop small {
  display: block;
  overflow-wrap: anywhere;
}

.file-drop strong {
  margin-bottom: 4px;
  font-size: 1.07rem;
  line-height: 1.25;
}

.file-drop small {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.upload-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(118px, 0.55fr) auto;
  gap: 10px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--subtle);
  font-size: 0.68rem;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink);
  outline: 0;
}

select,
input {
  min-height: 50px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-weight: 760;
}

textarea {
  min-height: 92px;
  padding: 13px 14px;
  border-radius: var(--radius-md);
  resize: vertical;
}

select:focus,
input:focus,
textarea:focus,
.file-drop:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(35, 111, 104, 0.1);
}

.primary-action,
.voice-button,
.icon-button,
.delete-button {
  border: 0;
  font-weight: 900;
}

.primary-action {
  min-height: 50px;
  padding: 0 22px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #ffffff;
  white-space: nowrap;
}

.advanced-panel {
  border-top: 1px solid var(--line);
  padding: 13px 6px 2px;
}

.advanced-panel summary {
  width: fit-content;
  color: var(--teal);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 900;
}

.advanced-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.brief-view {
  display: grid;
  gap: 26px;
}

.brief-heading {
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.brief-heading h1 {
  width: min(880px, 100%);
  font-size: clamp(1.55rem, 2.45vw, 2.65rem);
  line-height: 1.08;
}

.bucket-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
  width: min(1040px, 100%);
  margin: 0 auto;
}

.bucket-card,
.pending-card,
.voice-card,
.status-card {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.bucket-card {
  display: grid;
  align-content: start;
  gap: 16px;
  min-height: 210px;
  padding: 26px;
  border-radius: 22px;
}

.bucket-card h2 {
  margin-bottom: 0;
  color: var(--teal);
  font-size: 0.74rem;
  font-weight: 950;
  letter-spacing: 0.12em;
  line-height: 1.25;
  text-transform: uppercase;
}

.bucket-card:nth-child(3) h2 {
  color: var(--red);
}

.bucket-card p {
  margin-bottom: 0;
  font-size: clamp(0.98rem, 1.02vw, 1.08rem);
  font-weight: 620;
  line-height: 1.58;
  overflow-wrap: anywhere;
}

.pending-card {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  min-height: 220px;
  padding: 28px;
  border-radius: 24px;
  text-align: center;
  place-items: center;
}

.pending-card span {
  color: var(--teal);
  font-size: 0.74rem;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pending-card strong {
  font-size: clamp(1.5rem, 3vw, 2.4rem);
}

.pending-card small {
  max-width: 520px;
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 650;
  line-height: 1.5;
}

.failed-card {
  border-color: rgba(172, 83, 72, 0.28);
}

.failed-card span {
  color: var(--red);
}

.brief-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: min(1040px, 100%);
  margin: 0 auto;
}

.voice-card,
.status-card {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 150px;
  padding: 22px;
  border-radius: 22px;
}

.voice-card {
  grid-template-columns: 1fr auto;
}

.voice-card p:last-child,
.status-card small {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.45;
}

.voice-card strong,
.status-card strong {
  display: block;
  margin-top: 5px;
  font-size: 1.35rem;
}

.voice-button,
.icon-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #ffffff;
}

.drawer {
  position: fixed;
  inset: 96px 22px 22px auto;
  z-index: 40;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(430px, calc(100vw - 44px));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateX(16px);
  transition: opacity 160ms ease, transform 160ms ease;
  backdrop-filter: blur(24px) saturate(1.05);
  -webkit-backdrop-filter: blur(24px) saturate(1.05);
}

.drawer-open .drawer {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.drawer-header h2 {
  margin: 5px 0 0;
  font-size: 1.45rem;
  line-height: 1.15;
}

.drawer-body {
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
  padding: 16px;
}

.article-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.article-select,
.delete-button,
.concept-card,
.empty-drawer {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.article-select {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 14px;
  color: var(--ink);
  text-align: left;
}

.article-select strong {
  overflow: hidden;
  font-size: 0.96rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.article-select span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.delete-button {
  min-width: 74px;
  color: var(--red);
}

.concept-card,
.empty-drawer {
  display: grid;
  gap: 12px;
  padding: 15px;
}

.concept-card span {
  color: var(--teal);
  font-size: 0.68rem;
  font-weight: 950;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.concept-card h3 {
  margin: 4px 0 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.concept-card p,
.empty-drawer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 620;
  line-height: 1.45;
}

.concept-card dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.concept-card dl div {
  display: grid;
  gap: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.concept-card dt {
  color: var(--subtle);
  font-size: 0.66rem;
  font-weight: 950;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.concept-card dd {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.45;
}

.concept-card small {
  color: var(--subtle);
  font-size: 0.78rem;
  font-weight: 800;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(17, 23, 25, 0.08);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.drawer-open .scrim {
  opacity: 1;
  pointer-events: auto;
}

.is-loading .upload-card {
  box-shadow: 0 18px 58px rgba(35, 111, 104, 0.14);
}

@media (max-width: 900px) {
  .app-chrome {
    align-items: stretch;
    border-radius: 28px;
  }

  .brand-pill {
    min-width: 0;
  }

  .brand-copy {
    display: none;
  }

  .primary-nav {
    grid-template-columns: repeat(4, 1fr);
  }

  .stage {
    width: min(760px, calc(100vw - 28px));
    padding-top: 112px;
  }

  .upload-controls,
  .advanced-grid,
  .brief-footer {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 620px) {
  .app-chrome {
    inset: 10px 8px auto;
    width: auto;
    min-height: 54px;
    padding: 6px;
    transform: none;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .primary-nav button {
    min-height: 38px;
    padding: 0 6px;
    font-size: 0.72rem;
  }

  .stage {
    width: calc(100vw - 20px);
    padding-top: 92px;
    padding-bottom: 32px;
  }

  .hero-copy h1,
  .brief-heading h1 {
    font-size: clamp(2rem, 12vw, 3.4rem);
  }

  .upload-card,
  .bucket-card,
  .pending-card,
  .voice-card,
  .status-card {
    border-radius: 20px;
  }

  .file-drop {
    grid-template-columns: 1fr;
  }

  .drawer {
    inset: 76px 10px 10px;
    width: auto;
    border-radius: 22px;
  }
}


.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 14, 18, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.auth-overlay[hidden] { display: none; }
.auth-card {
  width: min(360px, 90vw);
  background: #fff;
  border-radius: 18px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.auth-card h1 { margin: 0; font-size: 22px; }
.auth-sub { margin: 0 0 6px; color: #5f5e5a; font-size: 14px; }
.auth-card input {
  padding: 12px 14px;
  font-size: 15px;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 12px;
}
.auth-actions { display: flex; gap: 10px; margin-top: 6px; }
.auth-actions button {
  flex: 1;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
}
.auth-actions .primary-action { background: #185fa5; color: #fff; border: none; }
.auth-actions #authRegister { background: transparent; border: 1px solid rgba(0,0,0,0.2); }
.auth-error { color: #a32d2d; font-size: 13px; min-height: 16px; }

.brief-view.explainer-only .brief-heading,
.brief-view.explainer-only .brief-footer { display: none; }
.brief-view.explainer-only .bucket-grid { display: block; padding: 0; }
.explainer-frame {
  width: 100%;
  height: 82vh;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 16px;
  background: #fff;
}
