/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d0d;
  --bg2: #161616;
  --bg3: #1f1f1f;
  --border: #2a2a2a;
  --accent: #e8ff47;
  --accent2: #b8cc1e;
  --text: #e8e8e8;
  --muted: #6b6b6b;
  --danger: #ff4d4d;
  --radius: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}
.logo span { color: var(--accent); }

.site-header nav {
  display: flex;
  gap: 24px;
  align-items: center;
}
.site-header nav a {
  color: var(--muted);
  font-size: 13px;
  transition: color 0.15s;
}
.site-header nav a:hover { color: var(--text); }
.site-header nav .logout:hover { color: var(--danger); }

/* ── Main ─────────────────────────────────────────────────────────────────── */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ── Flash ────────────────────────────────────────────────────────────────── */
.flash-wrap { margin-bottom: 20px; }
.flash {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 8px;
}
.flash.error { border-left-color: var(--danger); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: var(--accent2); }
.btn:active { transform: scale(0.98); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); background: var(--bg3); }

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}
.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.page-header .project-desc {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

/* ── Auth page ────────────────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  width: 100%;
  max-width: 360px;
  padding: 40px 32px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
}
.auth-card h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 4px;
}
.auth-card h1 span { color: var(--accent); }
.auth-card .subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 28px;
}
.auth-card input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  font-family: var(--font);
  text-align: center;
  letter-spacing: 3px;
  margin-bottom: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.auth-card input[type="password"]:focus { border-color: var(--accent); }
.auth-card button {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: background 0.15s;
}
.auth-card button:hover { background: var(--accent2); }

/* ── Project grid ─────────────────────────────────────────────────────────── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.project-card {
  display: block;
  padding: 20px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, background 0.15s;
}
.project-card:hover { border-color: var(--accent); background: var(--bg3); }
.project-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}
.project-desc {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.project-meta {
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
}

/* ── Upload zone ──────────────────────────────────────────────────────────── */
.upload-zone {
  margin-bottom: 36px;
  background: var(--bg2);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 24px;
  transition: border-color 0.2s;
}
.upload-zone.dragging { border-color: var(--accent); background: #1a1f00; }

.drop-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
  color: var(--muted);
  cursor: pointer;
}
.drop-area svg { color: var(--muted); }
.drop-area p { font-size: 14px; }
.drop-area .hint { font-size: 12px; color: #444; }
.drop-area .link { color: var(--accent); cursor: pointer; }
.drop-area .link:hover { text-decoration: underline; }

.file-list {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.file-list.hidden { display: none; }
.file-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text);
}
.file-chip .remove {
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.file-chip .remove:hover { color: var(--danger); }

.upload-btn {
  margin-top: 16px;
  width: 100%;
  justify-content: center;
  padding: 10px;
}
.upload-btn.hidden { display: none; }

/* Per-file upload progress bar — brandbook: Upload Interaction Pattern */
.progress-bar-wrap {
  width: 100%;
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  margin-top: 4px;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s;
}

/* File chip states — brandbook: File Chips component */
.file-chip.error {
  border-color: var(--danger);
  color: var(--danger);
}
.file-chip.done {
  border-color: #2a2a2a;
  opacity: 0.5;
}

/* ── Media sections ───────────────────────────────────────────────────────── */
.media-section { margin-bottom: 40px; }

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.cat-icon { font-size: 16px; }
.count {
  margin-left: auto;
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 11px;
  color: var(--text);
}

/* ── Media grid ───────────────────────────────────────────────────────────── */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.media-grid--audio { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.media-grid--font { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.media-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}
.media-card:hover { border-color: #3a3a3a; }

.media-thumb {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.media-thumb img, .media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.play-badge {
  position: absolute;
  font-size: 20px;
  color: rgba(255,255,255,0.8);
  pointer-events: none;
}
.audio-icon { font-size: 36px; color: var(--muted); }
.font-preview {
  font-size: 32px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: -1px;
}
.file-icon { font-size: 28px; }

.media-info {
  padding: 8px 10px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.media-name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.media-size { font-size: 11px; color: var(--muted); }

.audio-player {
  width: 100%;
  padding: 4px 8px;
  background: transparent;
  height: 32px;
  display: block;
}

.media-actions {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--border);
}
.action-link {
  flex: 1;
  text-align: center;
  padding: 7px 0;
  font-size: 11px;
  color: var(--muted);
  background: transparent;
  border: none;
  font-family: var(--font);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.action-link:hover { color: var(--text); background: var(--bg3); }
.action-link.danger:hover { color: var(--danger); }
.media-actions .action-link:not(:last-child) { border-right: 1px solid var(--border); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-page { max-width: 520px; }
.form-page h2 { font-size: 20px; font-weight: 700; margin-bottom: 24px; }
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 6px;
  margin-top: 18px;
}
label:first-of-type { margin-top: 0; }
.optional { text-transform: none; font-weight: 400; letter-spacing: 0; }
input[type="text"], textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}
input[type="text"]:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 28px;
  justify-content: flex-end;
}

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}
.empty-state p { margin-bottom: 16px; }

/* ── Analysis panel ───────────────────────────────────────────────────────── */
.analysis-panel {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  background: var(--bg);
}
.analysis-panel.pending { color: var(--muted); font-style: italic; }
.analysis-panel.processing { color: var(--accent); font-style: italic; }
.analysis-panel.error { color: var(--danger); }
.analysis-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px solid #1a1a1a;
}
.analysis-row:last-child { border-bottom: none; }
.a-label { color: var(--muted); flex-shrink: 0; }
.a-val { text-align: right; color: var(--text); }
.a-val.muted { color: var(--muted); }
.a-val.accent { color: var(--accent); }
.analysis-transcript {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #1a1a1a;
  max-height: 120px;
  overflow-y: auto;
}
.transcript-seg {
  display: flex;
  gap: 6px;
  margin-bottom: 3px;
  line-height: 1.4;
}
.tc { color: var(--accent); flex-shrink: 0; font-family: monospace; font-size: 10px; }
.txt { color: var(--text); }
.analysis-music-desc {
  color: var(--muted);
  font-size: 10px;
  margin: 4px 0;
  font-style: italic;
  line-height: 1.4;
}
.btn-analyze { margin-left: 12px; }
