:root {
  --bg: #111318;
  --bg2: #191c23;
  --bg3: #20242e;
  --bg4: #2a2f3d;
  --border: #2e3240;
  --border2: #3d4255;
  --text: #eceef2;
  --text2: #a8afc4;
  --text3: #5f6680;
  --accent: #e5a00d;
  --accent2: #c98a0a;
  --red: #f04b4b;
  --green: #3fca6d;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.7);
  --radius: 10px;
  --radius-lg: 14px;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'Inter', sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────── */

header {
  background: rgba(25, 28, 35, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 62px;
  flex-shrink: 0;
}

.logo {
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-shadow: 0 0 20px rgba(229, 160, 13, 0.3);
}

.logo span {
  color: var(--text3);
  font-weight: 400;
}

.header-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text3);
}

.stat-chip {
  display: flex;
  gap: 6px;
  align-items: center;
}

.stat-chip strong {
  color: var(--text2);
}

.header-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* ── Layout ──────────────────────────────────────────────── */

.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */

aside {
  width: 216px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 14px 0;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-section {
  padding: 4px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.sidebar-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 16px 8px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 8px 13px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text2);
  transition: background 0.12s, color 0.12s;
  user-select: none;
  border-left: 3px solid transparent;
}

.sidebar-item:hover {
  background: var(--bg3);
  color: var(--text);
}

.sidebar-item.active {
  border-left-width: 3px;
  border-left-style: solid;
}

.sidebar-item .type-icon {
  margin-right: 9px;
  font-size: 15px;
}

.sidebar-count {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text3);
  background: var(--bg4);
  padding: 2px 9px;
  border-radius: 20px;
}

/* ── Content area ────────────────────────────────────────── */

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Toolbar ─────────────────────────────────────────────── */

.toolbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.search-box {
  flex: 1;
  max-width: 360px;
  position: relative;
}

.search-box input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  padding: 7px 10px 7px 32px;
  outline: none;
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(229, 160, 13, 0.12);
}



.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  font-size: 13px;
  pointer-events: none;
}

.toolbar-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.count-display {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
}

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 16px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text2);
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--border2);
  color: var(--text);
  background: var(--bg4);
}

.btn.primary {
  background: var(--accent);
  color: #0a0a0a;
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(229, 160, 13, 0.3);
}

.btn.primary:hover {
  background: var(--accent2);
  border-color: var(--accent2);
  box-shadow: 0 3px 18px rgba(229, 160, 13, 0.45);
}

.btn.danger {
  border-color: var(--red);
  color: var(--red);
}

.btn.danger:hover {
  background: rgba(240, 75, 75, 0.12);
}

.btn.small {
  padding: 4px 11px;
  font-size: 12px;
  border-radius: 7px;
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
}

.btn.ghost:hover {
  background: var(--bg3);
  border-color: var(--border);
}

/* ── View toggle ─────────────────────────────────────────── */

.view-toggle {
  display: flex;
  gap: 3px;
}

.view-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  border-radius: 3px;
  font-size: 15px;
  transition: all 0.15s;
}

.view-btn:hover {
  color: var(--text2);
  border-color: var(--text3);
  background: var(--bg3);
}

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

/* ── Table view ──────────────────────────────────────────── */

.table-wrap {
  flex: 1;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg2);
}

th {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

th:hover {
  color: var(--text2);
}

th.sorted {
  color: var(--accent);
}

td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
  vertical-align: middle;
}

tr:hover td {
  background: var(--bg2);
}

.title-cell {
  color: var(--text);
  max-width: 280px;
}

.item-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  max-width: 220px;
  vertical-align: middle;
  cursor: pointer;
}

.item-title:hover {
  color: var(--accent);
}

.item-cover {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 1px;
  margin-right: 10px;
  vertical-align: middle;
  background: var(--bg4);
  border: 1px solid var(--border);
}

.row-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.1s;
}

tr:hover .row-actions {
  opacity: 1;
}

.check-cell {
  width: 36px;
}

.check-cell input {
  cursor: pointer;
  accent-color: var(--accent);
}

/* ── Badges ──────────────────────────────────────────────── */

.badge {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-book {
  background: rgba(212, 132, 74, 0.15);
  color: #d4844a;
  border: 1px solid rgba(212, 132, 74, 0.3);
}

.badge-movie {
  background: rgba(229, 56, 59, 0.15);
  color: #e5383b;
  border: 1px solid rgba(229, 56, 59, 0.3);
}

.badge-music {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.badge-game {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-tv {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-manga {
  background: rgba(244, 114, 182, 0.15);
  color: #f472b6;
  border: 1px solid rgba(244, 114, 182, 0.3);
}

.badge-other {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.stars {
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 1px;
}

/* ── Poster grid ─────────────────────────────────────────── */

.grid-wrap {
  flex: 1;
  overflow: auto;
  padding: 20px;
}

.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 14px;
}

.media-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg3);
  transition: transform 0.2s ease, box-shadow 0.25s ease;
  aspect-ratio: 2 / 3;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.media-card:hover {
  transform: translateY(-4px) scale(1.025);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
  border-color: rgba(255, 255, 255, 0.08);
  z-index: 2;
}

.card-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-no-art {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--bg3) 0%, var(--bg4) 100%);
  gap: 8px;
  padding: 12px;
}

.card-no-art .no-art-icon {
  font-size: 32px;
  opacity: 0.45;
}

.card-no-art .no-art-title {
  font-size: 11px;
  color: var(--text3);
  text-align: center;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.card-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.4) 55%, transparent 100%);
  padding: 30px 8px 8px;
  pointer-events: none;
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.card-sub {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.58);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-hover-overlay {
  position: absolute;
  inset: 0;
  background: rgba(18, 20, 26, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.18s ease;
  padding: 12px;
  pointer-events: none;
}

.media-card:hover .card-hover-overlay {
  opacity: 1;
  pointer-events: auto;
}

.card-stars {
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(229, 160, 13, 0.55);
}

.card-type-badge {
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.card-btn {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  padding: 5px 14px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  border-radius: 7px;
  transition: all 0.12s;
  white-space: nowrap;
}

.card-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.5);
}

.card-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

.card-btn.primary:hover {
  background: var(--accent2);
  border-color: var(--accent2);
}

/* ── Type group headers ─────────────────────────────────── */

.type-group-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px 9px 12px;
  border-left: 3px solid;
  border-radius: 0 8px 8px 0;
  margin: 12px 0 6px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.type-group-header:hover {
  filter: brightness(1.1);
}

.type-group-chevron {
  font-size: 14px;
  line-height: 1;
  transition: transform 0.18s ease;
  display: inline-block;
  opacity: 0.7;
}
.type-group-chevron.collapsed {
  transform: rotate(-90deg);
}

.type-group-icon {
  font-size: 16px;
  line-height: 1;
}

.type-group-label {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.type-group-count {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
}

.type-group-row td {
  padding: 10px 12px;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 2px solid var(--border);
  border-top: 8px solid var(--bg);
  user-select: none;
}

.type-group-row:hover td {
  background: inherit !important;
}

/* ── Empty state ─────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text3);
  font-size: 13px;
}

.empty-state .empty-icon {
  font-size: 40px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  margin-top: 8px;
  font-size: 12px;
}

/* ── Modals ──────────────────────────────────────────────── */

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.overlay.open {
  display: flex;
}

.modal {
  background: #1e2130;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  width: 560px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  animation: modal-in 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text);
}

.modal-body {
  padding: 22px;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Form ────────────────────────────────────────────────── */

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

.form-grid .full {
  grid-column: 1 / -1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
}

.field input,
.field select,
.field textarea {
  background: var(--bg4);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  padding: 8px 11px;
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(229, 160, 13, 0.12);
}

.field select option {
  background: var(--bg3);
}

.field textarea {
  resize: vertical;
  min-height: 70px;
}

/* ── Lookup bar ──────────────────────────────────────────── */

.lookup-bar {
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.lookup-bar label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  white-space: nowrap;
}

.lookup-bar input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 7px;
  outline: none;
}

.lookup-bar input:focus {
  border-color: var(--accent);
}

/* ── Search results ──────────────────────────────────────── */

.search-results {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  margin-top: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.result-item:hover {
  background: var(--bg4);
}

.result-item:last-child {
  border-bottom: none;
}

.result-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  background: var(--bg4);
  border-radius: 1px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.result-title {
  font-size: 13px;
  color: var(--text);
}

.result-meta {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

/* ── Drop zone ───────────────────────────────────────────── */

.drop-zone {
  border: 2px dashed var(--border2);
  border-radius: 10px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-size: 13px;
  color: var(--text3);
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(229, 160, 13, 0.04);
  color: var(--text2);
}

.drop-zone input {
  display: none;
}

/* ── Detail modal ────────────────────────────────────────── */

.modal-detail {
  width: 720px;
  max-width: 95vw;
}

.detail-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.detail-cover-wrap {
  flex-shrink: 0;
  width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.detail-cover {
  display: block;
  width: 160px;
  height: 240px;
  object-fit: cover;
  background: var(--bg3);
  border-radius: 6px;
  cursor: zoom-in;
  transition: opacity 0.15s, box-shadow 0.15s;
}

.detail-cover:hover {
  opacity: 0.85;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.detail-cover-hint {
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 0.04em;
}

.detail-info {
  flex: 1;
  min-width: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.detail-field .df-label {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
  margin-bottom: 3px;
}

.detail-field .df-value {
  color: var(--text);
  font-size: 13px;
}

/* ── Shared synopsis / notes blocks (all detail views) ────── */

.detail-synopsis-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.dsb-label {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text3);
  margin-bottom: 6px;
}

.dsb-text {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.65;
  margin: 0;
}

.dsb-notes {
  font-size: 12.5px;
  color: var(--text3);
  line-height: 1.6;
  font-style: italic;
  margin: 0;
}


#image-viewer {
  background: rgba(0, 0, 0, 0.88);
  z-index: 200;
  cursor: zoom-out;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.iv-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  cursor: default;
}

#image-viewer-img {
  max-width: 90vw;
  max-height: 78vh;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.iv-toolbar {
  display: flex;
  gap: 8px;
  justify-content: center;
  min-height: 36px;
}

/* ── Cover picker ──────────────────────────────────────────────────────────── */

#cover-picker-modal {
  z-index: 500;
  backdrop-filter: none;
}

.cp-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  padding: 2px;
}

.cp-result {
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
  background: var(--bg3);
  transition: border-color 0.15s, transform 0.1s;
}

.cp-result:hover {
  border-color: var(--accent);
  transform: scale(1.02);
}

.cp-result img {
  width: 100%;
  display: block;
  aspect-ratio: 2 / 3;
  object-fit: cover;
}

.cp-result-title {
  font-size: 10px;
  color: var(--text2);
  padding: 4px 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Toast ───────────────────────────────────────────────── */

#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(30, 33, 44, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 3px solid var(--accent);
  padding: 11px 18px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text);
  border-radius: var(--radius);
  z-index: 999;
  transform: translateY(70px);
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s;
  max-width: 320px;
  pointer-events: none;
  box-shadow: var(--shadow);
}

#toast.show {
  transform: translateY(0);
  opacity: 1;
}

#toast.error {
  border-left-color: var(--red);
}

/* ── Spinner ─────────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

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

/* ── Scrollbar ───────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text3);
}

/* ── Manga: series card progress bar ─────────────────────── */

.vol-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  z-index: 3;
}

.vol-progress-fill {
  height: 100%;
  background: #f472b6;
  transition: width 0.3s ease;
}

/* ── Manga: volume status chips ──────────────────────────── */

.vol-chip-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
}

.vol-chip {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 500;
}

.vol-chip.owned {
  background: rgba(78, 201, 78, 0.2);
  color: #4ec94e;
  border: 1px solid rgba(78, 201, 78, 0.35);
}

.vol-chip.wishlist {
  background: rgba(229, 160, 13, 0.2);
  color: #e5a00d;
  border: 1px solid rgba(229, 160, 13, 0.35);
}

.vol-chip.missing {
  background: rgba(224, 84, 84, 0.2);
  color: #e05454;
  border: 1px solid rgba(224, 84, 84, 0.35);
}

.vol-chip.lent {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

/* ── Manga: track-to tooltip ─────────────────────────────── */

.track-to-tooltip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 8px;
  padding: 10px 14px;
  background: rgba(244, 114, 182, 0.08);
  border: 1px solid rgba(244, 114, 182, 0.3);
  border-radius: 3px;
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
}

.tooltip-hand {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.track-to-tooltip strong {
  color: #f472b6;
}

/* ── Manga: detail modal header ──────────────────────────── */

.md-header {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.md-cover {
  width: 100px;
  flex-shrink: 0;
  border-radius: 3px;
  object-fit: cover;
  border: 1px solid var(--border);
  align-self: flex-start;
}

.md-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.md-creator {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.md-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.md-tag {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 2px;
  background: var(--bg4);
  color: var(--text3);
  text-transform: capitalize;
}

.md-counts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.md-track-badge {
  font-family: var(--mono);
  font-size: 10px;
  color: #f472b6;
  background: rgba(244, 114, 182, 0.1);
  border: 1px solid rgba(244, 114, 182, 0.25);
  padding: 3px 8px;
  border-radius: 2px;
  align-self: flex-start;
  cursor: default;
}

.md-track-badge.unset {
  color: var(--text3);
  background: var(--bg4);
  border-color: var(--border);
  cursor: pointer;
}

.md-missing-summary {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
  line-height: 1.6;
}

.md-missing-summary span {
  color: #e05454;
}

.md-description {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.6;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Manga: volume grid ──────────────────────────────────── */

.md-vol-section {
  margin-top: 8px;
}

.md-vol-legend {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
}

.vol-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.vol-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.vol-legend-dot.owned {
  background: rgba(78, 201, 78, 0.7);
}

.vol-legend-dot.wishlist {
  background: rgba(229, 160, 13, 0.7);
}

.vol-legend-dot.lent_out {
  background: rgba(56, 189, 248, 0.7);
}

.vol-legend-dot.missing {
  background: transparent;
  border: 1px solid rgba(224, 84, 84, 0.6);
}

.vol-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.vol-box {
  width: 40px;
  height: 40px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  transition: transform 0.1s, box-shadow 0.1s;
  user-select: none;
  border: 1px solid transparent;
  position: relative;
}

.vol-box:hover {
  transform: scale(1.12);
  z-index: 1;
}

.vol-box.selected {
  outline: 2px solid #f472b6;
  outline-offset: 2px;
}

.vol-num {
  pointer-events: none;
}

.vol-box.vol-owned {
  background: rgba(78, 201, 78, 0.18);
  color: #4ec94e;
  border-color: rgba(78, 201, 78, 0.35);
}

.vol-box.vol-wishlist {
  background: rgba(229, 160, 13, 0.18);
  color: #e5a00d;
  border-color: rgba(229, 160, 13, 0.35);
}

.vol-box.vol-lent_out {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
}

.vol-box.vol-missing {
  background: transparent;
  color: #e05454;
  border: 1px dashed rgba(224, 84, 84, 0.5);
}

.vol-box.vol-untracked {
  background: var(--bg4);
  color: var(--text3);
  border-color: var(--border);
}

.vol-box.vol-add {
  background: transparent;
  border: 1px dashed var(--border2);
  color: var(--text3);
  font-size: 18px;
  font-weight: 400;
}

.vol-box.vol-add:hover {
  border-color: #f472b6;
  color: #f472b6;
}

/* ── Manga: volume action panel ──────────────────────────── */

.vol-action-panel {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 3px;
}

.vap-title {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.vap-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── Volume detail panel ─────────────────────────────────── */

.vap-detail-layout {
  display: flex;
  gap: 16px;
}

.vap-cover-col {
  flex-shrink: 0;
  width: 90px;
}

.vap-cover {
  width: 90px;
  border-radius: 3px;
  object-fit: cover;
  border: 1px solid var(--border);
  display: block;
}

.vap-cover-placeholder {
  width: 90px;
  height: 128px;
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--text3);
}

.vap-info-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.vap-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vap-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  white-space: nowrap;
  flex-shrink: 0;
}

.vap-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 2px;
  resize: vertical;
  min-height: 64px;
  outline: none;
}

.vap-textarea:focus {
  border-color: #f472b6;
}

.vap-footer {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 2px;
}

/* Star rating */

.vap-stars {
  display: flex;
  gap: 3px;
}

.vap-star {
  font-size: 18px;
  color: var(--border2);
  cursor: pointer;
  transition: color 0.1s, transform 0.1s;
  user-select: none;
}

.vap-star.filled {
  color: #f472b6;
}

.vap-star:hover {
  transform: scale(1.2);
}

/* ── Volume add modal (lookup + confirm) ─────────────────── */

#manga-vol-add-modal {
  z-index: 200;
}

.mva-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.mva-cover-col {
  flex-shrink: 0;
  width: 130px;
}

.mva-cover {
  width: 130px;
  border-radius: 4px;
  object-fit: cover;
  display: block;
  border: 1px solid var(--border);
}

.mva-info-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mva-series-name {
  font-size: 12px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mva-vol-label {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-top: -6px;
}

.mva-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mva-status-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── TV: badges ─────────────────────────────────────────────────────────────── */
.badge-anime {
  background: #f472b620;
  color: #f472b6;
  border: 1px solid #f472b640;
}

/* ── TV: detail modal ───────────────────────────────────────────────────────── */
.tv-detail-layout {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.tv-detail-cover-wrap {
  flex: 0 0 140px;
  text-align: center;
}

.tv-detail-cover {
  width: 140px;
  border-radius: 4px;
  display: block;
}

.tv-cover-placeholder {
  width: 140px;
  height: 200px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

.tv-detail-info {
  flex: 1;
  min-width: 0;
}

.td-show-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.td-meta-line {
  font-size: 13px;
  color: var(--text3);
  margin-bottom: 6px;
}

.td-genre-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
  align-items: center;
}

.td-description {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
  max-height: 80px;
  overflow-y: auto;
  margin-bottom: 8px;
}

.td-rating {
  font-size: 16px;
  color: #f59e0b;
  margin-bottom: 6px;
}

.td-notes {
  font-size: 12px;
  color: var(--text3);
  font-style: italic;
}

/* ── TV: seasons section ────────────────────────────────────────────────────── */
.td-seasons-section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.td-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.td-section-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text3);
}

.td-season-count {
  background: var(--bg3);
  color: var(--text3);
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
}

.td-season-boxes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.season-box {
  width: 50px;
  height: 50px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s, box-shadow 0.1s;
  user-select: none;
}

.season-box:hover {
  transform: scale(1.06);
  box-shadow: 0 2px 8px #0006;
}

.season-owned {
  background: #22c55e20;
  border-color: #22c55e;
  color: #22c55e;
}

.season-watching {
  background: #38bdf820;
  border-color: #38bdf8;
  color: #38bdf8;
}

.season-completed {
  background: #a855f720;
  border-color: #a855f7;
  color: #a855f7;
}

.season-plan {
  background: var(--bg3);
  border-color: var(--border2);
  color: var(--text3);
}

.season-add {
  background: var(--bg3);
  border: 2px dashed var(--border2);
  color: var(--text3);
  font-size: 20px;
}

.season-add:hover {
  border-color: var(--text3);
  color: var(--text);
}

/* ── Genre multi-select ─────────────────────────────────────────────────────── */
.genre-multiselect {
  position: relative;
}

.gms-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  padding: 4px 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 3px;
  min-height: 34px;
  cursor: text;
}

.gms-tags:focus-within {
  border-color: var(--text3);
}

.gms-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg4);
  color: var(--text2);
  border: 1px solid var(--border2);
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 12px;
}

.gms-remove {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  line-height: 1;
}

.gms-remove:hover {
  color: var(--red);
}

.gms-input {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  outline: none;
  min-width: 100px;
  flex: 1;
}

.gms-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-top: none;
  border-radius: 0 0 4px 4px;
  z-index: 10;
  max-height: 180px;
  overflow-y: auto;
}

.gms-dropdown.hidden {
  display: none;
}

.gms-option {
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
}

.gms-option:hover {
  background: var(--bg4);
  color: var(--text);
}

.search-results-loading {
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
}

/* ── Login overlay ──────────────────────────────────────── */

#login-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg);
  align-items: center;
  justify-content: center;
}

#login-overlay.visible {
  display: flex;
}

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 48px;
  width: 360px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
  margin-bottom: 8px;
  text-shadow: 0 0 20px rgba(229, 160, 13, 0.3);
}

.login-logo span {
  color: var(--text3);
  font-weight: 400;
}

.login-hint {
  color: var(--text3);
  font-size: 13px;
  margin-bottom: 24px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-form input {
  text-align: center;
}

.login-error {
  color: var(--red);
  font-size: 12px;
  margin-top: 12px;
}

/* ── Gear / icon button ──────────────────────────────────── */

.btn.icon-btn {
  font-size: 16px;
  padding: 6px 10px;
  line-height: 1;
}

/* ── Settings modal ─────────────────────────────────────── */

.settings-section {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.settings-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.settings-section-title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: 10px;
}

.settings-hint {
  font-size: 12.5px;
  color: var(--text3);
  margin-bottom: 14px;
  line-height: 1.55;
}

.settings-link {
  font-size: 10px;
  color: var(--accent);
  text-decoration: none;
  margin-left: 6px;
  font-family: var(--mono);
}

.settings-link:hover {
  text-decoration: underline;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-link:hover {
  color: var(--accent2);
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE / MOBILE
   ═══════════════════════════════════════════════════════════ */

/* Hamburger — hidden on desktop */
.sidebar-toggle-btn {
  display: none;
  font-size: 20px;
  padding: 6px 10px;
  flex-shrink: 0;
}

/* Sidebar backdrop overlay */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 149;
  backdrop-filter: blur(2px);
}

/* ── Music Artist / Album Search ─────────────────────────────────────────── */

.music-search-msg {
  padding: 8px 4px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Artist list */
.music-artist-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 4px;
}

.music-artist-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.music-artist-item:last-child { border-bottom: none; }
.music-artist-item:hover,
.music-artist-item.selected { background: var(--bg4); }
.music-artist-item.selected { border-left: 2px solid var(--accent); }

.music-artist-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.music-artist-sub {
  font-size: 11px;
  color: var(--text3);
  font-family: var(--mono);
}

/* Album label */
.music-album-label {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Album art grid */
.music-album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding: 2px 2px 4px;
}

.music-album-item {
  cursor: pointer;
  border-radius: 7px;
  overflow: hidden;
  background: var(--bg3);
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.12s;
}
.music-album-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.music-album-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--bg4);
}
.music-album-item img.no-art { display: none; }

.music-album-info {
  padding: 4px 6px 6px;
}

.music-album-title {
  font-size: 10px;
  color: var(--text);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.music-album-meta {
  font-size: 9px;
  color: var(--text3);
  font-family: var(--mono);
  margin-top: 1px;
}

/* ── Album Tracklist ─────────────────────────────────────────────────────── */

.detail-tracklist {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.tracklist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.tracklist-actions {
  display: flex;
  gap: 6px;
}

.tracklist-loading,
.tracklist-empty {
  font-size: 12px;
  color: var(--text3);
  padding: 6px 2px;
}

.track-disc-header {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 10px 0 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}

.track-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 4px;
  border-radius: 5px;
  transition: background 0.1s;
}

.track-row:hover { background: var(--bg3); }

.track-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
  width: 22px;
  text-align: right;
  flex-shrink: 0;
}

.track-title {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-dur {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
  min-width: 38px;
  text-align: right;
  flex-shrink: 0;
}

/* Edit mode */

.track-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}

.track-edit-title {
  flex: 1;
  min-width: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 13px;
  font-family: var(--sans);
}

.track-edit-dur {
  width: 60px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--mono);
  text-align: center;
  flex-shrink: 0;
}

.track-edit-title:focus,
.track-edit-dur:focus {
  outline: none;
  border-color: var(--accent);
}

.track-remove-btn {
  flex-shrink: 0;
  opacity: 0.45;
  padding: 2px 6px !important;
}
.track-remove-btn:hover { opacity: 1; color: var(--red); }

.tracklist-edit-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ── Tablet (≤ 900px) ──────────────────────────────────────── */
@media (max-width: 900px) {
  .header-stats { display: none; }

  aside {
    width: 190px;
  }
}

/* ── Mobile (≤ 640px) ──────────────────────────────────────── */
@media (max-width: 640px) {

  /* Header */
  header {
    padding: 0 12px;
    gap: 10px;
    height: 54px;
  }

  .sidebar-toggle-btn { display: flex; }
  .hide-mobile        { display: none !important; }

  .logo { font-size: 16px; }

  .header-actions { gap: 4px; }
  .header-actions .btn.primary { padding: 6px 12px; font-size: 12px; }

  /* Sidebar — off-canvas drawer */
  aside {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    padding-top: 60px; /* clear header height */
    box-shadow: none;
  }

  body.sidebar-open aside {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.6);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  /* Content — full width when sidebar hidden */
  .content { width: 100%; }

  /* Toolbar */
  .toolbar {
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .search-box {
    max-width: 100%;
    width: 100%;
    order: 1;
    flex: 1 1 100%;
  }

  .view-toggle  { order: 2; }
  .toolbar-right { order: 3; margin-left: auto; }

  /* Grid — smaller cards on phone */
  .poster-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    padding: 10px;
  }

  .media-card { border-radius: 6px; }

  /* On touch devices show card overlay always */
  .card-hover-overlay {
    opacity: 1;
    pointer-events: auto;
    background: linear-gradient(to top, rgba(0,0,0,0.82) 0%, transparent 65%);
    justify-content: flex-end;
    padding-bottom: 8px;
  }

  .card-actions { flex-direction: row; gap: 4px; }
  .card-btn     { font-size: 10px; padding: 3px 8px; }
  .card-stars   { display: none; }

  /* Table — horizontal scroll, tighter */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table       { font-size: 12px; min-width: 520px; }
  td, th      { padding: 7px 8px; }

  /* Modals — full-width, slide up from bottom */
  .overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: modal-slide-up 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes modal-slide-up {
    from { transform: translateY(100%); opacity: 0.6; }
    to   { transform: translateY(0);    opacity: 1; }
  }

  /* Form grid → single column */
  .form-grid {
    grid-template-columns: 1fr;
  }

  /* Detail layout → stack vertically */
  .detail-layout,
  .vap-detail-layout {
    flex-direction: column;
  }

  .detail-cover-wrap,
  .vap-cover-col {
    width: 100% !important;
    align-items: center;
  }

  .detail-cover {
    width: 130px;
    height: 195px;
  }

  /* Detail grid → single column */
  .detail-grid { grid-template-columns: 1fr; }

  /* Manga vol grid — smaller boxes */
  .vol-box { width: 36px; height: 36px; font-size: 10px; }

  /* Vol action panel — full width */
  .vap-info-col { width: 100% !important; min-width: 0 !important; }

  /* Manga detail header — stack */
  .md-header { flex-direction: column; }
  .md-cover  { width: 120px !important; }

  /* Modal footer — stack buttons on very small screens */
  .modal-footer {
    flex-wrap: wrap;
    gap: 6px;
  }
  .modal-footer .btn { flex: 1 1 auto; text-align: center; }

  /* Hide some table columns on mobile by data attribute */
  .hide-xs { display: none !important; }
}