:root {
  color: #191b24;
  background: #f8f7f5;
  font-family: "Inter", "Aptos", system-ui, sans-serif;
  --ink: #191b24;
  --paper: #fffefa;
  --line: #e6e1eb;
  --muted: #626071;
  --accent: #5b45d9;
  --accent-hover: #4c35c7;
  --tint: #f0ebff;
  --shadow: 0 2px 4px #30285106, 0 12px 36px #30285108;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 300px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.top {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.top-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  min-height: 68px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 10px 34px;
}

.brand { display: inline-flex; width: max-content; align-items: center; gap: 9px; font-size: 17px; letter-spacing: -.045em; }
.top nav { display: flex; align-items: center; gap: 3px; padding: 3px; border: 1px solid #eeebf2; border-radius: 11px; background: #f7f5f8; }
.top nav a, .top-end { font-size: 13px; color: var(--muted); font-weight: 650; white-space: nowrap; }
.top nav a { display: block; padding: 8px 12px; border-radius: 8px; }
.top nav a:hover, .top-end:hover { color: var(--accent); }
.top nav [aria-current] { color: var(--accent); background: white; box-shadow: 0 1px 4px #28234114; }
.top-end { display: inline-flex; justify-self: end; align-items: center; gap: 7px; }

main { max-width: 1320px; margin: 0 auto; padding: 44px 34px 64px; }
.intro { margin-bottom: 26px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(36px, 5vw, 52px); font-weight: 720; line-height: 1.07; letter-spacing: -.062em; }
.intro p { margin-top: 10px; color: var(--muted); font-size: 15px; line-height: 1.65; }
.studio { display: grid; grid-template-columns: minmax(300px, 365px) minmax(0, 1fr); gap: 22px; align-items: start; }
.panel { min-width: 0; overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.controls { padding: 22px 24px 24px; }
.section-heading { display: flex; gap: 10px; align-items: center; }
.step, .preview-mark { display: grid; place-items: center; flex: 0 0 auto; color: var(--accent); background: var(--tint); border-radius: 8px; }
.step { width: 28px; height: 28px; font-size: 12px; font-weight: 750; }
.preview-mark { width: 34px; height: 34px; }
h2 { font-size: 16px; letter-spacing: -.028em; line-height: 1.25; }
label { display: block; margin: 16px 0 6px; color: #3a3747; font-size: 13px; line-height: 1.3; font-weight: 670; }
input, select, textarea {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #e1dce7;
  border-radius: 9px;
  font-size: 14px;
  line-height: 1.3;
}
input:hover, select:hover, textarea:hover { border-color: #c4b9dc; }
input, select { min-height: 43px; }
textarea { resize: vertical; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 13px; border: 1px solid transparent; border-radius: 9px; font-size: 13px; font-weight: 700; line-height: 1.3; }
.primary { background: var(--accent); border-color: var(--accent); color: white; box-shadow: 0 2px 5px #5b45d92a; }
.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.secondary, .icon { background: #fff; border-color: var(--line); color: var(--ink); }
.secondary:hover:not(:disabled), .icon:hover:not(:disabled) { background: var(--tint); color: var(--accent); }
.button:disabled { color: #817b8c; background: #f9f7fa; border-color: #eee9f2; box-shadow: none; cursor: default; }
.setup-button, .full { width: 100%; margin-top: 20px; }
.cast-form { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.field-help { margin-top: 9px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.account-details { margin-top: 10px; }
.account-link { display: inline-block; margin-top: 6px; color: var(--accent); font-size: 13px; font-weight: 670; text-decoration: underline; text-underline-offset: 3px; }
.cast-row { display: grid; grid-template-columns: 1.15fr 1fr; gap: 8px; }
.cast-row label { margin-top: 12px; }
.status { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.status:not(:empty) { margin-top: 14px; padding: 10px 11px; border: 1px solid #e9e0fb; border-radius: 8px; background: #f8f4ff; }
.status[data-error]:not(:empty) { color: #8f342b; background: #fff2ef; border-color: #f5dbd5; }

.preview-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.preview-header .button { flex-shrink: 0; white-space: nowrap; }
.preview-header .section-heading p { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.3; }
.page-scroll {
  display: grid;
  place-items: center;
  padding: 25px 18px;
  background-color: #f0edf5;
  background-image: radial-gradient(#d8d0e4 1px, transparent 1px);
  background-size: 16px 16px;
}
#book-page { display: block; width: min(100%, 380px); height: auto; aspect-ratio: 8.5 / 11; background: #fff; border: 1px solid #e1dce5; border-radius: 3px; box-shadow: 0 3px 5px #2d234018, 0 14px 28px #2d234028; }
.preview-footer { display: flex; align-items: center; justify-content: center; gap: 15px; padding: 12px 10px 0; border-top: 1px solid var(--line); }
.preview-footer p { min-width: 117px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; text-align: center; }
.icon { width: 38px; min-height: 36px; padding: 0; font-size: 17px; }
.page-strip { position: relative; display: flex; justify-content: safe center; gap: 7px; overflow: auto; padding: 10px 16px 14px; }
.page-strip button { flex: 0 0 auto; min-width: 30px; min-height: 29px; padding: 5px 8px; color: var(--muted); background: var(--paper); border: 1px solid var(--line); border-radius: 6px; font-size: 12px; }
.page-strip button:hover, .page-strip button[aria-current] { color: var(--accent); background: var(--tint); border-color: #cec2f8; }
.page-strip button[aria-current] { font-weight: 750; }
.page-actions { padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.page-actions-main { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.page-actions-main .button { min-height: 34px; padding: 6px 9px; }
.page-actions-main .redraw:not(:disabled) { color: var(--accent); }
.page-actions .status:not(:empty) { margin-top: 10px; }
.footer { display: flex; justify-content: space-between; gap: 12px; max-width: 1252px; margin: 0 auto; padding: 19px 0 23px; color: var(--muted); border-top: 1px solid var(--line); font-size: 13px; }
.footer a { color: var(--ink); font-weight: 700; }
.footer a:hover { color: var(--accent); }

@media (max-width: 1320px) {
  .footer { margin-inline: 34px; }
}

@media (max-width: 780px) {
  .studio { grid-template-columns: 1fr; }
  main { padding: 34px 18px 42px; }
  .footer { margin-inline: 18px; }
}

@media (max-width: 560px) {
  .top-inner { grid-template-columns: 1fr auto; gap: 8px; min-height: 59px; padding: 10px 14px; }
  .brand { --mte-mark-size: 26px; gap: 6px; font-size: 15px; }
  .top nav { gap: 1px; }
  .top nav a { padding: 7px 6px; font-size: 11px; }
  .top-end { display: none; }
  .controls, .preview-header { padding: 15px; }
  .preview-header { gap: 8px; }
  .preview-header .section-heading { gap: 7px; }
  .preview-header .button { padding-inline: 7px; font-size: 12px; }
  .preview-header .button svg { width: 14px; }
  .preview-mark { width: 26px; height: 28px; }
  .preview-mark svg { width: 15px; }
  .page-scroll { padding: 16px; }
}

@media (max-width: 375px) {
  .top-inner { grid-template-columns: 1fr; justify-items: start; }
}
