/* The app's own styles sit in a cascade layer, so the card editor's scoped
   card styles (unlayered) always win over them inside a card. See editor.js. */
@layer app {
/* Reset, type, and the controls every page is built from. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-gutter: stable; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: var(--type-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
}
img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
hr { border: 0; border-top: 1px solid var(--border-soft); margin: 24px 0; }
::selection { background: color-mix(in oklab, var(--accent) 34%, transparent); color: var(--text); }

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

/* Thin, quiet scrollbars that match the ground. */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--border-strong); }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 1000;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--accent-strong); color: var(--accent-ink); font-weight: 600;
  transition: top var(--quick);
}
.skip-link:focus { top: 12px; }

.jp { font-family: var(--font-mincho); font-feature-settings: normal; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font: var(--type-label); letter-spacing: var(--tracking-caps); text-transform: uppercase;
  color: var(--text-muted);
}
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }

kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-dim);
  font: 600 11.5px/1 var(--font); letter-spacing: 0.02em;
}

/* ---------- icons ---------- */

.icon { width: 20px; height: 20px; flex: none; }
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 24px; height: 24px; }

/* ---------- buttons ---------- */

.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  --btn-border: var(--border);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--control); padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg); color: var(--btn-fg);
  font: 600 14px/1 var(--font); letter-spacing: 0;
  white-space: nowrap; user-select: none;
  transition: background-color var(--quick), border-color var(--quick), color var(--quick), transform var(--quick), box-shadow var(--quick);
}
.btn:hover { --btn-bg: var(--surface-hover); --btn-border: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
.btn .icon { width: 18px; height: 18px; }
.btn--sm { height: var(--control-sm); padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn--lg { height: var(--control-lg); padding: 0 22px; font-size: 15px; }
.btn--lg .icon { width: 16px; height: 16px; }
.btn--block { width: 100%; }

.btn--accent { --btn-bg: var(--accent-strong); --btn-fg: var(--accent-ink); --btn-border: transparent; }
/* The main action's arrow leans the way it goes. */
.btn--accent .icon:last-child { transition: transform var(--quick); }
.btn--accent:hover .icon:last-child { transform: translateX(2px); }
.btn--accent:hover { --btn-bg: color-mix(in oklab, var(--accent-strong) 86%, white); --btn-border: transparent; }
.btn--ghost { --btn-bg: transparent; --btn-border: transparent; color: var(--text-dim); }
.btn--ghost:hover { --btn-bg: var(--surface-hover); --btn-border: transparent; color: var(--text); }
.btn--danger { --btn-bg: var(--danger-soft); --btn-fg: var(--danger); --btn-border: color-mix(in oklab, var(--danger) 30%, transparent); }
.btn--danger:hover { --btn-bg: color-mix(in oklab, var(--danger) 20%, transparent); --btn-border: var(--danger); }
.btn--danger-solid { --btn-bg: #c42b3a; --btn-fg: #fff; --btn-border: transparent; }
.btn--danger-solid:hover { --btn-bg: #d63546; --btn-border: transparent; }


.icon-btn {
  display: inline-grid; place-items: center;
  width: var(--control); height: var(--control); flex: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background-color var(--quick), color var(--quick);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.icon-btn--sm { width: var(--control-sm); height: var(--control-sm); border-radius: 8px; }
.icon-btn--sm .icon { width: 17px; height: 17px; }

.link { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 3px; transition: text-decoration-color var(--quick); }
.link:hover { text-decoration-color: var(--accent); }

/* ---------- fields ---------- */

.field { display: grid; gap: 8px; }
.field + .field { margin-top: 18px; }
.label { font: 600 13px/1.3 var(--font); color: var(--text-dim); }
.hint { font: var(--type-caption); color: var(--text-muted); }
.hint--error { color: var(--danger); }

.input, .select, .textarea {
  width: 100%;
  height: var(--control);
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-input);
  background: var(--bg-elevated);
  color: var(--text);
  transition: border-color var(--quick), box-shadow var(--quick), background-color var(--quick);
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); opacity: 0.85; }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in oklab, var(--border-input) 70%, var(--text)); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  outline: none;
}
.input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.input--lg { height: var(--control-lg); font-size: 16px; }
.textarea { height: auto; min-height: 96px; padding: 12px 14px; line-height: 1.55; resize: vertical; }
.textarea--code { font: 13px/1.6 var(--font-mono); tab-size: 2; }
.select {
  appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa1c1' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
/* The arrow takes the theme's muted ink (Paper's is darker). */
[data-theme="paper"] .select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23625d6e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-right: 46px; }
.input-group__suffix { position: absolute; right: 4px; }

/* Switch */
.switch { position: relative; display: inline-flex; flex: none; width: 42px; height: 24px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch__track {
  position: absolute; inset: 0; border-radius: 99px;
  background: var(--surface-active); border: 1px solid var(--border);
  transition: background-color var(--quick), border-color var(--quick);
}
.switch__track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--text-dim); box-shadow: var(--shadow-sm);
  transition: transform 0.26s var(--spring), background-color var(--quick);
}
.switch input:checked + .switch__track { background: var(--accent-strong); border-color: transparent; }
.switch input:checked + .switch__track::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Range */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 24px; background: transparent; cursor: pointer; --p: 50%; }
.range::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: linear-gradient(90deg, var(--accent-strong) var(--p), var(--surface-active) var(--p)); }
.range::-moz-range-track { height: 6px; border-radius: 6px; background: var(--surface-active); }
.range::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--accent-strong); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-sm); transition: box-shadow var(--quick); }
.range::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-sm); }
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 6px var(--accent-line); }

.checkbox { width: 18px; height: 18px; accent-color: var(--accent-strong); cursor: pointer; flex: none; }
button.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

/* ---------- boot ---------- */

.boot { position: fixed; inset: 0; display: grid; place-items: center; }
.boot__mark {
  display: block; width: 72px; height: auto;
  animation: boot-breathe 1.6s var(--ease) infinite alternate;
}
@keyframes boot-breathe { from { opacity: 0.35; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }

/* Motion preferences: the system's, unless the person chose otherwise. */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) *, :root:not([data-motion="full"]) *::before, :root:not([data-motion="full"]) *::after {
    animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important; scroll-behavior: auto !important;
  }
}
:root[data-motion="reduced"] *, :root[data-motion="reduced"] *::before, :root[data-motion="reduced"] *::after {
  animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important; scroll-behavior: auto !important;
}

/* Headings and containers that receive focus programmatically (after a
   route change, a new card) are landmarks, not controls: no ring. Controls
   with tabindex -1 (inactive radios in a roving group) keep theirs. */
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus, main[tabindex="-1"]:focus, .scard:focus { outline: none; }
}
