/* writekit — base tokens, type and controls.
   The palette is pigment: ink, paper, verdigris, plum, brass. No orange. */

@font-face {
  font-family: "Instrument Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/instrument-serif-400.ttf") format("truetype");
}
@font-face {
  font-family: "Instrument Serif";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/instrument-serif-400-italic.ttf") format("truetype");
}
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/geist-400.ttf") format("truetype");
}
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/geist-500.ttf") format("truetype");
}
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/geist-600.ttf") format("truetype");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-mono-400.ttf") format("truetype");
}

:root {
  --ink-950: #080d16;
  --ink-900: #0e1726;
  --ink-850: #121f33;
  --ink-800: #17273e;
  --ink-700: #20344f;
  --ink-600: #2c4467;
  --ink-500: #3b5680;
  --ink-400: #526a8e;
  --paper-50: #fcfaf4;
  --paper-100: #f5f0e4;
  --paper-200: #eae3d3;
  --paper-300: #d8ceba;
  --paper-400: #bfb39a;
  --verd-300: #86d6ca;
  --verd-400: #4fb8ab;
  --verd-500: #2e8c82;
  --verd-600: #23736b;
  --verd-700: #1a5a54;
  --plum-300: #b8749a;
  --plum-400: #94476f;
  --plum-500: #6e2e52;
  --plum-600: #54213f;
  --brass-300: #e6ce97;
  --brass-400: #c8a45f;
  --brass-500: #a98542;
  --slate-100: #e4e7ec;
  --slate-300: #afb7c3;
  --slate-500: #76818f;
  --slate-700: #48525f;
  --success: #2c7a52;
  --warning: #9a6b1e;
  --danger: #a93b4e;

  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --r-control: 4px;
  --r-panel: 8px;
  --shadow-sheet: 0 24px 64px rgba(4, 8, 14, 0.28);
  --rail: 232px;
  --topbar: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
html.reduce-motion { scroll-behavior: auto; }
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

body {
  margin: 0;
  background: var(--paper-100);
  color: var(--ink-900);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--verd-400); color: var(--ink-950); }
:focus-visible { outline: 2px solid var(--verd-500); outline-offset: 2px; border-radius: 2px; }

h1, h2, h3, h4, p, figure, blockquote { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img, svg { max-width: 100%; }

.serif { font-family: var(--serif); font-weight: 400; }
.mono { font-family: var(--mono); }
.wrap { width: min(1280px, 100%); margin: 0 auto; padding: 0 32px; }
.muted { color: var(--slate-700); }
.hair { height: 1px; background: var(--paper-300); border: 0; margin: 0; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--r-control);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-900);
  font: 500 14px/1 var(--sans);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease), color 120ms var(--ease);
}
.btn-primary { background: var(--verd-600); color: var(--paper-50); }
.btn-primary:hover { background: var(--verd-700); }
.btn-secondary { border-color: var(--ink-900); }
.btn-secondary:hover { background: var(--paper-200); }
.btn-quiet { border-color: var(--paper-300); color: var(--ink-900); }
.btn-quiet:hover { background: var(--paper-200); }
.btn-ink { background: var(--verd-400); color: var(--ink-950); }
.btn-ink:hover { background: var(--verd-300); }
.btn-ghost { color: var(--slate-300); }
.btn-ghost:hover { color: var(--paper-50); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 13px; }

.link {
  color: var(--verd-600);
  text-decoration: none;
  font-weight: 500;
}
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link-ink { color: var(--verd-300); }

/* Controls */
.field { display: grid; gap: 6px; }
.field > label, .label {
  font: 500 12px/1.2 var(--sans);
  color: var(--ink-900);
}
.input, .select, .textarea {
  min-height: 40px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--paper-300);
  border-radius: var(--r-control);
  background: var(--paper-50);
  color: var(--ink-900);
  font-size: 14px;
}
.textarea { min-height: 96px; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--verd-600); box-shadow: 0 0 0 1px var(--verd-600); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--slate-700) 50%), linear-gradient(135deg, var(--slate-700) 50%, transparent 50%); background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--slate-700); }
.check input { width: 16px; height: 16px; accent-color: var(--verd-600); }

.range { display: grid; gap: 6px; }
.range .top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 11px; color: var(--slate-700); text-transform: uppercase; letter-spacing: 0.06em; }
.range .top b { color: var(--ink-900); font: 400 11px/1 var(--mono); }
input[type="range"] { width: 100%; accent-color: var(--verd-600); }

/* Toggle */
.switch { position: relative; width: 44px; height: 24px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--paper-300); border-radius: 999px; transition: background 120ms var(--ease); }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; top: 3px; left: 3px; border-radius: 50%; background: var(--paper-50); transition: transform 120ms var(--ease); box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--verd-600); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--verd-500); outline-offset: 2px; }

/* Small helpers */
.kicker { font: 400 11px/1.4 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--slate-700); }
.note { font-size: 12px; line-height: 1.5; color: var(--slate-700); }
.pill { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 11px; border-radius: 999px; background: var(--paper-200); font: 400 10px/1 var(--mono); letter-spacing: 0.06em; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--slate-500); flex: 0 0 auto; }
.dot-ok { background: var(--success); }
.dot-busy { background: var(--warning); }
.dot-bad { background: var(--danger); }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: grid; gap: 8px; }
.toast { min-width: 240px; max-width: 380px; padding: 12px 14px; border-radius: var(--r-control); background: var(--ink-850); color: var(--paper-50); border: 1px solid var(--ink-700); font-size: 13px; box-shadow: 0 12px 30px rgba(0,0,0,.3); animation: toast-in 180ms var(--ease); }
.toast.bad { border-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-width: 640px) {
  .wrap { padding: 0 20px; }
}
