/* EditButler — mobile-first dark UI */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0f1115;
  --card: #1a1e26;
  --card-2: #232834;
  --text: #f2f4f8;
  --muted: #8b93a3;
  --accent: #4f8cff;
  --rec: #ff3b30;
  --done: #34c759;
  --radius: 14px;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- views ---------- */
.view { display: none; padding: 16px; padding-bottom: 48px; max-width: 560px; margin: 0 auto; }
.view.active { display: block; }

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 0 16px;
}
.app-header h1 { font-size: 1.35rem; margin: 0; font-weight: 700; flex: 1; }

.icon-btn {
  background: var(--card); color: var(--text); border: none;
  width: 44px; height: 44px; border-radius: 12px; font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  flex: none;
}
.icon-btn:active { background: var(--card-2); }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

/* ---------- buttons ---------- */
.btn-primary, .btn-secondary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; border: none; border-radius: var(--radius);
  font-size: 1.05rem; font-weight: 600; cursor: pointer; color: #fff;
}
.btn-primary { background: var(--accent); }
.btn-primary:active { filter: brightness(.85); }
.btn-secondary { background: var(--card-2); }
.btn-secondary:active { filter: brightness(.85); }
.btn-big { min-height: 56px; margin-top: 12px; }
.btn-text {
  background: none; border: none; color: var(--accent);
  font-size: .95rem; padding: 12px 4px; cursor: pointer;
}
button:disabled { opacity: .5; pointer-events: none; }

/* ---------- home: progress ---------- */
.progress-wrap { margin-bottom: 16px; }
.progress-row {
  display: flex; justify-content: space-between;
  font-size: .9rem; color: var(--muted); margin-bottom: 6px;
}
.progress-bar {
  height: 10px; background: var(--card); border-radius: 6px; overflow: hidden;
}
#progress-fill {
  height: 100%; width: 0%; background: var(--done);
  border-radius: 6px; transition: width .4s ease;
}

/* ---------- home: next-up card ---------- */
.next-card {
  background: linear-gradient(135deg, #1c2f55, #15203a);
  border: 1px solid #2c4a8a;
  border-radius: var(--radius); padding: 18px; margin-bottom: 24px;
}
.next-card .eyebrow {
  font-size: .75rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); font-weight: 700; margin: 0 0 8px;
}
.next-card h3 { margin: 0 0 6px; font-size: 1.2rem; }
.next-card .meta { font-size: .85rem; color: var(--muted); margin: 0 0 14px; }
.all-done {
  background: var(--card); border-radius: var(--radius);
  padding: 24px 18px; text-align: center; margin-bottom: 24px;
}

/* ---------- home: library ---------- */
.section-title { font-size: 1rem; color: var(--muted); margin: 20px 0 8px; font-weight: 600; }
.cat-title { font-size: .8rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin: 18px 0 8px; }
.script-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--card); border: none; color: var(--text);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 8px;
  font-size: .98rem; cursor: pointer;
}
.script-item:active { background: var(--card-2); }
.script-item .t { flex: 1; }
.script-item .t .sub { display: block; font-size: .8rem; color: var(--muted); margin-top: 2px; }
.badge {
  font-size: .72rem; font-weight: 700; padding: 4px 8px; border-radius: 999px; flex: none;
}
.badge-done { background: rgba(52,199,89,.15); color: var(--done); }
.badge-todo { background: rgba(139,147,163,.15); color: var(--muted); }

/* ---------- detail ---------- */
.detail-title { font-size: 1.15rem !important; }
.detail-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  background: rgba(79,140,255,.15); color: var(--accent);
  font-size: .75rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
}
#script-edit {
  width: 100%; min-height: 220px; background: var(--card); color: var(--text);
  border: 1px solid #2a3040; border-radius: var(--radius);
  padding: 14px; font-size: 1.05rem; line-height: 1.55; resize: vertical;
  font-family: inherit;
}
#script-edit:focus { outline: none; border-color: var(--accent); }
.detail-actions-row {
  display: flex; align-items: center; justify-content: space-between; min-height: 40px;
}

/* ---------- recorder ---------- */
.recorder-view.active {
  display: block; position: fixed; inset: 0; padding: 0; max-width: none;
  background: #000; z-index: 50; overflow: hidden;
}
#preview {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; transform: scaleX(-1); /* mirror selfie view */
  background: #000;
}
#preview.no-mirror { transform: none; } /* back camera: don't mirror */
#prompter {
  position: absolute; left: 0; right: 0; top: 0; height: 58%;
  overflow: hidden; z-index: 2;
  background: linear-gradient(rgba(0,0,0,.55), rgba(0,0,0,.35) 80%, transparent);
  -webkit-mask-image: linear-gradient(#000 82%, transparent);
          mask-image: linear-gradient(#000 82%, transparent);
}
#prompter-content {
  padding: 45vh 24px 60px;
  font-size: 30px; line-height: 1.5; font-weight: 600; text-align: center;
  color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.9);
  will-change: transform;
}
.rec-topbar {
  position: absolute; z-index: 3; left: 0; right: 0;
  top: env(safe-area-inset-top, 0px);
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
}
.rec-close { background: rgba(0,0,0,.45); }
.rec-indicator {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,.45); border-radius: 999px; padding: 8px 14px;
  font-variant-numeric: tabular-nums; font-weight: 700;
}
.rec-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--rec);
  animation: blink 1.2s infinite;
}
@keyframes blink { 50% { opacity: .25; } }

.rec-controls {
  position: absolute; z-index: 3; left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.rec-adjust { display: flex; gap: 18px; }
.adjust-group {
  display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,.45); border-radius: 999px; padding: 6px 10px;
}
.adjust-label { font-size: .75rem; color: #cdd3df; padding: 0 4px; }
.adjust-btn {
  background: rgba(255,255,255,.14); color: #fff; border: none;
  min-width: 42px; height: 38px; border-radius: 999px;
  font-size: 1rem; font-weight: 700; cursor: pointer;
}
.adjust-btn:active { background: rgba(255,255,255,.3); }

.record-btn {
  width: 76px; height: 76px; border-radius: 50%; cursor: pointer;
  border: 4px solid #fff; background: transparent; position: relative; padding: 0;
}
.record-btn::after {
  content: ""; position: absolute; inset: 6px;
  background: var(--rec); border-radius: 50%;
  transition: border-radius .2s, inset .2s;
}
.record-btn.recording::after { inset: 20px; border-radius: 6px; }

#countdown {
  position: absolute; inset: 0; z-index: 4;
  display: flex; align-items: center; justify-content: center;
  font-size: 120px; font-weight: 800; color: #fff;
  background: rgba(0,0,0,.35); text-shadow: 0 2px 12px rgba(0,0,0,.8);
}
#countdown[hidden] { display: none; }

.cam-error {
  position: absolute; inset: 0; z-index: 5; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 32px; gap: 6px;
}
.cam-error[hidden] { display: none; }
.cam-error .btn-primary { max-width: 280px; min-height: 52px; margin-top: 16px; }

/* ---------- review ---------- */
#playback {
  width: 100%; max-height: 56vh; background: #000;
  border-radius: var(--radius); display: block;
}
.review-actions { margin-top: 8px; }
.review-actions[hidden] { display: none; }
.upload-status { min-height: 22px; text-align: center; font-size: .92rem; color: var(--muted); }
.upload-status.ok { color: var(--done); }
.upload-status.err { color: var(--rec); }
.btn-next { background: var(--done); }

/* ---------- settings ---------- */
.field { display: block; margin-bottom: 18px; }
.field > span { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 8px; }
.field input[type="url"], .field input[type="text"] {
  width: 100%; background: var(--card); color: var(--text);
  border: 1px solid #2a3040; border-radius: 12px; padding: 14px; font-size: 1rem;
}
.field input:focus { outline: none; border-color: var(--accent); }
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
