/* common.css — shared look for every tagging page (dark, matches the
   tagging panel in the main Pakket dashboard). */

:root {
  --bg: #070D19;
  --panel: #0A1120;
  --panel-2: #111827;
  --border: #1F2937;
  --border-2: #374151;
  --text: #E5E7EB;
  --muted: #9CA3AF;
  --faint: #6B7280;
  --blue: #3B82F6;
  --blue-hover: #2563EB;
  --blue-soft: rgba(59,130,246,0.12);
  --yellow: #EAB308;
  --yellow-soft: rgba(234,179,8,0.12);
  --green: #22C55E;
  --red: #EF4444;
  --orange: #F97316;
  --radius: 8px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14px; line-height: 1.45;
}
a { color: #93C5FD; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 700; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 700; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 14px;
  height: 48px; padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; letter-spacing: 0.02em; color: #fff; }
.brand span { color: var(--blue); }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 12px; }
.topbar a, .topbar button.link { color: var(--muted); font-size: 13px; }
.topbar a:hover, .topbar button.link:hover { color: #fff; text-decoration: none; }
.crumb { color: var(--muted); font-size: 13px; }
.crumb b { color: var(--text); font-weight: 600; }

.page { max-width: 1180px; margin: 0 auto; padding: 28px 16px 60px; }

/* Buttons + inputs */
button { font-family: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 6px; border: 1px solid transparent;
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
  background: var(--panel-2); color: var(--text); border-color: var(--border-2);
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #1F2937; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--blue-hover); }
.btn.danger { color: #FCA5A5; border-color: #7F1D1D; }
.btn.danger:hover { background: rgba(239,68,68,.12); }
.btn.small { padding: 4px 9px; font-size: 12px; }
button.link { background: none; border: none; padding: 0; cursor: pointer; }

input, select {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--border-2);
  border-radius: 6px; padding: 8px 10px; outline: none;
}
input:focus, select:focus { border-color: var(--blue); }
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 4px; }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px;
}
.msg { padding: 8px 12px; border-radius: 6px; font-size: 13px; margin-top: 10px; }
.msg.err { background: rgba(239,68,68,.12); color: #FCA5A5; }
.msg.ok { background: rgba(34,197,94,.12); color: #86EFAC; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
  background: #1F2937; color: var(--muted);
}
.badge.blue { background: var(--blue-soft); color: #93C5FD; }
.badge.green { background: rgba(34,197,94,.12); color: #86EFAC; }
.badge.yellow { background: var(--yellow-soft); color: #FDE68A; }
.badge.red { background: rgba(239,68,68,.12); color: #FCA5A5; }

/* ── Tagging workspace (tag.html, review.html) ───────────────────────── */
.workspace {
  display: flex; height: calc(100vh - 48px);
}
.canvas-wrap {
  position: relative; flex: 1; min-width: 0;
  background: #000; overflow: hidden;
}
.canvas-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.canvas-hint {
  position: absolute; left: 10px; bottom: 8px; z-index: 2;
  font-size: 11px; color: #D1D5DB; background: rgba(0,0,0,.55);
  padding: 4px 8px; border-radius: 4px; pointer-events: none;
}
.canvas-tools {
  position: absolute; right: 10px; top: 10px; z-index: 2; display: flex; gap: 6px;
}
.canvas-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 10px; color: var(--muted); text-align: center; padding: 20px;
}

.sidebar {
  width: 260px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--panel); border-left: 1px solid var(--border);
  padding: 14px 12px; overflow-y: auto;
}
.side-header {
  font-size: 12px; font-weight: 700; color: var(--text);
  text-transform: uppercase; letter-spacing: .05em; margin: 4px 0 2px;
}
.side-sub { font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; margin-top: 8px; }
.type-group { display: flex; flex-direction: column; gap: 5px; }
.type-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border: 1.5px solid var(--border-2); border-radius: 6px;
  background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 500; cursor: pointer; text-align: left;
}
.type-btn:hover { border-color: var(--faint); color: var(--text); }
.type-btn.selected { border-color: var(--blue); background: var(--blue-soft); color: #BFDBFE; }
.type-btn .swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.type-btn .key { margin-left: auto; font-size: 11px; color: var(--faint); }
.sub-row { display: flex; gap: 4px; padding: 0 0 2px 12px; }
.sub-btn {
  flex: 1; padding: 5px 4px; border: 1.5px solid var(--border-2); border-radius: 5px;
  background: transparent; color: var(--muted); font-size: 11px; font-weight: 500; cursor: pointer;
}
.sub-btn:hover { color: var(--text); }
.sub-btn.on { border-color: var(--yellow); background: var(--yellow-soft); color: #FDE68A; }

.ann-list { display: flex; flex-direction: column; gap: 3px; flex: 1; min-height: 60px; overflow-y: auto; }
.ann-item {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 5px;
  background: var(--panel-2); font-size: 12px; color: #D1D5DB; cursor: pointer;
  border: 1px solid transparent;
}
.ann-item.active { border-color: var(--blue); }
.ann-item .swatch { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.ann-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ann-item .flag {
  font-size: 10px; padding: 1px 5px; border-radius: 3px; border: 1px solid var(--border-2);
  background: none; color: var(--muted); cursor: pointer;
}
.ann-item .flag.on { border-color: var(--yellow); color: #FDE68A; }
.ann-item .del { background: none; border: none; color: var(--faint); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.ann-item .del:hover { color: var(--red); }
.ann-empty { font-size: 12px; color: var(--faint); padding: 4px 2px; }

.action-bar { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.action-row { display: flex; gap: 6px; }
.action-row .btn { flex: 1; padding-left: 6px; padding-right: 6px; }
.shortcuts { font-size: 11px; color: var(--faint); line-height: 1.6; }
.shortcuts kbd {
  font-family: inherit; font-size: 10px; padding: 0 4px; border-radius: 3px;
  border: 1px solid var(--border-2); color: var(--muted);
}

/* Modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  width: min(1300px, 100%); max-height: 94vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.modal-body { display: flex; min-height: 0; flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  background: #111827; border: 1px solid var(--border-2); color: var(--text);
  padding: 9px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
.toast.err { border-color: #7F1D1D; color: #FCA5A5; }

@media (max-width: 800px) {
  .workspace { flex-direction: column; height: auto; }
  .canvas-wrap { height: 60vh; flex: none; }
  .sidebar { width: 100%; border-left: none; border-top: 1px solid var(--border); }
}
