/* monglog Lab — night theme polish.
 * Tokens mirror src/design-system/tokens/{colors,typography}.ts. The RN tokens
 * are the single source of truth; values here are duplicated by hand and
 * should be kept aligned by hand when the RN side moves.
 */

:root {
  /* Atomic palette */
  --ink-950: #07051a;
  --ink-900: #0e0b22;
  --moon-50: #fbf8f2;
  --aurora-700: #4a2c9c;
  --aurora-600: #623cc0;
  --aurora-400: #9971f0;
  --aurora-300: #b493fb;
  --ember-400: #ffa277;
  --ember-500: #f4814e;

  /* Semantic — Night theme */
  --bg-canvas: var(--ink-950);
  --bg-elevated: #110d2b;
  --bg-raised: #1a1538;
  --bg-input: rgba(255, 255, 255, 0.04);

  --fg-strong: var(--moon-50);
  --fg-normal: rgba(251, 248, 242, 0.88);
  --fg-subtle: rgba(251, 248, 242, 0.62);
  --fg-faint: rgba(251, 248, 242, 0.38);
  --fg-on-primary: var(--moon-50);

  --line-soft: rgba(255, 255, 255, 0.08);
  --line-solid: rgba(255, 255, 255, 0.16);
  --line-strong: rgba(255, 255, 255, 0.28);

  --primary: var(--aurora-700);
  --primary-hover: var(--aurora-600);
  --primary-soft: rgba(153, 113, 240, 0.16);
  --primary-glow: var(--aurora-400);
  --accent: var(--ember-400);
  --accent-soft: rgba(255, 162, 119, 0.18);

  --danger: #e66a78;
  --danger-soft: rgba(230, 106, 120, 0.18);
  --danger-line: rgba(230, 106, 120, 0.35);

  /* Mood palette — exact hexes from MOOD_POLICY */
  --mood-calm: #9db6ff;
  --mood-comforting: #ffc2d2;
  --mood-curious: #7dd3c0;
  --mood-hopeful: #f4dc9a;
  --mood-bittersweet: #c8a8ff;
  --mood-unsettled: #e66a78;

  /* Spacing rhythm */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  color-scheme: dark;
  font-family:
    'Pretendard',
    -apple-system,
    BlinkMacSystemFont,
    system-ui,
    sans-serif;
  font-feature-settings:
    'tnum' 1,
    'cv01' 1;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background-color: var(--bg-canvas);
  /* Subtle aurora glow — single soft pair, not a busy nebula. */
  background-image:
    radial-gradient(ellipse 60% 40% at 18% 12%, rgba(153, 113, 240, 0.12), transparent 70%),
    radial-gradient(ellipse 50% 35% at 85% 78%, rgba(255, 162, 119, 0.07), transparent 70%);
  background-attachment: fixed;
  color: var(--fg-normal);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(7, 5, 26, 0.7);
  backdrop-filter: saturate(140%) blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
@media (max-width: 760px) {
  .topbar {
    padding: var(--space-3) var(--space-4);
  }
}

.brand {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0;
  font-weight: 700;
  font-size: 17px;
  line-height: 1.4;
  color: var(--fg-strong);
  letter-spacing: -0.01em;
}
.brand-mark {
  font-size: 13px;
  color: var(--primary-glow);
  font-weight: 600;
}
.brand-sep {
  color: var(--fg-faint);
  font-weight: 400;
  margin: 0 2px;
}
.brand-wordmark {
  font-weight: 800;
  letter-spacing: 0.18em;
  font-size: 12px;
  padding: 2px 8px;
  border: 1px solid var(--line-solid);
  border-radius: 999px;
  color: var(--primary-glow);
  background: var(--primary-soft);
  margin-left: 2px;
}
@media (max-width: 480px) {
  .brand {
    font-size: 15px;
  }
  .brand-wordmark {
    font-size: 10px;
    padding: 1px 6px;
    letter-spacing: 0.14em;
  }
  .auth {
    font-size: 11px;
    gap: var(--space-2);
  }
  .auth button {
    padding: 6px 10px;
    font-size: 12px;
  }
}

.auth {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 13px;
  color: var(--fg-subtle);
}
#auth-status[data-state='signed-in'] {
  color: var(--fg-normal);
}

/* Buttons */
button {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.4;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  transition:
    background-color 200ms cubic-bezier(0.16, 1, 0.3, 1),
    border-color 200ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 200ms cubic-bezier(0.16, 1, 0.3, 1),
    color 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary {
  background: var(--primary);
  color: var(--fg-on-primary);
  border-color: var(--primary-hover);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 8px 24px -12px rgba(74, 44, 156, 0.6);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 0 0 4px var(--primary-soft),
    0 12px 32px -10px rgba(153, 113, 240, 0.55);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
}
.btn-primary:disabled {
  background: var(--bg-raised);
  color: var(--fg-faint);
  border-color: var(--line-soft);
  cursor: not-allowed;
  box-shadow: none;
}
.btn-primary.is-loading {
  background: var(--primary);
  color: var(--fg-on-primary);
  cursor: progress;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn-primary.is-loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(251, 248, 242, 0.3);
  border-top-color: var(--moon-50);
  animation: spinner 800ms linear infinite;
}
@keyframes spinner {
  to {
    transform: rotate(360deg);
  }
}

.btn-ghost {
  background: transparent;
  color: var(--fg-subtle);
  border-color: var(--line-soft);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--fg-strong);
  border-color: var(--line-solid);
  background: var(--bg-input);
}

.btn-run {
  width: 100%;
  padding: var(--space-3) var(--space-5);
  font-size: 15px;
}

/* App shell — sidebar + main */
.shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 0;
  max-width: 1640px;
  margin: 0 auto;
}
@media (max-width: 1000px) {
  .shell {
    grid-template-columns: 1fr;
  }
}

/* Sidebar */
.sidebar {
  padding: var(--space-5) var(--space-4);
  border-right: 1px solid var(--line-soft);
  position: sticky;
  top: 57px;
  align-self: start;
  height: calc(100vh - 57px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
@media (max-width: 1000px) {
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
    padding: var(--space-3) var(--space-4);
    gap: var(--space-2);
  }
}
@media (max-width: 760px) {
  .sidebar-link {
    font-size: 13px;
    padding: var(--space-2) var(--space-3);
  }
  .sidebar-meta {
    display: none;
  }
}

.sidebar-heading {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-faint);
  padding: 0 var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-heading-secondary {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line-soft);
}
.sidebar-subheading {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-faint);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-2) var(--space-2);
  margin-top: var(--space-3);
}
.sidebar-sublink {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--fg-subtle);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  transition:
    background-color 200ms cubic-bezier(0.16, 1, 0.3, 1),
    color 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.sidebar-sublink:hover {
  background: var(--bg-input);
  color: var(--fg-strong);
}
.sidebar-sublink.is-active {
  background: var(--primary-soft);
  color: var(--fg-strong);
}
.sidebar-sublabel {
  flex: 1;
}
.sidebar-clear {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-faint);
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: color 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.sidebar-clear:hover {
  color: var(--fg-subtle);
}

.sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-link {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--fg-subtle);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  transition:
    background-color 200ms cubic-bezier(0.16, 1, 0.3, 1),
    color 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.sidebar-link:hover {
  background: var(--bg-input);
  color: var(--fg-strong);
}
.sidebar-link.is-active {
  background: var(--primary-soft);
  color: var(--fg-strong);
}
.sidebar-link.is-active .sidebar-glyph {
  color: var(--primary-glow);
}
.sidebar-link.is-coming {
  color: var(--fg-faint);
  cursor: default;
}
.sidebar-link.is-coming:hover {
  background: transparent;
  color: var(--fg-faint);
}
.sidebar-glyph {
  text-align: center;
  font-weight: 600;
  color: var(--fg-faint);
}
.sidebar-meta {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

/* Subgroup — content indented under an active sidebar link */
.sidebar-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-subgroup {
  margin: var(--space-1) 0 var(--space-3) calc(18px + var(--space-3));
  padding-left: var(--space-3);
  border-left: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* History list */
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.history-empty {
  padding: var(--space-3);
  font-size: 12px;
  font-style: italic;
  color: var(--fg-faint);
  text-align: center;
}
.history-item {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition:
    background-color 200ms cubic-bezier(0.16, 1, 0.3, 1),
    border-color 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.history-item:hover {
  background: var(--bg-input);
  border-color: var(--line-soft);
}
.history-item-summary {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-normal);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
.history-item-meta {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--fg-faint);
  font-feature-settings:
    'tnum' 1,
    'cv01' 1;
}
.history-item-tone {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--tone-color, var(--fg-faint));
  margin-right: 4px;
  vertical-align: middle;
}

/* Main grid */
.grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 1.2fr;
  gap: var(--space-6);
  padding: var(--space-6);
}
@media (max-width: 1000px) {
  .grid {
    grid-template-columns: 1fr;
    gap: var(--space-5);
    padding: var(--space-5) var(--space-4);
  }
}
@media (max-width: 760px) {
  .grid {
    gap: var(--space-4);
    padding: var(--space-4) var(--space-3);
  }
  .input-col,
  .output-col {
    gap: var(--space-3);
  }
  textarea,
  select {
    font-size: 14px;
    padding: var(--space-2) var(--space-3);
  }
  .btn-run {
    padding: var(--space-3) var(--space-4);
    font-size: 14px;
  }
}

.input-col,
.output-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Form fields */
label {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.field-label {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

textarea,
select {
  font:
    500 15px/1.55 'Pretendard',
    sans-serif;
  color: var(--fg-strong);
  background: var(--bg-input);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  transition:
    border-color 200ms cubic-bezier(0.16, 1, 0.3, 1),
    background-color 200ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}
textarea::placeholder {
  color: var(--fg-faint);
  font-style: italic;
}
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary-glow);
  background: rgba(153, 113, 240, 0.06);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%23B0A9D6' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  padding-right: var(--space-6);
  cursor: pointer;
}

/* Output panel */
.meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-faint);
  padding: 0 var(--space-1);
}
#status {
  color: var(--fg-subtle);
}
#status[data-state='ok'] {
  color: var(--mood-curious);
}
#status[data-state='error'] {
  color: var(--danger);
}
#status[data-state='calling'] {
  color: var(--primary-glow);
  animation: pulse 1.6s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}
#latency {
  margin-left: auto;
  color: var(--fg-faint);
  font-feature-settings:
    'tnum' 1,
    'cv01' 1;
}
.cost-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--line-soft);
  color: var(--fg-subtle);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  font-feature-settings:
    'tnum' 1,
    'cv01' 1;
}
.cost-badge .cost-sep {
  color: var(--fg-faint);
}
#cost-usd {
  color: var(--accent);
}

.result {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-6);
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 48px -28px rgba(0, 0, 0, 0.6);
}

#r-summary {
  margin: 0;
  font-weight: 700;
  font-size: 28px;
  line-height: 1.3;
  letter-spacing: -0.024em;
  color: var(--fg-strong);
}

.row {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.row strong {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.row > p,
.row > span {
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg-normal);
}
#r-interpretation {
  font-size: 17px;
  line-height: 1.7;
  color: var(--fg-normal);
}

/* Tone — colored by emotionalTone via data-tone */
#r-tone {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--tone-soft, var(--bg-input));
  border: 1px solid var(--tone-line, var(--line-solid));
  color: var(--tone-color, var(--fg-strong));
  font-size: 13px;
  font-weight: 600;
  text-transform: lowercase;
  width: fit-content;
}
#r-tone::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--tone-color, var(--fg-strong));
}
#r-tone[data-tone='calm'] {
  --tone-color: var(--mood-calm);
  --tone-soft: rgba(157, 182, 255, 0.12);
  --tone-line: rgba(157, 182, 255, 0.35);
}
#r-tone[data-tone='comforting'] {
  --tone-color: var(--mood-comforting);
  --tone-soft: rgba(255, 194, 210, 0.12);
  --tone-line: rgba(255, 194, 210, 0.35);
}
#r-tone[data-tone='curious'] {
  --tone-color: var(--mood-curious);
  --tone-soft: rgba(125, 211, 192, 0.12);
  --tone-line: rgba(125, 211, 192, 0.35);
}
#r-tone[data-tone='hopeful'] {
  --tone-color: var(--mood-hopeful);
  --tone-soft: rgba(244, 220, 154, 0.12);
  --tone-line: rgba(244, 220, 154, 0.35);
}
#r-tone[data-tone='bittersweet'] {
  --tone-color: var(--mood-bittersweet);
  --tone-soft: rgba(200, 168, 255, 0.12);
  --tone-line: rgba(200, 168, 255, 0.35);
}
#r-tone[data-tone='unsettled'] {
  --tone-color: var(--mood-unsettled);
  --tone-soft: rgba(230, 106, 120, 0.12);
  --tone-line: rgba(230, 106, 120, 0.35);
}

/* Symbols — chip list */
#r-symbols {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
#r-symbols li {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-input);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg-normal);
}

/* Good / Caution — accent bands */
#r-good,
#r-caution {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.55;
  border: 1px solid transparent;
}
#r-good {
  background: rgba(125, 211, 192, 0.08);
  border-color: rgba(125, 211, 192, 0.28);
  color: rgba(251, 248, 242, 0.92);
}
#r-caution {
  background: rgba(255, 162, 119, 0.08);
  border-color: rgba(255, 162, 119, 0.28);
  color: rgba(251, 248, 242, 0.92);
}

#r-safety {
  font-size: 13px;
  line-height: 1.55;
  color: var(--fg-subtle);
  font-style: italic;
}

/* Raw JSON details */
details {
  border-top: 1px solid var(--line-soft);
  padding-top: var(--space-4);
  margin-top: var(--space-2);
}
details summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-faint);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  transition: color 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
details summary::-webkit-details-marker {
  display: none;
}
details summary::before {
  content: '▸';
  font-size: 10px;
  color: var(--fg-faint);
  transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
details[open] summary::before {
  transform: rotate(90deg);
}
details summary:hover {
  color: var(--fg-subtle);
}
details pre {
  margin: var(--space-3) 0 0;
  padding: var(--space-4);
  background: var(--bg-canvas);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  font:
    500 12px/1.55 ui-monospace,
    'SF Mono',
    'Menlo',
    monospace;
  color: var(--fg-subtle);
  overflow: auto;
  max-height: 320px;
}

/* Loading card — visible while interpretDreamLab is in flight */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-7) var(--space-6);
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}
.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 70% 50% at 50% 50%,
    rgba(153, 113, 240, 0.12),
    transparent 70%
  );
  pointer-events: none;
}
.loading-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  z-index: 1;
}
.loading-orb {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--primary-glow);
  box-shadow: 0 0 12px var(--primary-glow);
  opacity: 0.4;
  animation: orb 1.4s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}
.loading-orb:nth-child(2) {
  animation-delay: 200ms;
}
.loading-orb:nth-child(3) {
  animation-delay: 400ms;
}
@keyframes orb {
  0%,
  100% {
    opacity: 0.4;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-4px);
  }
}
.loading-line {
  font-size: 15px;
  font-style: italic;
  line-height: 1.55;
  color: var(--fg-normal);
  z-index: 1;
}
.loading-elapsed {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--fg-faint);
  font-feature-settings:
    'tnum' 1,
    'cv01' 1;
  z-index: 1;
}

/* Idle / empty state */
.idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-6);
  border: 1px dashed var(--line-soft);
  border-radius: var(--radius-lg);
  color: var(--fg-faint);
  text-align: center;
}
.idle-glyph {
  font-size: 28px;
  color: var(--primary-glow);
  letter-spacing: 0.2em;
}
.idle-line {
  font-size: 14px;
  font-style: italic;
  line-height: 1.55;
  max-width: 32ch;
}

/* Page (history / usage) */
.page {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-6);
  max-width: 1100px;
  width: 100%;
}
@media (max-width: 1000px) {
  .page {
    padding: var(--space-5) var(--space-4);
  }
}
@media (max-width: 760px) {
  .page {
    padding: var(--space-4) var(--space-3);
    gap: var(--space-4);
  }
  .page-title {
    font-size: 20px;
  }
  .page-sub {
    font-size: 13px;
  }
  .filters {
    padding: var(--space-3);
  }
  .filter-row {
    gap: var(--space-2);
  }
  .filter-label {
    min-width: 0;
    flex-basis: 100%;
  }
  .harness-card {
    padding: var(--space-4);
  }
  .stat-card {
    padding: var(--space-3);
  }
  .stat-value {
    font-size: 22px;
  }
  .history-card {
    padding: var(--space-3);
  }
  .history-card-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
  .history-card-stats {
    margin-left: 0;
  }
  .dist-table th,
  .dist-table td {
    padding: var(--space-2) var(--space-3);
    font-size: 12px;
  }
}
.page-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.018em;
  color: var(--fg-strong);
}
.page-sub {
  margin: 0;
  font-size: 14px;
  color: var(--fg-subtle);
}

/* Filters */
.filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
}
.filter-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.filter-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
  min-width: 56px;
}
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  font:
    600 12px/1.4 'Pretendard',
    sans-serif;
  letter-spacing: -0.005em;
  color: var(--fg-subtle);
  background: var(--bg-input);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  transition:
    background-color 200ms cubic-bezier(0.16, 1, 0.3, 1),
    border-color 200ms cubic-bezier(0.16, 1, 0.3, 1),
    color 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.chip:hover {
  border-color: var(--line-solid);
  color: var(--fg-strong);
}
.chip.is-active {
  background: var(--primary-soft);
  border-color: var(--primary-glow);
  color: var(--fg-strong);
}

/* History cards (history page) */
.history-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.history-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
}
.history-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.history-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--fg-subtle);
}
.history-card-meta .history-card-sep {
  color: var(--fg-faint);
}
.history-card-meta .history-card-caller {
  font-weight: 600;
  color: var(--fg-normal);
}
.history-card-meta .history-card-model {
  font-weight: 600;
  color: var(--primary-glow);
  font-feature-settings:
    'tnum' 1,
    'cv01' 1;
}
.history-card-stats {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-faint);
  letter-spacing: 0.04em;
  font-feature-settings:
    'tnum' 1,
    'cv01' 1;
}
.history-card-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--fg-strong);
}
.history-card-body {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg-subtle);
  font-style: italic;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.history-card-details summary {
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-faint);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--space-1);
}
.history-card-details summary::-webkit-details-marker {
  display: none;
}
.history-card-details summary::before {
  content: '▸';
  font-size: 10px;
  transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.history-card-details[open] summary::before {
  transform: rotate(90deg);
}
.history-card-detail {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line-soft);
}
.history-card-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.history-card-row strong {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.history-card-row p {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg-normal);
}
.history-card-raw {
  margin: 0;
  padding: var(--space-3);
  background: var(--bg-canvas);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  font:
    500 11px/1.55 ui-monospace,
    'SF Mono',
    'Menlo',
    monospace;
  color: var(--fg-subtle);
  overflow: auto;
  max-height: 280px;
}

/* Harness card grid (home page) */
.harness-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-4);
}
.harness-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition:
    border-color 200ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 200ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.harness-card.is-available {
  cursor: pointer;
}
.harness-card.is-available:hover {
  border-color: var(--primary-glow);
  transform: translateY(-2px);
  box-shadow: 0 16px 32px -20px rgba(153, 113, 240, 0.5);
}
.harness-card.is-coming {
  opacity: 0.55;
  cursor: default;
}
.harness-card-glyph {
  font-size: 24px;
  color: var(--primary-glow);
  letter-spacing: 0.1em;
}
.harness-card.is-coming .harness-card-glyph {
  color: var(--fg-faint);
}
.harness-card-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.018em;
  color: var(--fg-strong);
}
.harness-card-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg-subtle);
}
.harness-card-stats {
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--fg-faint);
  font-feature-settings:
    'tnum' 1,
    'cv01' 1;
}

/* Stats grid (usage page) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--fg-strong);
  letter-spacing: -0.018em;
  font-feature-settings:
    'tnum' 1,
    'cv01' 1;
}
.stat-sub {
  font-size: 12px;
  color: var(--fg-subtle);
  font-feature-settings:
    'tnum' 1,
    'cv01' 1;
}

/* Distribution tables (usage page) */
.dist-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.dist-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.dist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.dist-table th,
.dist-table td {
  padding: var(--space-2) var(--space-4);
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line-soft);
}
.dist-table tbody tr:last-child td {
  border-bottom: 0;
}
.dist-table th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
  background: rgba(255, 255, 255, 0.02);
}
.dist-table td {
  color: var(--fg-normal);
}
.dist-table .num {
  text-align: right;
  font-feature-settings:
    'tnum' 1,
    'cv01' 1;
}
.dist-empty {
  text-align: center;
  color: var(--fg-faint);
  font-style: italic;
}

/* Error */
.error {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  background: var(--danger-soft);
  border: 1px solid var(--danger-line);
  border-radius: var(--radius-md);
  color: var(--fg-strong);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  font-family: inherit;
}

/* Access gate — covers the page until sign-in + allow-list probe pass.
 * [data-lab-locked] is set on <body> in the page HTML (no flash) and removed
 * by mountLabGate() once access is granted. */
.lab-gate {
  display: none;
}
body[data-lab-locked] .shell {
  display: none;
}
body[data-lab-locked] .lab-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 72px);
  padding: var(--space-6) var(--space-4);
}
.lab-gate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-3);
  max-width: 420px;
  padding: var(--space-7) var(--space-6);
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px -32px rgba(0, 0, 0, 0.6);
}
.lab-gate-icon {
  font-size: 32px;
  line-height: 1;
}
.lab-gate-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.018em;
  color: var(--fg-strong);
}
.lab-gate-message {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--fg-subtle);
  word-break: keep-all;
}
.lab-gate-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
