/* Roughhouse: the cassette-deck look, for phones and desktops. */
@font-face { font-family: Heros; src: url(fonts/heros_regular.otf) format('opentype'); font-weight: 400; font-display: swap; }
@font-face { font-family: Heros; src: url(fonts/heros_bold.otf) format('opentype'); font-weight: 700; font-display: swap; }
@font-face { font-family: Termes; src: url(fonts/termes_regular.otf) format('opentype'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: Termes; src: url(fonts/termes_italic.otf) format('opentype'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: Termes; src: url(fonts/termes_bold.otf) format('opentype'); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --body: #1B1A18; --panel: #262522; --edge: #3A3833; --lane: #12100E;
  --cream: #E8DFC8; --dim: #9C9584; --faint: #5E5A51;
  --amber: #E9A23B; --red: #D8452E; --green: #7FA65A; --blue: #5B8DB8; --yellow: #E5C547;
  --ink: #2A2420; --paper: #F1E8D0;
  --sans: Heros, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --serif: Termes, "Times New Roman", Times, serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--body); color: var(--cream); }
body {
  font-family: var(--sans); font-size: 14px; overflow: hidden; overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
button:focus-visible, canvas:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
canvas { display: block; touch-action: none; max-width: 100%; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- layout */

#app {
  height: 100dvh; display: flex; flex-direction: column;
  padding-top: var(--safe-t);
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
.colL, .colR { display: contents; }

.top { display: flex; align-items: center; gap: 6px; padding: 10px 10px 6px 14px; }
.brand { flex: 1; min-width: 0; }
.word { font-weight: 700; font-size: 15px; letter-spacing: .3em; color: var(--cream); }
.mode { display: block; font-weight: 700; font-size: 7.5px; letter-spacing: .14em; color: var(--amber); padding: 3px 0; text-align: left; }

.panel { background: var(--panel); border: 1px solid var(--edge); border-radius: 6px; }
.deck { margin: 0 8px; padding: 8px; }
.cassette { width: 100%; height: 146px; cursor: pointer; }
.meters { display: flex; align-items: center; padding-top: 8px; gap: 4px; }
.counter { flex: 1; height: 46px; min-width: 0; cursor: pointer; }
.meterslot { width: 164px; height: 46px; position: relative; flex: none; }
.vupair { position: absolute; right: 0; top: 0; bottom: 0; display: flex; gap: 4px; }
.vu { width: 78px; height: 46px; }
.tuner { position: absolute; right: 0; top: 0; width: 160px; height: 46px; }
.chips { display: flex; gap: 6px; padding-top: 8px; }
.chips .chip { flex: 1; }
.chips .chip.w13 { flex: 1.3; }

.rulerrow { display: flex; align-items: center; padding: 8px 14px 2px; gap: 6px; }
.rulerrow .silk { width: 28px; text-align: center; font-size: 7.5px; }
.ruler { flex: 1; height: 42px; min-width: 0; }
.rspacer { width: 34px; flex: none; }
.lyricstrip {
  font-family: var(--serif); font-style: italic; font-size: 15px; color: var(--cream);
  padding: 2px 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
}
.lyricstrip.ahead { color: var(--faint); }

.tracks { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 8px 8px; -webkit-overflow-scrolling: touch; }
.row { display: flex; align-items: center; height: 78px; margin-top: 6px; padding: 5px 6px; }
.cap {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  color: var(--ink); font-weight: 700; font-size: 12px; display: grid; place-items: center;
}
.wave { flex: 1; height: 100%; min-width: 0; margin-left: 6px; cursor: pointer; }
.btns { width: 34px; margin-left: 6px; display: flex; flex-direction: column; gap: 3px; flex: none; }
.empty {
  font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--dim);
  text-align: center; white-space: pre-line; line-height: 1.25; padding: 40px 0 16px;
}
.foot { display: flex; gap: 6px; padding-top: 8px; }
.foot .chip { flex: 1; }

.keys { display: flex; gap: 6px; padding: 8px 8px 0; background: var(--panel); }
.key { flex: 1; height: 70px; min-width: 0; cursor: pointer; }
.small { display: flex; gap: 6px; padding: 8px 8px calc(12px + var(--safe-b)); background: var(--panel); }
.small .chip { flex: 1; }
.small .chip.w12 { flex: 1.2; }

/* wide screens: deck on the left, tape on the right (like the Android app in landscape) */
@media (min-width: 760px) and (min-aspect-ratio: 1/1) {
  #app { flex-direction: row; }
  .colL, .colR { display: flex; flex-direction: column; min-height: 0; }
  .colL { width: clamp(340px, 40%, 460px); flex: none; overflow-y: auto; }
  .colR { flex: 1; min-width: 0; }
  .colL > *, .colR > * { order: 0 !important; }
  .small { background: none; padding: 8px 8px calc(12px + var(--safe-b)); }
  .keys { padding: 6px 8px calc(8px + var(--safe-b)); }
  .key { height: 60px; }
  .cassette { height: 132px; }
}
@media (min-width: 1100px) and (min-aspect-ratio: 1/1) {
  .cassette { height: 160px; }
  .row { height: 92px; }
}
/* phones on their side */
@media (max-height: 520px) and (min-aspect-ratio: 1/1) {
  #app { flex-direction: row; }
  .colL, .colR { display: flex; flex-direction: column; min-height: 0; }
  .colL { width: 46%; flex: none; overflow-y: auto; }
  .colR { flex: 1; min-width: 0; }
  .colL > *, .colR > * { order: 0 !important; }
  .small { background: none; }
  .keys { padding: 6px 8px calc(8px + var(--safe-b)); }
  .key { height: 56px; }
  .cassette { height: 118px; }
}

/* ---------------------------------------------------------------- chips */

.chip {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  font-weight: 700; font-size: 11px; letter-spacing: .14em; color: var(--cream);
  background: var(--panel); border: 1px solid var(--edge); border-radius: 4px;
  padding: 8px 10px; min-height: 32px; white-space: nowrap;
}
.chip:active { filter: brightness(1.15); }
.chip.on { color: var(--ink); }
.chip.on[data-color=amber] { background: var(--amber); border-color: var(--amber); }
.chip.on[data-color=green] { background: var(--green); border-color: var(--green); }
.chip.on[data-color=blue] { background: var(--blue); border-color: var(--blue); }
.chip.on[data-color=yellow] { background: var(--yellow); border-color: var(--yellow); }
.chip.tiny { padding: 0; min-height: 0; height: 20px; font-size: 10px; letter-spacing: .1em; }
.top .chip { padding: 8px 10px; }
.silk { font-weight: 700; letter-spacing: .14em; }
.faint { color: var(--faint); }

/* ---------------------------------------------------------------- note strip */

.notebar {
  position: fixed; left: 12px; right: 12px; bottom: calc(150px + var(--safe-b)); z-index: 50;
  background: var(--paper); color: var(--ink); border-radius: 4px; padding: 10px 14px;
  font-size: 13px; line-height: 1.3; box-shadow: 0 4px 18px rgba(0,0,0,.4); cursor: pointer;
  max-width: 560px; margin: 0 auto;
}
@media (min-width: 760px) and (min-aspect-ratio: 1/1) { .notebar { bottom: calc(96px + var(--safe-b)); } }

/* ---------------------------------------------------------------- dialogs */

.scrim {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.dlg {
  background: var(--panel); border: 1px solid var(--edge); border-radius: 8px;
  width: 100%; max-width: 440px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.dlg-title { font-family: var(--serif); font-weight: 700; font-size: 21px; color: var(--cream); padding: 20px 24px 4px; }
.dlg-body { overflow-y: auto; flex: 1; min-height: 0; -webkit-user-select: text; user-select: text; }
.dlg-msg { padding: 22px 24px 10px; font-size: 15px; line-height: 1.35; color: var(--cream); }
.dlg-buttons { display: flex; justify-content: flex-end; gap: 4px; padding: 8px 12px 10px; }
.dlg-btn { font-weight: 700; letter-spacing: .1em; color: var(--amber); padding: 10px 12px; font-size: 14px; border-radius: 4px; }
.dlg-btn:hover { background: rgba(233,162,59,.08); }
.dlg-btn.left { margin-right: auto; }
.dlg-list { padding: 6px 0 10px; }
.dlg-item { display: block; width: 100%; text-align: left; padding: 12px 24px; font-size: 16px; color: var(--cream); }
.dlg-item:hover { background: rgba(232,223,200,.05); }
.dlg-item-main, .dlg-item-sub { display: block; }
.dlg-item-sub { color: var(--dim); font-size: 14px; margin-top: 2px; }
.listdlg .dlg-title { padding-bottom: 8px; }

.body { padding: 4px 24px 10px; }
.para { padding-top: 4px; line-height: 1.35; white-space: pre-wrap; }
.para.cream { color: var(--cream); } .para.dim { color: var(--dim); } .para.amber { color: var(--amber); }
.heading { font-family: var(--serif); font-weight: 700; font-size: 17px; color: var(--cream); padding-top: 16px; }
.chiprow { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; }
.slider { display: block; padding-top: 10px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; }
.slider-head .silk { font-size: 10.5px; color: var(--cream); }
.slider-val { font-weight: 700; font-size: 13px; color: var(--amber); }
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 2px 0 0;
  --fill: 0%;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 3px; border-radius: 2px; background: linear-gradient(to right, var(--amber) var(--fill), var(--edge) var(--fill));
}
input[type=range]::-moz-range-track { height: 3px; border-radius: 2px; background: var(--edge); }
input[type=range]::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--amber); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--cream); margin-top: -7.5px; border: 0;
}
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--cream); border: 0; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0 4px; color: var(--cream); cursor: pointer; }
.toggle input, .check input { accent-color: var(--amber); width: 20px; height: 20px; }
.check { display: flex; align-items: center; gap: 12px; padding: 10px 0; font-size: 16px; cursor: pointer; }
.prompt { padding: 8px 22px 0; }
.prompt-input {
  width: 100%; font-family: var(--serif); font-style: italic; font-size: 18px; color: var(--cream);
  background: transparent; border: 0; border-bottom: 2px solid var(--amber); padding: 8px 2px; outline: none;
}
.link { display: inline-block; color: var(--amber); padding-top: 12px; font-size: 14px; }
.fifths { width: 100%; max-width: 360px; aspect-ratio: 1; margin: 6px auto 0; cursor: pointer; }
.melody { width: 100%; margin-top: 10px; cursor: pointer; }

/* full-screen sheets (lyrics, track view) */
.scrim.full { padding: 0; background: var(--body); }
.scrim.full .dlg { max-width: none; max-height: none; height: 100%; border: 0; border-radius: 0; box-shadow: none; background: var(--body); }
.scrim.full .dlg-body { overflow: hidden; display: flex; }
.fs { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; width: 100%; padding-top: var(--safe-t); }
.fs-top { display: flex; align-items: center; gap: 6px; padding: 10px 10px 4px; }
.fs-title {
  flex: 1; min-width: 0; font-family: var(--serif); font-style: italic; font-size: 20px; color: var(--cream);
  padding: 0 8px 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lyrics { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 12px calc(12px + var(--safe-b)); width: 100%; max-width: 760px; margin: 0 auto; }
.lyrics .para { padding: 8px 0; }
.lyrics-text {
  flex: 1; min-height: 0; resize: none; font-family: var(--serif); font-size: 18px; line-height: 1.4; color: var(--cream);
  background: var(--lane); border: 1px solid var(--edge); border-radius: 6px; padding: 10px 12px; outline: none;
  -webkit-user-select: text; user-select: text;
}
.tv { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.tv-info { font-size: 12px; color: var(--dim); padding: 2px 14px 6px; }
.tv-actions { display: flex; gap: 6px; padding: 0 10px 8px; }
.tv-actions .chip { flex: 1; min-width: 0; }
.tv-actions .chip.zoom { flex: .5; }
.trackview { flex: 1 1 0; height: 0; min-height: 0; width: calc(100% - 16px); margin: 0 8px; cursor: crosshair; }
.tv-noteedit { display: flex; align-items: center; gap: 4px; padding: 6px 10px 0; }
.tv-noteedit .chip { flex: 1; padding: 8px 4px; letter-spacing: .06em; font-size: 10px; }
.tv-note { flex: 1.3; font-weight: 700; font-size: 14px; padding-right: 6px; }
.tv-hint { font-size: 11px; color: var(--faint); text-align: center; padding: 6px 10px; }
.tv-keys { padding: 4px 8px calc(12px + var(--safe-b)); }
.tv-keys .key { height: 60px; max-width: 220px; }
.tv-keys { justify-content: center; }

.noscript { padding: 40px; font-family: var(--serif); font-size: 18px; }
