:root {
  color-scheme: light;
  --ink: #241c19;
  --muted: #726660;
  --line: #e7dcd4;
  --paper: #fffaf5;
  --surface: #ffffff;
  --soft: #fff0e8;
  --accent: #bd432e;
  --accent-dark: #96311f;
  --focus: #155e75;
  --shadow: 0 12px 34px rgb(77 41 28 / 8%);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { min-width: 320px; margin: 0; background: var(--paper); color: var(--ink); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif; line-height: 1.55; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.page-width { width: min(1120px, calc(100% - 32px)); margin-inline: auto; }
.skip-link { position: fixed; z-index: 20; top: .5rem; left: .5rem; transform: translateY(-160%); padding: .55rem .8rem; border-radius: .45rem; background: #fff; color: #000; box-shadow: var(--shadow); }
.skip-link:focus { transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.site-header { border-bottom: 1px solid var(--line); background: rgb(255 250 245 / 92%); }
.header-content { display: flex; min-height: 66px; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); font-size: 1.1rem; font-weight: 800; text-decoration: none; letter-spacing: -.02em; }
.brand small { color: var(--accent); font-size: .7em; }
.brand-mark { display: grid; width: 31px; height: 31px; place-items: center; border-radius: 9px; background: var(--accent); color: #fff; font-family: Georgia, serif; }
.header-actions { display: flex; align-items: center; gap: .75rem; }
.local-chip, .count-badge { display: inline-block; padding: .27rem .56rem; border: 1px solid #ead0c4; border-radius: 99px; background: #fff7f1; color: #8b3d2d; font-size: .75rem; font-weight: 700; white-space: nowrap; }

.button { min-height: 42px; padding: .55rem .85rem; border: 1px solid transparent; border-radius: .6rem; font-weight: 700; line-height: 1.2; }
.button-primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.button-primary:hover { border-color: var(--accent-dark); background: var(--accent-dark); }
.button-secondary { border-color: #d5bdb2; background: #fff; color: #6b3025; }
.button-secondary:hover, .button-quiet:hover { background: #fff0e8; }
.button-quiet { border-color: #dacbc4; background: transparent; color: #573a32; }
.icon-button { display: grid; width: 36px; height: 36px; padding: 0; place-items: center; border: 0; border-radius: .45rem; background: transparent; color: var(--muted); font-size: 1.3rem; }
.icon-button:hover { background: #f4e9e3; color: var(--ink); }

.intro { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 2rem; align-items: end; padding: clamp(2.3rem, 6vw, 4.6rem) 0 1.6rem; }
.eyebrow { margin: 0 0 .3rem; color: var(--accent); font-size: .77rem; font-weight: 800; letter-spacing: .08em; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { max-width: 800px; margin: 0; font-size: clamp(2rem, 5vw, 3.55rem); line-height: 1.15; letter-spacing: -.045em; }
.intro-copy { max-width: 700px; margin: 1rem 0 0; color: var(--muted); font-size: 1rem; }
.android-link { display: flex; align-items: center; gap: .75rem; padding: .9rem; border: 1px solid #d7c1b6; border-radius: .85rem; background: #fff; box-shadow: 0 4px 15px rgb(77 41 28 / 5%); text-decoration: none; }
.android-link:hover { border-color: var(--accent); }
.android-link > span:first-child { display: grid; width: 36px; height: 36px; flex: none; place-items: center; border-radius: .55rem; background: #eef7ec; color: #32742d; }
.android-link strong, .android-link small { display: block; }
.android-link strong { font-size: .85rem; }
.android-link small { margin-top: .1rem; color: var(--muted); font-size: .71rem; }

.install-guidance { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: .8rem; align-items: center; margin: 0 0 1.4rem; padding: .8rem 1rem; border: 1px solid #e9c0ae; border-radius: .8rem; background: #fff4ed; }
.guidance-icon { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: 1.25rem; font-weight: 700; }
.install-guidance h2 { margin: 0; font-size: .94rem; }
.install-guidance p { margin: .08rem 0 0; color: #6e5248; font-size: .79rem; }
.install-guidance .button { min-height: 36px; font-size: .78rem; }
.message { margin: 0 0 1rem; padding: .75rem 1rem; border-radius: .65rem; }
.message-error { border: 1px solid #e3aaa4; background: #fff0ef; color: #8f2119; }

.app-layout { display: grid; grid-template-columns: minmax(290px, .84fr) minmax(0, 1.16fr); gap: 1.25rem; align-items: stretch; }
.panel, .backup-panel, .series-card, .privacy-note { border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); box-shadow: var(--shadow); }
.panel { padding: clamp(1rem, 3vw, 1.45rem); }
.panel-heading, .section-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.panel-heading h2, .section-heading h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.025em; }
.panel-description { margin: .85rem 0; color: var(--muted); font-size: .84rem; }
.field { margin-top: 1rem; }
.field label { display: block; margin-bottom: .35rem; font-size: .86rem; font-weight: 750; }
.field input { width: 100%; min-height: 45px; padding: .55rem .7rem; border: 1px solid #cfc1ba; border-radius: .55rem; background: #fff; color: var(--ink); }
.field input::placeholder { color: #a79c96; }
.field input:focus { border-color: var(--focus); outline: 2px solid rgb(21 94 117 / 15%); }
.field-help { margin: .34rem 0 0; color: var(--muted); font-size: .74rem; }
.form-actions { display: flex; gap: .55rem; margin-top: 1.2rem; }

.shopping-list { display: grid; gap: .55rem; max-height: 285px; margin: 0; padding: 0; overflow: auto; list-style: none; }
.shopping-item { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem .75rem; border-radius: .65rem; background: #fff8f4; }
.shopping-item-title { min-width: 0; font-size: .87rem; font-weight: 750; }
.shopping-item-title span { overflow: hidden; display: block; text-overflow: ellipsis; white-space: nowrap; }
.shopping-item-kind { display: block; margin-top: .1rem; color: var(--muted); font-size: .7rem; font-weight: 400; }
.volume-label { flex: none; padding: .22rem .48rem; border-radius: .35rem; background: #f3d6c8; color: #803323; font-size: .8rem; font-weight: 800; }
.empty-state { display: grid; min-height: 155px; place-items: center; padding: 1rem; border: 1px dashed #d9cac2; border-radius: .7rem; color: var(--muted); font-size: .86rem; text-align: center; }
.shopping-list .empty-state { min-height: 195px; }

.library-section { padding: clamp(2.4rem, 5vw, 4rem) 0; }
.section-heading { margin-bottom: 1rem; }
.backup-panel { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; padding: 1rem; background: #fffcf9; box-shadow: none; }
.backup-panel h3 { margin: 0; font-size: .95rem; }
.backup-panel p { max-width: 690px; margin: .2rem 0 0; color: var(--muted); font-size: .78rem; }
.backup-actions { display: flex; flex: none; flex-wrap: wrap; gap: .5rem; justify-content: end; }
.backup-actions .button { min-height: 38px; font-size: .78rem; }
.series-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.series-grid > .empty-state { grid-column: 1 / -1; }
.series-card { display: flex; min-width: 0; flex-direction: column; padding: 1rem; }
.series-card-top { display: flex; align-items: start; justify-content: space-between; gap: .5rem; }
.series-card h3 { margin: 0; font-size: 1.02rem; line-height: 1.35; }
.series-menu { display: flex; flex: none; gap: .2rem; }
.text-button { padding: .32rem .42rem; border: 0; border-radius: .35rem; background: transparent; color: #70473b; font-size: .74rem; font-weight: 700; }
.text-button:hover { background: #f5e8e1; }
.text-button-danger { color: #9a2d22; }
.progress-row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: 1rem 0 .8rem; }
.progress-box { padding: .58rem .5rem; border-radius: .55rem; background: #faf4ef; }
.progress-box span, .volume-caption { display: block; color: var(--muted); font-size: .68rem; }
.progress-box strong { display: block; margin-top: .08rem; color: #713326; font-size: 1.02rem; }
.owned-section { margin-top: auto; }
.volume-badges { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.volume-badge { display: inline-block; min-width: 2.25rem; padding: .21rem .38rem; border: 1px solid #e3d6cf; border-radius: .34rem; background: #fff; color: #4d3e38; font-size: .74rem; text-align: center; }
.volume-badge.missing { border-color: #f0bfac; background: #fff0ea; color: #9a3827; }
.muted-inline { color: var(--muted); font-size: .76rem; }
.privacy-note { display: flex; gap: .85rem; align-items: start; margin-bottom: 3rem; padding: 1rem; background: #fffdfb; box-shadow: none; }
.privacy-note > span { display: grid; width: 35px; height: 35px; flex: none; place-items: center; border-radius: 50%; background: #f3e6df; color: #783629; }
.privacy-note h2 { margin: 0; font-size: .9rem; }
.privacy-note p { margin: .16rem 0 0; color: var(--muted); font-size: .78rem; }
.site-footer { padding: 1.4rem 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .74rem; }
.site-footer > div { display: flex; flex-wrap: wrap; gap: .8rem 1.2rem; }
.site-footer a:hover { color: var(--accent); }

@media (max-width: 760px) {
  .page-width { width: min(100% - 24px, 1120px); }
  .local-chip { display: none; }
  .intro { grid-template-columns: 1fr; gap: 1.15rem; padding-top: 2.25rem; }
  .android-link { max-width: 380px; }
  .install-guidance { grid-template-columns: auto minmax(0, 1fr) auto; }
  .install-guidance-close { grid-column: 3; grid-row: 1; align-self: start; }
  .install-guidance-button { grid-column: 2 / -1; }
  .app-layout { grid-template-columns: 1fr; }
  .series-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .backup-panel { align-items: start; flex-direction: column; }
  .backup-actions { justify-content: start; }
}

@media (max-width: 440px) {
  .header-content { min-height: 60px; }
  .header-actions .button { padding-inline: .62rem; font-size: .76rem; }
  h1 { font-size: 2rem; }
  .intro-copy { font-size: .9rem; }
  .install-guidance { gap: .55rem; padding: .75rem; }
  .install-guidance p { font-size: .73rem; }
  .series-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: center; }
  .section-heading .button { padding-inline: .65rem; font-size: .75rem; }
  .backup-actions { width: 100%; }
  .backup-actions .button { flex: 1; }
}

@media (prefers-reduced-motion: no-preference) { .series-card, .button, .android-link { transition: border-color .16s ease, background-color .16s ease, transform .16s ease; } .series-card:hover { transform: translateY(-2px); } }
