/* ── Theme ────────────────────────────────────────────────────────── */
:root {
  --primary:    #10b981;
  --secondary:  #059669;
  --grad:       linear-gradient(135deg, #10b981, #059669);
  --bg:         #0f0f14;
  --bg-card:    #1e1e28;
  --bg-surface: #18181f;
  --text:       #e8e8f0;
  --text-muted: #a0a0b8;
  --text-faint: #636380;
  --border:        rgba(255,255,255,.07);
  --border-medium: rgba(255,255,255,.12);
  --radius:    14px;
  --radius-sm:  8px;
  --font: system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.7; }
a    { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; border: none; font-family: inherit; }

/* ── Header ───────────────────────────────────────────────────────── */
.site-header { background: rgba(15,15,20,.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.header-inner { max-width: 1140px; margin: 0 auto; padding: 0 20px; height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.logo { display: flex; align-items: center; gap: 9px; text-decoration: none; }
.logo-icon { width: 32px; height: 32px; flex-shrink: 0; }
.logo-text { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.main-nav { display: flex; align-items: center; gap: 4px; }
.nav-link { padding: 6px 12px; border-radius: var(--radius-sm); font-size: .88rem; font-weight: 500; color: var(--text-muted); transition: color .15s, background .15s; }
.nav-link:hover, .nav-link.active { color: var(--text); background: rgba(255,255,255,.06); }
@media (max-width: 540px) { .main-nav { display: none; } }

/* ── Layout ───────────────────────────────────────────────────────── */
.main-wrap { max-width: 760px; margin: 0 auto; padding: 28px 20px 80px; }
.ad-slot { background: var(--bg-surface); border: 1px dashed var(--border-medium); border-radius: var(--radius-sm); min-height: 90px; display: flex; align-items: center; justify-content: center; margin: 18px 0; color: var(--text-faint); font-size: .78rem; }

/* ── Hero ─────────────────────────────────────────────────────────── */
.tool-hero { text-align: center; padding: 20px 0 28px; }
.tool-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 13px; border-radius: 20px; background: rgba(16,185,129,.12); color: var(--primary); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 14px; }
.tool-title { font-size: clamp(1.8rem,4vw,2.6rem); font-weight: 800; line-height: 1.2; margin-bottom: 12px; }
.gradient-title { background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.tool-subtitle { font-size: 1rem; color: var(--text-muted); max-width: 580px; margin: 0 auto; }

/* ── Error banner ─────────────────────────────────────────────────── */
.error-banner { background: rgba(248,113,113,.08); border: 1px solid rgba(248,113,113,.25); border-radius: var(--radius-sm); padding: 12px 16px; font-size: .88rem; color: #f87171; margin-bottom: 16px; }

/* ── Cards ────────────────────────────────────────────────────────── */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; margin-bottom: 20px; }
.card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.card-icon { width: 42px; height: 42px; border-radius: 10px; background: rgba(16,185,129,.14); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.card-icon svg { width: 22px; height: 22px; color: var(--primary); }
.card-title { font-size: 1.15rem; font-weight: 700; }
.card-desc  { font-size: .87rem; color: var(--text-muted); }

/* ── Drop zone ────────────────────────────────────────────────────── */
.drop-zone { border: 2px dashed var(--border-medium); border-radius: var(--radius); padding: 52px 20px; text-align: center; cursor: pointer; transition: border-color .2s, background .2s; }
.drop-zone:hover, .drop-zone.dragover { border-color: var(--primary); background: rgba(16,185,129,.04); }
.drop-icon { font-size: 2.8rem; margin-bottom: 12px; }
.drop-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.drop-hint  { font-size: .87rem; color: var(--text-muted); margin-bottom: 20px; }
.btn-upload { display: inline-flex; align-items: center; gap: 8px; background: var(--grad); color: #fff; font-weight: 600; font-size: .9rem; padding: 10px 22px; border-radius: 8px; transition: opacity .15s; }
.btn-upload:hover { opacity: .88; }
.upload-note { font-size: .76rem; color: var(--text-faint); margin-top: 14px; }

/* ── File info bar ────────────────────────────────────────────────── */
.file-info-bar { display: flex; align-items: center; gap: 14px; padding: 14px 18px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 24px; }
.file-info-icon { width: 36px; height: 36px; background: rgba(16,185,129,.14); border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.file-info-icon svg { width: 20px; height: 20px; color: var(--primary); }
.file-info-text { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: .78rem; color: var(--text-muted); }
.btn-change { padding: 6px 12px; border-radius: 6px; background: rgba(255,255,255,.06); color: var(--text-muted); font-size: .8rem; font-weight: 500; transition: background .15s, color .15s; }
.btn-change:hover { background: rgba(255,255,255,.1); color: var(--text); }

/* ── Mode selector ────────────────────────────────────────────────── */
.mode-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 24px; }
.mode-tab { padding: 12px 8px; border-radius: var(--radius-sm); border: 2px solid var(--border); background: var(--bg-surface); text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.mode-tab.on { border-color: var(--primary); background: rgba(16,185,129,.07); }
.mode-tab-icon { font-size: 1.3rem; margin-bottom: 5px; }
.mode-tab-label { font-size: .83rem; font-weight: 600; }
.mode-tab-desc  { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }
.mode-tab.on .mode-tab-label { color: var(--primary); }

/* ── Config inputs ────────────────────────────────────────────────── */
.config-panel { padding: 18px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 20px; }
.config-label { font-size: .84rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }
.stepper { display: flex; align-items: center; gap: 0; width: fit-content; border: 1px solid var(--border-medium); border-radius: 8px; overflow: hidden; }
.stepper-btn { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.06); color: var(--text); font-size: 1.2rem; transition: background .15s; user-select: none; }
.stepper-btn:hover { background: rgba(16,185,129,.14); color: var(--primary); }
.stepper-btn:disabled { opacity: .4; cursor: default; }
.stepper-val { width: 64px; height: 38px; background: var(--bg-card); color: var(--text); font-size: 1rem; font-weight: 600; text-align: center; border: none; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
.stepper-val:focus { outline: none; border-color: var(--primary); }
.stepper-hint { font-size: .82rem; color: var(--text-faint); margin-top: 8px; }

.range-input { width: 100%; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border-medium); background: var(--bg-card); color: var(--text); font-size: .92rem; font-family: 'SF Mono', 'Cascadia Code', monospace; transition: border-color .15s; }
.range-input:focus { outline: none; border-color: var(--primary); }
.range-input::placeholder { color: var(--text-faint); }
.range-hint { font-size: .79rem; color: var(--text-faint); margin-top: 8px; }
.range-error { font-size: .79rem; color: #f87171; margin-top: 6px; }
.range-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.range-example { padding: 3px 9px; border-radius: 4px; background: rgba(255,255,255,.05); font-size: .75rem; font-family: monospace; color: var(--text-muted); cursor: pointer; transition: background .15s; }
.range-example:hover { background: rgba(16,185,129,.1); color: var(--primary); }

/* ── Parts preview ────────────────────────────────────────────────── */
.parts-preview { margin-bottom: 24px; }
.parts-preview-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.parts-preview-title { font-size: .84rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.parts-count-badge { padding: 2px 9px; border-radius: 20px; background: rgba(16,185,129,.12); color: var(--primary); font-size: .75rem; font-weight: 700; }
.parts-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; max-height: 260px; overflow-y: auto; }
.parts-list::-webkit-scrollbar { width: 5px; }
.parts-list::-webkit-scrollbar-track { background: transparent; }
.parts-list::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: 3px; }
.part-chip { padding: 8px 12px; border-radius: 7px; background: var(--bg-surface); border: 1px solid var(--border); }
.part-num  { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--primary); margin-bottom: 2px; }
.part-range { font-size: .83rem; font-weight: 500; }
.part-pages-count { font-size: .72rem; color: var(--text-muted); }
.parts-overflow { font-size: .82rem; color: var(--text-faint); margin-top: 8px; text-align: center; padding: 8px; background: var(--bg-surface); border-radius: 6px; }
.parts-empty { padding: 20px; text-align: center; font-size: .88rem; color: var(--text-faint); background: var(--bg-surface); border-radius: var(--radius-sm); }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn-primary { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 13px 20px; border-radius: 10px; background: var(--grad); color: #fff; font-size: 1rem; font-weight: 700; letter-spacing: .01em; transition: opacity .15s, transform .1s; }
.btn-primary:hover:not(:disabled) { opacity: .9; transform: translateY(-1px); }
.btn-primary:disabled { opacity: .45; cursor: default; transform: none; }
.btn-secondary { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; border-radius: 8px; background: rgba(255,255,255,.06); color: var(--text-muted); font-size: .9rem; font-weight: 600; transition: background .15s, color .15s; }
.btn-secondary:hover { background: rgba(255,255,255,.1); color: var(--text); }

/* ── Progress ─────────────────────────────────────────────────────── */
.progress-wrap { margin: 24px 0; }
.progress-msg  { font-size: .88rem; color: var(--text-muted); margin-bottom: 10px; text-align: center; min-height: 1.4em; }
.progress-bar  { height: 7px; border-radius: 4px; background: rgba(255,255,255,.06); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; background: var(--grad); transition: width .3s ease; }
.progress-pct  { font-size: .78rem; color: var(--text-faint); text-align: right; margin-top: 5px; }

/* ── Result ───────────────────────────────────────────────────────── */
.result-hero { text-align: center; padding: 10px 0 24px; }
.result-check { font-size: 3rem; margin-bottom: 8px; }
.result-title { font-size: 1.4rem; font-weight: 800; margin-bottom: 6px; }
.result-subtitle { font-size: .9rem; color: var(--text-muted); }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-box { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 12px; text-align: center; }
.stat-num   { font-size: 1.5rem; font-weight: 800; color: var(--primary); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: .74rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.btn-download { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 15px 20px; border-radius: 10px; background: var(--grad); color: #fff; font-size: 1.05rem; font-weight: 700; letter-spacing: .01em; margin-bottom: 12px; transition: opacity .15s, transform .1s; }
.btn-download:hover { opacity: .88; transform: translateY(-1px); }
.result-actions { display: flex; gap: 10px; margin-top: 8px; }
.result-actions .btn-secondary { flex: 1; }

/* ── Part list in done stage ──────────────────────────────────────── */
.parts-done-list { margin: 20px 0; max-height: 340px; overflow-y: auto; }
.parts-done-list::-webkit-scrollbar { width: 5px; }
.parts-done-list::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: 3px; }
.part-done-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 7px; background: var(--bg-surface); border: 1px solid var(--border); margin-bottom: 6px; }
.part-done-num  { width: 28px; height: 28px; border-radius: 50%; background: rgba(16,185,129,.14); display: flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700; color: var(--primary); flex-shrink: 0; }
.part-done-info { flex: 1; min-width: 0; }
.part-done-name  { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part-done-pages { font-size: .76rem; color: var(--text-muted); }
.btn-dl-part { width: 30px; height: 30px; border-radius: 6px; background: rgba(16,185,129,.1); display: flex; align-items: center; justify-content: center; color: var(--primary); transition: background .15s; flex-shrink: 0; }
.btn-dl-part:hover { background: rgba(16,185,129,.2); }
.btn-dl-part svg { width: 15px; height: 15px; }

/* ── FAQ ──────────────────────────────────────────────────────────── */
.faq-section { margin-top: 40px; }
.faq-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 16px; }
.faq-item { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; overflow: hidden; }
.faq-q { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; cursor: pointer; font-weight: 600; font-size: .93rem; user-select: none; }
.faq-q svg { width: 18px; height: 18px; color: var(--text-muted); transition: transform .2s; flex-shrink: 0; }
.faq-item.open .faq-q svg { transform: rotate(180deg); }
.faq-a { display: none; padding: 0 18px 16px; font-size: .88rem; color: var(--text-muted); line-height: 1.7; }
.faq-item.open .faq-a { display: block; }

/* ── Toast ────────────────────────────────────────────────────────── */
#toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(14px); background: #1e2d27; color: #4ade80; border: 1px solid rgba(74,222,128,.25); padding: 10px 22px; border-radius: 24px; font-size: .88rem; font-weight: 600; pointer-events: none; opacity: 0; transition: opacity .25s, transform .25s; z-index: 999; white-space: nowrap; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Features grid ────────────────────────────────────────────────── */
.features { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin: 28px 0; }
.feature-item { display: flex; align-items: flex-start; gap: 11px; padding: 14px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.feature-icon { width: 32px; height: 32px; border-radius: 7px; background: rgba(16,185,129,.12); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.feature-icon svg { width: 17px; height: 17px; color: var(--primary); }
.feature-text strong { font-size: .85rem; display: block; margin-bottom: 3px; }
.feature-text span   { font-size: .78rem; color: var(--text-muted); }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 540px) {
  .mode-tabs { grid-template-columns: 1fr; }
  .result-stats { grid-template-columns: repeat(2, 1fr); }
  .result-stats .stat-box:last-child { grid-column: span 2; }
  .parts-list { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
