/* RiffDrop — dark, dense DAW styling. */

:root {
  --bg: #16171a;
  --panel: #212328;
  --panel-2: #27292f;
  --panel-3: #30333a;
  --lane: #1a1b1f;
  --line: #0c0d0f;
  --line-soft: #34373e;
  --grid-bar: rgba(255, 255, 255, 0.075);
  --grid-beat: rgba(255, 255, 255, 0.03);
  --text: #d9dce2;
  --text-dim: #8b909a;
  --accent: #4f9cff;
  --rec: #e5484d;
  --play: #4cc472;
  --mute: #f0a23d;
  --solo: #f1d548;
  --header-w: 224px; /* keep in sync with HEADER_W in daw.js */
  --track-h: 68px;
  --ruler-h: 26px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 12px/1.35 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--text-dim); }
.spacer { flex: 1; }
.error-text { color: #ff8d8f; }

/* ── Top bar (shared by home + DAW) ───────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: none;
  min-width: 0;
}

.brand {
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
  flex: none;
}
.brand span { color: var(--rec); }

.drop-name {
  font-weight: 600;
  font-size: 13px;
  max-width: 220px;
  min-width: 60px;
  padding: 3px 6px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}
.drop-name:hover { background: var(--panel-3); }

.transport, .tempo, .zoom { display: flex; align-items: center; gap: 3px; flex: none; }

.tbtn {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: linear-gradient(#33363d, #2a2d33);
  color: var(--text);
  cursor: pointer;
}
.tbtn:hover { background: linear-gradient(#3a3d45, #30333a); }
.tbtn .icon { width: 14px; height: 14px; fill: currentColor; }
.tbtn.play .icon { fill: #c9ccd2; }
.tbtn.play.on { background: #1f3a29; }
.tbtn.play.on .icon { fill: var(--play); }
.tbtn.rec .icon { fill: var(--rec); }
.tbtn.rec.on { background: var(--rec); }
.tbtn.rec.on .icon { fill: #fff; }
.tbtn.rec.blink { animation: blink 0.5s steps(2, start) infinite; }
.tbtn.toggle.on { background: #263b57; color: #cfe3ff; border-color: #0d1a2b; }
.tbtn.toggle.on .icon { fill: #9cc8ff; }
.tbtn.text { font-size: 11px; font-weight: 600; color: var(--text-dim); }
.tbtn.text.on { color: #cfe3ff; }
@keyframes blink { to { background: var(--rec); } }

.lcd {
  font-family: var(--mono);
  background: #0e0f11;
  border: 1px solid #000;
  border-radius: 3px;
  padding: 1px 10px;
  min-width: 112px;
  text-align: right;
  line-height: 1.15;
  flex: none;
}
.lcd-main { font-size: 15px; color: #e8f1ff; letter-spacing: 0.02em; }
.lcd-sub { font-size: 10px; color: var(--text-dim); }

.field-btn, .field-static {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid #000;
  border-radius: 3px;
  background: #0e0f11;
  font-family: var(--mono);
  line-height: 26px;
}
.field-btn { cursor: text; }
.field-btn .bpm-value { font-size: 14px; color: #e8f1ff; }
.field-btn .unit, .field-static { font-size: 10px; color: var(--text-dim); }
.field-static { font-size: 12px; color: #c9ccd2; }

.author-input {
  width: 110px;
  height: 26px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #18191c;
}

.share-btn, .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: linear-gradient(#33363d, #2a2d33);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
}
.share-btn .icon, .add-track .icon { width: 13px; height: 13px; fill: currentColor; }
.btn.primary { background: linear-gradient(#3d79c9, #2f63a8); border-color: #10233d; color: #fff; }
.btn:disabled { opacity: 0.5; cursor: default; }
.text-btn { background: none; border: 0; color: var(--text-dim); cursor: pointer; text-decoration: underline; }

.inline-edit {
  width: 100%;
  min-width: 60px;
  height: 22px;
  padding: 0 5px;
  border: 1px solid var(--accent);
  border-radius: 2px;
  background: #0e0f11;
  outline: none;
}
.bpm-edit { width: 58px; font-family: var(--mono); }

.notice-bar {
  padding: 6px 12px;
  background: #3a2a12;
  color: #ffd9a3;
  border-bottom: 1px solid var(--line);
}

/* ── DAW layout ───────────────────────────────────────────────────── */

body.daw-page { overflow: hidden; }
.daw { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.arrange {
  position: relative;
  flex: 1;
  overflow: auto;
  background: var(--bg);
  overscroll-behavior: contain;
}
.arrange-inner {
  position: relative;
  width: calc(var(--header-w) + var(--timeline-w, 1000px));
  min-height: 100%;
}

/* Ruler (sticky on top) */
.ruler-row {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  height: var(--ruler-h);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.corner {
  position: sticky;
  left: 0;
  z-index: 6;
  width: var(--header-w);
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.ruler {
  position: relative;
  width: var(--timeline-w);
  flex: none;
  cursor: pointer;
  user-select: none;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.32) 1px, transparent 1px),
    linear-gradient(to right, rgba(255, 255, 255, 0.16) 1px, transparent 1px);
  background-size: var(--bar-px) 100%, var(--beat-px) 7px;
  background-position: 0 0, 0 100%;
  background-repeat: repeat-x;
}
.dense .ruler { background-size: var(--bar-px) 100%, 0 0; }
.bar-label {
  position: absolute;
  top: 3px;
  padding-left: 4px;
  font-size: 11px;
  color: #aeb3bc;
  font-family: var(--mono);
  pointer-events: none;
}
.ruler-head {
  position: absolute;
  bottom: 0;
  left: -6px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid #f4f4f4;
  pointer-events: none;
}

/* Tracks */
.track-row {
  display: flex;
  height: var(--track-h);
  border-bottom: 1px solid var(--line);
}
.track-header {
  position: sticky;
  left: 0;
  z-index: 6;
  display: flex;
  width: var(--header-w);
  flex: none;
  background: var(--panel-2);
  border-right: 1px solid var(--line);
  user-select: none;
}
.track-row.selected .track-header { background: #31353d; }
.track-row.selected .track-name { color: #fff; }
.color-chip {
  width: 7px;
  flex: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.track-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 0 8px 0 9px;
}
.track-top { display: flex; align-items: center; gap: 4px; min-width: 0; }
.track-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #c9ccd2;
}
.more {
  display: grid;
  place-items: center;
  width: 20px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.more:hover { background: var(--panel-3); color: var(--text); }
.more .icon { width: 12px; height: 12px; fill: currentColor; }
.track-controls { display: flex; align-items: center; gap: 4px; }
.flag {
  width: 22px;
  height: 18px;
  padding: 0;
  border: 1px solid #111215;
  border-radius: 2px;
  background: #3a3d44;
  color: #c3c7ce;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.flag:hover { background: #454952; }
.flag.arm.on { background: var(--rec); color: #fff; }
.flag.mute.on { background: var(--mute); color: #1d1406; }
.flag.solo.on { background: var(--solo); color: #1d1a06; }
.meter {
  flex: 1;
  height: 6px;
  margin-left: 4px;
  background: #0f1012;
  border-radius: 1px;
  overflow: hidden;
  visibility: hidden;
}
.track-row.armed .meter { visibility: visible; }
.meter-fill { width: 0; height: 100%; background: var(--play); transition: width 50ms linear; }
.meter-fill.hot { background: var(--rec); }

.lane {
  position: relative;
  width: var(--timeline-w);
  flex: none;
  background-color: var(--lane);
  background-image:
    linear-gradient(to right, var(--grid-bar) 1px, transparent 1px),
    linear-gradient(to right, var(--grid-beat) 1px, transparent 1px);
  background-size: var(--bar-px) 100%, var(--beat-px) 100%;
}
.dense .lane { background-size: var(--bar-px) 100%, 0 0; }
.track-row.selected .lane { background-color: #1e2025; }

.add-row { height: 34px; }
.add-cell { align-items: center; padding-left: 10px; background: var(--panel); }
.add-track {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: linear-gradient(#33363d, #2a2d33);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}
.add-track:hover { background: linear-gradient(#3a3d45, #30333a); }
.lane.filler { background-color: transparent; }

/* Clips */
.clip {
  position: absolute;
  top: 3px;
  bottom: 3px;
  overflow: hidden;
  border-radius: 3px;
  /* Plain fallbacks first for Safari < 16.2 (no color-mix). */
  border: 1px solid var(--track-color);
  background: #2a2c31;
  border: 1px solid color-mix(in srgb, var(--track-color) 75%, #000);
  background: color-mix(in srgb, var(--track-color) 26%, #121316);
}
.clip-label {
  height: 14px;
  padding: 0 5px;
  font-size: 10px;
  line-height: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255, 255, 255, 0.92);
  background: var(--track-color);
  background: color-mix(in srgb, var(--track-color) 62%, #000);
}
.clip .wave {
  position: absolute;
  left: 0;
  top: 15px;
  width: 100%;
  height: calc(100% - 16px);
  fill: var(--track-color);
  stroke: var(--track-color);
  fill: color-mix(in srgb, var(--track-color) 80%, #fff);
  stroke: color-mix(in srgb, var(--track-color) 80%, #fff);
  stroke-width: 0.6px;
}
.clip.loading { animation: pulse 1.2s ease-in-out infinite; }
.clip.error {
  border-color: var(--rec);
  background: repeating-linear-gradient(45deg, #3b1d1f 0 6px, #2a1517 6px 12px);
}
.clip.saving .clip-label { font-style: italic; }
.clip-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: rgba(0, 0, 0, 0.45); }
.clip-progress > div { height: 100%; background: #fff; transition: width 0.15s; }
.clip.failed { border: 1px dashed var(--rec); }
.clip.failed .clip-label { background: var(--rec); }
.clip.recording { border-color: var(--rec); background: rgba(229, 72, 77, 0.22); }
.clip.recording .clip-label { background: var(--rec); }
.clip.recording .wave { fill: #ffc9cb; stroke: #ffc9cb; }
@keyframes pulse { 50% { opacity: 0.45; } }

/* Playhead */
.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 1px;
  background: #f4f4f4;
  z-index: 4;
  pointer-events: none;
  will-change: transform;
}

.load-error { padding: 40px 20px; text-align: center; color: var(--text-dim); }

/* Menus */
.menu {
  position: fixed;
  z-index: 50;
  min-width: 170px;
  padding: 4px;
  background: #2b2e34;
  border: 1px solid #0b0c0e;
  border-radius: 4px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.menu-item {
  display: block;
  width: 100%;
  padding: 5px 10px;
  border: 0;
  border-radius: 2px;
  background: none;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover { background: var(--accent); color: #fff; }
.menu-item.danger { color: #ff8d8f; }
.menu-item.danger:hover { background: var(--rec); color: #fff; }
.swatches { display: grid; grid-template-columns: repeat(6, 20px); gap: 5px; padding: 6px 8px; }
.swatch { width: 20px; height: 20px; border: 1px solid #000; border-radius: 3px; cursor: pointer; padding: 0; }
.swatch.on { outline: 2px solid #fff; outline-offset: 1px; }

/* Toasts */
.toasts { position: fixed; right: 14px; bottom: 14px; display: grid; gap: 6px; z-index: 60; }
.toast {
  padding: 7px 12px;
  background: #2f333a;
  border: 1px solid #0b0c0e;
  border-left: 3px solid var(--accent);
  border-radius: 3px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  max-width: 360px;
}

/* ── Home ─────────────────────────────────────────────────────────── */

.home { max-width: 920px; margin: 0 auto; padding: 22px 16px 60px; }
.hero h1 { font-size: 26px; margin: 34px 0 10px; }
.hero p { max-width: 36em; margin: 0 0 20px; font-size: 13px; }
.browser-head { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 12px; }
.browser-head h2 { margin: 0; font-size: 15px; }
.drop-table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); }
.drop-table th, .drop-table td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); }
.drop-table th { font-size: 11px; font-weight: 600; color: var(--text-dim); background: var(--panel-2); }
.drop-table tr:hover td { background: var(--panel-2); }
.drop-table a { color: var(--text); font-weight: 600; text-decoration: none; }

/* Documents (privacy, terms) and the footer linking to them. */
.doc { max-width: 680px; margin: 0 auto; padding: 22px 16px 24px; font-size: 14px; line-height: 1.6; }
.doc h1 { font-size: 24px; margin: 18px 0 2px; }
.doc h2 { font-size: 15px; margin: 26px 0 6px; }
.doc p, .doc ul { margin: 0 0 10px; }
.doc ul { padding-left: 20px; }
.doc li { margin: 3px 0; }
.doc code { font-family: var(--mono); font-size: 12px; }
.site-footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; padding: 18px 16px 28px; font-size: 12px; }
.site-footer a { color: var(--text-dim); }

/* Narrow screens: keep the DAW layout, just tighter. */
@media (max-width: 760px) {
  :root { --header-w: 150px; }
  .topbar { overflow-x: auto; }
  .drop-name, .author-input, .zoom { display: none; }
}
