:root {
  --bg: #0f1214;
  --panel: #171b1f;
  --line: #2a3037;
  --text: #e8ebee;
  --dim: #9aa4ae;
  --accent: #ff5a4f;
  --ok: #3ecf8e;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px calc(14px);
  padding-top: calc(14px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.brand { color: var(--accent); font-weight: 700; text-decoration: none; letter-spacing: .3px; }
.topbar nav { display: flex; gap: 6px; }
.topbar nav a {
  color: var(--dim); text-decoration: none; padding: 6px 12px; border-radius: 999px;
  font-size: 14px;
}
.topbar nav a.on { color: var(--text); background: var(--panel); }

main { max-width: 640px; margin: 0 auto; padding: 20px 16px 60px; }
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.pane.narrow { max-width: 360px; margin: 40px auto; }
h1 { font-size: 20px; margin: 0 0 16px; }

label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--dim); }
label .opt { opacity: .7; }
input[type=text], input[type=password], textarea {
  width: 100%; padding: 12px; font: inherit; color: var(--text);
  background: #0c0f11; border: 1px solid var(--line); border-radius: 10px;
}
textarea { resize: vertical; }
button, .btn {
  font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line);
  background: #20262c; color: var(--text); padding: 12px 16px;
}
button.primary, .primary {
  background: var(--accent); border-color: var(--accent); color: #1a0d0c; font-weight: 700;
  width: 100%; padding: 14px; margin-top: 18px;
}
button.ghost { background: transparent; }
button.danger, .btn.danger { color: #ff8a82; border-color: #4a2b2b; }
.err { color: #ff8a82; font-size: 14px; }

/* ---- recorder ---- */
.recorder { text-align: center; }
.stage {
  position: relative; height: 150px; border-radius: 14px; overflow: hidden;
  background: #0c0f11; border: 1px solid var(--line); margin-bottom: 22px;
  display: flex; align-items: center; justify-content: center;
}
.stage.rec { border-color: var(--accent); }
#meter { position: absolute; inset: 0; width: 100%; height: 100%; }
.timer {
  position: relative; font-variant-numeric: tabular-nums; font-size: 34px; font-weight: 600;
  letter-spacing: 1px; text-shadow: 0 2px 12px #000;
}
.controls { display: flex; align-items: center; justify-content: center; gap: 18px; }
.recbtn {
  width: 84px; height: 84px; border-radius: 50%; padding: 0;
  background: var(--accent); border: 4px solid #2a1512;
  transition: border-radius .15s ease, transform .1s ease;
}
.recbtn:active { transform: scale(.96); }
.recbtn.recording { border-radius: 22px; }
.recbtn:disabled { opacity: .4; }
.hint { color: var(--dim); font-size: 14px; min-height: 1.4em; margin: 14px 0 0; }

.saveform { margin-top: 22px; text-align: left; border-top: 1px solid var(--line); padding-top: 18px; }
.saveform audio { width: 100%; margin-bottom: 8px; }
.saveform .row { display: flex; gap: 10px; margin-top: 18px; }
.saveform .row .primary { margin-top: 0; }
.saveform .row .ghost { flex: 0 0 auto; }
.status { font-size: 14px; color: var(--dim); min-height: 1.3em; margin: 12px 0 0; }

/* ---- library ---- */
.libhead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.pubnote, .rec-meta { color: var(--dim); font-size: 12px; }
.reclist { list-style: none; padding: 0; margin: 8px 0 0; }
.rec {
  display: flex; gap: 12px; justify-content: space-between;
  padding: 16px 0; border-top: 1px solid var(--line);
}
.rec-main { flex: 1; min-width: 0; }
.rec-title {
  font-size: 15px; font-weight: 600; border: 1px solid transparent; background: transparent;
  padding: 4px 6px; margin: -4px -6px 4px;
}
.rec-title:focus { border-color: var(--line); background: #0c0f11; }
.rec-title.ok { border-color: var(--ok); }
.rec-note { font-size: 13px; color: var(--text); opacity: .85; margin: 6px 0; white-space: pre-wrap; }
.rec audio { width: 100%; margin-top: 10px; height: 38px; }
.tag {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  background: #12312a; color: var(--ok); border: 1px solid #1c4a3f;
  font-size: 11px; white-space: nowrap;
}
.tag.warn { background: #3a2020; color: #ff8a82; border-color: #4a2b2b; }
.rec-actions { display: flex; flex-direction: column; gap: 8px; flex: 0 0 auto; }
.rec-actions .btn { text-align: center; text-decoration: none; font-size: 13px; padding: 8px 12px; }
