:root {
  font-family: system-ui, -apple-system, sans-serif;
  color: #17213c;
  background: #f4f5fb;
  --primary: #3845b7;
  --soft: #eceffe;
  --muted: #555f78;
  --line: #d8deeb;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.65rem, 4vw, 2.1rem); line-height: 1.2; }
h2 { font-size: 1.08rem; }
p { line-height: 1.5; }
button, input, select, textarea, .button { font: inherit; }
button, .button {
  background: #fff; color: #182348; border: 1px solid var(--line);
  padding: .56rem .8rem; border-radius: .55rem; text-decoration: none;
  min-height: 2.65rem; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; cursor: pointer; line-height: 1.2;
}
button:disabled { opacity: .48; cursor: default; }
button:not(:disabled):hover, .button:hover { background: var(--soft); }
:focus-visible, .button:has(+ input:focus-visible) { outline: 3px solid #aa6a29; outline-offset: 2px; }
.primary, .primary:not(:disabled):hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.primary:not(:disabled):hover { background: #2c389f; }
.quiet { border-color: transparent; background: transparent; color: var(--muted); }
input:not([type="color"], [type="range"]), textarea, select {
  width: 100%; min-width: 0; max-width: 100%; padding: .62rem;
  background: #fff; border: 1px solid var(--line); border-radius: .45rem; color: inherit;
}
label { font-weight: 600; }
.site-header { background: #fff; border-bottom: 1px solid var(--line); }
.header-inner, body > main, footer { max-width: 76rem; margin: 0 auto; padding-inline: clamp(.8rem, 3vw, 2rem); }
.header-inner { min-height: 4.25rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.brand { display: inline-flex; align-items: center; gap: .7rem; text-decoration: none; color: inherit; font-weight: 750; }
.brand-mark {
  width: 2.45rem; height: 2.45rem; background: var(--primary); color: #fff; border-radius: .65rem;
  font-size: 1.55rem; display: inline-grid; place-items: center; line-height: 1;
}
.view-nav { display: flex; gap: .4rem; padding-block: 1.2rem .9rem; }
.tab, .tool { border-color: transparent; }
.tab[aria-pressed="true"], .tool[aria-pressed="true"] { color: #303d9e; background: var(--soft); border-color: #c2cafb; }
.work-header { display: flex; justify-content: space-between; align-items: end; gap: .85rem; flex-wrap: wrap; margin-bottom: 1rem; }
.work-header p { color: var(--muted); margin-top: .25rem; }
.row { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.workbench { display: grid; grid-template-columns: minmax(10rem, 13rem) minmax(0, 1fr); gap: .85rem; align-items: start; }
.pages-panel, .editor, .audio-card { background: #fff; border: 1px solid var(--line); border-radius: .75rem; }
.pages-panel, .audio-card { padding: .9rem; display: grid; gap: .55rem; align-content: start; }
.pages-panel h2 { margin-top: .4rem; }
.pages { display: grid; gap: .35rem; margin: 0; padding: .12rem .12rem .3rem; list-style: none; max-height: 22rem; overflow: auto; }
.pages button { width: 100%; }
.pages button[aria-current="page"] { background: var(--soft); color: #303d9e; border-color: #b9c4fa; }
.page-actions { display: flex; gap: .28rem; flex-wrap: wrap; }
.page-actions button { padding-inline: .52rem; }
.toolbar { padding: .62rem .7rem; border-bottom: 1px solid var(--line); display: grid; gap: .5rem; }
.options { gap: .55rem .8rem; }
.options label { display: flex; align-items: center; gap: .35rem; font-size: .93rem; }
.options input[type="range"] { width: 6rem; }
.options p { font-size: .88rem; color: var(--muted); }
.stage {
  padding: clamp(.65rem, 2vw, 1.25rem); background: #e8ecf5; min-height: 12rem;
  border-radius: 0 0 .75rem .75rem;
}
.sheet { position: relative; max-width: 44rem; margin: auto; background: #fff; box-shadow: 0 2px 10px #17213c23; }
.sheet canvas { width: 100%; height: auto; display: block; }
.sheet #overlay { position: absolute; inset: 0; height: 100%; }
.sheet #overlay[data-tool="pen"], .sheet #overlay[data-tool="image"] {
  cursor: crosshair; touch-action: none;
}
.sheet #overlay[data-tool="text"] { cursor: text; touch-action: manipulation; }
.sheet #text-editor {
  position: absolute; display: grid; gap: .45rem; width: min(19rem, calc(100% - 1rem));
  padding: .55rem; background: #fff; border: 1px solid #aeb8ee; border-radius: .65rem;
  box-shadow: 0 4px 16px #17213c28;
}
#text-editor textarea { font-size: 1rem; resize: none; }
#text-editor .row { justify-content: flex-end; }
.sheet #overlay[data-tool="select"] { cursor: grab; touch-action: pan-y; }
.status { min-height: 1.35rem; margin-top: .35rem; color: var(--muted); font-size: .95rem; }
.alert { color: #a32930; }
.audio-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.audio-grid output { font-variant-numeric: tabular-nums; color: var(--primary); font-size: 1.5rem; font-weight: 700; }
.audio-grid audio { width: 100%; }
footer { padding-block: 1.2rem; font-size: .9rem; color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; clip-path: inset(50%); overflow: hidden; }
.login { display: grid; min-height: 100svh; place-items: center; padding: 1rem; }
.login .login-card { width: min(100%, 27rem); margin: 0; display: grid; gap: .85rem; padding: 1.55rem; background: #fff; border: 1px solid var(--line); border-radius: .8rem; }
.login form { display: grid; gap: .55rem; }
@media (max-width: 44rem) {
  .workbench, .audio-grid { grid-template-columns: minmax(0, 1fr); }
  .pages { display: flex; overflow-x: auto; }
  .pages li { flex: 0 0 auto; }
}
.sheet #overlay[data-tool="select"][data-selected="true"] { touch-action: none; }
