:root {
  --bg: #16131f;
  --surface: #221d31;
  --surface-2: #2c2542;
  --text: #ece8f6;
  --muted: #a79fc0;
  --accent: #8b6ef0;
  --accent-dark: #6d4fc4;
  --danger: #e06c75;
  --ok: #7bd88f;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  padding-top: max(0.6rem, env(safe-area-inset-top));
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar a, .topbar .linklike {
  color: var(--text);
  text-decoration: none;
  font-size: 1rem;
}
.topbar nav { display: flex; gap: 1rem; align-items: center; }
.brand { font-weight: 700; }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

input[type="text"], input[type="password"], input[type="time"], input[type="url"], textarea {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  font: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 4.5rem; }

label.field { display: block; margin-bottom: 0.8rem; }
label.field > span { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.25rem; }

button {
  font: inherit;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 0.9rem;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
button:active { transform: translateY(1px); }
button.primary { background: var(--accent-dark); }
button.primary:hover { background: var(--accent); }
button.linklike {
  background: none;
  padding: 0;
  color: var(--muted);
  text-decoration: underline;
}

.error { color: var(--danger); }
.muted { color: var(--muted); font-size: 0.85rem; }
.hidden { display: none !important; }

.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* page list */
.page-list { list-style: none; padding: 0; margin: 0; }
.page-list li a {
  display: block;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin-bottom: 0.5rem;
  color: var(--text);
  text-decoration: none;
}
.page-list li a:hover { background: var(--surface-2); }
.page-list .date { color: var(--muted); font-size: 0.8rem; }

/* slot transport */
.slot {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 0.8rem;
  margin-bottom: 0.6rem;
}
.slot-label { font-weight: 600; margin-bottom: 0.5rem; }

.transport { display: flex; gap: 0.6rem; align-items: center; }
.transport-btn {
  width: 8.5rem;
  height: 3rem;
  flex: none;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  background: var(--accent-dark);
}
.transport-btn.recording { background: var(--danger); }
.transport-btn.playing { background: var(--ok); color: #10241a; }
.retake-btn { height: 3rem; }

.upload-status { font-size: 0.8rem; color: var(--muted); }
.upload-status.failed { color: var(--danger); }
.upload-status.saved { color: var(--ok); }

/* take list */
.takes { list-style: none; padding: 0; margin: 0.6rem 0 0; }
.takes li {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem 0;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-wrap: wrap;
}
.takes .take-no { font-variant-numeric: tabular-nums; min-width: 2.2rem; }
.takes .take-time { color: var(--muted); font-size: 0.75rem; }
.takes input.note { flex: 1 1 10rem; padding: 0.3rem 0.5rem; font-size: 0.85rem; }
.star-btn { background: none; padding: 0.2rem; font-size: 1.1rem; }
.star-btn.starred { color: gold; }
.icon-btn { background: none; padding: 0.2rem 0.4rem; font-size: 1rem; }
.takes a.dl { color: var(--muted); text-decoration: none; font-size: 0.9rem; }

/* share box */
.share-url {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  word-break: break-all;
  background: var(--surface-2);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  flex: 1;
}

/* settings */
.day-picker { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.day-picker button { padding: 0.4rem 0.6rem; }
.day-picker button.on { background: var(--accent-dark); }
.time-list { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.time-chip {
  background: var(--surface-2);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
}

/* login overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.login-card {
  width: min(90vw, 320px);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  text-align: center;
}

/* toggle switch (checkbox based, kept simple) */
.check { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.8rem; }
.check input { width: auto; }
