/* Aula in Chrome. Tokens first, then layout, components, pages. */
:root {
  --accent: #4f6ef7;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #14171c;
  --muted: #646c79;
  --danger: #d92d20;
  --warn: #b25e00;
  --ok: #12805c;
  --cap: #ffffff;
  --cap-border: #cfd4dc;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%);
  --radius: 10px;
  --gap: 16px;
  --pad: 20px;
  --ctl: 36px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-text: color-mix(in srgb, var(--accent) 80%, var(--text));
}
:root[data-theme="dark"] {
  --bg: #0f1114;
  --surface: #171a1f;
  --surface-2: #1e2228;
  --border: #272c34;
  --border-strong: #363d48;
  --text: #eceef2;
  --muted: #9099a8;
  --danger: #f97066;
  --warn: #f5a524;
  --ok: #3ccb93;
  --cap: #20242b;
  --cap-border: #363d48;
  --shadow: none;
}
:root[data-density="compact"] { --gap: 10px; --pad: 14px; --ctl: 30px; font-size: 14px; }
:root[data-motion="off"] *, :root[data-motion="off"] *::before, :root[data-motion="off"] *::after {
  transition: none !important; animation: none !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, dl, dd { margin: 0; }
h1 { font-size: 1.25rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1rem; font-weight: 650; }
h3 { font-size: 0.86rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
a { color: var(--accent-text); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.mono { font-family: var(--mono); }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.icon { display: inline-flex; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }
:root[data-sidebar="icons"] .app { grid-template-columns: 64px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 16px 10px; background: var(--surface); border-right: 1px solid var(--border);
}
/* The logo is a mask, so it takes the accent colour. */
.duck { display: inline-block; flex: none; background: var(--accent); -webkit-mask: url("../assets/duck.svg") center / contain no-repeat; mask: url("../assets/duck.svg") center / contain no-repeat; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-weight: 700; letter-spacing: -0.01em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 10px; border: 0; border-radius: 8px;
  background: none; color: var(--muted); font: inherit; font-weight: 550; text-align: left; cursor: pointer;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.on { background: var(--accent-soft); color: var(--accent-text); }
.sidebar-foot { margin-top: auto; display: grid; gap: 4px; padding: 8px; font-size: 0.78rem; color: var(--muted); }
:root[data-sidebar="icons"] .brand span, :root[data-sidebar="icons"] .nav-item span:not(.icon),
:root[data-sidebar="icons"] .sidebar-foot { display: none; }
:root[data-sidebar="icons"] .nav-item, :root[data-sidebar="icons"] .brand { justify-content: center; padding-inline: 0; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: var(--gap);
  min-height: 60px; padding: 10px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.content { padding: 24px 28px 48px; width: 100%; max-width: 1180px; margin: 0 auto; }
.page { display: grid; gap: var(--gap); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--gap); align-items: start; }
.grid-2.tight { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.center { justify-content: center; }
.row.end { justify-content: flex-end; }

/* ---------- components ---------- */
.card {
  display: grid; gap: 14px; padding: var(--pad); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0;
}
.card-head p { margin-top: 2px; font-size: 0.9rem; }
.card > .btn { justify-self: start; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: var(--ctl); padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; white-space: nowrap; cursor: pointer; transition: background 0.12s, border-color 0.12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 88%, #000); }
.btn.danger-text { color: var(--danger); }
.btn.recording { background: var(--danger); border-color: var(--danger); color: #fff; animation: pulse 1.2s infinite; }
.btn.small { height: 28px; padding: 0 10px; font-size: 0.86rem; }
.btn.large { height: 44px; padding: 0 22px; font-size: 1rem; }
.btn.icon-btn { width: 30px; height: 30px; padding: 0; }
@keyframes pulse { 50% { opacity: 0.7; } }

.input {
  height: var(--ctl); padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; min-width: 0;
}
textarea.input { height: auto; padding: 10px; width: 100%; resize: vertical; font-size: 0.86rem; line-height: 1.6; }
.input.num { width: 86px; }
.field { display: grid; gap: 6px; font-size: 0.9rem; }
.field > span { color: var(--muted); font-weight: 550; }
.color-input { width: var(--ctl); height: var(--ctl); padding: 2px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); cursor: pointer; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 9px; }
.segmented button {
  height: calc(var(--ctl) - 6px); padding: 0 12px; border: 0; border-radius: 7px; background: none; color: var(--muted);
  font: inherit; font-weight: 550; cursor: pointer;
}
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 12%); }
.segmented button:disabled { opacity: 0.4; cursor: default; }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 0.9rem; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { position: relative; width: 38px; height: 22px; border-radius: 11px; background: var(--border-strong); transition: background 0.15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgb(0 0 0 / 25%); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.pill { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); font-size: 0.86rem; font-weight: 550; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.pill.off .dot { background: var(--border-strong); }
.pill.warn { color: var(--warn); border-color: currentColor; }
.battery { display: inline-flex; align-items: center; gap: 7px; font-size: 0.86rem; font-weight: 550; font-variant-numeric: tabular-nums; }
.battery-shell { position: relative; width: 26px; height: 13px; padding: 1.5px; border: 1.5px solid var(--muted); border-radius: 4px; }
.battery-shell::after { content: ""; position: absolute; right: -4.5px; top: 3px; width: 2px; height: 4px; border-radius: 0 2px 2px 0; background: var(--muted); }
.battery-fill { display: block; height: 100%; border-radius: 1.5px; background: var(--ok); }
.battery-fill.low { background: var(--danger); }
/* Always in the layout so nothing shifts; fades in only if the keyboard is busy for a moment. */
.spinner { width: 15px; height: 15px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; opacity: 0; transition: opacity 0.2s; }
.status.busy .spinner { opacity: 1; transition: opacity 0.15s 0.25s; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 9%, var(--surface)); font-size: 0.92rem;
}
.banner.inline { justify-content: center; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch {
  width: 28px; height: 28px; padding: 0; border: 1px solid rgb(0 0 0 / 14%); border-radius: 50%; cursor: pointer;
  display: inline-grid; place-items: center; color: var(--muted); background: var(--surface);
}
:root[data-theme="dark"] .swatch { border-color: rgb(255 255 255 / 16%); }
.swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.swatch.random { background: conic-gradient(#ff3b30, #ffd60a, #34c759, #32d5f5, #0a84ff, #ff2d92, #ff3b30); }
.swatch.add { border-style: dashed; border-color: var(--border-strong); }
.swatch:disabled { opacity: 0.3; cursor: default; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.chip button { border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.chip-main { padding: 0 10px 0 12px; height: 32px; font-weight: 550; }
.chip-x { padding: 0 8px; color: var(--muted); display: inline-flex; align-items: center; border-left: 1px solid var(--border) !important; }
.chip button:hover { background: var(--surface-2); }

.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter-fill { height: 100%; width: 0; border-radius: 3px; background: var(--accent); transition: width 0.08s linear; }
.meter.over .meter-fill { background: var(--danger); }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: grid; gap: 8px; justify-items: end; max-width: min(440px, calc(100vw - 40px)); }
.toast {
  padding: 10px 14px; border-radius: 9px; background: var(--text); color: var(--bg); font-size: 0.92rem; font-weight: 500;
  box-shadow: 0 6px 20px rgb(0 0 0 / 22%); animation: rise 0.18s ease-out; transition: opacity 0.2s, transform 0.2s;
}
.toast.error { background: var(--danger); color: #fff; }
:root[data-theme="dark"] .toast.error { color: #1a0605; }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.dialog {
  width: min(440px, calc(100vw - 32px)); padding: 22px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgb(0 0 0 / 28%);
}
.dialog::backdrop { background: rgb(10 12 16 / 45%); }
.dialog h3 { font-size: 1.05rem; color: var(--text); text-transform: none; letter-spacing: 0; margin-bottom: 8px; }
.dialog p { color: var(--muted); }
.dialog .input { width: 100%; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- landing ---------- */
.landing { display: grid; gap: 28px; padding: 6vh 0 0; }
.hero { display: grid; gap: 16px; justify-items: center; text-align: center; max-width: 620px; margin: 0 auto; }
.hero h2 { font-size: 1.9rem; letter-spacing: -0.02em; line-height: 1.15; }
.lead { font-size: 1.05rem; color: var(--muted); }
.facts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--gap); max-width: 880px; margin: 0 auto; width: 100%; }
.fact { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); display: grid; gap: 4px; }
.fact p { font-size: 0.9rem; }

/* ---------- keyboard ---------- */
.board { container-type: inline-size; width: 100%; margin: 0 auto; user-select: none; }
:root[data-board="medium"] .board { max-width: 820px; }
:root[data-board="small"] .board { max-width: 640px; }
.board-inner { position: relative; width: 100%; }
.cap {
  --key: var(--cap);
  position: absolute; display: grid; place-items: center; padding: 0; overflow: hidden;
  border: 1px solid var(--cap-border); border-radius: 0.55cqw; background: var(--key); color: var(--text);
  font: inherit; font-size: clamp(7px, 1.12cqw, 13px); line-height: 1.05; cursor: pointer; touch-action: none;
  transition: transform 0.08s, box-shadow 0.12s, border-color 0.12s;
}
.cap:hover:not(:disabled) { border-color: var(--accent); z-index: 1; }
.cap:active:not(:disabled) { transform: scale(0.95); }
.cap-legend, .cap-label { grid-area: 1 / 1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 0.3cqw; pointer-events: none; }
.cap-legend { font-weight: 600; }
.cap-label:not(:empty) { font-weight: 650; color: var(--accent-text); white-space: normal; text-align: center; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; padding-top: 0.9cqw; }
.cap:has(.cap-label:not(:empty)) .cap-legend { align-self: start; justify-self: start; padding: 0.25cqw 0.4cqw; font-size: 0.72em; font-weight: 500; color: var(--muted); }
.cap.changed { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--cap)); }
.cap.dim { opacity: 0.45; }
.cap.selected { border-color: var(--accent); box-shadow: 0 0 0 0.3cqw var(--accent-soft), inset 0 0 0 1px var(--accent); z-index: 2; opacity: 1; }
.cap.knob { border-radius: 50%; }
.cap:disabled { opacity: 0.3; cursor: default; }
.cap.lit { border-color: color-mix(in srgb, var(--key) 70%, #000); color: #fff; box-shadow: 0 0 1.1cqw color-mix(in srgb, var(--key) 55%, transparent); }
.cap.lit.bright { color: #111; }
.board.readonly .cap { cursor: default; }
.board.readonly .cap:hover { border-color: var(--cap-border); }

/* ---------- lighting ---------- */
.effect-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }
.effect {
  display: flex; align-items: center; gap: 9px; height: 42px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; font-weight: 550; text-align: left; cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.effect:hover { border-color: var(--border-strong); background: var(--surface-2); }
.effect.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.effect-no { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.effect.on .effect-no { color: inherit; opacity: 0.7; }
.slider { display: grid; gap: 6px; }
.slider-head { display: flex; justify-content: space-between; font-size: 0.9rem; font-weight: 550; color: var(--muted); }
.slider-value { font-variant-numeric: tabular-nums; color: var(--text); }
.slider.disabled { opacity: 0.45; }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 0; height: 22px; }

/* ---------- keys ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs button { height: 30px; padding: 0 11px; border: 0; border-radius: 7px; background: none; color: var(--muted); font: inherit; font-weight: 550; cursor: pointer; }
.tabs button:hover { background: var(--surface-2); color: var(--text); }
.tabs button.on { background: var(--accent-soft); color: var(--accent-text); }
.tabs.muted-tabs { opacity: 0.45; }
.inspector { display: grid; gap: 12px; }
.options { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; max-height: 300px; overflow: auto; padding: 2px; }
.option {
  display: grid; gap: 1px; align-content: center; min-height: 40px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 0.9rem; font-weight: 550; text-align: left; cursor: pointer;
}
.option small { font-weight: 450; color: var(--muted); font-size: 0.8rem; }
.option:hover { border-color: var(--border-strong); background: var(--surface-2); }
.option.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }

/* ---------- macros ---------- */
.macro-layout { display: grid; grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.macro-list { display: grid; gap: 4px; }
.macro-item { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--text); font: inherit; font-weight: 550; text-align: left; cursor: pointer; }
.macro-item:hover { background: var(--surface-2); }
.macro-item.on { border-color: var(--accent); background: var(--accent-soft); }
.macro-no { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; background: var(--surface-2); font-size: 0.8rem; font-family: var(--mono); }
.macro-item .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.macro-editor { display: grid; gap: 14px; }
.steps { display: grid; gap: 6px; max-height: 420px; overflow: auto; }
.step { display: flex; align-items: center; gap: 8px; }
.step-no { width: 24px; text-align: right; font-family: var(--mono); font-size: 0.8rem; }
.step .dir { width: 96px; }
.step .dir.down { color: var(--accent-text); border-color: var(--accent); }
.step select { flex: 1; }
.step-delay { display: inline-flex; align-items: center; gap: 5px; }

/* ---------- device / prefs ---------- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: 0.94rem; }
.facts dt { color: var(--muted); }
.points { display: grid; gap: 6px; }
.point { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; flex-wrap: wrap; }
.raw { min-height: 150px; }
.pref { display: flex; align-items: center; gap: 18px; padding: 10px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pref:first-of-type { border-top: 0; padding-top: 0; }
.pref:last-child { padding-bottom: 0; }
.pref p { margin-top: 2px; max-width: 60ch; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  :root[data-sidebar="icons"] .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .brand { padding: 0 8px 0 0; }
  .brand span, .sidebar-foot { display: none; }
  .nav { flex-direction: row; }
  .nav-item span:not(.icon) { display: none; }
  .nav-item { padding: 0 12px; }
  .topbar { padding: 10px 16px; position: static; }
  .content { padding: 16px; }
  .macro-layout { grid-template-columns: 1fr; }
}
