:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --text: #0f172a;
  --text-muted: #64748b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App header ─────────────────────────────────────────── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}
.app-header h1 {
  font-size: 15px;
  font-weight: 600;
}
.app-header .subtitle {
  font-size: 13px;
  color: var(--text-muted);
}
.app-header .back-link {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}
.app-header .back-link:hover { color: var(--primary); text-decoration: none; }

/* ── Page container ─────────────────────────────────────── */
.container {
  max-width: 820px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ── Upload form ────────────────────────────────────────── */
.upload-form { display: grid; gap: .625rem; }
.form-row {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.form-row label {
  width: 80px;
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.form-row input[type="text"],
.form-row input[type="file"] {
  flex: 1;
  min-width: 0;
  padding: .4rem .625rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

@media (max-width: 480px) {
  .form-row {
    flex-direction: column;
    align-items: stretch;
    gap: .3rem;
  }
  .form-row label { width: auto; }
}
.form-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-actions { display: flex; align-items: center; gap: .75rem; margin-top: .25rem; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  padding: .45rem .875rem;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s, box-shadow .12s;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:not(:disabled):hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:not(:disabled):hover { background: var(--bg); }

/* ── Upload status ──────────────────────────────────────── */
#upload-status {
  font-size: 13px;
  padding: .4rem .75rem;
  border-radius: 5px;
  display: none;
}
#upload-status.success { background: #dcfce7; color: #166534; }
#upload-status.error   { background: #fee2e2; color: #991b1b; }

/* ── Session list ───────────────────────────────────────── */
.session-list { display: flex; flex-direction: column; gap: .5rem; list-style: none; }
.session-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: .75rem 1.25rem;
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}
.session-item:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.07);
}
.session-item a { font-weight: 500; }
.session-item .files { font-size: 12px; color: var(--text-muted); grid-column: 1 / -1; font-family: monospace; }
.session-item .date  { font-size: 12px; color: var(--text-muted); }
.btn-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .25rem .35rem;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s, background .12s, color .12s, border-color .12s;
}
.session-item:hover .btn-delete { opacity: 1; }
.btn-delete:hover { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── View page layout ───────────────────────────────────── */
body.view-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: #fff;
}
.timeline-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}
#timeline-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: default;
}

/* ── Zoom controls ──────────────────────────────────────── */
.zoom-controls {
  position: absolute;
  top: 10px;
  right: 12px;
  display: flex;
  gap: .3rem;
  z-index: 10;
}
.zoom-controls .btn { padding: .3rem .6rem; font-size: 14px; }
.zoom-hint { font-size: 11px; color: var(--text-muted); white-space: nowrap; align-self: center; }

/* ── Tooltip ────────────────────────────────────────────── */
#tooltip {
  position: fixed;
  background: rgba(15,23,42,.88);
  color: #f8fafc;
  font-size: 12px;
  padding: .35rem .6rem;
  border-radius: 5px;
  pointer-events: none;
  display: none;
  white-space: pre-line;
  max-width: 300px;
  z-index: 200;
  line-height: 1.45;
}

/* ── Error banner ───────────────────────────────────────── */
.error-banner {
  background: #fee2e2;
  color: #991b1b;
  padding: 1rem 1.5rem;
  font-size: 13px;
  border-bottom: 1px solid #fca5a5;
}
