:root {
  --bg: #14110f;
  --surface: #1f1a17;
  --surface-2: #2a2320;
  --text: #f8f1ea;
  --muted: #b9aca1;
  --accent: #f2a65a;
  --accent-2: #7cc6b8;
  --danger: #ef7d6d;
  --line: rgba(255, 255, 255, 0.09);
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  --radius: 16px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 90% -10%, rgba(242, 166, 90, 0.18), transparent 30rem),
    radial-gradient(circle at 0% 40%, rgba(124, 198, 184, 0.08), transparent 26rem),
    var(--bg);
  font-family: Inter, ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
  padding-bottom: 6rem;
}
button, input { font: inherit; }
a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, .card:focus-visible {
  outline: 3px solid rgba(242, 166, 90, 0.8); outline-offset: 3px;
}
.skip-link { position: absolute; left: -9999px; top: 1rem; z-index: 30; padding: .7rem; background: #fff; color: #111; }
.skip-link:focus { left: 1rem; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem clamp(1rem, 4vw, 3rem);
  background: rgba(20, 17, 15, 0.88); backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; text-decoration: none; font-size: 1.1rem; }
.brand-mark { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 12px; background: var(--accent); color: #1d1712; }
.nav { display: flex; gap: .4rem; }
.nav a { text-decoration: none; padding: .5rem .8rem; border-radius: 999px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.nav a.active, .nav a:hover { color: var(--text); background: var(--surface-2); }
.pill { display: inline-block; min-width: 1.4rem; padding: 0 .4rem; border-radius: 999px; background: var(--accent); color: #1d1712; font-size: .8rem; text-align: center; }
main { max-width: 1180px; margin: 0 auto; padding: 1.2rem clamp(1rem, 4vw, 3rem); outline: none; }
.hero { text-align: center; padding: clamp(1.5rem, 7vw, 4.5rem) 0 1.5rem; }
.hero h1 { font-size: clamp(1.7rem, 5vw, 2.8rem); margin: 0 0 .4rem; letter-spacing: -.02em; }
.hero p { color: var(--muted); margin: 0 0 1.4rem; }
.searchbox { display: flex; gap: .5rem; max-width: 640px; margin: 0 auto; }
.searchbox input {
  flex: 1; min-width: 0; padding: .95rem 1.1rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 1.05rem;
}
.searchbox input::placeholder { color: #8d8177; }
button.primary, button.ghost, a.button {
  border: 0; border-radius: 999px; padding: .75rem 1.2rem; font-weight: 700; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .4rem;
}
button.primary, a.button.primary { background: var(--accent); color: #1d1712; }
button.primary:disabled { opacity: .45; cursor: not-allowed; }
button.ghost, a.button.ghost { background: var(--surface-2); color: var(--text); }
.section { margin: 1.8rem 0; }
.section h2 { font-size: 1.15rem; margin: 0 0 .8rem; display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.section h2 small { color: var(--muted); font-weight: 500; font-size: .9rem; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { display: inline-flex; align-items: center; gap: .5rem; padding: .55rem .9rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; font-weight: 600; }
.chip img { width: 1.6rem; height: 1.6rem; border-radius: 6px; object-fit: cover; }
.chip small { color: var(--muted); font-weight: 500; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; } }
.card {
  position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); cursor: pointer; transition: transform .15s ease;
}
.card:hover { transform: translateY(-2px); }
.card.selected { outline: 3px solid var(--accent); }
.cover { position: relative; aspect-ratio: 1 / 1; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .placeholder { padding: 1rem; text-align: center; color: var(--muted); font-weight: 700; font-size: .95rem; }
.card .body { padding: .7rem .8rem .8rem; display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.card .title { font-weight: 700; line-height: 1.25; font-size: .98rem; }
.card .meta { color: var(--muted); font-size: .85rem; line-height: 1.3; }
.seq { position: absolute; left: .5rem; top: .5rem; background: rgba(20, 17, 15, .85); padding: .2rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.pick { position: absolute; right: .45rem; top: .45rem; width: 2.1rem; height: 2.1rem; border-radius: 999px; border: 2px solid rgba(255,255,255,.8); background: rgba(20,17,15,.65); color: transparent; font-weight: 900; display: grid; place-items: center; cursor: pointer; }
.card.selected .pick { background: var(--accent); border-color: var(--accent); color: #1d1712; }
.badge { align-self: flex-start; margin-top: .35rem; padding: .2rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.badge.in_library, .badge.available { background: rgba(124, 198, 184, .18); color: var(--accent-2); }
.badge.downloading, .badge.processing, .badge.imported, .badge.submitting, .badge.searching, .badge.queued, .badge.ready { background: rgba(242, 166, 90, .18); color: var(--accent); }
.badge.needs_attention, .badge.failed, .badge.waiting_paused { background: rgba(239, 125, 109, .16); color: var(--danger); }
.badge.dramatized { background: rgba(255,255,255,.06); color: #9a8f86; }
.series-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.2rem; }
.series-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .8rem; }
.series-head h3 { margin: 0; font-size: 1.1rem; }
.list { display: flex; flex-direction: column; gap: .6rem; }
.row { display: grid; grid-template-columns: 56px 1fr auto; gap: .8rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .6rem; }
.row img, .row .ph { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--surface-2); }
.row .t { font-weight: 700; }
.row .m { color: var(--muted); font-size: .85rem; }
.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: .35rem; }
.progress > span { display: block; height: 100%; background: var(--accent); }
.detail { display: grid; grid-template-columns: minmax(180px, 300px) 1fr; gap: clamp(1rem, 4vw, 2.5rem); align-items: start; }
@media (max-width: 700px) { .detail { grid-template-columns: 1fr; } .detail .cover { max-width: 280px; margin: 0 auto; width: 100%; } }
.detail .cover { border-radius: var(--radius); box-shadow: var(--shadow); }
.detail h1 { margin: 0 0 .3rem; font-size: clamp(1.5rem, 4vw, 2.2rem); }
.detail .by { color: var(--muted); margin: 0 0 1rem; }
.facts { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0 1.2rem; }
.fact { background: var(--surface); border: 1px solid var(--line); padding: .45rem .75rem; border-radius: 999px; font-size: .88rem; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1rem 0; }
.description { color: #ddd1c6; line-height: 1.6; white-space: pre-line; max-width: 70ch; }
.notice { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: .8rem 1rem; border-radius: 12px; color: var(--muted); }
.banner { max-width: 1180px; margin: .8rem auto 0; padding: .7rem 1rem; border-radius: 12px; background: rgba(239, 125, 109, .14); color: #ffd5cd; width: calc(100% - 2rem); }
.empty { color: var(--muted); text-align: center; padding: 2rem 0; }
.spinner { width: 2rem; height: 2rem; border-radius: 50%; border: 3px solid var(--surface-2); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 2rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.selection-bar {
  position: fixed; left: 50%; bottom: max(1rem, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: .6rem; padding: .6rem .6rem .6rem 1.1rem; border-radius: 999px;
  background: #2f2723; border: 1px solid var(--line); box-shadow: var(--shadow); width: max-content; max-width: calc(100% - 1.5rem);
}
.selection-bar span { font-weight: 700; white-space: nowrap; }
.toast { position: fixed; left: 50%; top: 4.8rem; transform: translateX(-50%); z-index: 30; background: #2f2723; border: 1px solid var(--line); padding: .7rem 1.1rem; border-radius: 12px; box-shadow: var(--shadow); max-width: calc(100% - 2rem); }
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 2rem 1rem; }
.footer .diag { margin-left: .6rem; color: #7d7168; font-size: .8rem; }
.back { display: inline-block; margin-bottom: 1rem; color: var(--muted); text-decoration: none; font-weight: 600; }
.userbox { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .9rem; }
.userbox button { padding: .45rem .8rem; font-size: .85rem; }
.topbar-right { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; gap: .5rem; }
  .brand span:last-child { display: none; }
  .userbox span { display: none; }
}
.row .actions { margin: 0; }
.row .by-line { color: #8d8177; font-size: .8rem; }
.badge.preordered, .badge.unreleased, .badge.awaiting_release { background: rgba(124, 198, 184, .12); color: var(--accent-2); }
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login-wrap { width: 100%; max-width: 380px; padding: 0; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.6rem; }
.login-brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.1rem; margin-bottom: 1rem; }
.login-card h1 { font-size: 1.4rem; margin: 0 0 1rem; }
.login-form { display: flex; flex-direction: column; gap: .45rem; }
.login-form label { font-weight: 600; color: var(--muted); font-size: .9rem; }
.login-form input[type=text], .login-form input[type=password] {
  padding: .85rem 1rem; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 1rem; margin-bottom: .5rem;
}
.login-form .remember { display: flex; align-items: center; gap: .5rem; color: var(--text); font-weight: 500; margin: .2rem 0 .6rem; }
.login-form .remember input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }
.login-form button { justify-content: center; margin-top: .3rem; }
.login-error { color: #ffd5cd; background: rgba(239, 125, 109, .14); padding: .6rem .8rem; border-radius: 10px; margin: 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
