/* DictaFone — dark, tactile, built for a phone held in one hand. */

:root {
  --bg: #0b0b0d;
  --panel: #141418;
  --panel-2: #1b1b21;
  --line: #2a2a31;
  --line-soft: #202027;
  --text: #ecebe8;
  --dim: #8d8d97;
  --dimmer: #62626c;
  --accent: #ff7a35;
  --accent-dim: #a24d1f;
  --rec: #ff3b30;
  --ok: #7fce4d;

  --c-thump: #f0554b;
  --c-crack: #ffb020;
  --c-tick: #4dd6c8;
  --c-tone: #7c8cff;
  --c-texture: #b06bff;
  --c-perc: #7fce4d;

  --r: 10px;
  --tap: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body {
  min-height: 100dvh;
  padding-bottom: calc(24px + var(--safe-b));
}

h2 {
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0 0 12px;
  font-weight: 600;
}

p { margin: 0 0 10px; }
.hint { color: var(--dim); font-size: 13px; line-height: 1.55; margin: 8px 0 0; }
.empty { color: var(--dimmer); text-align: center; padding: 40px 20px; font-size: 14px; }
.lab { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }

/* ── top bar ───────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px calc(10px) 14px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: rgba(11,11,13,.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 800; font-size: 14px; letter-spacing: .12em;
  color: var(--text); white-space: nowrap;
}
.brand span { color: var(--accent); }

.transport { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.play {
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), #101014);
  color: var(--text); font-size: 15px; cursor: pointer;
  display: grid; place-items: center;
  transition: background .12s, border-color .12s, transform .08s;
}
.play:active { transform: scale(.94); }
.play[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--accent), var(--accent-dim));
  border-color: var(--accent);
  color: #170a02;
}
.play .glyph { line-height: 1; transform: translateX(1px); }
.play[aria-pressed="true"] .glyph { transform: none; }

.tempo { display: flex; align-items: center; gap: 8px; }
.tempo .lab { display: none; }
.tempo input { width: 84px; }
.tempo output {
  font-variant-numeric: tabular-nums; font-size: 13px;
  color: var(--dim); min-width: 26px; text-align: right;
}

.meterwrap { display: none; }
.meter {
  width: 60px; height: 6px; border-radius: 3px;
  background: var(--panel-2); overflow: hidden; border: 1px solid var(--line);
}
.meter i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--ok), var(--accent) 72%, var(--rec));
  transition: width .06s linear;
}

/* ── tabs ──────────────────────────────────────────────── */
.tabs {
  position: sticky; top: 62px; z-index: 25;
  display: flex; gap: 2px; overflow-x: auto;
  padding: 8px 10px; background: var(--bg);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 0 0 auto; padding: 9px 11px; border-radius: 999px;
  border: 1px solid transparent; background: none;
  color: var(--dim); font-size: 12.5px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  font-family: inherit;
}
.tabs button[aria-selected="true"] {
  background: var(--panel-2); color: var(--text); border-color: var(--line);
}
.tabs em {
  font-style: normal; font-size: 11px; color: var(--dimmer);
  margin-left: 4px; font-variant-numeric: tabular-nums;
}

main { padding: 14px; max-width: 900px; margin: 0 auto; }
.pane { display: none; }
.pane.active { display: block; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 12px;
}

/* ── buttons ───────────────────────────────────────────── */
.btn {
  appearance: none; font-family: inherit;
  padding: 11px 16px; min-height: var(--tap);
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background .12s, border-color .12s, transform .08s;
}
.btn:hover { background: #22222a; }
.btn:active { transform: scale(.98); }
.btn.primary {
  background: linear-gradient(180deg, var(--accent), #e8631f);
  border-color: var(--accent); color: #180a02; font-weight: 650;
}
.btn.primary:hover { filter: brightness(1.07); }
.btn.small { padding: 7px 11px; min-height: 34px; font-size: 12.5px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--rec); border-color: #4a2320; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ── record ────────────────────────────────────────────── */
.recstage { text-align: center; padding: 8px 0 18px; }

.recbtn {
  width: 168px; height: 168px; border-radius: 50%;
  border: 1px solid var(--line);
  background: radial-gradient(circle at 50% 34%, #1e1e25, #101014 68%);
  color: var(--dim); cursor: pointer; font-family: inherit;
  display: grid; place-content: center; gap: 14px; justify-items: center;
  margin: 0 auto;
  box-shadow: 0 12px 40px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.04);
  transition: transform .1s, border-color .2s;
}
.recbtn:active { transform: scale(.97); }
.recbtn .dot {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--rec);
  box-shadow: 0 0 0 0 rgba(255,59,48,.5);
  transition: border-radius .18s, transform .18s, background .18s;
}
.recbtn .rlabel {
  font-size: 10.5px; letter-spacing: .18em; font-weight: 600;
}
.recbtn.armed { border-color: #3a3a44; }
.recbtn.recording { border-color: var(--rec); color: var(--rec); }
.recbtn.recording .dot {
  border-radius: 8px; transform: scale(.62);
  animation: pulse 1.4s ease-out infinite;
}
.recbtn.busy { opacity: .55; pointer-events: none; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,59,48,.45); }
  70%  { box-shadow: 0 0 0 34px rgba(255,59,48,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,59,48,0); }
}

.status { color: var(--dim); font-size: 13.5px; margin: 18px auto 0; max-width: 34ch; min-height: 42px; }
.scope { margin-top: 6px; }
.scope canvas { width: 100%; height: 60px; display: block; opacity: .85; }

.row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.row:last-child { margin-bottom: 0; }
.row.toggle { align-items: flex-start; cursor: pointer; }
.row.toggle input { margin-top: 3px; flex: 0 0 auto; }
.row.toggle strong { display: block; font-size: 14px; font-weight: 550; }
.row.toggle em { display: block; font-style: normal; color: var(--dim); font-size: 12.5px; margin-top: 3px; }
.row.slider .lab { flex: 0 0 108px; }
.row.slider input[type=range] { flex: 1; }
.row.slider output {
  flex: 0 0 46px; text-align: right; font-variant-numeric: tabular-nums;
  font-size: 12.5px; color: var(--dim);
}

/* ── inputs ────────────────────────────────────────────── */
input[type=range] {
  appearance: none; -webkit-appearance: none;
  height: 26px; background: none; cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 3px; border-radius: 2px; background: var(--line);
}
input[type=range]::-moz-range-track { height: 3px; border-radius: 2px; background: var(--line); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 17px; height: 17px; border-radius: 50%;
  background: var(--text); margin-top: -7px;
  border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--line);
}
input[type=range]::-moz-range-thumb {
  width: 17px; height: 17px; border-radius: 50%; background: var(--text);
  border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--line);
}

select, input[type=text] {
  appearance: none; font-family: inherit; font-size: 13px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 8px 10px; min-height: 36px;
}
input[type=checkbox] { accent-color: var(--accent); width: 18px; height: 18px; }

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

/* ── library ───────────────────────────────────────────── */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  padding: 6px 11px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--dim); cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip .sw { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip[aria-pressed="true"] { color: var(--text); border-color: #3c3c46; background: var(--panel-2); }
.chip .n { color: var(--dimmer); font-variant-numeric: tabular-nums; }

.sortrow { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sortrow select { flex: 1; max-width: 240px; }

.samples { display: flex; flex-direction: column; gap: 8px; }

.sample {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 10px 12px;
}
.sample.sel { border-color: var(--accent); }
.sample .wave {
  width: 52px; height: 40px; border-radius: 6px;
  background: var(--panel-2); cursor: pointer; display: block;
}
.sample .meta { min-width: 0; }
.sample .nm {
  font-size: 14px; font-weight: 500; border: none; background: none;
  color: var(--text); padding: 2px 0; width: 100%; font-family: inherit;
  text-overflow: ellipsis;
}
.sample .nm:focus { outline: none; border-bottom: 1px solid var(--accent); }
.sample .sub {
  font-size: 11.5px; color: var(--dimmer); display: flex;
  align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 2px;
}
.badge {
  font-size: 10px; letter-spacing: .09em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 4px; font-weight: 650;
  background: color-mix(in srgb, currentColor 16%, transparent);
}
.sample .acts { display: flex; gap: 4px; }
.iconbtn {
  width: 34px; height: 34px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--panel-2);
  color: var(--dim); cursor: pointer; font-size: 13px;
  display: grid; place-items: center; font-family: inherit;
}
.iconbtn:hover { color: var(--text); background: #24242c; }
.iconbtn.on { color: var(--accent); border-color: var(--accent-dim); }

/* ── map ───────────────────────────────────────────────── */
.mapwrap { position: relative; margin: 10px 0; }
#map {
  width: 100%; aspect-ratio: 1; display: block;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); touch-action: manipulation;
}
.axis {
  position: absolute; font-size: 10px; letter-spacing: .08em;
  color: var(--dimmer); text-transform: uppercase; pointer-events: none;
}
.ax-x { bottom: 8px; left: 50%; transform: translateX(-50%); }
.ax-y { top: 50%; left: 8px; transform: rotate(-90deg) translateX(50%); transform-origin: left center; }

.legend { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.legend span { font-size: 11.5px; color: var(--dim); display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: block; }

.mapdetail:empty { display: none; }
.mapdetail { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.mapdetail h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.nearlist { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.nearlist button {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  width: 100%; text-align: left; padding: 9px 11px; border-radius: 7px;
  background: var(--panel-2); border: 1px solid var(--line-soft);
  color: var(--text); font-size: 13px; cursor: pointer; font-family: inherit;
}
.nearlist button:hover { border-color: var(--line); }
.nearlist .d { font-size: 11px; color: var(--dimmer); font-variant-numeric: tabular-nums; }

/* ── sequencer ─────────────────────────────────────────── */
.seqhead {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 10px; flex-wrap: wrap;
}
.seqhead .hint { margin: 0; }
.seqbtns { display: flex; gap: 6px; }

/* The grid scrolls sideways on a phone — 16 steps at a hittable size will not
   fit otherwise. The right-edge fade is there so that reads as scrollable. */
.gridwrap {
  overflow-x: auto; margin: 0 -14px 12px; padding: 0 14px 4px;
  scrollbar-width: thin;
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 26px), transparent 100%);
          mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 26px), transparent 100%);
}
.gridwrap.at-end {
  -webkit-mask-image: none; mask-image: none;
}
.grid { display: flex; flex-direction: column; gap: 4px; min-width: min-content; }

.trk { display: grid; grid-template-columns: 110px 1fr; gap: 8px; align-items: center; }
.trk .head {
  display: flex; align-items: center; gap: 5px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 7px; padding: 5px 6px; height: 42px;
  position: sticky; left: 0; z-index: 2;
}
.trk .head .tname {
  flex: 1; min-width: 0; font-size: 11.5px; line-height: 1.15;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: none; border: none; color: var(--text); cursor: pointer;
  text-align: left; font-family: inherit; padding: 0;
}
.trk .head .tname .cls { display: block; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }
.trk .head .tname.empty { color: var(--dimmer); font-style: italic; }
.trk .head .m {
  width: 22px; height: 22px; border-radius: 5px; flex: 0 0 auto;
  border: 1px solid var(--line); background: var(--panel-2);
  color: var(--dimmer); font-size: 9.5px; font-weight: 700; cursor: pointer;
  font-family: inherit; padding: 0;
}
.trk .head .m.on { color: var(--rec); border-color: #4a2320; }
.trk .head .m.cfg.open { color: var(--accent); border-color: var(--accent-dim); }

.steps { display: grid; grid-template-columns: repeat(16, minmax(23px, 1fr)); gap: 3px; }
.step {
  height: 42px; border-radius: 5px; cursor: pointer; padding: 0;
  border: 1px solid var(--line-soft); background: #101014;
  position: relative; transition: background .08s, border-color .08s;
}
.step:nth-child(4n+1) { border-color: #34343d; }
.step.on { background: var(--trkcol, var(--accent)); border-color: transparent; }
.step.v1 { opacity: .42; }
.step.v2 { opacity: .7; }
.step.v3 { opacity: 1; }
.step.playing::after {
  content: ''; position: absolute; inset: -2px;
  border-radius: 6px; border: 2px solid var(--text); opacity: .55;
}
.trk.muted .steps { opacity: .32; }

.tcfg { display: none; }
.tcfg.open { display: block; }
.tcfg h3 {
  margin: 0 0 12px; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.knobs { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px 18px; }
.knob { display: flex; flex-direction: column; gap: 3px; }
.knob .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.knob output { font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.knob select { width: 100%; }

/* ── toast + sheet ─────────────────────────────────────── */
.credit {
  text-align: center; color: var(--dimmer); font-size: 12px;
  padding: 8px 16px 24px; letter-spacing: .02em;
}
.credit strong { color: var(--dim); font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + var(--safe-b));
  transform: translate(-50%, 16px);
  background: #23232b; border: 1px solid #35353f; color: var(--text);
  padding: 11px 16px; border-radius: 999px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 60; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.sheet {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,.6); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet[hidden] { display: none; }
.sheetinner {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px 14px 0 0; width: 100%; max-width: 520px;
  padding: 18px 18px calc(18px + var(--safe-b));
  max-height: 82dvh; overflow-y: auto;
  animation: rise .2s ease-out;
}
@keyframes rise { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheetinner h3 { margin: 0 0 14px; font-size: 15px; }
.picklist { display: flex; flex-direction: column; gap: 6px; }
.picklist button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--line-soft); color: var(--text);
  font-size: 14px; cursor: pointer; text-align: left; font-family: inherit;
}
.picklist button .sub { color: var(--dimmer); font-size: 11.5px; margin-left: auto; }

.spinner {
  display: inline-block; width: 13px; height: 13px; vertical-align: -2px;
  border: 2px solid rgba(255,255,255,.25); border-top-color: var(--text);
  border-radius: 50%; animation: spin .7s linear infinite; margin-right: 7px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── wider screens ─────────────────────────────────────── */
@media (min-width: 620px) {
  .tempo .lab { display: inline; }
  .meterwrap { display: block; }
  .trk { grid-template-columns: 150px 1fr; }
  .trk .head .tname { font-size: 12.5px; }
  main { padding: 20px; }
  .gridwrap { margin: 0 0 12px; padding: 0 0 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
