:root {
  --bg: #12100e;
  --panel: #1c1917;
  --panel-2: #262220;
  --line: #38322e;
  --text: #f5f0e8;
  --muted: #a39a90;
  --accent: #e4572e;
  --accent-2: #f5b700;
  --ok: #4a9d5f;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--accent-2); }

button, .button {
  font: inherit;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.1); }
button.danger { color: #ff9b8a; }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; min-height: 200px; font-family: ui-monospace, monospace; line-height: 1.55; }

/* login */
.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card { width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px; }
.brand { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 4px; }
.brand span { color: var(--accent); }
.tagline { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.login-card label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.login-card button { width: 100%; margin-top: 14px; }

/* layout */
header {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
header .brand { font-size: 20px; margin: 0; }
header .spacer { flex: 1; }
header input[type="search"] { width: 220px; }
header select { width: auto; }

main { padding: 20px; }

.count { color: var(--muted); font-size: 13px; }

/* table */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--panel); }
tbody tr.selected { background: var(--panel-2); }
td.year { font-variant-numeric: tabular-nums; color: var(--accent-2); font-weight: 600; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px;
  border: 1px solid var(--line); color: var(--muted); }
.tag.published { color: var(--ok); border-color: #2f5c3a; }
.dot { color: var(--muted); font-size: 15px; }
.dot.on { color: var(--ok); }

/* editor panel */
/* Sits between the page and the panel: dims the catalog and catches the
   click-outside that closes the editor. */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 9; }

.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(1000px, 92vw);
  background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 10;
  box-shadow: -20px 0 50px rgba(0,0,0,.45);
}
.panel-head, .panel-foot {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px;
}
.panel-head { border-bottom: 1px solid var(--line); }
.panel-foot { border-top: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 16px; flex: 1; }
.panel-body { flex: 1; overflow-y: auto; padding: 18px; }

/* Columns are driven by the panel's own width, so the same markup gives four
   columns on a desktop and one on a phone with no breakpoint bookkeeping. */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field.wide { grid-column: 1 / -1; }
.field.span2 { grid-column: span 2; }
/* Below two columns a span-2 field would invent a third, overflowing the panel. */
@media (max-width: 560px) { .field.span2 { grid-column: 1 / -1; } }
.field label { color: var(--muted); font-size: 12px; }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 16px; }
legend { color: var(--accent-2); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 0 6px; }

audio { width: 100%; margin-top: 8px; }
.hint { color: var(--muted); font-size: 12px; }
.warn { color: var(--accent-2); font-size: 12px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 18px; z-index: 50;
}
.toast.error { border-color: var(--accent); color: #ffb4a2; }

.error-text { color: #ffb4a2; margin-top: 12px; min-height: 20px; font-size: 13px; }

/* clip editor */
.clip-editor { margin-top: 12px; }
.wave {
  width: 100%; height: 104px; display: block;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  touch-action: none;   /* dragging the selection must not scroll the panel */
}
.clip-readout { margin-top: 6px; font-variant-numeric: tabular-nums; color: var(--accent-2); font-size: 13px; }
.clip-controls { display: flex; align-items: flex-end; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.clip-field { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.clip-field input { width: 130px; }
