/* ─── Google Fonts ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,600;12..96,700&family=Instrument+Sans:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  --ink: #171D2B;
  --paper: #FFFFFF;
  --mat: #E8EBF0;
  --mat-line: #DDE2E9;
  --muted: #6B7280;
  --border: #D1D5DB;
  --shadow-card: 0 2px 8px rgb(23 29 43 / 0.10);
  --shadow-hover: 0 6px 20px rgb(23 29 43 / 0.18);
  --radius-card: 16px;
  --radius-btn: 10px;
  --foil: linear-gradient(135deg, #F7D774, #E8B33C 60%, #F9E7A0);
  /* App accents */
  --accent-stkrr: #FF6B81;
  --accent-nekome: #8B7CF6;
  --accent-purrify: #F59E0B;
  --accent: var(--accent-stkrr);
  /* Typography */
  --font-display: 'Bricolage Grotesque', sans-serif;
  --font-body: 'Instrument Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* ─── Icons ──────────────────────────────────────────────────────────────────── */
.icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Slightly larger icons in headings/titles */
.backups-title .icon,
.rail-action .icon {
  width: 15px;
  height: 15px;
}

/* Tiny star in foil badge */
.foil-badge .icon {
  width: 10px;
  height: 10px;
}

/* Close button icon */
.drawer-close .icon,
.backups-close .icon {
  width: 18px;
  height: 18px;
}

/* Buttons that contain icons: ensure flex + gap for alignment */
/* .rail-action and .btn-new-style-global already have display:flex in their own rules */
.group-add-btn,
.foil-badge,
#btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.rail-action { gap: 8px; }        /* already display:flex */
.btn-new-style-global { gap: 8px; } /* already display:flex */

/* group-header-icon mirrors group-header-emoji sizing */
.group-header-icon {
  display: inline-flex;
  align-items: center;
  color: #F59E0B;
}
.group-header-icon .icon {
  width: 20px;
  height: 20px;
}

/* ─── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  background-color: var(--mat);
  background-image:
    linear-gradient(var(--mat-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--mat-line) 1px, transparent 1px);
  background-size: 24px 24px;
  min-height: 100vh;
}

/* ─── Login gate ─────────────────────────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--paper);
  border-radius: 20px;
  padding: 40px 48px;
  box-shadow: var(--shadow-hover);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: 28px;
  margin-bottom: 8px;
}

.login-card p {
  color: var(--muted);
  margin-bottom: 28px;
  font-size: 14px;
}

.login-card input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-btn);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
  margin-bottom: 16px;
  transition: border-color 0.15s;
}

.login-card input:focus {
  border-color: var(--ink);
}

.login-card .btn-primary {
  width: 100%;
}

.login-error {
  color: #DC2626;
  font-size: 13px;
  margin-top: 10px;
  min-height: 20px;
}

/* ─── App shell ───────────────────────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-rows: 56px 1fr;
  grid-template-columns: 220px 1fr;
  grid-template-areas:
    "topbar topbar"
    "rail   main";
  min-height: 100vh;
}

/* ─── Topbar ──────────────────────────────────────────────────────────────────── */
#topbar {
  grid-area: topbar;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.topbar-spacer { flex: 1; }

.changes-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--mat);
  border-radius: 20px;
  padding: 3px 10px;
  display: none;
}

.changes-badge.visible { display: inline-block; }
.changes-badge.has-changes { color: var(--ink); background: #FEF3C7; }

#btn-discard {
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  font-family: var(--font-body);
  display: none;
}
#btn-discard:hover { color: var(--ink); background: var(--mat); }
#btn-discard.visible { display: inline-block; }

.topbar-btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

#btn-logout {
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  font-family: var(--font-body);
}
#btn-logout:hover { color: var(--ink); background: var(--mat); }

/* ─── Rail ────────────────────────────────────────────────────────────────────── */
#rail {
  grid-area: rail;
  background: var(--paper);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 4px;
}

.rail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 4px 8px 8px;
}

.rail-app {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  color: var(--ink);
  transition: background 0.12s;
}

.rail-app:hover { background: var(--mat); }

.rail-app.active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--ink);
  font-weight: 600;
}

.rail-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.rail-section { margin-top: 16px; }

.rail-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  color: var(--muted);
  transition: background 0.12s;
}
.rail-action:hover { background: var(--mat); color: var(--ink); }

/* ─── Main ────────────────────────────────────────────────────────────────────── */
#main {
  grid-area: main;
  overflow-y: auto;
  padding: 28px 32px;
}

/* ─── App header ─────────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.app-header-left h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
}

.app-header-left p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.pack-detail-nav { display:flex; align-items:center; justify-content:space-between; margin-bottom:24px; }
.back-button { border:0; background:none; color:var(--muted); font:600 13px var(--font-body); cursor:pointer; padding:8px 0; }
.back-button:hover { color:var(--ink); }
.pack-detail-header { display:flex; align-items:center; gap:18px; background:var(--paper); border-radius:16px; padding:20px 24px; margin-bottom:24px; box-shadow:var(--shadow-card); }
.pack-detail-icon { display:grid; place-items:center; width:64px; height:64px; border-radius:14px; background:color-mix(in srgb, var(--accent) 16%, white); font-size:34px; flex-shrink:0; }
.pack-detail-header h2 { font:700 22px var(--font-display); }
.pack-detail-header p { color:var(--muted); margin:3px 0 7px; }
.pack-detail-header code { font:11px var(--font-mono); color:var(--muted); }
.expression-grid { display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:18px; max-width:900px; }
.expression-card { position:relative; min-width:0; border:0; border-radius:16px; padding:18px; background:var(--paper); box-shadow:var(--shadow-card); cursor:pointer; display:flex; flex-direction:column; align-items:center; gap:9px; font-family:var(--font-body); color:var(--ink); transition:transform .15s, box-shadow .15s; }
.expression-card:hover { transform:translateY(-2px); box-shadow:var(--shadow-hover); }
.expression-card img, .expression-emoji { width:150px; height:150px; object-fit:contain; border-radius:12px; }
.expression-emoji { display:grid; place-items:center; font-size:64px; background:var(--mat); }
.expression-card strong { font-size:14px; }
.expression-card small { max-width:100%; overflow:hidden; text-overflow:ellipsis; font:10px var(--font-mono); color:var(--muted); }
.cell-number { position:absolute; top:10px; left:10px; width:24px; height:24px; display:grid; place-items:center; border-radius:50%; background:var(--ink); color:white; font-size:11px; font-weight:700; }
.expression-preview { min-height:190px; display:grid; place-items:center; border-radius:14px; background:var(--mat); }
.expression-preview img { width:190px; height:190px; object-fit:contain; }
.expression-preview span { font-size:76px; }
.field-hint { color:var(--muted); font-size:11px; }
@media (max-width: 850px) { .expression-grid { grid-template-columns:repeat(2, minmax(0,1fr)); } }
@media (max-width: 620px) { .expression-grid { grid-template-columns:1fr; } .pack-detail-header { align-items:flex-start; } }

/* ─── Group section ────────────────────────────────────────────────────────────── */
.group-section { margin-bottom: 40px; }

.group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent);
}

.group-header-emoji { font-size: 20px; }

.group-header-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}

.group-header-count {
  font-size: 12px;
  color: var(--muted);
  background: var(--mat);
  border-radius: 20px;
  padding: 2px 8px;
}

.group-add-btn {
  margin-left: auto;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1.5px dashed var(--border);
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-family: var(--font-body);
  transition: all 0.12s;
}
.group-add-btn:hover { border-color: var(--ink); color: var(--ink); background: var(--paper); }

/* ─── Style grid ──────────────────────────────────────────────────────────────── */
.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

/* ─── Die-cut sticker card ───────────────────────────────────────────────────── */
.style-card {
  background: var(--paper);
  border-radius: var(--radius-card);
  box-shadow: 0 0 0 4px var(--paper), var(--shadow-card);
  padding: 16px 12px 14px;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  user-select: none;
}

.style-card:hover {
  transform: rotate(-1.5deg) translateY(-2px);
  box-shadow: 0 0 0 4px var(--paper), var(--shadow-hover);
}

@media (prefers-reduced-motion: reduce) {
  .style-card:hover { transform: none; }
  .foil-badge::after { display: none; }
}

.style-card:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.card-icon {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: contain;
  display: block;
}

.card-emoji {
  font-size: 56px;
  line-height: 1;
  display: block;
  text-align: center;
  width: 72px;
  height: 72px;
}

.card-name {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
}

.card-id {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Foil badge ──────────────────────────────────────────────────────────────── */
.foil-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--foil);
  color: #7A4F00;
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  padding: 3px 7px;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.18);
  overflow: hidden;
  z-index: 1;
}

.foil-badge::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
  transition: left 0.5s ease;
}

.foil-badge:hover::after {
  left: 150%;
}

/* ─── Global new style button ────────────────────────────────────────────────── */
.btn-new-style-global {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-btn);
  border: 1.5px dashed var(--border);
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.12s;
}
.btn-new-style-global:hover { border-color: var(--ink); color: var(--ink); background: var(--paper); }

/* ─── Buttons ─────────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: var(--radius-btn);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.btn-danger {
  background: none;
  border: none;
  color: #DC2626;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-body);
  padding: 6px 8px;
  border-radius: 8px;
}
.btn-danger:hover { background: #FEE2E2; }

/* ─── Editor drawer ───────────────────────────────────────────────────────────── */
#drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgb(23 29 43 / 0.35);
  z-index: 200;
  backdrop-filter: blur(2px);
}
#drawer-overlay.open { display: block; }

#drawer {
  position: fixed;
  top: 0;
  right: -440px;
  width: 420px;
  height: 100vh;
  background: var(--paper);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  z-index: 201;
  transition: right 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  display: flex;
  flex-direction: column;
}

#drawer.open { right: 0; }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 1;
}

.drawer-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}

.drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 20px;
  padding: 4px 8px;
  border-radius: 8px;
  line-height: 1;
  font-family: var(--font-body);
}
.drawer-close:hover { color: var(--ink); background: var(--mat); }
.drawer-close:focus-visible { outline: 2px solid var(--ink); }

.drawer-body {
  padding: 20px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  bottom: 0;
  background: var(--paper);
}

/* ─── Form fields ─────────────────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

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

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
input[type="number"],
select,
textarea {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink);
  background: var(--paper);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: var(--ink);
}

input[readonly] {
  background: var(--mat);
  color: var(--muted);
  cursor: not-allowed;
}

textarea {
  font-family: var(--font-mono);
  font-size: 12px;
  resize: vertical;
  min-height: 100px;
  line-height: 1.55;
}

.char-counter {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}

/* ─── Emojis row ────────────────────────────────────────────────────────────── */
.emojis-row {
  display: flex;
  gap: 8px;
}

.emojis-row input {
  text-align: center;
  font-size: 20px;
  padding: 6px 4px;
  flex: 1;
}

/* ─── Toggle switch ─────────────────────────────────────────────────────────── */
.toggle-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
}

.toggle-label {
  font-size: 13px;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.toggle-label small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--ink);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.toggle-switch input:focus-visible + .toggle-slider {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* Premium foil toggle state */
.toggle-switch input:checked + .toggle-slider.foil {
  background: var(--foil);
}

/* ─── Icon upload ───────────────────────────────────────────────────────────── */
.icon-upload-area {
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.icon-upload-area:hover { border-color: var(--ink); background: var(--mat); }

.icon-preview {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: contain;
  display: block;
  margin: 0 auto 8px;
}

.icon-upload-hint {
  font-size: 12px;
  color: var(--muted);
}

/* ─── Backups panel ─────────────────────────────────────────────────────────── */
#backups-panel {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  background: var(--paper);
  border-radius: 16px;
  box-shadow: var(--shadow-hover);
  border: 1px solid var(--border);
  z-index: 300;
  overflow: hidden;
}

#backups-panel.open { display: block; }

.backups-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.backups-title {
  font-size: 14px;
  font-weight: 600;
}

.backups-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 18px;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
}
.backups-close:hover { color: var(--ink); background: var(--mat); }

.backups-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px 0;
}

.backup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--mat);
  gap: 12px;
}

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

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

.backup-key {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.backup-date {
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 2px;
}

.backup-restore {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-body);
  white-space: nowrap;
  color: var(--ink);
  transition: all 0.12s;
  flex-shrink: 0;
}
.backup-restore:hover { border-color: var(--ink); background: var(--mat); }

/* ─── Toast ─────────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 999;
  pointer-events: none;
  white-space: nowrap;
}

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

#toast.error {
  background: #DC2626;
}

/* ─── Draft restore banner ───────────────────────────────────────────────────── */
#draft-banner {
  display: none;
  background: #FEF3C7;
  border: 1px solid #FCD34D;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 20px;
  display: none;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
#draft-banner.visible { display: flex; }
#draft-banner-text { flex: 1; }
#draft-banner-restore {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  border: none;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  font-family: var(--font-body);
}
#draft-banner-dismiss {
  font-size: 12px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
}

/* ─── Empty state ─────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}
.empty-state h3 { font-size: 16px; margin-bottom: 8px; color: var(--ink); }
.empty-state p { font-size: 13px; }

/* ─── Loading spinner ─────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--muted);
  gap: 12px;
  font-size: 13px;
}

/* ─── Validation error list ───────────────────────────────────────────────────── */
.error-list {
  background: #FEE2E2;
  border: 1px solid #FCA5A5;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 12px;
  color: #7F1D1D;
  max-height: 200px;
  overflow-y: auto;
}

.error-list ul {
  padding-left: 16px;
  margin-top: 6px;
}

.error-list li { margin-bottom: 4px; }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #app {
    grid-template-rows: auto 56px 1fr;
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "rail"
      "main";
  }

  #rail {
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    gap: 8px;
  }

  .rail-label { display: none; }
  .rail-app { padding: 8px 14px; font-size: 13px; }
  .rail-section { display: none; }

  #main { padding: 16px; }

  .style-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  #drawer {
    width: 100%;
    right: -100%;
    top: auto;
    bottom: -100%;
    height: 90vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
  }

  #drawer.open {
    right: 0;
    bottom: 0;
  }

  #backups-panel {
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
  }
}

@media (max-width: 380px) {
  .style-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  #main { padding: 12px; }
}
