:root {
  --bg: #111418;
  --card: #1b2027;
  --card-2: #242b34;
  --line: #313a45;
  --text: #eef1f5;
  --muted: #9aa5b1;
  --accent: #4f9cff;
  --accent-text: #0b1320;
  --highlight: #2c3f5c;
  --danger: #ff6b6b;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 18px;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  padding: calc(14px + env(safe-area-inset-top)) 16px 6px;
  max-width: 720px;
  margin: 0 auto;
}
.topbar h1 { margin: 0; font-size: 24px; }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 20px; }

.muted { color: var(--muted); }
.center { text-align: center; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { color: var(--muted); font-size: 15px; }

input[type="text"], textarea, select {
  width: 100%;
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font: inherit;
  font-size: 18px; /* 16px+ stops iPhone from zooming in */
}
textarea { resize: vertical; min-height: 200px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  border-radius: 12px;
  min-height: 52px;
  padding: 10px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.wide { width: 100%; }
.btn.big { min-height: 60px; font-size: 20px; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: 15px; font-weight: 500; }
.btn.danger { color: var(--danger); }

.row { display: flex; gap: 10px; margin-top: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font: inherit;
  font-size: 17px;
  min-height: 46px;
  min-width: 60px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 700; }

/* Segments */
.segment-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.segment { display: flex; gap: 10px; align-items: flex-start; }
.segment-num { flex: 0 0 28px; padding-top: 12px; text-align: right; color: var(--muted); font-weight: 600; }
.segment-body { flex: 1; min-width: 0; }
.segment-text { min-height: 0; resize: none; overflow: hidden; line-height: 1.35; }
.segment-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* Generate */
.progress-wrap { margin-top: 14px; }
.progress { height: 10px; background: var(--card-2); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.progress-text { margin: 8px 0 0; text-align: center; font-weight: 600; }
.status { margin: 10px 0 0; color: var(--muted); text-align: center; }
.status:empty { display: none; }

/* Player */
audio { width: 100%; }
.now-text { font-size: 22px; font-weight: 600; text-align: center; min-height: 2.9em; margin: 4px 0; }
.controls { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 8px; }
.btn.icon { width: 58px; height: 58px; min-height: 0; padding: 0; font-size: 22px; border-radius: 50%; }
.btn.icon.play { width: 74px; height: 74px; font-size: 28px; background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* Library */
.library-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

/* Camera Mode */
.camera-screen {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: calc(20px + env(safe-area-inset-top)) 20px calc(30px + env(safe-area-inset-bottom));
  gap: 20px;
}
.camera-screen[hidden] { display: none; }
.camera-close { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; width: 52px; padding: 0; }
.camera-progress { color: var(--muted); font-size: 22px; margin: 0; }
.camera-text {
  font-size: clamp(32px, 8vw, 64px);
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  margin: 0;
  max-width: 1000px;
  overflow-wrap: anywhere;
}
.camera-screen .controls { gap: 24px; }
.camera-screen .btn.icon { width: 80px; height: 80px; font-size: 32px; }
.camera-screen .btn.icon.play { width: 96px; height: 96px; font-size: 38px; }

[hidden] { display: none !important; }
