:root {
  color-scheme: light;

  /* HandBand design system: Airy / Light Studio.
     Warm beige surfaces, charcoal ink, muted brown for primary actions, champagne
     for selection, sage for life (status and expression). Components use these tokens, never raw colours. */

  /* canvas and surfaces */
  --bg: #e9e0d1;
  --bg-raise: #efe7da;
  --paper-rgb: 244 236 223;
  --paper: #f4ecdf;
  --surface: rgb(var(--ink-rgb) / 0.04);
  --surface-strong: rgb(var(--ink-rgb) / 0.075);
  --field: rgb(249 243 233 / 0.72);
  --field-focus: #f9f3e9;
  --glass: rgb(var(--paper-rgb) / 0.84);
  --line: rgb(var(--ink-rgb) / 0.14);
  --line-strong: rgb(var(--ink-rgb) / 0.26);
  --edge-light: inset 0 1px 0 rgb(255 255 255 / 0.28);

  /* ink: --ink-4 is decorative only, the rest pass AA on every surface */
  --ink-rgb: 50 44 37;
  --ink: #322c25;
  --ink-2: #544d43;
  --ink-3: #625b50;
  --ink-4: #a89e8c;

  /* accents */
  --primary-rgb: 134 104 76;
  --primary: #86684c;
  --primary-hover: #775b41;
  --on-primary: #faf4e9;
  --accent-rgb: 191 165 119;
  --accent: #bfa577;
  --accent-ink: #6b5527;
  --accent-fill: linear-gradient(180deg, #f3e7c9, #ead9b1);
  --accent-fill-hover: linear-gradient(180deg, #f8efd9, #f0e2c1);
  --on-accent: #2b261b;
  --sage-rgb: 122 141 115;
  --sage: #7a8d73;
  --sage-ink: #4a5c43;
  --danger-rgb: 156 66 49;
  --danger: #9c4231;

  /* Floating tool surfaces sit over a live camera image of unknown brightness,
     so they stay nearly opaque. */
  --panel-bg: rgb(var(--paper-rgb) / 0.96);
  --panel-line: rgb(var(--ink-rgb) / 0.16);
  --panel-ink: var(--ink);
  --panel-ink-dim: var(--ink-3);
  --panel-label: var(--ink-2);

  --scrim: rgb(226 216 199 / 0.72);
  --scrim-spotlight: rgb(58 50 40 / 0.5);

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 22px;
  --shadow-rgb: 92 72 44;
  --shadow-soft: 0 1px 2px rgb(var(--shadow-rgb) / 0.08), 0 10px 24px -16px rgb(var(--shadow-rgb) / 0.3);
  --shadow-lift: 0 2px 6px -2px rgb(var(--shadow-rgb) / 0.12), 0 22px 48px -22px rgb(var(--shadow-rgb) / 0.42);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

/* Figtree carries Latin text, digits and chord symbols; each language then falls
   back to a platform font drawn for its own script. */
:root:lang(ko) { --font: 'Figtree', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif; }
:root:lang(ja) { --font: 'Figtree', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic', Meiryo, sans-serif; }
:root:lang(zh) { --font: 'Figtree', 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', sans-serif; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

body { overflow: hidden; }

#app { height: 100%; width: 100%; position: relative; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

input {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

::selection { background: rgb(var(--accent-rgb) / 0.4); }

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

.screen {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(0.985);
  transition: opacity 420ms var(--ease-out), transform 520ms var(--ease-out), filter 420ms var(--ease-out);
  filter: blur(6px);
  pointer-events: none;
}
.screen.is-active {
  opacity: 1;
  transform: none;
  filter: none;
  pointer-events: auto;
}
.screen.is-leaving {
  opacity: 0;
  transform: scale(1.02);
  filter: blur(8px);
}

/* ---------- shared atoms ---------- */

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(22px) saturate(1.15);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
  box-shadow: var(--shadow-lift), var(--edge-light);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: 9px;
  color: var(--ink-2);
  letter-spacing: 0.01em;
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: color 200ms var(--ease-out), background 200ms var(--ease-out),
              border-color 200ms var(--ease-out), transform 320ms var(--ease-out);
  white-space: nowrap;
}
.btn:hover { color: var(--ink); background: var(--surface); }
.btn:active { transform: scale(0.965); }
.btn.is-on {
  color: var(--on-primary);
  background: var(--primary);
  border-color: transparent;
  box-shadow: 0 8px 18px -12px rgb(var(--primary-rgb) / 0.9), var(--edge-light);
}
.btn.is-on:hover { color: var(--on-primary); background: var(--primary-hover); }

/* Inside the instrument and tutorial, active controls are pale gold, not brown. */
.workspace .btn.is-on, .tutorial-layer .btn.is-on {
  color: var(--on-accent);
  background: var(--accent-fill);
  border-color: rgb(var(--accent-rgb) / 0.85);
  box-shadow: var(--edge-light);
}
.workspace .btn.is-on:hover, .tutorial-layer .btn.is-on:hover {
  color: var(--on-accent);
  background: var(--accent-fill-hover);
}
.btn.is-ghost { border-color: var(--line); }
.btn.is-danger:hover { color: var(--danger); background: rgb(var(--danger-rgb) / 0.09); }

.icon { width: 15px; height: 15px; flex: none; display: block; }
.icon path, .icon circle, .icon rect, .icon line { vector-effect: non-scaling-stroke; }

.label-xs {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}

.divider { height: 1px; background: var(--line); border: 0; margin: 0; }
.vdivider { width: 1px; align-self: stretch; background: var(--line); margin: 6px 2px; }

/* ---------- toasts ---------- */

.toast-layer {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 900;
  pointer-events: none;
}
.toast {
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--ink);
  background: var(--panel-bg);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow-lift);
  animation: toast-in 420ms var(--ease-out) both;
  max-width: 78vw;
  text-align: center;
}
.toast.is-error { border-color: rgb(var(--danger-rgb) / 0.4); color: var(--danger); }
.toast.is-out { animation: toast-out 300ms var(--ease-out) both; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(14px) scale(0.94); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-6px) scale(0.97); }
}

/* ---------- scrollbars ---------- */

*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgb(var(--ink-rgb) / 0.16);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgb(var(--ink-rgb) / 0.28); background-clip: content-box; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- language selector and non-Latin text ---------- */

.language-select {
  position: relative;
  display: inline-flex;
  height: 32px;
  border-radius: 9px;
  color: var(--ink-2);
  transition: color 200ms var(--ease-out), background 200ms var(--ease-out);
}
.language-select:hover { color: var(--ink); background: var(--surface); }
.language-select:hover .language-select-input { border-color: var(--line-strong); }
.language-select:focus-within { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.language-select .icon {
  position: absolute;
  top: 50%;
  left: 9px;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  pointer-events: none;
}
.language-select-input {
  -webkit-appearance: none;
  appearance: none;
  /* The select fills the control so every pixel of it opens the list. */
  height: 100%;
  padding: 0 21px 0 29px;
  border: 1px solid var(--line);
  border-radius: inherit;
  outline: none;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23544d43' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 7px center / 9px 6px;
  color: inherit;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.language-select-input option { color: var(--ink); background: var(--paper); }
.entry-nav .language-select { height: 38px; }
.account-control .language-select { height: 26px; }

:root:lang(ko) { word-break: keep-all; overflow-wrap: anywhere; }
:root:lang(ja), :root:lang(zh) { line-break: strict; }

/* Wide tracking and tight headlines are tuned for Latin capitals. */
:is(:lang(ko), :lang(ja), :lang(zh)) :is(.label-xs, .dock-label, .entry-eyebrow, .demo-hub-label, .save-status, .tutorial-title, .slider-ends, .drop-hint) {
  letter-spacing: 0.04em;
}
:is(:lang(ko), :lang(ja), :lang(zh)) .entry-copy h1 {
  font-size: clamp(34px, 4.3vw, 60px);
  line-height: 1.22;
  letter-spacing: -0.025em;
}

@media (max-width: 620px) {
  .entry-header { flex-wrap: wrap; row-gap: 8px; }
  .entry-nav .language-select { height: 34px; }
  .entry-nav .language-select .icon { display: none; }
  .entry-nav .language-select-input { padding-left: 9px; }
}
