/* ============================================================
   The Vault — Collection Tracker
   Dark cinematic aesthetic. Deep blacks, warm amber accents.
   Mobile-first, designed for one-handed use.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
  --bg:           #0a0a0a;
  --bg-card:      #141414;
  --bg-elevated:  #1c1c1c;
  --bg-input:     #242424;

  --text:         #f0ece4;
  --text-muted:   #7a7570;
  --text-dim:     #4a4642;

  --amber:        #e8a020;
  --amber-dim:    #7a5210;
  --green:        #4caf72;
  --green-dim:    #1e4a2e;
  --red:          #e05050;
  --red-dim:      #5a1e1e;

  --border:       rgba(255,255,255,0.06);
  --border-light: rgba(255,255,255,0.10);

  --font-display: 'Bebas Neue', sans-serif;
  --font-body:    'DM Sans', sans-serif;

  --radius:       12px;
  --radius-sm:    8px;
  --sheet-radius: 24px;

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text);
}

img { display: block; }

/* ============================================================
   GRAIN OVERLAY
   ============================================================ */
.grain {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 200px;
}

/* ============================================================
   SCREENS — stack management
   ============================================================ */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
  overflow: hidden;
}

.screen.active {
  transform: translateX(0);
}

.screen.slide-out {
  transform: translateX(-30%);
}

/* ============================================================
   APP HEADER (browse screen)
   ============================================================ */
.app-header {
  padding: calc(var(--safe-top) + 16px) 16px 0;
  background: var(--bg);
  position: relative;
  z-index: 10;
}

.app-title {
  font-family: var(--font-display);
  font-size: 42px;
  letter-spacing: 0.06em;
  color: var(--text);
  line-height: 1;
  margin-bottom: 14px;
}

.app-title::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--amber);
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
  margin-bottom: 8px;
}

/* Search bar */
.header-search {
  position: relative;
  margin-bottom: 12px;
}

.header-search input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 10px 16px 10px 40px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.header-search input::placeholder { color: var(--text-dim); }
.header-search input:focus { border-color: var(--amber-dim); }

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  gap: 6px;
  padding: 0 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.filter-bar::-webkit-scrollbar { display: none; }

.filter-btn {
  flex-shrink: 0;
  padding: 5px 14px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: transparent;
  transition: all 0.18s;
}

.filter-btn.active {
  background: var(--amber);
  border-color: var(--amber);
  color: #000;
}

/* ============================================================
   MOVIE GRID
   ============================================================ */
.grid-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 4px 12px calc(var(--safe-bottom) + 80px);
  scrollbar-width: none;
}
.grid-container::-webkit-scrollbar { display: none; }

.movie-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

/* Movie card */
.movie-card {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card);
  cursor: pointer;
  aspect-ratio: 2/3;
  animation: fadeUp 0.3s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.movie-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.movie-card-no-cover {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-elevated);
  line-height: 1.3;
}

/* Format badges on card */
.card-badges {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px 5px 5px;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
}

.format-badge {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 3px;
  line-height: 1.4;
}

.format-badge.green {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(76, 175, 114, 0.3);
}

.format-badge.amber {
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid rgba(232, 160, 32, 0.3);
}

/* ============================================================
   EMPTY & LOADING STATES
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 80px 40px;
  color: var(--text-muted);
  line-height: 1.6;
}

.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state strong { color: var(--text); }

.loading-state {
  display: flex;
  justify-content: center;
  padding: 80px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ============================================================
   FAB
   ============================================================ */
.fab {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 20px);
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--amber);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(232, 160, 32, 0.4);
  transition: transform 0.15s, box-shadow 0.15s;
  z-index: 50;
}

.fab:active {
  transform: scale(0.92);
  box-shadow: 0 2px 10px rgba(232, 160, 32, 0.3);
}

.fab svg { width: 26px; height: 26px; }

/* ============================================================
   SCANNER SCREEN
   ============================================================ */
.scanner-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(var(--safe-top) + 16px) 16px 16px;
  background: var(--bg);
}

.btn-back {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-elevated);
}

.btn-back svg { width: 20px; height: 20px; }

.scanner-title {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.05em;
}

.scanner-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}

#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
}

.scanner-frame {
  width: 240px;
  height: 150px;
  position: relative;
  overflow: hidden;
}

/* Corner markers */
.corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--amber);
  border-style: solid;
}
.corner.tl { top: 0; left: 0; border-width: 3px 0 0 3px; }
.corner.tr { top: 0; right: 0; border-width: 3px 3px 0 0; }
.corner.bl { bottom: 0; left: 0; border-width: 0 0 3px 3px; }
.corner.br { bottom: 0; right: 0; border-width: 0 3px 3px 0; }

/* Scan line animation */
.scan-line {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--amber), transparent);
  top: 0;
  animation: scanline 2s ease-in-out infinite;
}

@keyframes scanline {
  0%   { top: 0; opacity: 1; }
  90%  { top: calc(100% - 2px); opacity: 1; }
  100% { top: calc(100% - 2px); opacity: 0; }
}

.scanner-hint {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  text-align: center;
  max-width: 240px;
  line-height: 1.5;
}

.scanner-barcode-entry {
  padding: 12px 16px 0;
}

.barcode-entry-wrap {
  display: flex;
  gap: 8px;
}

.barcode-entry-wrap input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  /* hide number spinners */
  -moz-appearance: textfield;
}
.barcode-entry-wrap input::-webkit-outer-spin-button,
.barcode-entry-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; }
.barcode-entry-wrap input:focus { border-color: var(--amber-dim); }
.barcode-entry-wrap input::placeholder { color: var(--text-dim); }

.barcode-entry-wrap button {
  background: var(--amber);
  color: #000;
  font-weight: 500;
  font-size: 14px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.scanner-manual-link {
  padding: 12px 16px;
  text-align: center;
  padding-bottom: calc(var(--safe-bottom) + 16px);
}

.scanner-manual-link button {
  font-size: 14px;
  color: var(--amber);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ============================================================
   TITLE SEARCH SCREEN
   ============================================================ */
.title-search-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow: hidden;
}

.title-search-input-wrap {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.title-search-input-wrap input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  color: var(--text);
  outline: none;
}

.title-search-input-wrap input:focus {
  border-color: var(--amber-dim);
}

.title-search-input-wrap button {
  background: var(--amber);
  color: #000;
  font-weight: 500;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  flex-shrink: 0;
}

.title-search-results {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.title-search-results::-webkit-scrollbar { display: none; }

/* Search result row */
.search-result-row {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  align-items: flex-start;
  transition: background 0.15s;
}

.search-result-row:active { background: var(--bg-elevated); }

.search-result-poster {
  width: 50px;
  height: 75px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.search-result-info {
  flex: 1;
  padding-top: 2px;
}

.search-result-title {
  font-weight: 500;
  font-size: 15px;
  line-height: 1.3;
  margin-bottom: 3px;
}

.search-result-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.search-result-owned {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ============================================================
   BOTTOM SHEETS
   ============================================================ */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
  padding: 0 20px calc(var(--safe-bottom) + 20px);
  z-index: 101;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bottom-sheet::-webkit-scrollbar { display: none; }

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  margin: 12px auto 20px;
}

.sheet-title {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 0.05em;
  margin-bottom: 20px;
}

/* Scan result: movie info row */
.sheet-movie-info {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
}

.result-poster {
  width: 70px;
  height: 105px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  flex-shrink: 0;
}

.result-meta { flex: 1; padding-top: 2px; }

.result-title {
  font-size: 18px;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 4px;
}

.result-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.result-runtime {
  font-size: 12px;
  color: var(--text-dim);
}

/* Format status row */
.format-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.format-status-label {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.format-badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Add format picker */
.add-copy-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.add-label {
  font-size: 13px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 8px;
}

.add-format-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.add-format-btn {
  padding: 8px 16px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--bg-card);
  transition: all 0.18s;
}

.add-format-btn.selected {
  background: var(--amber);
  border-color: var(--amber);
  color: #000;
}

.add-format-btn.owned {
  background: var(--green-dim);
  border-color: rgba(76, 175, 114, 0.3);
  color: var(--green);
  cursor: default;
}

.add-format-btn.owned::after {
  content: ' ✓';
}

.add-notes {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  resize: none;
  outline: none;
  font-size: 14px;
  line-height: 1.5;
}

.add-notes:focus { border-color: var(--amber-dim); }
.add-notes::placeholder { color: var(--text-dim); }

/* Not found sheet */
.sheet-not-found-content {
  text-align: center;
  padding: 20px 0;
}

.not-found-icon { font-size: 40px; margin-bottom: 12px; }

.sheet-not-found-content h2 {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 8px;
}

.not-found-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* Already owned sheet */
.already-owned-msg {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  background: var(--green-dim);
  border: 1px solid rgba(76,175,114,0.2);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--green);
}

/* ============================================================
   MANUAL ENTRY FORM
   ============================================================ */
.manual-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  outline: none;
  width: 100%;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--amber-dim);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-dim);
}

.form-group select option {
  background: var(--bg-elevated);
}

.form-group textarea {
  resize: none;
  line-height: 1.5;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--amber);
  flex-shrink: 0;
}

/* ============================================================
   MOVIE DETAIL SHEET — format rows
   ============================================================ */
.detail-format-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Each format is a row */
.detail-format-row {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: border-color 0.2s;
}

/* Row header — always visible */
.detail-format-row-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

/* Owned row */
.detail-format-row.owned {
  border-color: rgba(76, 175, 114, 0.25);
  background: rgba(76, 175, 114, 0.05);
}
.detail-format-row.owned-upgrade {
  border-color: rgba(232, 160, 32, 0.25);
  background: rgba(232, 160, 32, 0.05);
}

/* Not owned row */
.detail-format-row.not-owned {
  border-color: var(--border);
  background: transparent;
  opacity: 0.6;
}
.detail-format-row.not-owned .detail-format-row-header {
  cursor: pointer;
}
.detail-format-row.not-owned:hover,
.detail-format-row.not-owned:active {
  opacity: 1;
  border-color: var(--amber-dim);
  background: rgba(232, 160, 32, 0.05);
}

.detail-format-name {
  font-size: 15px;
  font-weight: 500;
  flex: 1;
}

.detail-format-status {
  font-size: 12px;
  color: var(--text-muted);
}

.detail-format-row.owned .detail-format-status { color: var(--green); }
.detail-format-row.owned-upgrade .detail-format-status { color: var(--amber); }

.detail-format-add-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: all 0.2s;
}

.detail-format-row.not-owned:hover .detail-format-add-icon,
.detail-format-row.not-owned:active .detail-format-add-icon {
  border-color: var(--amber);
  color: var(--amber);
}

/* Expandable body for owned rows */
.detail-format-row-body {
  padding: 0 14px 14px;
  display: none;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.detail-format-row-body.open {
  display: flex;
}

.detail-format-row-body textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  resize: none;
  outline: none;
  line-height: 1.5;
}
.detail-format-row-body textarea:focus { border-color: var(--amber-dim); }
.detail-format-row-body textarea::placeholder { color: var(--text-dim); }

.detail-format-row-actions {
  display: flex;
  gap: 8px;
}

.detail-format-row-actions .btn-save {
  flex: 1;
  padding: 9px;
  background: var(--amber);
  color: #000;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
}

.detail-format-row-actions .btn-remove {
  padding: 9px 14px;
  background: transparent;
  color: var(--red);
  font-size: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--red-dim);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--amber);
  color: #000;
  font-size: 15px;
  font-weight: 500;
  border-radius: var(--radius);
  transition: opacity 0.15s, transform 0.1s;
}

.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-secondary {
  width: 100%;
  padding: 13px;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}

.btn-secondary:active { border-color: var(--border-light); }

.btn-danger {
  width: 100%;
  padding: 13px;
  background: transparent;
  color: var(--red);
  font-size: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--red-dim);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 90px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 50px;
  border: 1px solid var(--border-light);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 200;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   MISC UTILITIES
   ============================================================ */
.no-results-msg {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

/* ============================================================
   MEDIA TYPE TABS
   ============================================================ */
.media-tabs {
  display: flex;
  padding: 0 16px;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.media-tab {
  flex: 1;
  padding: 10px 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  border-radius: 0;
  transition: color 0.2s, border-color 0.2s;
  text-align: center;
}

.media-tab.active {
  color: var(--amber);
  border-bottom-color: var(--amber);
}

/* ============================================================
   HEADER REDESIGN — title + actions row
   ============================================================ */
.app-header {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 10px) 16px 8px !important;
}

.app-title {
  font-size: 32px !important;
  margin-bottom: 0 !important;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logout-btn {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: color 0.2s;
  text-decoration: none;
}
.logout-btn:hover { color: var(--text); }

/* ============================================================
   USER SWITCHER
   ============================================================ */
.user-switcher { position: relative; }

.user-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--amber);
  white-space: nowrap;
}

.user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  min-width: 200px;
  overflow: hidden;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s, color 0.15s;
}
.user-menu-item:last-child { border-bottom: none; }
.user-menu-item:hover, .user-menu-item.active {
  background: var(--bg-input);
  color: var(--amber);
}

/* ============================================================
   BROWSE SEARCH (moved below tabs)
   ============================================================ */
.browse-search-wrap {
  position: relative;
  padding: 10px 16px 0;
  flex-shrink: 0;
}

.browse-search-wrap input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 9px 16px 9px 38px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}
.browse-search-wrap input::placeholder { color: var(--text-dim); }
.browse-search-wrap input:focus { border-color: var(--amber-dim); }

.browse-search-wrap .search-icon {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-30%);
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

/* ============================================================
   CARD OWNER LABEL (multi-user view)
   ============================================================ */
.card-owner {
  position: absolute;
  bottom: 28px;
  left: 0; right: 0;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(0,0,0,0.65);
  padding: 2px 4px;
  pointer-events: none;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
}

.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--sheet-radius);
  padding: 40px 32px 36px;
  text-align: center;
}

.login-title {
  font-family: var(--font-display);
  font-size: 52px;
  letter-spacing: 0.08em;
  color: var(--text);
  line-height: 1;
}
.login-title::after {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--amber);
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
  margin-bottom: 10px;
}

.login-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 6px;
  margin-bottom: 28px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.login-error {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 18px;
  text-align: left;
}

.login-form .form-group {
  text-align: left;
  margin-bottom: 16px;
}

.login-form label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.login-form input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}
.login-form input:focus { border-color: var(--amber-dim); }
