:root {
  --bg: #14110d;
  --surface: #1c1810;
  --surface-2: #241f15;
  --border: #362d1c;
  --border-soft: #2a2417;
  --text: #f4ede1;
  --text-dim: #a49a86;
  --accent: #ff6a2b;
  --accent-soft: #ff6a2b1e;
  --accent-ink: #2b1206;

  --feel: #8ed17c; --feel-bg: #8ed17c1c;
  --evidence: #6fb6e0; --evidence-bg: #6fb6e01c;
  --reference: #caa0f2; --reference-bg: #caa0f21c;
  --nothing: #8a8172; --nothing-bg: #8a81721c;

  --radius: 10px;
  --radius-lg: 14px;

  --font-display: "Bricolage Grotesque", "IBM Plex Sans", sans-serif;
  --font-body: "IBM Plex Sans", -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  background-image: radial-gradient(circle at 12% -10%, #2a2013 0%, transparent 45%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
svg { display: block; }

button, input, textarea { font-family: inherit; }

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border-soft);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
  font-family: var(--font-body);
}

.btn:hover { transform: translateY(-1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-dark {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border);
}

.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }

/* ---- Layout ---- */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 44px 24px 90px;
}

.page-head h1 {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
  text-wrap: balance;
}

.page-head p {
  color: var(--text-dim);
  margin: 0 0 30px;
  font-size: 15px;
}

/* ---- Empty state ---- */
.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 72px 20px;
  text-align: center;
  background: var(--surface);
}

.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}

.empty-state h3 { font-family: var(--font-display); margin: 0 0 8px; font-size: 17px; font-weight: 700; }
.empty-state p { color: var(--text-dim); margin: 0 0 22px; font-size: 13.5px; }

/* ---- Project grid ---- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  transition: border-color .12s ease;
}

.project-card:hover { border-color: var(--accent); }

.project-thumb {
  height: 104px;
  border-radius: 8px;
  background: var(--surface-2);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  background-image: repeating-linear-gradient(90deg, var(--border-soft) 0 1px, transparent 1px 14px);
}

.project-card h4 { font-family: var(--font-display); margin: 0 0 3px; font-size: 14.5px; font-weight: 600; }
.project-card .meta { color: var(--text-dim); font-size: 12px; font-family: var(--font-mono); }

.project-card-new {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  min-height: 158px;
  border-style: dashed;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
}

/* ---- Card / form ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 26px;
}

label.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .04em;
}

input[type="text"], textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 12px 14px;
  font-size: 14px;
}

input[type="text"]::placeholder, textarea::placeholder { color: #5c5647; }

textarea { min-height: 180px; resize: vertical; line-height: 1.55; font-family: var(--font-body); }

.field { margin-bottom: 22px; }

.choice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.choice-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: left;
  cursor: pointer;
  background: var(--bg);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.choice-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice-card .icon { color: var(--text-dim); flex: 0 0 auto; margin-top: 2px; }
.choice-card.active .icon { color: var(--accent); }
.choice-card h4 { margin: 0 0 3px; font-size: 13.5px; font-weight: 600; }
.choice-card p { margin: 0; font-size: 12px; color: var(--text-dim); }

.upload-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}

.upload-link:hover { color: var(--text); border-color: var(--text-dim); }

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

/* ---- Workspace ---- */
.workspace-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.workspace-head h1 { font-family: var(--font-display); font-size: 30px; margin: 0 0 12px; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 18px;
}

.back-link:hover { color: var(--text); }

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}

.segment-list { margin-top: 26px; display: flex; flex-direction: column; gap: 10px; }

.segment-row {
  display: grid;
  grid-template-columns: 128px 1fr;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}

.segment-row.empty-beat { opacity: .5; }

.segment-meta {
  padding: 16px 14px;
  border-right: 1px dashed var(--border);
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
}

.segment-row.empty-beat .segment-meta { border-left-color: var(--nothing); }

.segment-meta .idx {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: .03em;
}

.segment-meta .time {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  margin: 4px 0 2px;
  font-variant-numeric: tabular-nums;
}

.segment-meta .dur {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .05em;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}

.badge-feel { background: var(--feel-bg); color: var(--feel); }
.badge-evidence { background: var(--evidence-bg); color: var(--evidence); }
.badge-reference { background: var(--reference-bg); color: var(--reference); }
.badge-nothing { background: var(--nothing-bg); color: var(--nothing); }

.segment-body { padding: 16px 18px; }
.segment-text { font-size: 15px; margin: 0 0 14px; line-height: 1.45; font-weight: 400; }

.clip-queue {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 4px 6px;
  margin: 0 -4px;
}

.clip-card {
  flex: 0 0 auto;
  width: 124px;
  cursor: pointer;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1.5px solid var(--border);
  background: var(--bg);
  transition: border-color .12s ease;
}

.clip-card:hover, .clip-card.selected { border-color: var(--accent); }

.clip-thumb {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--surface-2);
  color: var(--text-dim);
}

.clip-card:hover .clip-thumb, .clip-card.selected .clip-thumb { color: var(--accent); }

.src-chip {
  position: absolute;
  top: 6px;
  left: 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .03em;
  color: #0d0b08;
  padding: 2px 6px;
  border-radius: 4px;
}

.src-youtube { background: #ff9a76; }
.src-giphy { background: #caa0f2; }
.src-tenor { background: #6fb6e0; }

.clip-label {
  font-size: 11px;
  padding: 7px 8px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.no-clip-msg {
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
}

/* ---- Preview modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8,6,4,.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 420px;
  max-width: 90vw;
  overflow: hidden;
  box-shadow: 0 30px 70px rgba(0,0,0,.5);
}

.modal-preview {
  height: 230px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--surface-2);
}

.modal-play {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
}

.modal-body { padding: 18px 20px; }
.modal-body h4 { font-family: var(--font-display); margin: 0 0 5px; font-size: 15.5px; font-weight: 600; }
.modal-body p { margin: 0 0 16px; font-size: 12.5px; color: var(--text-dim); font-family: var(--font-mono); }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; justify-content: center; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  cursor: pointer;
  color: #fff;
  background: rgba(0,0,0,.4);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Evidence footage ---- */
.evidence-block { padding-top: 2px; }
.btn-find-footage { padding: 8px 14px; }

.clip-sub {
  font-size: 10px;
  padding: 0 8px 8px;
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ev-ok { color: var(--evidence); }
.ev-warn { color: var(--nothing); font-style: italic; }

/* Excerpt preview iframe fills the modal's preview area, replacing the gif thumbnail.
   Kept below the close button so the X stays clickable over the embed. */
#modal-iframe { position: absolute; inset: 0; z-index: 1; }
.modal-close { z-index: 2; }

@media (prefers-reduced-motion: reduce) {
  .btn, .project-card, .clip-card { transition: none; }
}
