/* Notebook plates (design 132). One parchment card per frame: a title strip,
   a drawing stage that takes the space left, live readings and controls.
   The frame is sandboxed, so nothing here can reach the article page. */

:root {
  --nb-paper: #efe5cf;
  --nb-paper-deep: #e4d6b8;
  --nb-ink: #2b2118;
  --nb-ink-soft: #5b4a39;
  --nb-faint: rgba(43, 33, 24, 0.16);
  --nb-rule: rgba(64, 92, 140, 0.13);
  --nb-copper: #a65a24;
  --nb-blue: #2c4fa3;
  --nb-violet: #6a3fa0;
  --nb-red: #a3352a;
  --nb-green: #3f6b3a;
  --nb-title: 'IM Fell English', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --nb-hand: 'Cormorant Garamond', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px 12px;
  color: var(--nb-ink);
  font-family: var(--nb-hand);
  font-size: 16px;
  line-height: 1.35;
  background-color: var(--nb-paper);
  background-image:
    radial-gradient(120% 90% at 50% 40%, rgba(255, 252, 240, 0.55), rgba(255, 252, 240, 0) 60%),
    radial-gradient(80% 60% at 100% 100%, rgba(150, 110, 60, 0.18), rgba(150, 110, 60, 0) 70%),
    radial-gradient(70% 50% at 0% 0%, rgba(150, 110, 60, 0.12), rgba(150, 110, 60, 0) 70%),
    repeating-linear-gradient(0deg, transparent 0 27px, var(--nb-rule) 27px 28px);
  box-shadow: inset 0 0 0 1px rgba(90, 64, 36, 0.28), inset 0 0 0 5px var(--nb-paper), inset 0 0 0 6px rgba(90, 64, 36, 0.18), inset 0 0 40px rgba(120, 84, 40, 0.18);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.nb-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--nb-faint);
}

.nb-plate {
  font-family: var(--nb-title);
  font-variant: small-caps;
  letter-spacing: 0.12em;
  font-size: 0.82rem;
  color: var(--nb-copper);
}

.nb-head h1 {
  margin: 0;
  font-family: var(--nb-title);
  font-weight: 400;
  font-size: clamp(1.02rem, 3.6vw, 1.32rem);
  line-height: 1.15;
  flex: 1 1 auto;
}

.nb-date {
  font-style: italic;
  font-size: 0.86rem;
  color: var(--nb-ink-soft);
}

.nb-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 120px;
  touch-action: none;
}

.nb-stage > canvas,
.nb-stage > svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.nb-readout {
  font-size: 0.98rem;
  font-variant-numeric: tabular-nums lining-nums;
  min-height: 1.3em;
}

.nb-readout > span {
  display: inline-block;
  margin-right: 16px;
}

.nb-readout b {
  font-weight: 600;
  color: var(--nb-blue);
}

.nb-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px 14px;
  align-items: end;
}

.nb-control {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.nb-control label,
.nb-control .nb-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.92rem;
  font-style: italic;
  color: var(--nb-ink-soft);
}

.nb-control output {
  font-style: normal;
  font-weight: 600;
  color: var(--nb-ink);
  font-variant-numeric: tabular-nums lining-nums;
  white-space: nowrap;
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--nb-ink-soft);
  border-radius: 2px;
}

input[type='range']::-moz-range-track {
  height: 2px;
  background: var(--nb-ink-soft);
  border-radius: 2px;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--nb-paper);
  border: 2px solid var(--nb-copper);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--nb-paper);
  border: 2px solid var(--nb-copper);
}

input[type='range']:focus-visible {
  outline: 2px solid var(--nb-blue);
  outline-offset: 2px;
  border-radius: 4px;
}

.nb-buttons {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.nb-btn {
  font: inherit;
  font-size: 0.95rem;
  min-height: 34px;
  padding: 4px 12px;
  color: var(--nb-ink);
  background: rgba(255, 252, 240, 0.6);
  border: 1px solid rgba(90, 64, 36, 0.45);
  border-radius: 999px;
  cursor: pointer;
}

.nb-btn:hover { background: rgba(255, 252, 240, 0.95); }

.nb-btn[aria-pressed='true'] {
  background: var(--nb-ink);
  color: var(--nb-paper);
  border-color: var(--nb-ink);
}

.nb-btn:focus-visible {
  outline: 2px solid var(--nb-blue);
  outline-offset: 2px;
}

.nb-note {
  font-style: italic;
  font-size: 0.9rem;
  color: var(--nb-ink-soft);
}

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

@media (max-width: 420px) {
  body { padding: 10px 10px 10px; gap: 6px; font-size: 15px; }
  .nb-controls { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 4px 10px; }
  .nb-date { width: 100%; }
}
