/* ---------- Theme (matches Studio Lab: Light / Grey / Dark × Indigo / B&W, with optional rainbow touches) ---------- */
:root {
  --violet: #8e7cc3; --blue: #6d8fc7; --teal: #5fa8a0; --green: #84a96b;
  --yellow: #d2b25a; --orange: #d58c5a; --red: #c96b6b; --mauve: #b07a9b;
  --radius: 10px;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
[data-theme="light"] { --bg:#faf9f7; --surface:#ffffff; --surface2:#f1efeb; --text:#1d1c1a; --muted:#6f6b64; --line:#e4e0d9; --shadow:0 1px 3px rgba(0,0,0,.08); }
[data-theme="grey"]  { --bg:#d9d8d5; --surface:#e9e8e5; --surface2:#cfcdc9; --text:#1d1c1a; --muted:#5d5a55; --line:#c2bfba; --shadow:0 1px 3px rgba(0,0,0,.1); }
[data-theme="dark"]  { --bg:#141416; --surface:#1d1d21; --surface2:#28282e; --text:#ecebe8; --muted:#9b988f; --line:#34343a; --shadow:0 1px 3px rgba(0,0,0,.4); }

[data-accent^="bw"] { --accent:#111111; --on-accent:#ffffff; }
[data-theme="dark"][data-accent^="bw"] { --accent:#f2f2f2; --on-accent:#111111; }
[data-accent^="indigo"] { --accent:#4b4fa8; --on-accent:#ffffff; }
[data-theme="dark"][data-accent^="indigo"] { --accent:#a5a8f2; --on-accent:#141416; }

/* rainbow touches: used for list chips, progress bars, title */
:root { --r1:var(--accent); --r2:var(--accent); --r3:var(--accent); --r4:var(--accent); --r5:var(--accent); --r6:var(--accent); --r7:var(--accent); --r8:var(--accent); }
[data-accent$="rainbow"] { --r1:var(--violet); --r2:var(--blue); --r3:var(--teal); --r4:var(--green); --r5:var(--yellow); --r6:var(--orange); --r7:var(--red); --r8:var(--mauve); }

* { box-sizing: border-box; }
html, body { margin:0; background:var(--bg); color:var(--text); font-family:var(--sans); font-size:15px; line-height:1.45; }
a { color:inherit; }
button, input, select, textarea { font:inherit; color:inherit; }
h1, h2, h3 { font-family:var(--serif); font-weight:600; margin:0 0 .4em; letter-spacing:-.01em; }
h1 { font-size:1.9rem; } h2 { font-size:1.35rem; } h3 { font-size:1.05rem; }
.muted { color:var(--muted); }
.small { font-size:.85rem; }

/* ---------- Top bar ---------- */
.topbar { position:sticky; top:0; z-index:20; display:flex; align-items:center; gap:24px; padding:12px 24px; padding-top:max(12px, env(safe-area-inset-top)); background:color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter:blur(10px); border-bottom:1px solid var(--line); flex-wrap:wrap; }
.brand { font-family:var(--serif); font-size:1.5rem; font-weight:600; text-decoration:none; white-space:nowrap; }
.accent-word { color:var(--accent); }
[data-theme="dark"][data-accent$="rainbow"] .accent-word { background:linear-gradient(90deg,var(--violet),var(--blue),var(--teal),var(--green),var(--yellow),var(--orange),var(--red)); -webkit-background-clip:text; background-clip:text; color:transparent; }
.tabs { display:flex; gap:4px; flex-wrap:wrap; }
.tabs a { text-decoration:none; padding:6px 12px; border-radius:999px; color:var(--muted); font-weight:500; }
.tabs a:hover { color:var(--text); background:var(--surface2); }
.tabs a.active { background:var(--accent); color:var(--on-accent); }
.count:empty { display:none; }
.count { font-size:.75rem; opacity:.8; }

main { padding:24px; max-width:1400px; margin:0 auto; padding-bottom:80px; }

/* ---------- Controls ---------- */
.btn { border:1px solid var(--line); background:var(--surface); padding:7px 14px; border-radius:8px; cursor:pointer; font-weight:500; white-space:nowrap; }
.btn:hover { border-color:var(--muted); }
.btn.primary { background:var(--accent); color:var(--on-accent); border-color:var(--accent); }
.btn.ghost { background:transparent; }
.btn.small { padding:4px 10px; font-size:.85rem; }
.btn.on { background:var(--accent); color:var(--on-accent); border-color:var(--accent); }
.btn:disabled { opacity:.5; cursor:default; }
.iconbtn { border:none; background:transparent; cursor:pointer; padding:4px 6px; border-radius:6px; color:var(--muted); }
.iconbtn:hover { background:var(--surface2); color:var(--text); }
input[type=text], input[type=search], input[type=url], input[type=password], input[type=number], select, textarea {
  background:var(--surface); border:1px solid var(--line); border-radius:8px; padding:7px 10px; outline:none; }
input:focus, select:focus, textarea:focus { border-color:var(--accent); }
textarea { width:100%; min-height:120px; resize:vertical; line-height:1.5; }
label.field { display:flex; flex-direction:column; gap:4px; font-size:.85rem; color:var(--muted); }
label.field > input, label.field > select { color:var(--text); font-size:.95rem; }
.row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.spread { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; }
.seg { display:inline-flex; border:1px solid var(--line); border-radius:8px; overflow:hidden; }
.seg button { border:none; background:var(--surface); padding:6px 12px; cursor:pointer; border-right:1px solid var(--line); }
.seg button:last-child { border-right:none; }
.seg button.on { background:var(--accent); color:var(--on-accent); }

.filters { display:flex; gap:10px; flex-wrap:wrap; align-items:center; margin:12px 0 18px; }
.filters input[type=search] { min-width:200px; flex:1; max-width:320px; }

.chips { display:flex; gap:6px; flex-wrap:wrap; margin:8px 0; }
.chip { border:1px solid var(--line); background:var(--surface); border-radius:999px; padding:4px 12px; cursor:pointer; font-size:.88rem; display:inline-flex; gap:6px; align-items:center; }
.chip .dot { width:8px; height:8px; border-radius:50%; background:var(--c, var(--accent)); }
.chip.on { background:var(--c, var(--accent)); border-color:var(--c, var(--accent)); color:#fff; }
[data-accent^="bw"]:not([data-accent$="rainbow"]) .chip.on { color:var(--on-accent); }
.chip.on .dot { background:#fff; }

/* ---------- Album grid ---------- */
.grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(160px, 1fr)); gap:20px 16px; }
.card { cursor:pointer; position:relative; min-width:0; }
.cover { aspect-ratio:1; width:100%; border-radius:var(--radius); overflow:hidden; background:var(--surface2); box-shadow:var(--shadow); position:relative; }
.cover img { width:100%; height:100%; object-fit:cover; display:block; transition:transform .2s; }
.card:hover .cover img { transform:scale(1.03); }
.ph { width:100%; height:100%; display:grid; place-items:center; font-family:var(--serif); font-size:2rem; color:#fff; background:var(--c, var(--muted)); }
.card .t { font-weight:600; margin-top:8px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.card .a { color:var(--muted); font-size:.88rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.badges { position:absolute; top:8px; left:8px; right:8px; display:flex; justify-content:space-between; gap:4px; pointer-events:none; }
.badge { background:rgba(0,0,0,.72); color:#fff; font-size:.72rem; font-weight:600; padding:2px 7px; border-radius:999px; backdrop-filter:blur(4px); }
.badge.heard { background:var(--accent); color:var(--on-accent); }
.badge.lfm { background:rgba(0,0,0,.55); }
.card.unheard .cover img { filter:saturate(.35); opacity:.75; }
.card.skipped { opacity:.35; }
.quick { display:flex; gap:4px; margin-top:6px; flex-wrap:wrap; }
.quick .btn { padding:3px 8px; font-size:.78rem; }
.stars { color:var(--accent); font-size:.85rem; letter-spacing:1px; }

.empty { text-align:center; padding:60px 20px; color:var(--muted); }
.empty h2 { color:var(--text); }

/* ---------- Up Next ---------- */
.qlist { display:flex; flex-direction:column; gap:8px; max-width:760px; }
.qitem { display:flex; align-items:center; gap:14px; background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:8px 12px 8px 8px; }
.qitem.dragging { opacity:.4; }
.qitem.over { border-color:var(--accent); }
.qitem .num { font-family:var(--serif); font-size:1.2rem; width:28px; text-align:center; color:var(--muted); }
.qitem .cover { width:56px; height:56px; flex:none; border-radius:6px; }
.qitem .info { flex:1; min-width:0; cursor:pointer; }
.qitem .info .t { font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.qitem .handle { cursor:grab; color:var(--muted); padding:0 4px; user-select:none; }

/* ---------- Deep dives ---------- */
.dives { display:grid; grid-template-columns:repeat(auto-fill, minmax(280px, 1fr)); gap:16px; }
.divecard { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:14px; cursor:pointer; display:flex; gap:12px; align-items:center; }
.divecard:hover { border-color:var(--muted); }
.divecard .mini { display:grid; grid-template-columns:repeat(2, 36px); gap:3px; flex:none; }
.divecard .mini > * { width:36px; height:36px; border-radius:4px; overflow:hidden; background:var(--surface2); }
.divecard .mini img { width:100%; height:100%; object-fit:cover; }
.divecard .body { flex:1; min-width:0; }
.progress { height:8px; background:var(--surface2); border-radius:999px; overflow:hidden; margin:6px 0 4px; }
.progress > span { display:block; height:100%; background:var(--bar, var(--accent)); border-radius:999px; transition:width .4s; }
.divehead { display:flex; gap:20px; align-items:flex-end; flex-wrap:wrap; margin-bottom:12px; }
.divehead .big { font-family:var(--serif); font-size:2.6rem; line-height:1; }
.nextdive { display:flex; gap:18px; align-items:center; background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:14px; margin:8px 0 14px; max-width:620px; }
.nextdive .cover { width:120px; flex:none; }
.nextdive .lbl { font-size:.75rem; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); font-weight:600; }
.nextdive h2 { margin:2px 0; }
.journey { display:flex; gap:10px; overflow-x:auto; padding:6px 2px 12px; margin:6px 0 18px; }
.journey .step { flex:none; width:92px; text-align:center; font-size:.75rem; color:var(--muted); cursor:pointer; }
.journey .step .jt { color:var(--text); font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.journey .step .cover { width:92px; height:92px; margin-bottom:4px; }
.suggest { display:flex; gap:8px; flex-wrap:wrap; }
.section { margin:28px 0 10px; }

/* ---------- Modal ---------- */
dialog { border:none; border-radius:16px; padding:0; background:var(--surface); color:var(--text); width:min(760px, 94vw); max-height:90vh; box-shadow:0 20px 60px rgba(0,0,0,.35); }
dialog::backdrop { background:rgba(0,0,0,.45); }
.album { display:grid; grid-template-columns:240px 1fr; gap:24px; padding:24px; }
.album .cover { width:240px; }
.album h2 { font-size:1.6rem; margin-bottom:2px; }
.album .meta { color:var(--muted); margin-bottom:12px; }
.album .group { margin:14px 0; }
.album .group > .lbl { font-size:.78rem; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); margin-bottom:6px; font-weight:600; }
.ask { width:min(420px, 92vw); }
.askform { padding:22px 22px 18px; display:flex; flex-direction:column; gap:10px; }
.askform h3 { font-size:1.15rem; margin:0; }
.askform p { margin:0; }
.askform input { width:100%; font-size:1rem; padding:9px 12px; }
.askbtns { display:flex; justify-content:flex-end; gap:8px; margin-top:6px; }
.btn.danger { background:var(--red); border-color:var(--red); color:#fff; }
.close { position:absolute; top:10px; right:12px; font-size:1.4rem; }
.rating { display:inline-flex; gap:2px; cursor:pointer; font-size:1.5rem; line-height:1; user-select:none; }
.rating .s { position:relative; color:var(--line); width:1em; }
.rating .s .fill { position:absolute; left:0; top:0; overflow:hidden; color:var(--accent); }
.dates { display:flex; gap:6px; flex-wrap:wrap; }
.date { background:var(--surface2); border-radius:6px; padding:2px 8px; font-size:.82rem; display:inline-flex; gap:4px; align-items:center; }
.date button { border:none; background:none; cursor:pointer; color:var(--muted); padding:0; }
.links { display:flex; gap:12px; flex-wrap:wrap; font-size:.88rem; margin-top:16px; }
.links a { color:var(--muted); }

/* ---------- Settings ---------- */
.settings { max-width:720px; display:flex; flex-direction:column; gap:22px; }
.panel { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:18px 20px; }
.panel h2 { font-size:1.15rem; }
.panel .row + .row { margin-top:10px; }
.panel p { margin:.3em 0 .8em; }
.listrow { display:flex; align-items:center; gap:8px; padding:6px 0; border-bottom:1px solid var(--line); }
.listrow:last-child { border-bottom:none; }
.listrow .name { flex:1; }

.toast { position:fixed; bottom:24px; left:50%; transform:translateX(-50%) translateY(20px); background:var(--text); color:var(--bg); padding:10px 18px; border-radius:999px; font-weight:500; opacity:0; pointer-events:none; transition:all .25s; z-index:100; max-width:90vw; text-align:center; }
.toast.show { opacity:1; transform:translateX(-50%) translateY(0); }
.spinner { display:inline-block; width:14px; height:14px; border:2px solid var(--line); border-top-color:var(--accent); border-radius:50%; animation:spin .8s linear infinite; vertical-align:-2px; }
@keyframes spin { to { transform:rotate(360deg); } }

/* ---------- "Modern" style option: all sans, neutral (no cream) ---------- */
[data-style="modern"] { --serif: var(--sans); }
[data-style="modern"][data-theme="light"] { --bg:#ffffff; --surface:#ffffff; --surface2:#f2f3f5; --text:#0f1012; --muted:#6b6f76; --line:#e5e7eb; --shadow:0 1px 2px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.05); }
[data-style="modern"][data-theme="grey"]  { --bg:#e4e5e8; --surface:#f1f2f4; --surface2:#d8dade; --text:#0f1012; --muted:#585c63; --line:#cbced3; }
[data-style="modern"][data-theme="dark"]  { --bg:#0e0f11; --surface:#17181b; --surface2:#222428; --text:#f2f3f5; --muted:#9196a0; --line:#2c2f34; --shadow:0 1px 3px rgba(0,0,0,.5); }
[data-style="modern"] h1, [data-style="modern"] h2, [data-style="modern"] h3 { font-weight:700; letter-spacing:-.025em; }
[data-style="modern"] .brand { font-size:1.35rem; font-weight:800; letter-spacing:-.04em; }
[data-style="modern"] .ph { font-weight:700; }
[data-style="modern"] .qitem .num { font-weight:600; font-size:1rem; font-variant-numeric:tabular-nums; }
[data-style="modern"] .divehead .big { font-weight:800; letter-spacing:-.04em; font-variant-numeric:tabular-nums; }

@media (max-width:640px) {
  main { padding:16px; }
  .topbar { padding:10px 16px; gap:8px; }
  .tabs a { padding:5px 9px; font-size:.9rem; }
  .grid { grid-template-columns:repeat(auto-fill, minmax(130px, 1fr)); gap:16px 12px; }
  .album { grid-template-columns:1fr; padding:20px; }
  .album .cover { width:min(240px, 70vw); }
}
@media (max-width:640px) {
  .qitem { gap:8px; padding:8px; }
  .qitem .handle, .qitem .num { display:none; }
  .divehead .big { font-size:2rem; }
}
