:root {
  color-scheme: light;
  --canvas: #f3f0e9;
  --canvas-deep: #e8e3da;
  --paper: #fffdf9;
  --paper-soft: #faf7f1;
  --ink: #1e2922;
  --ink-soft: #5f6962;
  --ink-faint: #89918c;
  --pine: #416451;
  --pine-deep: #2f4c3d;
  --pine-dark: #263f33;
  --pine-soft: #dfe8e1;
  --sage: #829686;
  --clay: #b66e50;
  --clay-soft: #f1dfd6;
  --gold: #9a7740;
  --gold-soft: #f0e7d4;
  --danger: #a94f48;
  --danger-soft: #f4dfdc;
  --line: #ddd9d0;
  --line-strong: #c8c3b8;
  --shadow-soft: 0 5px 20px rgba(40, 49, 43, 0.07);
  --shadow: 0 18px 48px rgba(40, 49, 43, 0.11);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --serif: Iowan Old Style, Baskerville, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-family: var(--sans);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 255, 255, 0.88), transparent 29rem),
    var(--canvas);
  font-family: var(--sans);
  line-height: 1.48;
  -webkit-font-smoothing: antialiased;
}

body.sidebar-open {
  overflow: hidden;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}

a {
  color: inherit;
}

img,
svg {
  display: block;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

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

h1,
h2,
h3 {
  text-wrap: balance;
}

h1,
h2 {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -0.03em;
}

h1 {
  margin-bottom: 13px;
  font-size: clamp(42px, 5vw, 66px);
  line-height: 0.99;
}

h2 {
  margin-bottom: 9px;
  font-size: clamp(27px, 3vw, 37px);
  line-height: 1.08;
}

h3 {
  margin-bottom: 7px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.28;
}

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

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: #fff;
  background: var(--pine-deep);
  border-radius: 8px;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.eyebrow {
  margin-bottom: 9px;
  color: var(--pine);
  font-size: 11px;
  font-weight: 780;
  letter-spacing: 0.14em;
  line-height: 1.4;
  text-transform: uppercase;
}

.lead {
  max-width: 690px;
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: clamp(16px, 2vw, 19px);
  line-height: 1.55;
}

.fine-print {
  color: var(--ink-faint);
  font-size: 12px;
}

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

.topbar {
  position: sticky;
  z-index: 60;
  top: 0;
  display: grid;
  min-height: 72px;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  padding: 0 max(24px, env(safe-area-inset-left));
  background: rgba(243, 240, 233, 0.84);
  border-bottom: 1px solid rgba(200, 195, 184, 0.65);
  backdrop-filter: blur(22px) saturate(135%);
}

.brand-lockup {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  color: #fff;
  background: var(--pine-deep);
  border-radius: 12px 12px 12px 5px;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 5px 14px rgba(47, 76, 61, 0.2);
}

.brand-copy {
  display: grid;
  line-height: 1.05;
}

.brand-copy strong {
  font-size: 17px;
}

.brand-copy small {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.topbar-context {
  max-width: 440px;
  margin: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 13px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  padding: 0;
  flex: 0 0 auto;
  place-items: center;
  color: var(--ink-soft);
  background: transparent;
  border-radius: 12px;
  cursor: pointer;
}

.icon-button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.66);
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 17px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.button svg {
  width: 18px;
  height: 18px;
}

.button-primary {
  color: #fff;
  background: var(--pine-deep);
  box-shadow: 0 7px 18px rgba(47, 76, 61, 0.17);
}

.button-primary:hover:not(:disabled) {
  background: var(--pine-dark);
  box-shadow: 0 10px 22px rgba(47, 76, 61, 0.22);
}

.button-secondary {
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(40, 49, 43, 0.04);
}

.button-secondary:hover:not(:disabled) {
  border-color: var(--line-strong);
}

.button-quiet {
  min-height: 38px;
  padding: 0 11px;
  color: var(--pine);
  background: transparent;
}

.button-quiet:hover:not(:disabled) {
  background: var(--pine-soft);
}

.button-danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.button-sm {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 12px;
}

.button.is-loading {
  pointer-events: none;
}

.button.is-loading::before {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  content: "";
  animation: spin 0.75s linear infinite;
}

.button.is-loading svg {
  display: none;
}

.icon-button:focus-visible,
.button:focus-visible,
.mode-tab:focus-visible,
.history-item:focus-visible,
.drop-zone:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(65, 100, 81, 0.24);
  outline-offset: 2px;
}

.app-layout {
  display: grid;
  min-height: calc(100vh - 72px);
  grid-template-columns: 286px minmax(0, 1fr);
}

.history-sidebar {
  position: sticky;
  z-index: 30;
  top: 72px;
  height: calc(100vh - 72px);
  overflow: auto;
  padding: 31px 20px max(26px, env(safe-area-inset-bottom));
  background: rgba(250, 247, 241, 0.7);
  border-right: 1px solid rgba(200, 195, 184, 0.64);
}

.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 4px 21px;
}

.sidebar-head h2 {
  margin: 0;
  font-size: 30px;
}

.sidebar-close,
.history-toggle {
  display: none;
}

.sidebar-new {
  width: 100%;
  margin-bottom: 24px;
}

.history-status {
  display: flex;
  min-height: 96px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink-faint);
  font-size: 12px;
}

.history-status.is-empty {
  align-items: flex-start;
  padding: 18px 8px;
  line-height: 1.55;
  text-align: center;
}

.history-list {
  display: grid;
  gap: 7px;
}

.history-item {
  position: relative;
  display: grid;
  width: 100%;
  min-width: 0;
  grid-template-columns: 42px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 10px;
  padding: 10px 7px 10px 9px;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 13px;
  cursor: pointer;
  text-align: left;
}

.history-item:hover {
  background: rgba(255, 253, 249, 0.74);
  border-color: var(--line);
}

.history-item.is-active {
  background: var(--paper);
  border-color: var(--line);
  box-shadow: 0 4px 14px rgba(40, 49, 43, 0.05);
}

.history-date {
  display: grid;
  width: 42px;
  height: 49px;
  place-items: center;
  align-content: center;
  color: var(--pine-deep);
  background: var(--pine-soft);
  border-radius: 11px 11px 11px 4px;
  line-height: 1;
}

.history-date strong {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
}

.history-date small {
  margin-top: 3px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.history-copy {
  min-width: 0;
}

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

.history-copy strong {
  margin-bottom: 4px;
  font-size: 12px;
}

.history-copy small {
  color: var(--ink-faint);
  font-size: 10px;
}

.history-delete {
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  color: var(--ink-faint);
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0;
}

.history-item:hover .history-delete,
.history-item:focus-within .history-delete,
.history-item.is-active .history-delete {
  opacity: 1;
}

.history-delete:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.history-delete svg {
  width: 15px;
  height: 15px;
}

#main-content {
  min-width: 0;
  min-height: calc(100vh - 72px);
}

.page-shell {
  width: min(calc(100% - 56px), 1380px);
  margin: 0 auto;
  padding: clamp(42px, 5vw, 70px) 0 90px;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 35px;
}

.page-heading h1 {
  max-width: 770px;
}

.document-state {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  color: var(--ink-soft);
  background: rgba(255, 253, 249, 0.65);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.state-dot {
  width: 7px;
  height: 7px;
  background: var(--sage);
  border-radius: 50%;
}

.document-state.is-dirty .state-dot {
  background: var(--gold);
}

.document-state.is-saving .state-dot {
  background: var(--gold);
  animation: breathe 1s ease-in-out infinite;
}

.document-state.is-error {
  color: var(--danger);
}

.document-state.is-error .state-dot {
  background: var(--danger);
}

.notice {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 20px;
  padding: 14px 16px;
  color: #703d37;
  background: var(--danger-soft);
  border: 1px solid rgba(169, 79, 72, 0.2);
  border-radius: 13px;
}

.notice svg {
  width: 21px;
  height: 21px;
  margin-top: 1px;
}

.notice strong {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
}

.notice p {
  margin: 0;
  font-size: 12px;
}

.workspace-grid {
  display: grid;
  max-width: 850px;
  gap: 24px;
}

.workspace-grid.has-script {
  max-width: none;
  grid-template-columns: minmax(400px, 0.78fr) minmax(500px, 1.22fr);
  align-items: start;
}

.content-card,
.script-paper {
  background: rgba(255, 253, 249, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.content-card {
  padding: clamp(23px, 3vw, 34px);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.card-head h2 {
  margin-bottom: 0;
  font-size: clamp(28px, 3vw, 35px);
}

.mode-switch {
  display: inline-grid;
  flex: 0 0 auto;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  background: var(--canvas-deep);
  border-radius: 11px;
}

.mode-tab {
  min-height: 33px;
  padding: 0 11px;
  color: var(--ink-soft);
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
}

.mode-tab.is-active {
  color: var(--pine-deep);
  background: var(--paper);
  box-shadow: 0 2px 7px rgba(40, 49, 43, 0.09);
}

.mode-panel {
  margin-bottom: 23px;
}

.panel-intro {
  margin-bottom: 0;
  padding-bottom: 19px;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.upload-panel {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.drop-zone {
  display: grid;
  min-height: 190px;
  place-items: center;
  align-content: center;
  gap: 7px;
  padding: 25px;
  color: var(--ink-soft);
  background: rgba(223, 232, 225, 0.28);
  border: 1.5px dashed var(--sage);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  background: rgba(223, 232, 225, 0.65);
  border-color: var(--pine);
}

.drop-zone.is-dragging {
  transform: scale(1.006);
}

.drop-zone strong {
  color: var(--ink);
  font-size: 14px;
}

.drop-zone > span:last-child {
  font-size: 11px;
}

.upload-mark {
  display: grid;
  width: 49px;
  height: 49px;
  margin-bottom: 4px;
  place-items: center;
  color: var(--pine);
  background: var(--paper);
  border-radius: 15px 15px 15px 6px;
  box-shadow: 0 4px 14px rgba(40, 49, 43, 0.07);
}

.upload-mark svg {
  width: 23px;
  height: 23px;
}

.capture-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-top: 11px;
}

.capture-thumb {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: var(--canvas-deep);
  border: 1px solid var(--line);
  border-radius: 11px;
}

.capture-thumb img {
  width: 100%;
  height: 94px;
  object-fit: cover;
}

.capture-thumb p {
  margin: 0;
  overflow: hidden;
  padding: 7px 8px;
  color: var(--ink-soft);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.capture-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  width: 27px;
  height: 27px;
  padding: 0;
  place-items: center;
  color: #fff;
  background: rgba(30, 41, 34, 0.72);
  border-radius: 8px;
  cursor: pointer;
  backdrop-filter: blur(7px);
}

.capture-remove svg {
  width: 14px;
  height: 14px;
}

.upload-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 13px;
}

.upload-actions p {
  margin: 0;
}

.ocr-summary {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 11px;
  margin-top: 15px;
  padding: 13px;
  color: var(--pine-deep);
  background: var(--pine-soft);
  border-radius: 12px;
}

.ocr-summary.needs-review {
  color: #73592f;
  background: var(--gold-soft);
}

.ocr-summary-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  background: rgba(255, 255, 255, 0.52);
  border-radius: 10px;
  font-size: 17px;
  font-weight: 800;
}

.ocr-summary strong {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
}

.ocr-summary p {
  margin: 0;
  font-size: 11px;
  line-height: 1.45;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(145px, 0.45fr) minmax(220px, 1fr);
  gap: 17px;
}

.field {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 7px;
}

.field.full {
  grid-column: 1 / -1;
}

.field > span:first-child {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 720;
}

.field small {
  min-height: 0;
  color: var(--ink-faint);
  font-size: 10px;
}

.field-feedback:empty {
  display: none;
}

.field.is-review > span:first-child {
  color: var(--gold);
}

.field.is-review input {
  background: #fffaf0;
  border-color: #c7ac78;
}

.field.is-review .field-feedback {
  display: block;
  color: var(--gold);
  font-weight: 650;
}

.field.is-confident .field-feedback {
  display: block;
  color: var(--pine);
}

.field input,
.section-editor {
  width: 100%;
  color: var(--ink);
  background: #fffefa;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.field input {
  min-height: 45px;
  padding: 0 12px;
}

.field input::placeholder,
.section-editor::placeholder {
  color: #a1a7a3;
}

.field input:focus,
.section-editor:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(65, 100, 81, 0.11);
}

.field input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(169, 79, 72, 0.09);
}

.input-with-prefix {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  overflow: hidden;
  background: #fffefa;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.input-with-prefix:focus-within {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(65, 100, 81, 0.11);
}

.input-with-prefix > span {
  padding-left: 12px;
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 750;
}

.input-with-prefix input {
  border: 0;
  box-shadow: none !important;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 19px;
  margin-top: 27px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.form-actions p {
  max-width: 410px;
  margin: 0;
  color: var(--ink-faint);
  font-size: 10px;
  line-height: 1.5;
}

.form-actions p strong {
  color: var(--ink-soft);
}

.generate-button {
  min-width: 174px;
  flex: 0 0 auto;
}

.script-result {
  min-width: 0;
}

.script-paper {
  overflow: hidden;
}

.script-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: clamp(25px, 3vw, 34px) clamp(22px, 3vw, 36px) 24px;
  border-bottom: 1px solid var(--line);
}

.script-head h2 {
  margin-bottom: 5px;
}

.script-date {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.script-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
}

.script-guidance {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  margin: 18px clamp(22px, 3vw, 36px) 0;
  padding: 12px 13px;
  color: var(--ink-soft);
  background: var(--paper-soft);
  border-radius: 11px;
}

.script-guidance svg {
  width: 18px;
  height: 18px;
  color: var(--pine);
}

.script-guidance p {
  margin: 0;
  font-size: 10px;
  line-height: 1.5;
}

.script-sections {
  display: grid;
  padding: 4px clamp(22px, 3vw, 36px) 7px;
}

.script-section {
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.script-section:last-child {
  border-bottom: 0;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 11px;
}

.section-order {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--pine);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.section-order::before {
  display: grid;
  width: 21px;
  height: 21px;
  place-items: center;
  color: #fff;
  background: var(--pine);
  border-radius: 7px 7px 7px 3px;
  content: attr(data-number);
  font-size: 9px;
}

.section-head h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
}

.copy-section {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.copy-section svg {
  width: 16px;
  height: 16px;
}

.section-cue {
  display: inline-flex;
  margin: 0 0 11px;
  padding: 4px 8px;
  color: #705934;
  background: var(--gold-soft);
  border-radius: 7px;
  font-size: 9px;
  font-weight: 700;
}

.section-editor {
  display: block;
  min-height: 128px;
  padding: 13px 14px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.62;
  resize: vertical;
}

.section-print-text {
  display: none;
}

.script-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 19px clamp(22px, 3vw, 36px);
  background: var(--paper-soft);
  border-top: 1px solid var(--line);
}

.save-message {
  color: var(--ink-faint);
  font-size: 10px;
}

.initial-loading,
.fatal-state {
  display: grid;
  min-height: calc(100vh - 72px);
  align-content: center;
  justify-items: center;
  padding: 40px 20px;
  text-align: center;
}

.initial-loading p {
  margin: 16px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.spinner {
  width: 29px;
  height: 29px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--pine);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.spinner-small {
  width: 17px;
  height: 17px;
}

.fatal-state {
  max-width: 620px;
  margin: 0 auto;
}

.fatal-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 20px;
  place-items: center;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 30px;
}

.fatal-state h1 {
  font-size: 46px;
}

.fatal-state p:not(.eyebrow) {
  margin-bottom: 23px;
  color: var(--ink-soft);
}

.confirm-dialog {
  width: min(calc(100% - 36px), 480px);
  padding: 30px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-lg);
  box-shadow: 0 28px 80px rgba(25, 34, 28, 0.25);
}

.confirm-dialog::backdrop {
  background: rgba(28, 37, 31, 0.48);
  backdrop-filter: blur(7px);
}

.confirm-dialog form {
  position: relative;
}

.dialog-close {
  position: absolute;
  top: -17px;
  right: -17px;
}

.confirm-dialog h2 {
  padding-right: 25px;
}

.dialog-copy {
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 24px;
}

.toast-region {
  position: fixed;
  z-index: 300;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  display: grid;
  width: min(380px, calc(100vw - 40px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  padding: 13px 15px;
  color: #fff;
  background: var(--pine-deep);
  border-radius: 12px;
  box-shadow: var(--shadow);
  animation: toast-in 180ms ease-out;
  pointer-events: auto;
}

.toast.is-error {
  background: #7e3935;
}

.toast svg {
  width: 19px;
  height: 19px;
}

.toast p {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
}

.noscript {
  position: fixed;
  z-index: 999;
  inset: 0;
  display: grid;
  padding: 30px;
  place-items: center;
  color: #fff;
  background: var(--pine-deep);
  text-align: center;
}

.clipboard-proxy {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Mode Play · cover flow 3D adapté du mode Président de VCM */
body.play-mode {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #dce8e1;
}

body.play-mode > .skip-link,
body.play-mode > .app-shell {
  display: none;
}

.play-mode-root {
  position: fixed;
  z-index: 500;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.play-mode-root:fullscreen {
  width: 100vw;
  height: 100vh;
}

.presenter {
  --presenter-scale: 1;
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  color: #17231d;
  background:
    radial-gradient(circle at 17% 14%, rgba(255, 255, 255, 0.96), transparent 30rem),
    radial-gradient(circle at 78% 22%, rgba(121, 177, 151, 0.36), transparent 34rem),
    radial-gradient(circle at 48% 88%, rgba(208, 181, 140, 0.28), transparent 32rem),
    linear-gradient(145deg, #e9f0eb 0%, #cfddd5 48%, #e7e0d5 100%);
  font-size: calc(16px * var(--presenter-scale));
}

.presenter::before,
.presenter::after {
  position: absolute;
  border-radius: 999px;
  content: "";
  filter: blur(1px);
  opacity: 0.54;
  pointer-events: none;
}

.presenter::before {
  width: 38vw;
  height: 38vw;
  top: -20vw;
  right: -7vw;
  background: rgba(255, 255, 255, 0.58);
}

.presenter::after {
  width: 30vw;
  height: 30vw;
  bottom: -19vw;
  left: -7vw;
  background: rgba(68, 126, 98, 0.18);
}

.presenter.is-dark {
  color: #f1f6f2;
  background:
    radial-gradient(circle at 14% 10%, rgba(87, 137, 108, 0.22), transparent 33rem),
    radial-gradient(circle at 82% 24%, rgba(75, 112, 93, 0.25), transparent 36rem),
    radial-gradient(circle at 50% 100%, rgba(137, 113, 81, 0.17), transparent 30rem),
    linear-gradient(145deg, #17221c 0%, #0c1510 58%, #1e201b 100%);
  color-scheme: dark;
}

.presenter-topbar {
  position: relative;
  z-index: 30;
  display: grid;
  min-height: 84px;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  padding: max(10px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, 0.19);
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 10px 38px rgba(34, 56, 44, 0.07);
  -webkit-backdrop-filter: blur(26px) saturate(155%);
  backdrop-filter: blur(26px) saturate(155%);
}

.is-dark .presenter-topbar {
  background: rgba(10, 20, 14, 0.26);
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.presenter-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 14px;
}

.presenter-title {
  overflow: hidden;
  font-family: var(--serif);
  font-size: calc(19px * var(--presenter-scale));
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.presenter-live {
  display: inline-flex;
  min-height: 30px;
  flex: none;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  color: inherit;
  background: rgba(255, 255, 255, 0.3);
  border: 1px solid rgba(61, 99, 78, 0.18);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 780;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.presenter-live span {
  width: 7px;
  height: 7px;
  background: #3f7c5d;
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(63, 124, 93, 0.13);
  animation: presenter-live-pulse 2.2s ease-in-out infinite;
}

.is-dark .presenter-live {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.11);
}

.presenter-time {
  display: grid;
  justify-items: center;
  gap: 2px;
}

.presenter-clock {
  font-family: var(--serif);
  font-size: calc(27px * var(--presenter-scale));
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.presenter-time .timing-readout {
  margin: 0;
  padding: 2px 8px;
  font-size: 8px;
}

.presenter-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.presenter-controls {
  display: flex;
  gap: 2px;
}

.presenter .icon-button {
  color: inherit;
}

.presenter .icon-button:hover {
  background: rgba(128, 145, 133, 0.14);
}

.presenter-stopwatch {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 5px;
  padding: 5px 7px 5px 12px;
  background: rgba(255, 255, 255, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72), 0 8px 24px rgba(39, 64, 49, 0.08);
  -webkit-backdrop-filter: blur(18px) saturate(155%);
  backdrop-filter: blur(18px) saturate(155%);
}

.is-dark .presenter-stopwatch {
  background: rgba(255, 255, 255, 0.065);
  border-color: rgba(255, 255, 255, 0.13);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09), 0 8px 24px rgba(0, 0, 0, 0.18);
}

.presenter-stopwatch-readout {
  display: grid;
  min-width: 60px;
  grid-template-columns: auto;
  align-items: baseline;
}

.presenter-stopwatch-readout span {
  color: inherit;
  font-size: 8px;
  font-weight: 780;
  letter-spacing: 0.1em;
  opacity: 0.55;
  text-transform: uppercase;
}

.presenter-stopwatch-readout output {
  font-family: var(--serif);
  font-size: calc(19px * var(--presenter-scale));
  font-variant-numeric: tabular-nums;
  font-weight: 660;
  line-height: 1;
}

.presenter-stopwatch-button {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  padding: 0;
  color: inherit;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(78, 106, 90, 0.12);
  border-radius: 10px;
  cursor: pointer;
}

.presenter-stopwatch-button:hover {
  background: rgba(255, 255, 255, 0.7);
}

.presenter-stopwatch-button svg {
  width: 14px;
  height: 14px;
}

.is-dark .presenter-stopwatch-button {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.1);
}

.presenter-carousel {
  position: relative;
  z-index: 2;
  min-height: 0;
  perspective: 1700px;
  perspective-origin: 50% 48%;
  transform-style: preserve-3d;
  overflow: hidden;
  touch-action: pan-y;
}

.presenter-carousel-halo {
  position: absolute;
  width: min(900px, 70vw);
  height: 48%;
  top: 25%;
  left: 50%;
  background: rgba(255, 255, 255, 0.52);
  border-radius: 50%;
  filter: blur(85px);
  opacity: 0.7;
  pointer-events: none;
  transform: translateX(-50%);
}

.is-dark .presenter-carousel-halo {
  background: rgba(86, 132, 105, 0.17);
}

.presenter-slide {
  position: absolute;
  width: min(940px, 68vw);
  height: calc(100% - 34px);
  top: 17px;
  left: 50%;
  overflow: hidden;
  color: inherit;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.28)),
    rgba(240, 247, 242, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: clamp(26px, 3vw, 42px);
  box-shadow:
    0 45px 90px rgba(35, 59, 45, 0.18),
    0 12px 34px rgba(35, 59, 45, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.94),
    inset 0 -1px 0 rgba(76, 106, 89, 0.08);
  -webkit-backdrop-filter: blur(30px) saturate(165%);
  backdrop-filter: blur(30px) saturate(165%);
  transform:
    translateX(calc(-50% + (var(--carousel-offset) * 52%)))
    translateZ(calc(var(--carousel-distance) * -220px))
    rotateY(calc(var(--carousel-offset) * -34deg))
    scale(calc(1 - (var(--carousel-distance) * 0.055)));
  transform-style: preserve-3d;
  opacity: calc(1 - (var(--carousel-distance) * 0.26));
  transition: transform 620ms cubic-bezier(0.2, 0.72, 0.2, 1), opacity 420ms ease, box-shadow 420ms ease;
}

.presenter-slide:not(.is-active) {
  cursor: pointer;
}

.presenter-slide:not(.is-active):hover,
.presenter-slide:not(.is-active):focus-visible {
  opacity: calc(0.9 - (var(--carousel-distance) * 0.12));
  outline: 2px solid rgba(65, 100, 81, 0.38);
  outline-offset: -2px;
  box-shadow: 0 48px 100px rgba(35, 59, 45, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.94);
}

.is-dark .presenter-slide {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.105), rgba(255, 255, 255, 0.035)),
    rgba(18, 31, 23, 0.5);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow:
    0 45px 100px rgba(0, 0, 0, 0.44),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}

.presenter-slide-sheen {
  position: absolute;
  width: 72%;
  height: 42%;
  top: -30%;
  left: -18%;
  background: rgba(255, 255, 255, 0.62);
  border-radius: 50%;
  filter: blur(45px);
  opacity: 0.65;
  pointer-events: none;
  transform: rotate(-12deg);
}

.is-dark .presenter-slide-sheen {
  opacity: 0.09;
}

.presenter-slide-scroll {
  position: relative;
  z-index: 2;
  height: 100%;
  padding: clamp(28px, 4vw, 54px);
  overflow: auto;
  scrollbar-color: rgba(72, 106, 87, 0.32) transparent;
  scrollbar-width: thin;
}

.presenter-slide:not(.is-active) .presenter-slide-scroll {
  overflow: hidden;
}

.presenter-slide-head {
  max-width: 820px;
}

.presenter-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--sage);
  font-size: calc(10px * var(--presenter-scale));
  font-weight: 780;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.presenter-kicker::before {
  width: 28px;
  height: 2px;
  background: currentColor;
  content: "";
}

.presenter-slide h1 {
  max-width: 860px;
  margin-bottom: 10px;
  font-size: calc(clamp(38px, 4.5vw, 68px) * var(--presenter-scale));
  line-height: 0.98;
  letter-spacing: -0.035em;
  transition: font-size 420ms ease;
}

.presenter-slide:not(.is-active) h1 {
  max-width: 520px;
  font-size: calc(clamp(30px, 3.2vw, 48px) * var(--presenter-scale));
}

.presenter-person {
  margin-bottom: 0;
  color: var(--pine);
  font-size: calc(16px * var(--presenter-scale));
  font-weight: 650;
}

.is-dark .presenter-person {
  color: #a9c5b0;
}

.presenter-slide-content {
  display: grid;
  gap: clamp(20px, 3vh, 30px);
  margin-top: clamp(24px, 4vh, 38px);
  opacity: 1;
  transition: opacity 220ms ease 160ms, transform 420ms ease;
}

.presenter-slide:not(.is-active) .presenter-slide-content {
  opacity: 0;
  transform: translateY(18px);
  transition-delay: 0ms;
}

.presenter-launch {
  padding-bottom: clamp(20px, 3vh, 28px);
  border-bottom: 1px solid rgba(75, 104, 88, 0.15);
}

.is-dark .presenter-launch {
  border-bottom-color: rgba(255, 255, 255, 0.12);
}

.presenter-launch .eyebrow {
  margin-bottom: 12px;
  color: var(--sage);
}

.presenter-launch > div {
  max-width: 820px;
  white-space: pre-wrap;
  font-family: var(--serif);
  font-size: calc(clamp(19px, 1.7vw, 25px) * var(--presenter-scale));
  line-height: 1.62;
}

.timing-readout {
  display: inline-flex;
  margin-top: 12px;
  padding: 6px 10px;
  color: var(--pine-deep);
  background: var(--pine-soft);
  border-radius: 999px;
  font-size: calc(10px * var(--presenter-scale));
  font-weight: 780;
}

.is-dark .timing-readout {
  color: #b8d0bd;
  background: rgba(108, 151, 119, 0.16);
}

.presenter-footer {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 13px max(18px, env(safe-area-inset-left)) max(13px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.16);
  border-top: 1px solid rgba(255, 255, 255, 0.46);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
}

.is-dark .presenter-footer {
  background: rgba(8, 16, 11, 0.24);
  border-top-color: rgba(255, 255, 255, 0.09);
}

.presenter-progress {
  color: inherit;
  font-size: calc(11px * var(--presenter-scale));
  opacity: 0.62;
}

.presenter-nav {
  display: flex;
  gap: 9px;
}

.presenter-nav .button {
  min-width: 135px;
}

.presenter-shortcuts {
  justify-self: end;
  color: inherit;
  font-size: calc(10px * var(--presenter-scale));
  opacity: 0.5;
}

.presenter.is-dark .button-secondary {
  color: #e8f0ea;
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.13);
}

@keyframes presenter-live-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(63, 124, 93, 0.1); }
  50% { box-shadow: 0 0 0 7px rgba(63, 124, 93, 0.02); }
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .presenter-slide { background: rgba(244, 248, 245, 0.94); }
  .presenter.is-dark .presenter-slide { background: rgba(24, 37, 29, 0.96); }
  .presenter-topbar,
  .presenter-footer { background: rgba(233, 241, 236, 0.96); }
  .presenter.is-dark .presenter-topbar,
  .presenter.is-dark .presenter-footer { background: rgba(15, 25, 18, 0.96); }
}

@media (max-width: 1050px) {
  .presenter-slide {
    width: min(900px, 76vw);
  }

  .presenter-title {
    font-size: calc(16px * var(--presenter-scale));
  }

  .presenter-toolbar {
    gap: 4px;
  }
}

@media (max-width: 820px) {
  .presenter-slide {
    width: min(760px, 82vw);
  }

  .presenter-footer {
    grid-template-columns: 1fr auto;
  }

  .presenter-shortcuts {
    display: none;
  }
}

@media (max-width: 600px) {
  .presenter-topbar {
    min-height: 128px;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  }

  .presenter-identity {
    gap: 8px;
  }

  .presenter-title {
    font-size: 14px;
  }

  .presenter-live {
    padding: 4px 7px;
    font-size: 8px;
  }

  .presenter-time {
    justify-self: end;
  }

  .presenter-clock {
    font-size: 22px;
  }

  .presenter-toolbar {
    grid-column: 1 / -1;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px solid rgba(110, 121, 113, 0.2);
  }

  .presenter-stopwatch {
    min-height: 40px;
  }

  .presenter-controls .icon-button:nth-child(-n + 2) {
    display: none;
  }

  .presenter-slide {
    width: calc(100% - 22px);
    height: calc(100% - 18px);
    top: 9px;
    border-radius: 25px;
  }

  .presenter-slide:not(.is-active) {
    visibility: hidden;
  }

  .presenter-slide-scroll {
    padding: 24px 20px;
  }

  .presenter-slide h1 {
    font-size: calc(34px * var(--presenter-scale));
  }

  .presenter-slide-content {
    margin-top: 22px;
  }

  .presenter-launch > div {
    font-size: calc(17px * var(--presenter-scale));
  }

  .presenter-footer {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  }

  .presenter-progress {
    text-align: center;
  }

  .presenter-nav {
    width: 100%;
  }

  .presenter-nav .button {
    min-width: 0;
    min-height: 42px;
    flex: 1;
  }
}

/* Connexion */
.login-page {
  background: var(--paper);
}

.login-layout {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1.08fr) minmax(430px, 0.92fr);
}

.login-story {
  position: relative;
  display: grid;
  min-height: 100vh;
  align-items: center;
  overflow: hidden;
  padding: clamp(45px, 8vw, 120px);
  color: #f7f4ed;
  background:
    radial-gradient(circle at 18% 18%, rgba(166, 190, 172, 0.34), transparent 28rem),
    linear-gradient(145deg, #395849, #243d31);
}

.login-story::after {
  position: absolute;
  right: -16%;
  bottom: -30%;
  width: 70%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  box-shadow: 0 0 0 70px rgba(255, 255, 255, 0.035), 0 0 0 140px rgba(255, 255, 255, 0.025);
  content: "";
}

.login-story-inner {
  position: relative;
  z-index: 1;
  max-width: 690px;
}

.login-brand {
  margin-bottom: clamp(70px, 13vh, 150px);
  color: #fff;
}

.login-brand .brand-mark {
  color: var(--pine-deep);
  background: #f7f4ed;
}

.login-story .eyebrow {
  color: #cad8cd;
}

.login-story h1 {
  margin-bottom: 24px;
  font-size: clamp(45px, 6.5vw, 82px);
}

.login-lead {
  max-width: 570px;
  margin-bottom: 40px;
  color: rgba(247, 244, 237, 0.72);
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.58;
}

.login-motif {
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-motif span {
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
}

.login-motif span:first-child {
  width: 70px;
  background: #cedbcf;
}

.login-panel {
  display: grid;
  min-height: 100vh;
  align-items: center;
  padding: clamp(34px, 7vw, 100px);
  background:
    radial-gradient(circle at 86% 8%, rgba(241, 223, 214, 0.48), transparent 24rem),
    var(--paper);
}

.login-card {
  width: min(100%, 430px);
  margin: 0 auto;
}

.login-card h2 {
  margin-bottom: 11px;
  font-size: clamp(34px, 4vw, 46px);
}

.login-card-intro {
  margin-bottom: 32px;
  color: var(--ink-soft);
  font-size: 14px;
}

.login-form {
  display: grid;
  gap: 18px;
}

.password-wrap {
  position: relative;
  display: block;
}

.password-wrap input {
  padding-right: 84px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  padding: 5px 7px;
  color: var(--pine);
  background: transparent;
  border-radius: 7px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  transform: translateY(-50%);
}

.password-toggle:hover {
  background: var(--pine-soft);
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 9px;
  font-size: 12px;
}

.login-button {
  min-height: 51px;
  justify-content: space-between;
  margin-top: 4px;
  padding: 0 19px;
}

.login-security {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 24px 0 0;
  color: var(--ink-faint);
  font-size: 11px;
  text-align: center;
}

.login-security svg {
  width: 14px;
  height: 14px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes breathe {
  0%, 100% { opacity: 0.46; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.08); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1180px) {
  .workspace-grid.has-script {
    grid-template-columns: minmax(360px, 0.72fr) minmax(440px, 1.28fr);
  }

  .script-actions {
    display: grid;
  }
}

@media (max-width: 1020px) {
  .workspace-grid.has-script {
    max-width: 850px;
    grid-template-columns: minmax(0, 1fr);
  }

  .script-actions {
    display: flex;
  }
}

@media (max-width: 820px) {
  .topbar {
    min-height: 64px;
    grid-template-columns: 1fr auto;
    padding: 0 15px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    font-size: 19px;
  }

  .brand-copy small,
  .topbar-context,
  .topbar-new {
    display: none;
  }

  .history-toggle {
    display: inline-grid;
  }

  .app-layout {
    display: block;
    min-height: calc(100vh - 64px);
  }

  .history-sidebar {
    position: fixed;
    z-index: 90;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(340px, calc(100vw - 38px));
    height: 100vh;
    height: 100dvh;
    padding-top: max(28px, env(safe-area-inset-top));
    background: var(--paper-soft);
    box-shadow: 20px 0 55px rgba(25, 34, 28, 0.2);
    transform: translateX(-105%);
    transition: transform 180ms ease-out;
  }

  .history-sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: inline-grid;
  }

  .sidebar-scrim {
    position: fixed;
    z-index: 80;
    inset: 0;
    display: block;
    background: rgba(28, 37, 31, 0.42);
    backdrop-filter: blur(4px);
  }

  #main-content {
    min-height: calc(100vh - 64px);
  }

  .page-shell {
    width: min(calc(100% - 30px), 850px);
    padding-top: 39px;
  }

  .initial-loading,
  .fatal-state {
    min-height: calc(100vh - 64px);
  }

  .login-layout {
    grid-template-columns: 1fr;
  }

  .login-story {
    min-height: auto;
    padding: 42px 28px 52px;
  }

  .login-brand {
    margin-bottom: 60px;
  }

  .login-story h1 {
    font-size: clamp(42px, 11vw, 64px);
  }

  .login-panel {
    min-height: auto;
    padding: 52px 28px 65px;
  }
}

@media (max-width: 600px) {
  h1 {
    font-size: 42px;
  }

  .brand-copy strong {
    font-size: 15px;
  }

  .page-heading {
    display: grid;
    gap: 17px;
  }

  .document-state {
    width: fit-content;
  }

  .content-card {
    padding: 21px 16px;
    border-radius: var(--radius);
  }

  .card-head {
    display: grid;
    gap: 16px;
  }

  .mode-switch {
    width: 100%;
  }

  .mode-tab {
    min-height: 38px;
  }

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

  .field.full {
    grid-column: auto;
  }

  .capture-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .upload-actions,
  .form-actions,
  .script-head,
  .script-footer {
    display: grid;
  }

  .upload-actions .button,
  .generate-button,
  .script-footer .button {
    width: 100%;
  }

  .script-paper {
    border-radius: var(--radius);
  }

  .script-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .section-editor {
    font-size: 16px;
  }

  .confirm-dialog {
    width: calc(100% - 20px);
    padding: 26px 20px max(24px, env(safe-area-inset-bottom));
  }

  .dialog-actions {
    display: grid;
  }

  .dialog-actions .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  @page {
    margin: 17mm 18mm;
  }

  body {
    color: #111;
    background: #fff;
  }

  body * {
    visibility: hidden !important;
  }

  #script-result,
  #script-result * {
    visibility: visible !important;
  }

  #script-result {
    position: absolute;
    inset: 0 auto auto 0;
    display: block !important;
    width: 100%;
  }

  .script-paper {
    overflow: visible;
    background: #fff;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .script-head {
    padding: 0 0 8mm;
    border-bottom: 1px solid #bbb;
  }

  .script-head h2 {
    font-size: 28pt;
  }

  .script-actions,
  .script-guidance,
  .script-footer,
  .copy-section,
  .section-editor {
    display: none !important;
  }

  .script-sections {
    display: block;
    padding: 0;
  }

  .script-section {
    break-inside: avoid;
    padding: 7mm 0;
    border-bottom: 1px solid #ddd;
  }

  .section-print-text {
    display: block;
    font-family: var(--serif);
    font-size: 12pt;
    line-height: 1.55;
    white-space: pre-wrap;
  }

  .section-head h3 {
    font-size: 17pt;
  }

  .section-order::before {
    color: #fff !important;
    background: #333 !important;
    print-color-adjust: exact;
  }

  .section-cue {
    color: #333;
    background: transparent;
    border: 1px solid #bbb;
  }
}
