/*
 * theme.css — design tokens + semantic component classes.
 *
 * THEMING CONTRACT (see docs/UI.md):
 *  - Views use ONLY semantic classes from this file (.card, .btn, .chip, …).
 *  - No hardcoded colors/pixels in feature code — ever.
 *  - A future polish pass = edit the tokens below and/or restyle the
 *    component classes. Feature views stay untouched.
 */

/* ---------- design tokens ---------- */
:root {
  /* palette */
  --bg: #12141a;
  --bg-2: #171a21;
  --surface: #1c2028;
  --surface-2: #232933;
  --border: #2c3340;
  --border-strong: #3a4350;
  --text: #e8ebf0;
  --muted: #8b94a0;
  --accent: #5b9bd5;
  --accent-strong: #7ab0e0;
  --accent-2: #e8a34d;
  --success: #58a05c;
  --danger: #d96a5a;
  --warning: #d9a441;

  /* typography */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  /* spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;

  /* shape + depth */
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.35);

  /* motion */
  --transition: 120ms ease;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

/* ---------- layout ---------- */
.app-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header h1 { font-size: 18px; margin: 0; }
.app-main {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-4);
}

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  gap: var(--space-1);
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  transition: var(--transition);
  flex-shrink: 0;
  white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
}

/* ---------- cards / surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
}
.card + .card { margin-top: var(--space-3); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font: inherit;
  cursor: pointer;
  transition: var(--transition);
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #0d1620; font-weight: 600; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: rgba(217, 106, 90, 0.12); }
.btn-sm { padding: var(--space-1) var(--space-2); font-size: 13px; }
.btn-icon {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  font: inherit;
}
.btn-icon:hover { color: var(--danger); }

/* ---------- forms ---------- */
.form-row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.form-row > * { flex: 1 1 auto; min-width: 120px; }
.input, .select {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  font: inherit;
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); }
.label { font-size: 12px; color: var(--muted); display: block; margin-bottom: var(--space-1); }

/* ---------- chips & filters ---------- */
.chip-row { display: flex; gap: var(--space-1); flex-wrap: wrap; margin-bottom: var(--space-3); }
.chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: var(--space-1) var(--space-3);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}
.chip:hover { color: var(--text); }
.chip.active { color: var(--text); border-color: var(--accent); }

/* ---------- todos ---------- */
.todo-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  transition: var(--transition);
}
.todo-row:hover { border-color: var(--border-strong); }
.todo-row.done .todo-title { text-decoration: line-through; color: var(--muted); }
.todo-check {
  appearance: none;
  width: 18px; height: 18px;
  border: 2px solid var(--border-strong);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition);
}
.todo-check:checked { background: var(--success); border-color: var(--success); }
.todo-title { flex: 1; }
.todo-meta { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px var(--space-2);
  white-space: nowrap;
}
.tag .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.tag.due-soon { color: var(--warning); border-color: var(--warning); }
.tag.due-overdue { color: var(--danger); border-color: var(--danger); }

/* ---------- misc ---------- */
.empty { color: var(--muted); text-align: center; padding: var(--space-5); }
.muted { color: var(--muted); }
.userchip { margin-left: auto; color: var(--muted); }

/* ---------- generic rows / checkboxes ---------- */
.list-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
}
.list-row:hover { border-color: var(--border-strong); }
.check {
  appearance: none;
  width: 18px; height: 18px;
  border: 2px solid var(--border-strong);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition);
}
.check:checked { background: var(--success); border-color: var(--success); }
.row-done { opacity: 0.55; }
.row-done .row-title { text-decoration: line-through; }
.row-title { flex: 1; }
.row-meta { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }

/* ---------- wishlist ---------- */
.wish-head { display: flex; align-items: center; gap: var(--space-3); }
.wish-title { flex: 1; font-weight: 600; }
.status-badge {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  white-space: nowrap;
}
.status-badge.wanting { color: var(--accent); border-color: var(--accent); }
.status-badge.bought { color: var(--success); border-color: var(--success); }
.status-badge.abandoned { color: var(--muted); }
.wish-notes { color: var(--muted); margin-top: var(--space-2); font-size: 14px; }
.alt-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.alt-name { flex: 1; }
.alt-link { color: var(--accent); text-decoration: none; font-size: 13px; }
.alt-link:hover { text-decoration: underline; }
.price { color: var(--accent-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.alt-chosen { outline: 1px solid var(--success); }
.src-tag { font-size: 11px; color: var(--muted); background: var(--bg-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; }

/* ---------- groceries ---------- */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); align-items: start; }
@media (max-width: 800px) { .split { grid-template-columns: 1fr; } }
.recipe-title { font-weight: 600; }
.ing-line { color: var(--muted); font-size: 13px; margin-top: var(--space-1); }
.ing-row { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: var(--space-2); margin-bottom: var(--space-2); }
.recipe-actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); }
.shop-qty { color: var(--muted); white-space: nowrap; }

/* ---------- members ---------- */
.avatar { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; }

/* ---------- inventory ---------- */
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-sm); flex-shrink: 0; background: var(--surface-2); }
.no-photo {
  width: 64px; height: 64px; border-radius: var(--radius-sm); flex-shrink: 0;
  background: var(--surface-2); border: 1px dashed var(--border-strong);
  display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.clamp {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; font-size: 13px;
}
.item-detail {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3);
  max-width: 560px;
}
.detail-img { max-width: 100%; border-radius: var(--radius); max-height: 360px; object-fit: cover; }
.qr-img { width: 96px; height: 96px; border-radius: var(--radius-sm); background: #fff; padding: 4px; }

/* ==========================================================================
   Shared primitives (ui.ts): spinner, toast, modal, empty state
   ========================================================================== */

.spinner, .spin {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: -3px;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

#toast-box { pointer-events: none; }
.toast-card {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow);
}
.toast-card.success { border-color: var(--success); }
.toast-card.error { border-color: var(--danger); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.22s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
}
.modal-title {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent-strong);
}
.modal-close {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.modal-close:hover { background: var(--border); }
.modal-body { padding: 20px; }
.modal-wide { max-width: 620px; }

.empty-icon { font-size: 3.2rem; margin-bottom: 16px; }
.empty h3 { margin: 0 0 8px; font-size: 1.05rem; }

/* ==========================================================================
   Inventory (BoxTrack UX, family-os tokens)
   ========================================================================== */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.section-header-left { display: flex; align-items: center; gap: 10px; }
.section-heading { font-size: 0.85rem; font-weight: 700; letter-spacing: 0.08em; color: var(--muted); }
.count-badge {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.search-wrap { position: relative; margin-bottom: 20px; }
.search-wrap .input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  font-size: 0.95rem;
  background: var(--surface);
  border-radius: var(--radius);
}
.search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
@media (max-width: 600px) {
  .items-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
}
.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.item-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 8px 28px rgba(91, 155, 213, 0.18);
}
.item-card-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  font-size: 2.5rem;
}
.item-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item-card-body { padding: 14px; }
.item-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item-card-desc {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px 12px;
}
.item-card-date { font-size: 0.72rem; color: var(--muted); }
.qr-thumb { width: 36px; height: 36px; border-radius: 6px; background: #fff; padding: 2px; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.form-group input,
.form-group textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
  resize: vertical;
}
.form-group input:focus,
.form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { min-height: 80px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

.image-upload-area {
  border: 2px dashed var(--border-strong);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s;
  position: relative;
  overflow: hidden;
}
.image-upload-area:hover { border-color: var(--accent); background: rgba(91, 155, 213, 0.05); }
.image-upload-area.has-image { padding: 0; border-style: solid; }
.image-upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%; height: 100%;
  z-index: 1;
}
.image-upload-area img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}
.upload-icon { font-size: 2rem; margin-bottom: 8px; }
.upload-hint { color: var(--muted); font-size: 0.85rem; }

.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  margin-bottom: 20px;
  transition: color var(--transition);
}
.detail-back:hover { color: var(--text); }
.detail-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 16px;
}
.detail-hero-img {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  font-size: 4rem;
  min-height: 180px;
}
.detail-hero-img img { width: 100%; max-height: 320px; object-fit: cover; display: block; }
.detail-body { padding: 20px; }
.detail-title { font-size: 1.5rem; font-weight: 600; margin-bottom: 8px; }
.detail-desc { color: var(--muted); line-height: 1.6; font-size: 0.95rem; margin-bottom: 20px; }
.detail-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.75rem;
  color: var(--muted);
}
.detail-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.detail-qr-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.detail-qr {
  width: 100px; height: 100px;
  background: #fff;
  border-radius: 10px;
  padding: 6px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.detail-qr img { width: 100%; height: 100%; object-fit: contain; }
.detail-qr-info h4 { margin: 0 0 4px; font-size: 0.9rem; }
.detail-qr-hint { font-size: 0.8rem; color: var(--muted); margin: 0 0 8px; }
.detail-qr-id {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  word-break: break-all;
}
.detail-qr-dl { margin-top: 10px; }
@media (max-width: 600px) { .detail-qr-section { flex-direction: column; text-align: center; } }

/* scanner */
.scanner-wrap { max-width: 480px; margin: 0 auto; }
.scanner-title { font-size: 1rem; font-weight: 700; letter-spacing: 0.08em; color: var(--accent-strong); margin-bottom: 6px; }
.scanner-hint { color: var(--muted); font-size: 0.85rem; margin-bottom: 20px; }
#reader { border-radius: var(--radius); overflow: hidden; border: 2px solid var(--border); }
#reader video { border-radius: var(--radius); }
#reader * { border-radius: 0 !important; }
.scanner-result {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.scanner-result.error { border-color: var(--danger); }
.scanner-result.success { border-color: var(--success); }
.scanner-found-head {
  font-size: 0.75rem;
  color: var(--success);
  font-weight: 600;
  margin-bottom: 8px;
}
.scanner-found { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.scanner-found-img {
  width: 60px; height: 60px;
  border-radius: 8px;
  background: var(--surface-2);
  object-fit: cover;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 1.5rem;
  overflow: hidden;
}
.scanner-found-img img { width: 100%; height: 100%; object-fit: cover; }
.scanner-found-title { font-weight: 600; }
.scanner-found-arrow { margin-left: auto; font-size: 1.3rem; }
.scanner-error { color: var(--danger); }

/* print */
.print-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.print-toolbar .search-wrap { flex: 1; min-width: 160px; margin-bottom: 0; }
.print-toolbar .search-wrap .input { padding: 9px 14px 9px 38px; font-size: 0.85rem; }
.print-sel-count { font-size: 0.75rem; color: var(--accent-strong); white-space: nowrap; }
.print-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}
.print-item-card {
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
  position: relative;
  user-select: none;
}
.print-item-card:hover { border-color: var(--accent); }
.print-item-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(91, 155, 213, 0.25); }
.print-item-check {
  position: absolute;
  top: 6px; right: 6px;
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  z-index: 1;
  color: #0d1620;
}
.print-item-card.selected .print-item-check { background: var(--accent); border-color: var(--accent); }
.print-item-thumb {
  width: 100%;
  aspect-ratio: 1;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  overflow: hidden;
}
.print-item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.print-item-label {
  padding: 6px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.print-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; gap: 10px; flex-wrap: wrap; }
.print-footer-left { display: flex; gap: 8px; }
.print-empty-msg { grid-column: 1 / -1; text-align: center; padding: 40px 20px; color: var(--muted); font-size: 0.9rem; }

/* ==========================================================================
   YouTube gate (youtube-proxy/ytgate UX, family-os tokens)
   ========================================================================== */

.searchbox { display: flex; gap: 10px; }
.searchbox input {
  flex: 1;
  padding: 13px 16px;
  font-size: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.searchbox input:focus { border-color: var(--accent); }

.status, .error {
  margin-top: 26px;
  padding: 22px;
  border-radius: var(--radius);
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
}
.error { color: var(--danger); border-color: var(--danger); border-style: solid; }

.results-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 30px 0 12px;
  color: var(--muted);
  font-size: 13px;
}
.yt-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.yt-head h2 { margin: 0; }

.yt-card {
  display: flex;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.yt-thumb {
  width: 160px; height: 90px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--surface-2);
}
.yt-meta { flex: 1; min-width: 0; }
.yt-row1 { display: flex; align-items: flex-start; gap: 10px; }
.yt-row1 h3 { margin: 0; font-size: 16px; line-height: 1.35; }
.score {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 13px;
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 2px;
}
.score.good { background: rgba(88, 160, 92, 0.16); color: var(--success); }
.score.ok   { background: rgba(217, 164, 65, 0.16); color: var(--warning); }
.score.meh  { background: rgba(217, 106, 90, 0.16); color: var(--danger); }
.sub { color: var(--muted); font-size: 13px; margin: 4px 0 6px; }
.reason { color: #c3ccd6; font-size: 14px; margin: 0 0 10px; }
.yt-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.watched-badge {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
}
.btn.fb { padding: 8px 12px; font-size: 14px; }
.btn.fb.on { background: var(--surface-2); border-color: var(--accent); }
.btn.mini { padding: 2px 8px; font-size: 11px; border-radius: 6px; margin-left: auto; flex-shrink: 0; }
.hint { color: var(--muted); font-size: 13px; }

.player-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.gate-note { color: var(--muted); font-size: 13px; margin-left: auto; }
.player h1 { font-size: 22px; margin: 0 0 4px; line-height: 1.3; }
.embed-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  margin: 16px 0;
  overflow: hidden;
}
.embed-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  border: 0;
}
.ended-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(10, 13, 18, 0.94);
  z-index: 5;
  padding: 20px;
}
.ended-overlay.hidden { display: none; }
.ended-overlay p { margin: 0 0 6px; font-size: 17px; }
.player .reason {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  border-radius: 8px;
  margin: 0 0 16px;
}

.panel {
  position: fixed;
  top: 64px;
  right: 18px;
  width: min(420px, 92vw);
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  z-index: 20;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.panel.hidden { display: none; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel h2 { margin: 0; font-size: 17px; }
.panel h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted); }
.panel textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
  resize: vertical;
  margin: 10px 0;
}
.panel hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.fb-list { list-style: none; margin: 0; padding: 0; }
.fb-list li {
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
}
.fb-list .tag { font-weight: 700; flex-shrink: 0; }
.tag.liked { color: var(--success); }
.tag.disliked { color: var(--danger); }
.fb-list .t { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.add-user { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.add-user input {
  padding: 9px 12px;
  font-size: 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 18px;
  margin-top: 20px;
  border-top: 1px solid var(--border);
}

@media (max-width: 560px) {
  .yt-thumb { width: 100%; height: auto; aspect-ratio: 16 / 9; }
  .yt-card { flex-direction: column; }
}

/* ==========================================================================
   Home / landing (tool picker)
   ========================================================================== */

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-3);
}
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.tool-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(91, 155, 213, 0.16);
}
.tool-icon { font-size: 2rem; line-height: 1; margin-bottom: var(--space-3); }
.tool-name { font-weight: 600; font-size: 1rem; margin-bottom: var(--space-1); }
.tool-desc { color: var(--muted); font-size: 0.85rem; line-height: 1.4; }

/* ==========================================================================
   Mobile: stack the header and make tabs a swipeable strip
   ========================================================================== */

@media (max-width: 700px) {
  .app-header {
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
  }
  .app-header h1 { font-size: 16px; }
  .tabs { display: none; }
  .app-header .nav-toggle { display: inline-flex; }
  .app-main { padding: var(--space-3); }
  .tool-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-2); }
  .section-header { margin-bottom: 14px; }
}

/* ==========================================================================
   Mobile hamburger nav (drawer)
   ========================================================================== */

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.nav-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.nav-drawer-overlay.open { opacity: 1; visibility: visible; }

.nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(280px, 82vw);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  z-index: 91;
  padding: var(--space-4);
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
}
.nav-drawer.open { transform: translateX(0); }

.nav-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.nav-drawer-title { font-weight: 700; font-size: 16px; }

.drawer-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  padding: var(--space-3) var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  text-align: left;
  transition: background var(--transition);
}
.drawer-item:hover { background: var(--surface-2); }
.drawer-icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }
.drawer-label { flex: 1; }

/* ==========================================================================
   Inventory: location + status (packed/unpacked)
   ========================================================================== */

.filter-bar {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.filter-bar .select { max-width: 220px; }

.item-card-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.badge-unpacked { color: var(--accent-2); border-color: var(--accent-2); }
.item-card.unpacked { border-color: var(--accent-2); }
.item-card.unpacked .item-card-img { opacity: 0.7; }

/* ==========================================================================
   Inventory: multiple photos (modal thumbs + detail gallery)
   ========================================================================== */

.image-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: var(--space-2);
}
.image-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.image-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-thumb-add {
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: var(--muted);
  border-style: dashed;
  cursor: pointer;
}
.image-thumb-add:hover { color: var(--accent); border-color: var(--accent); }

.detail-thumbs {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-2);
}
.detail-thumb {
  width: 64px; height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  background: var(--surface-2);
}
.detail-thumb.active { border-color: var(--accent); }
