/* ── Reset & Variables ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d1117;
  --bg-2:      #161b27;
  --bg-3:      #1e2535;
  --border:    #2a3347;
  --border-2:  #374461;
  --text:      #e2e8f0;
  --text-2:    #8b9ab0;
  --text-3:    #5a6782;
  --primary:   #4f7ef8;
  --primary-h: #3d67e0;
  --gold:      #f5a623;
  --success:   #22c55e;
  --danger:    #ef4444;
  --radius:    12px;
  --radius-sm: 7px;
}

[v-cloak] { display: none; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 58px;
  background: rgba(13,17,23,.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}
.logo img { display: block; }

/* ── Step nav ──────────────────────────────────────────────────────────────── */
.steps-nav { display: flex; gap: .25rem; }
.step-item {
  display: flex; align-items: center; gap: .45rem;
  padding: .3rem .7rem;
  border-radius: 6px;
  color: var(--text-3);
  font-size: .8rem;
  cursor: default;
  transition: all .15s;
}
.step-item.done  { color: var(--text-2); cursor: pointer; }
.step-item.done:hover { background: var(--bg-3); }
.step-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.step-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem;
  flex-shrink: 0;
}
.step-dot svg { stroke: currentColor; stroke-width: 2; fill: none; }

/* ── Hero ──────────────────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(160deg, #0d1117 0%, #111827 50%, #0d1117 100%);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4rem;
}

.hero-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 5rem 2rem 3rem;
  text-align: center;
}

.hero-badge {
  display: inline-block;
  background: rgba(79,126,248,.12);
  border: 1px solid rgba(79,126,248,.3);
  color: #90abff;
  padding: .3rem .85rem;
  border-radius: 99px;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.15;
  margin-bottom: 1.25rem;
  color: #f0f4ff;
}
.hero-title em {
  font-style: normal;
  background: linear-gradient(90deg, #4f7ef8, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-lead {
  font-size: 1.1rem;
  color: var(--text-2);
  max-width: 560px;
  margin: 0 auto 2.5rem;
  line-height: 1.7;
}

/* ── Stats bar ─────────────────────────────────────────────────────────────── */
.hero-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 2rem;
  margin: 0 auto 2.5rem;
  max-width: 600px;
}
.stat { text-align: center; flex: 1; }
.stat-num {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: -.02em;
}
.stat-label { font-size: .78rem; color: var(--text-3); margin-top: .15rem; }
.stat-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
  margin: 0 1.5rem;
  flex-shrink: 0;
}

/* ── Hero CTA button ───────────────────────────────────────────────────────── */
.btn-hero {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .9rem 2.2rem;
  background: linear-gradient(135deg, #4f7ef8, #6d5ce7);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  box-shadow: 0 4px 20px rgba(79,126,248,.35);
  text-decoration: none;
}
.btn-hero:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(79,126,248,.45);
}
.btn-hero:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ── How it works ──────────────────────────────────────────────────────────── */
.how-it-works {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 2rem;
}
.how-title {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: var(--text-2);
}
.how-steps {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}
.how-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: .75rem;
  padding: 1.25rem 1rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.how-icon { font-size: 1.8rem; }
.how-info strong { display: block; font-size: .9rem; margin-bottom: .3rem; }
.how-info p { font-size: .8rem; color: var(--text-3); line-height: 1.5; }
.how-arrow {
  color: var(--text-3);
  font-size: 1.2rem;
  padding-top: 2.5rem;
  flex-shrink: 0;
}
@media (max-width: 700px) {
  .how-steps { flex-direction: column; }
  .how-arrow { transform: rotate(90deg); padding-top: 0; align-self: center; }
}

/* ── Upload section ────────────────────────────────────────────────────────── */
.upload-section {
  max-width: 640px;
  margin: 3rem auto 5rem;
  padding: 0 1.5rem;
}

.upload-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.25rem;
  box-shadow: 0 8px 40px rgba(0,0,0,.3);
}

.upload-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: .4rem;
}
.upload-sub {
  color: var(--text-2);
  font-size: .9rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

/* ── Drop zone ─────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  margin-bottom: 1.25rem;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(79,126,248,.06);
}
.drop-zone.has-file {
  border-style: solid;
  border-color: var(--success);
  background: rgba(34,197,94,.05);
  padding: 1rem 1.5rem;
}
.drop-icon { font-size: 2rem; margin-bottom: .6rem; }
.drop-primary { font-weight: 600; margin-bottom: .3rem; }
.drop-hint { color: var(--text-3); font-size: .8rem; }

.file-info { display: flex; align-items: center; gap: .85rem; text-align: left; }
.file-icon  { font-size: 1.8rem; }
.file-name  { font-weight: 600; }
.file-size  { color: var(--text-3); font-size: .8rem; }

/* ── Form ──────────────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .85rem;
  margin-bottom: 1.25rem;
}
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.full-width  { grid-column: 1/-1; }
@media (max-width: 500px) { .form-grid { grid-template-columns: 1fr; } }
.form-group label { color: var(--text-2); font-size: .8rem; font-weight: 500; }
.hint  { font-weight: 400; color: var(--text-3); }
.link  { color: var(--primary); text-decoration: none; }
.link:hover { text-decoration: underline; }

.input, .select {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: .55rem .75rem;
  font-size: .9rem;
  transition: border .15s;
  width: 100%;
}
.input:focus, .select:focus { outline: none; border-color: var(--primary); }

/* ── Cost estimate ─────────────────────────────────────────────────────────── */
.cost-estimate {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  background: rgba(79,126,248,.06);
  border: 1px solid rgba(79,126,248,.2);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  margin-bottom: 1.25rem;
}
.cost-item { display: flex; align-items: center; gap: .6rem; font-size: .875rem; color: var(--text-2); }
.cost-icon { font-size: 1rem; }

.server-key-notice {
  grid-column: 1/-1;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem .9rem;
  background: rgba(34,197,94,.08);
  border: 1px solid rgba(34,197,94,.25);
  border-radius: var(--radius-sm);
  color: #86efac;
  font-size: .85rem;
}
.key-icon { font-size: 1rem; }

.upload-footnote {
  text-align: center;
  color: var(--text-3);
  font-size: .75rem;
  margin-top: .85rem;
}

/* ── Alert ─────────────────────────────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .875rem; }
.alert-error {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  color: #fca5a5;
}

/* ── Main + Panels ─────────────────────────────────────────────────────────── */
.main { max-width: 900px; margin: 0 auto; padding: 2.5rem 1.5rem 5rem; }
.panel { animation: fadeIn .2s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  margin-bottom: 1.75rem;
}
.panel-header-actions { display: flex; gap: .5rem; }
.panel-title { font-size: 1.5rem; font-weight: 700; margin-bottom: .3rem; }
.panel-sub   { color: var(--text-2); font-size: .9rem; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 500;
  cursor: pointer; border: none;
  transition: all .15s; text-decoration: none;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-h); }

.btn-secondary {
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--border-2); }

.btn-ghost {
  background: none; color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--border-2); }

.btn-danger   { background: var(--danger); color: #fff; }
.btn-sm       { padding: .35rem .85rem; font-size: .8rem; }

.btn-icon {
  background: none; border: none; color: var(--text-2);
  cursor: pointer; padding: .25rem .5rem;
  border-radius: var(--radius-sm); font-size: 1rem;
  margin-left: auto;
}
.btn-icon:hover   { color: var(--text); background: var(--bg-3); }
.btn-icon:disabled { opacity: .3; cursor: default; }

/* ── Spinner ───────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite; flex-shrink: 0;
}
.spinner.large { width: 40px; height: 40px; border-width: 3px; border-color: rgba(79,126,248,.2); border-top-color: var(--primary); }
.spinner.small { width: 12px; height: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Loading state ─────────────────────────────────────────────────────────── */
.loading-state { text-align: center; padding: 4rem 2rem; color: var(--text-2); }
.loading-state p { margin-top: 1rem; }

/* ── Glossary ──────────────────────────────────────────────────────────────── */
.glossary-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem;
}
.card-title { font-size: .8rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; margin-bottom: .85rem; }
.narrative-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: .5rem; }
@media (max-width: 600px) { .narrative-grid { grid-template-columns: 1fr 1fr; } }
.narrative-item { display: flex; flex-direction: column; gap: .15rem; }
.label { color: var(--text-3); font-size: .75rem; }
.style-notes { color: var(--text-2); font-size: .85rem; margin-top: .5rem; border-top: 1px solid var(--border); padding-top: .5rem; }

.glossary-section { margin-bottom: 1.75rem; }
.section-title    { font-size: .95rem; font-weight: 600; margin-bottom: .65rem; }

.glossary-table { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table-header {
  display: grid; grid-template-columns: 1.4fr 1.4fr .7fr 1.5fr;
  padding: .55rem 1rem;
  background: var(--bg-3); font-size: .72rem; font-weight: 600;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
.table-row {
  display: grid; grid-template-columns: 1.4fr 1.4fr .7fr 1.5fr;
  align-items: center; padding: .4rem 1rem;
  border-bottom: 1px solid var(--border); transition: background .1s;
}
.table-row:last-child { border-bottom: none; }
.table-row:hover      { background: var(--bg-3); }
.original   { font-weight: 500; }
.cell-input {
  background: transparent; border: 1px solid transparent;
  border-radius: 4px; color: var(--text); padding: .22rem .4rem;
  font-size: .875rem; width: 100%; transition: border .15s;
}
.cell-input:focus { outline: none; border-color: var(--primary); background: var(--bg); }
.badge {
  display: inline-block; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 4px; padding: .12rem .45rem; font-size: .72rem; color: var(--text-2);
}

.glossary-actions {
  display: flex; gap: 1rem; justify-content: flex-end;
  padding-top: 1rem; border-top: 1px solid var(--border);
}

/* ── Preview step ──────────────────────────────────────────────────────────── */
.preview-generating {
  text-align: center;
  padding: 3rem 2rem;
}
.preview-gen-msg { font-size: 1.05rem; font-weight: 500; margin-top: 1rem; }
.preview-gen-sub { color: var(--text-3); font-size: .85rem; margin-top: .4rem; }

.preview-verdict {
  background: rgba(79,126,248,.08);
  border: 1px solid rgba(79,126,248,.2);
  border-radius: var(--radius-sm);
  padding: .85rem 1.1rem;
  color: var(--text-2);
  font-size: .9rem;
  margin-bottom: 1.25rem;
}

.preview-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 680px) { .preview-columns { grid-template-columns: 1fr; } }

.preview-col { display: flex; flex-direction: column; gap: .5rem; }
.preview-col-label {
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-3);
}
.preview-text {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
  font-size: .9rem; line-height: 1.8;
  color: var(--text-2); white-space: pre-wrap;
  max-height: 480px; overflow-y: auto;
}
.translated-text { color: var(--text); }

.preview-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 1.25rem;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.preview-actions-left  { display: flex; gap: .75rem; }
.preview-actions-right { display: flex; align-items: center; gap: 1.25rem; }
.preview-nogo { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.nogo-label   { font-size: .75rem; color: var(--text-3); }

/* ── Progress ──────────────────────────────────────────────────────────────── */
.progress-bar-wrap {
  height: 5px; background: var(--bg-3);
  border-radius: 99px; overflow: hidden; margin: 1.25rem 0 .65rem;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #818cf8);
  border-radius: 99px; transition: width .5s ease;
}

.progress-stats {
  display: flex; gap: 1.5rem; color: var(--text-2);
  font-size: .85rem; margin-bottom: 1.5rem; align-items: center;
}
.done-badge    { color: var(--success); font-weight: 600; }
.working-badge { color: var(--primary); }

/* ── Chapter list ──────────────────────────────────────────────────────────── */
.chapter-list { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1.25rem; }
.chapter-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .85rem;
  border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--border);
  transition: all .2s;
}
.chapter-item.done   { border-color: rgba(34,197,94,.2); }
.chapter-item.active { border-color: var(--primary); background: rgba(79,126,248,.07); }
.chapter-item.error  { border-color: rgba(239,68,68,.3); }
.ch-status-icon { width: 18px; text-align: center; flex-shrink: 0; color: var(--success); font-size: .85rem; }
.chapter-item.error .ch-status-icon { color: var(--danger); }
.dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--border-2); }
.ch-info  { display: flex; align-items: center; gap: 1rem; flex: 1; }
.ch-title { font-size: .875rem; }
.ch-words { color: var(--text-3); font-size: .78rem; margin-left: auto; }

/* ── Event log ─────────────────────────────────────────────────────────────── */
.event-log {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .65rem;
  max-height: 140px; overflow-y: auto;
  font-family: "SF Mono", "Fira Mono", monospace; font-size: .75rem;
}
.log-line { display: flex; gap: .75rem; padding: .08rem 0; }
.log-time { color: var(--text-3); flex-shrink: 0; }
.log-msg  { color: var(--text-2); }

/* ── Download ──────────────────────────────────────────────────────────────── */
.download-hero { text-align: center; padding: 2rem 0 1.5rem; }
.download-hero-icon { font-size: 3rem; margin-bottom: .75rem; }
.download-cards { display: flex; flex-direction: column; gap: .75rem; margin: 1.5rem 0; }
.download-card {
  display: flex; align-items: center; gap: 1rem; padding: 1.25rem 1.5rem;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; transition: all .2s;
}
.download-card:hover { border-color: var(--primary); background: rgba(79,126,248,.07); }
.dl-icon  { font-size: 1.75rem; }
.dl-info  { flex: 1; }
.dl-title { font-weight: 600; margin-bottom: .2rem; }
.dl-hint  { color: var(--text-3); font-size: .8rem; }
.dl-arrow { font-size: 1.4rem; color: var(--primary); }

/* ── Chapter preview (download step) ──────────────────────────────────────── */
.chapter-preview {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; margin: 1.25rem 0;
}
.preview-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: .85rem;
}
.preview-header h3 { font-size: .95rem; font-weight: 600; }
.preview-nav { display: flex; align-items: center; gap: .65rem; color: var(--text-2); font-size: .85rem; }

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
