/* Base: reset, typography, focus, motion discipline (style guide section 3). */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--ink);
  color: var(--linen);
  font-family: var(--font-body);
  font-size: var(--fs-2);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
/* Woven texture: two faint diagonal thread passes over the night cloth. */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    repeating-linear-gradient(45deg, transparent 0 7px, var(--weave-light) 7px 8px),
    repeating-linear-gradient(-45deg, transparent 0 7px, var(--weave-dark) 7px 8px);
}
#app { position: relative; z-index: 1; height: 100%; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; }
h1 { font-size: var(--fs-4); letter-spacing: 0.02em; }
h2 { font-size: var(--fs-3); }
p { margin: 0 0 var(--sp-4); }
a { color: var(--thread); text-decoration-color: var(--thread-dim); }
button, input, select, textarea { font-family: var(--font-ui); font-size: var(--fs-1); }

:focus-visible {
  outline: 2px solid var(--thread);
  outline-offset: 2px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Chrome text (labels, nav, meta) uses the UI face. */
.ui { font-family: var(--font-ui); font-size: var(--fs-1); }
.caption { font-family: var(--font-ui); font-size: var(--fs-0); color: var(--linen-dim); }

/* Labeled rows (style guide: multi-fact helper text wants labeled rows). */
.rows { display: grid; gap: var(--sp-2); }
.row { display: grid; grid-template-columns: 9rem 1fr; gap: var(--sp-3); align-items: baseline; }
.row > b { font-family: var(--font-ui); font-weight: 700; font-size: var(--fs-1); }
.row > span { color: var(--linen); }

/* Empty states: colored callout with the next click (style guide section 8). */
.callout {
  border: 1px solid var(--edge);
  border-left: 3px solid var(--thread);
  background: var(--panel);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--radius);
  font-family: var(--font-ui);
}
.callout.info { border-left-color: var(--info); }
.callout.danger { border-left-color: var(--danger); }

/* Layout utilities: shared patterns instead of repeated inline styles. */
.spacer { flex: 1; }
.card-row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.section-head { margin-top: var(--sp-6); }
.btn-row { display: flex; gap: var(--sp-3); justify-content: flex-end; }
.screen-title { font-size: var(--fs-4); }
.beta-note { text-align: center; color: var(--warning); margin: calc(-1 * var(--sp-5)) 0 var(--sp-5); }

/* Status and error lines reserve their height (layout stability, section 3). */
[role="status"], [role="alert"] { display: block; min-height: 1.2em; margin: var(--sp-3) 0 0; }

/* Story preference: narration text size (M3). */
:root[data-textsize="large"] { --fs-2: 1.1875rem; }
