:root {
  --black: #0a0a0a;
  --anthracite: #171717;
  --ink: #24211d;
  --muted: #6b665f;
  --warm-white: #f8f6f1;
  --paper: #fffdf8;
  --line: #ded7c9;
  --gold: #c8a96b;
  --gold-dark: #a78748;
  --sage: #5e7465;
  --clay: #9a624a;
  --danger: #9b3730;
  --shadow: 0 18px 45px rgba(10, 10, 10, 0.11);
  --radius: 8px;
  --topbar-height: 72px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--warm-white);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100%;
  margin: 0;
  background: var(--warm-white);
}

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

button {
  cursor: pointer;
}

.app-root {
  min-height: 100vh;
}

.noscript {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  text-align: center;
}

.entry-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(28px, 7vw, 88px);
  background: var(--black);
  color: var(--warm-white);
}

.entry-panel {
  width: min(680px, 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
}

.entry-panel h1,
.command-panel h1,
.page-header h1,
.chat-header h1 {
  margin: 0;
  max-width: 820px;
  font-size: 42px;
  line-height: 1.04;
  font-weight: 720;
}

.entry-panel .lead,
.command-panel p,
.page-header p {
  max-width: 640px;
  color: rgba(248, 246, 241, 0.76);
  font-size: 18px;
  line-height: 1.55;
}

.brand-lockup,
.brand-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  font-weight: 700;
}

.brand-button {
  border: 0;
  background: transparent;
  white-space: nowrap;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-block;
  border: 1px solid var(--gold);
  border-radius: 7px;
  background:
    linear-gradient(90deg, transparent 20%, var(--gold) 20%, var(--gold) 32%, transparent 32%),
    linear-gradient(0deg, transparent 20%, var(--gold) 20%, var(--gold) 32%, transparent 32%),
    var(--black);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 28px;
  background: rgba(10, 10, 10, 0.96);
  color: var(--warm-white);
  border-bottom: 1px solid rgba(200, 169, 107, 0.22);
}

.desktop-nav,
.topbar-actions,
.bottom-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sign-out-action {
  min-height: 38px;
}

.nav-item,
.ghost-action {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 14px;
  background: transparent;
  color: rgba(248, 246, 241, 0.72);
}

.nav-item.active,
.nav-item:hover,
.ghost-action:hover {
  border-color: rgba(200, 169, 107, 0.36);
  color: var(--warm-white);
  background: rgba(248, 246, 241, 0.06);
}

.user-chip {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(200, 169, 107, 0.42);
  border-radius: 50%;
  color: var(--gold);
  font-weight: 800;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 104px;
}

.command-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 28px;
  padding: 32px;
  border-radius: var(--radius);
  background: var(--black);
  color: var(--warm-white);
  box-shadow: var(--shadow);
}

.command-panel p {
  margin: 12px 0 0;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.surface,
.metric-card,
.session-item,
.summary-panel,
.empty-state,
.danger-zone {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 1px 0 rgba(10, 10, 10, 0.03);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 32px;
}

.metric-card {
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 18px;
}

.metric-card strong {
  font-size: 30px;
  line-height: 1;
}

.metric-card span,
.session-main small,
.mode-card small,
.saved-feedback span {
  color: var(--muted);
}

.section-head,
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: 0 0 24px;
}

.page-header {
  display: block;
  max-width: 820px;
}

.page-header h1,
.section-head h2,
.feedback-panel h2,
.profile-summary h2,
.account-panel h2,
.notice-panel h2,
.danger-zone h2 {
  margin: 0;
}

.page-header p {
  color: var(--muted);
  margin: 10px 0 0;
}

.session-list {
  display: grid;
  gap: 10px;
}

.session-item {
  min-height: 78px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
}

.session-main {
  min-width: 0;
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.session-main:hover {
  background: #f1ece1;
}

.session-main strong,
.session-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-dot {
  width: 12px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 20px;
  background: var(--gold);
}

.mode-dot.sage,
.mode-card.sage input:checked + .mode-card-body {
  border-color: var(--sage);
}

.mode-dot.clay,
.mode-card.clay input:checked + .mode-card-body {
  border-color: var(--clay);
}

.mode-dot.gold,
.mode-card.gold input:checked + .mode-card-body {
  border-color: var(--gold);
}

.session-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.primary-action,
.secondary-action,
.danger-action {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: var(--radius);
  padding: 0 18px;
  font-weight: 780;
  text-decoration: none;
}

.primary-action {
  border: 1px solid var(--gold);
  background: var(--gold);
  color: var(--black);
}

.primary-action:hover {
  background: #d7bd84;
}

.primary-action:disabled,
.secondary-action:disabled,
.danger-action:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.secondary-action {
  border: 1px solid #c9c0ad;
  background: #fffaf0;
  color: var(--ink);
}

.danger-action {
  border: 1px solid var(--danger);
  background: var(--danger);
  color: white;
}

.compact {
  min-height: 38px;
  padding: 0 12px;
}

.button-icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(10, 10, 10, 0.16);
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
}

.flow-layout {
  display: grid;
  gap: 18px;
}

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

.mode-card {
  display: block;
}

.mode-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-card-body {
  min-height: 172px;
  display: grid;
  align-content: start;
  gap: 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--paper);
}

.mode-card-body:hover {
  background: #fbf4e7;
}

.mode-card strong {
  font-size: 22px;
}

.mode-card em {
  color: var(--ink);
  font-style: normal;
}

.form-stack,
.form-grid,
.feedback-form {
  display: grid;
  gap: 16px;
}

.form-grid,
.feedback-panel,
.profile-summary,
.account-panel,
.topic-card,
.notice-panel,
.danger-zone {
  padding: 24px;
}

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

.form-grid label:nth-child(4),
.form-grid label:nth-child(5),
.form-grid .form-actions {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

label span,
legend {
  font-size: 14px;
}

.input-hint,
.form-error {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
}

.form-error {
  color: var(--danger);
  font-weight: 700;
}

.form-error[hidden] {
  display: none;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cfc6b7;
  border-radius: var(--radius);
  background: #fffdf8;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--gold-dark);
  box-shadow: 0 0 0 3px rgba(200, 169, 107, 0.18);
}

textarea {
  resize: vertical;
  min-height: 92px;
}

.entry-panel input {
  background: rgba(248, 246, 241, 0.08);
  color: var(--warm-white);
  border-color: rgba(248, 246, 241, 0.22);
}

.check-row {
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  font-weight: 500;
  color: rgba(248, 246, 241, 0.78);
}

.check-row input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.chat-layout {
  min-height: calc(100vh - var(--topbar-height) - 32px);
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  overflow: hidden;
}

.chat-header {
  min-height: 86px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.chat-header h1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 22px;
}

.chat-stream {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  overflow-y: auto;
}

.chat-message {
  width: min(760px, 92%);
}

.chat-message.user {
  align-self: flex-end;
}

.message-meta {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.message-content {
  border-radius: var(--radius);
  padding: 16px;
  background: #f0eadf;
  white-space: pre-line;
  line-height: 1.55;
}

.chat-message.user .message-content {
  background: var(--black);
  color: var(--warm-white);
}

.chat-message.assistant .message-content {
  border-left: 4px solid var(--gold);
}

.typing .message-content {
  color: var(--muted);
}

.chat-composer,
.closed-notice {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #f5efe4;
}

.chat-composer textarea {
  min-height: 54px;
  max-height: 140px;
}

.closed-notice {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
}

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

.summary-panel {
  padding: 22px;
}

.summary-panel h2 {
  margin: 0 0 12px;
  font-size: 19px;
}

.summary-panel ul {
  margin: 0;
  padding-left: 20px;
}

.summary-panel li,
.summary-panel p {
  line-height: 1.55;
}

.feedback-panel {
  margin: 16px 0;
  display: grid;
  gap: 18px;
}

.rating-row {
  display: flex;
  gap: 8px;
}

.rating-row label {
  display: block;
}

.rating-row input {
  position: absolute;
  opacity: 0;
}

.rating-row span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.rating-row input:checked + span {
  border-color: var(--gold-dark);
  background: var(--gold);
  color: var(--black);
  font-weight: 800;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.saved-feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.saved-feedback strong {
  font-size: 30px;
}

.saved-feedback p {
  flex-basis: 100%;
  margin: 0;
  color: var(--muted);
}

.profile-summary dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 24px;
}

.profile-summary dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.profile-summary dd {
  margin: 4px 0 0;
}

.account-panel,
.notice-panel,
.danger-zone {
  margin-top: 16px;
}

.account-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.account-panel p {
  max-width: 680px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.danger-zone {
  border-color: rgba(155, 55, 48, 0.36);
}

.empty-state {
  min-height: 240px;
  display: grid;
  gap: 12px;
  justify-items: center;
  place-items: center;
  text-align: center;
  padding: 28px;
}

.empty-state h2 {
  margin: 0;
}

.empty-state p {
  max-width: 460px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.bottom-nav {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 860px) {
  .entry-screen {
    align-items: center;
  }

  .entry-panel h1,
  .command-panel h1,
  .page-header h1 {
    font-size: 34px;
  }

  .topbar {
    padding: 0 16px;
  }

  .desktop-nav {
    display: none;
  }

  .app-shell {
    width: min(100% - 24px, 720px);
    padding-top: 18px;
    padding-bottom: 104px;
  }

  .command-panel,
  .metric-strip,
  .mode-grid,
  .summary-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .command-panel {
    align-items: stretch;
    padding: 24px;
  }

  .form-grid label:nth-child(4),
  .form-grid label:nth-child(5),
  .form-grid .form-actions {
    grid-column: auto;
  }

  .bottom-nav {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 8px;
    border: 1px solid rgba(200, 169, 107, 0.26);
    border-radius: var(--radius);
    background: rgba(10, 10, 10, 0.96);
    box-shadow: var(--shadow);
  }

  .bottom-nav .nav-item {
    min-width: 0;
    padding: 0 8px;
  }
}

@media (max-width: 560px) {
  .entry-screen {
    padding: 28px 20px;
  }

  .profile-summary dl {
    grid-template-columns: 1fr;
  }

  .metric-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .metric-card {
    min-height: 74px;
    padding: 12px;
  }

  .metric-card strong {
    font-size: 24px;
  }

  .metric-card span {
    font-size: 13px;
  }

  .entry-panel h1,
  .command-panel h1,
  .page-header h1 {
    font-size: 30px;
  }

  .topbar-actions .ghost-action {
    display: none;
  }

  .brand-button span:last-child {
    max-width: 155px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .session-item {
    grid-template-columns: minmax(0, 1fr);
  }

  .empty-state {
    min-height: 190px;
    padding: 22px;
  }

  .session-actions {
    justify-content: flex-end;
  }

  .chat-layout {
    min-height: 0;
    height: calc(100vh - var(--topbar-height) - 112px);
  }

  .chat-header {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .chat-stream {
    min-height: 0;
  }

  .chat-header .secondary-action {
    grid-column: 1 / -1;
  }

  .chat-composer,
  .closed-notice,
  .account-panel {
    grid-template-columns: 1fr;
  }

  .account-panel {
    display: grid;
    align-items: stretch;
  }

  .chat-message {
    width: 100%;
  }

  .form-actions {
    justify-content: stretch;
  }

  .form-actions > *,
  .primary-action,
  .secondary-action,
  .danger-action {
    width: 100%;
  }
}
