:root {
  color-scheme: light;
  --ivory: #f8f1e5;
  --brown: #2f211c;
  --red: #a93d37;
  --sand: #dfcaa5;
  --paper: #fffaf2;
  --muted: #71635a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--brown);
  background: var(--ivory);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--ivory);
}

button {
  min-height: 44px;
  border: 1px solid var(--brown);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  color: var(--brown);
  background: transparent;
  font: inherit;
  cursor: pointer;
}

button:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}

#app-root {
  width: min(100%, 1120px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 1.25rem 1rem calc(6rem + env(safe-area-inset-bottom));
}

.page-header { margin-bottom: 1.4rem; }
.eyebrow, .notice { margin: 0 0 0.45rem; color: var(--red); font-size: 0.9rem; font-weight: 700; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0.45rem; font-size: clamp(2rem, 7vw, 3.5rem); }
.lede, .meta { color: var(--muted); }

.login-panel, .week-summary, .candidate-card, .placeholder-panel, .content-card, .package-section, .shooting-panel, .preflight-panel, .filmed-form, .published-form, .review-form, .record-card, .review-history, .codex-edit-panel {
  border: 1px solid var(--sand);
  border-radius: 16px;
  background: var(--paper);
  padding: 1rem;
}

.login-panel { display: grid; gap: 1rem; max-width: 34rem; }
.primary { color: var(--paper); background: var(--brown); }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.actions .selected { color: var(--paper); background: var(--red); border-color: var(--red); }

.week-summary { margin-bottom: 1rem; }
.week-summary ul { margin: 0; padding-left: 1.2rem; }
.candidate-list { display: grid; gap: 0.9rem; }
.candidate-card h3 { margin-bottom: 0.35rem; }
.candidate-card p { margin-bottom: 0.5rem; }

.content-filters, .mode-switch { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.content-filters .selected, .mode-switch .selected { color: var(--paper); background: var(--red); border-color: var(--red); }
.content-list, .content-package { display: grid; gap: 0.9rem; }
.content-card h2, .package-section h2 { margin-bottom: 0.45rem; }
.content-detail-header { display: grid; gap: 0.6rem; }
.content-detail-header h1 { margin-bottom: 0; }
.text-button { justify-self: start; border: 0; padding-inline: 0; }
.approved-version { margin: 0; color: var(--muted); font-size: 0.9rem; }
.script-line { padding: 0.85rem 0; border-top: 1px solid var(--sand); }
.script-line:first-of-type { border-top: 0; }
.script-line p:last-child { margin-bottom: 0; }
.english-line, .shooting-english { font-size: 1.15rem; font-weight: 700; }
.shooting-panel { margin-bottom: 0.9rem; }
.next-line { color: var(--muted); }
.preflight-panel, .filmed-form, .published-form, .codex-edit-panel { margin-top: 0.9rem; }
.preflight-panel ul { display: grid; gap: 0.6rem; padding-left: 1.2rem; }
.preflight-panel li button { margin-left: 0.4rem; padding: 0.35rem 0.55rem; }
.filmed-form, .published-form, .review-form { display: grid; gap: 0.8rem; }
.filmed-form label, .published-form label, .review-form label { display: grid; gap: 0.35rem; font-weight: 700; }
.filmed-form input, .filmed-form textarea, .published-form input, .published-form select, .review-form input { width: 100%; border: 1px solid var(--sand); border-radius: 8px; padding: 0.6rem; color: var(--brown); font: inherit; background: var(--paper); }
.empty-state { color: var(--muted); }
button:disabled { cursor: not-allowed; opacity: 0.5; }

.record-section, .review-history { margin-top: 1.2rem; }
.record-list, .review-list { display: grid; gap: 0.9rem; }
.record-section h2, .review-history h2 { margin-bottom: 0.5rem; }
.record-card p:last-child { margin-bottom: 0; }
.conflict-values, .review-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.conflict-value { border: 1px solid var(--sand); border-radius: 10px; padding: 0.75rem; }
.conflict-value h3 { margin-bottom: 0.4rem; }
.conflict-value p { margin-bottom: 0; }
.review-due { color: var(--muted); }
.settings-details { display: grid; gap: 0.5rem; margin: 0 0 1rem; }
.settings-details div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--sand); padding-bottom: 0.35rem; }
.settings-details dt { font-weight: 700; }
.settings-details dd { margin: 0; text-align: right; }

[data-bottom-nav] {
  position: fixed;
  z-index: 5;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem max(0.75rem, env(safe-area-inset-left)) calc(0.5rem + env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-right));
  border-top: 1px solid var(--sand);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
}

[data-bottom-nav] button { flex: 1 1 0; max-width: 9rem; border: 0; }
[data-bottom-nav] button[aria-current="page"] { color: var(--red); font-weight: 700; }

dialog {
  width: min(100% - 2rem, 32rem);
  border: 1px solid var(--sand);
  border-radius: 16px;
  color: var(--brown);
  background: var(--paper);
}
dialog::backdrop { background: rgb(47 33 28 / 45%); }

[data-toast] {
  position: fixed;
  right: 1rem;
  bottom: calc(5rem + env(safe-area-inset-bottom));
  left: 1rem;
  z-index: 10;
  color: var(--paper);
  background: var(--red);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  opacity: 0;
  pointer-events: none;
}
[data-toast]:not(:empty) { opacity: 1; }

@media (max-width: 700px) {
  .candidate-card { padding: 0.9rem; }
  .actions button { flex: 1 1 8rem; }
  [data-bottom-nav] { gap: 0.1rem; }
  [data-bottom-nav] button { padding-inline: 0.25rem; font-size: 0.8rem; }
  .conflict-values, .review-metrics { grid-template-columns: 1fr; }
}
