/* MediaAtlas - mobile-first stylesheet */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1c1f24;
  --muted: #5f6672;
  --border: #dde0e5;
  --primary: #2458d6;
  --primary-text: #ffffff;
  --danger: #c62f2f;
  --book: #2458d6;
  --cd: #8a3fd1;
  --dvd: #d1602a;
  --radius: 12px;
  --tap: 48px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1e2127;
    --text: #eceef1;
    --muted: #a0a7b3;
    --border: #333842;
    --primary: #5b86f0;
    --danger: #ef5b5b;
    --book: #5b86f0;
    --cd: #b07ae8;
    --dvd: #ee8a57;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Header */
.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-header h1 { font-size: 1.15rem; margin: 0; flex: 1; }
.app-header a.back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  color: var(--text); text-decoration: none; font-size: 1.4rem;
}
.app-header a.back:hover { background: var(--bg); }
.brand { display: flex; align-items: center; gap: 8px; }
.brand svg { width: 28px; height: 28px; }

main { padding: 16px; max-width: 640px; margin: 0 auto; }

/* Home menu */
.menu-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-top: 8px;
}
.menu-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; min-height: 112px; padding: 12px 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; font-weight: 600; font-size: 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.menu-btn:active { transform: scale(.98); }
.menu-btn svg { width: 36px; height: 36px; stroke: var(--primary); }
.menu-btn.danger svg { stroke: var(--danger); }
.menu-btn.scan { grid-column: 1 / -1; min-height: 96px; flex-direction: row; background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.menu-btn.scan svg { stroke: var(--primary-text); }

.stats { display: flex; gap: 8px; margin: 20px 0 8px; }
.stat {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; text-align: center;
}
.stat b { display: block; font-size: 1.4rem; }
.stat span { color: var(--muted); font-size: .85rem; }

h2 { font-size: 1rem; margin: 20px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* Segmented media-type control */
.segmented {
  display: flex; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 4px; gap: 4px; margin-bottom: 16px;
}
.segmented button {
  flex: 1; min-height: 40px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--primary); color: var(--primary-text); }

/* Forms */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
label { display: block; font-weight: 600; font-size: .9rem; margin: 12px 0 4px; }
label:first-child { margin-top: 0; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 18px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.block { width: 100%; margin-top: 16px; }
.btn-row { display: flex; gap: 8px; margin-top: 16px; }
.btn-row .btn { flex: 1; }

.hint { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }
.hidden { display: none !important; }

/* Result list */
.results { list-style: none; padding: 0; margin: 0; }
.result {
  display: flex; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px; margin-bottom: 8px; cursor: pointer;
}
.result:active { background: var(--bg); }
.cover {
  flex: 0 0 52px; height: 72px; border-radius: 6px;
  background: var(--bg); border: 1px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: .7rem; text-align: center;
  position: relative; overflow: hidden;
}
.cover img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: var(--surface);
}
.result .meta { flex: 1; min-width: 0; }
.result .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result .sub { color: var(--muted); font-size: .85rem; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; color: #fff;
}
.badge.book { background: var(--book); }
.badge.cd { background: var(--cd); }
.badge.dvd { background: var(--dvd); }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }

/* Scanner */
.viewfinder {
  position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius);
  background: #000; overflow: hidden; display: flex; align-items: center; justify-content: center;
  color: #bbb; text-align: center; padding: 16px;
}
.viewfinder::after {
  content: ""; position: absolute; left: 12%; right: 12%; top: 50%;
  height: 2px; background: #ff3b3b; box-shadow: 0 0 8px #ff3b3b;
}
.viewfinder .frame {
  position: absolute; inset: 22% 10%; border: 2px solid rgba(255,255,255,.7); border-radius: 8px;
}

/* Toast */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: 20px; z-index: 50;
  max-width: 480px; margin: 0 auto; padding: 14px 16px; border-radius: 10px;
  background: #1c1f24; color: #fff; font-weight: 600; text-align: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}

footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 16px 32px; }


/* Header drop-down menu */
.menu-wrap { position: relative; margin-left: auto; }
.menu-toggle { background: none; border: 0; color: inherit; font-size: 1.5rem; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; }
.menu-toggle:hover { background: var(--bg); }
.menu-panel { position: absolute; right: 0; top: 46px; min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.2); padding: 6px; z-index: 30; }
.menu-panel a, .menu-panel .who { display: block; padding: 12px; color: var(--text); text-decoration: none; border-radius: 8px; }
.menu-panel a:hover { background: var(--bg); }
.menu-panel .who { color: var(--muted); font-size: .85rem; }

a.stat { color: inherit; text-decoration: none; display: block; }
a.stat:active { background: var(--bg); }

.by { color: var(--muted); font-size: .7rem; margin-left: 25px; }
