:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8f8fd;
  --surface-tint: #f1efff;
  --text: #17182b;
  --muted: #696b80;
  --line: #e5e7f0;
  --brand: #5b4ae6;
  --brand-deep: #4636c8;
  --brand-soft: #ebe8ff;
  --accent: #f6c94c;
  --accent-soft: #fff3bb;
  --success: #27a46d;
  --danger: #c54155;
  --shadow-lg: 0 28px 70px rgba(28, 30, 72, .12);
  --shadow-md: 0 14px 38px rgba(28, 30, 72, .09);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 4% 0%, rgba(91, 74, 230, .10), transparent 28rem),
    radial-gradient(circle at 95% 12%, rgba(246, 201, 76, .13), transparent 25rem),
    var(--bg);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled, select:disabled, input:disabled { cursor: not-allowed; opacity: .48; }
svg { display: block; }

.app-shell { width: min(1440px, calc(100% - 36px)); margin: 0 auto; }
.topbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand { display: inline-flex; align-items: center; gap: 13px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 50px; height: 50px; border-radius: 16px;
  display: grid; place-items: center;
  color: white; background: linear-gradient(145deg, var(--brand), #7866ff);
  box-shadow: 0 14px 28px rgba(91, 74, 230, .24);
}
.brand-mark svg { width: 31px; height: 31px; }
.brand strong { display: block; font-size: 20px; letter-spacing: -.02em; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.privacy-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255,255,255,.76); color: var(--muted); font-size: 13px; font-weight: 650;
  backdrop-filter: blur(12px);
}
.privacy-pill svg { width: 17px; height: 17px; color: var(--success); }

.hero-card {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(330px, .85fr);
  gap: clamp(34px, 6vw, 90px); align-items: center;
  min-height: 390px; padding: clamp(30px, 5vw, 68px);
  border: 1px solid rgba(91, 74, 230, .13); border-radius: var(--radius-xl);
  background:
    linear-gradient(120deg, rgba(255,255,255,.98), rgba(247,246,255,.96)),
    var(--surface);
  box-shadow: var(--shadow-lg); overflow: hidden; position: relative;
}
.hero-card::before {
  content: ""; position: absolute; width: 380px; height: 380px; border-radius: 50%;
  right: -170px; top: -210px; border: 70px solid rgba(91,74,230,.05);
}
.hero-copy, .drop-zone { position: relative; z-index: 1; }
.eyebrow, .section-kicker {
  display: block; color: var(--brand); font-size: 11px; line-height: 1;
  font-weight: 850; letter-spacing: .16em;
}
.hero-copy h1 {
  margin: 16px 0 16px; max-width: 780px;
  font-size: clamp(34px, 4.6vw, 62px); line-height: 1.05; letter-spacing: -.055em;
}
.hero-copy > p { max-width: 720px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.75; }
.hero-features { display: flex; flex-wrap: wrap; gap: 12px 22px; margin-top: 28px; }
.hero-features span { display: inline-flex; align-items: center; gap: 8px; color: #45475b; font-size: 13px; font-weight: 700; }
.hero-features i { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(39,164,109,.11); }

.drop-zone {
  min-height: 286px; padding: 30px 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  border: 2px dashed #c7c2f2; border-radius: 24px;
  color: var(--brand); background: rgba(255,255,255,.74);
  transition: transform .2s ease, border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.drop-zone:hover, .drop-zone.dragover { transform: translateY(-3px); border-color: var(--brand); background: #fff; box-shadow: 0 18px 42px rgba(91,74,230,.14); }
.drop-zone input { display: none; }
.upload-illustration { width: 72px; height: 72px; margin-bottom: 12px; }
.upload-illustration svg { width: 100%; height: 100%; }
.drop-zone strong { color: var(--text); font-size: 19px; }
.drop-zone > span:not(.upload-illustration):not(.upload-button) { margin-top: 6px; color: var(--muted); font-size: 14px; }
.upload-button {
  margin-top: 18px; padding: 11px 19px; border-radius: 12px;
  color: white; background: var(--brand); font-weight: 800; font-size: 14px;
  box-shadow: 0 11px 22px rgba(91, 74, 230, .22);
}
.drop-zone small { margin-top: 14px; color: #88899a; font-size: 11px; }

.workspace { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 22px; }
.card { background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.control-panel { position: sticky; top: 16px; padding: 22px; }
.panel-heading, .reader-header, .document-info, .label-row, .page-picker, .status-card, .progress-meta { display: flex; align-items: center; }
.panel-heading { justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.panel-heading h2 { margin: 6px 0 0; font-size: 20px; letter-spacing: -.025em; }
.icon-button, .page-button {
  border: 1px solid var(--line); background: var(--surface-soft); color: var(--text);
  display: grid; place-items: center; transition: .18s ease;
}
.icon-button { width: 40px; height: 40px; border-radius: 12px; }
.icon-button svg, .page-button svg { width: 20px; height: 20px; }
.icon-button:hover:not(:disabled), .page-button:hover:not(:disabled) { color: var(--brand); border-color: #c9c3f7; background: var(--brand-soft); }

.selected-start {
  min-height: 64px; display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px; padding: 11px 13px; border-radius: 14px;
  border: 1px solid #dcd8fc; background: var(--surface-tint);
}
.selected-start-icon { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 11px; color: white; background: var(--brand); font-weight: 900; }
.selected-start small, .status-card small { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.selected-start strong { display: block; max-width: 210px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }

.primary-action, .secondary-action {
  min-height: 46px; border-radius: 13px; border: 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800;
}
.primary-action { width: 100%; padding: 0 15px; color: white; background: linear-gradient(135deg, var(--brand), #7463f9); box-shadow: 0 13px 25px rgba(91,74,230,.23); }
.primary-action:hover:not(:disabled) { background: linear-gradient(135deg, var(--brand-deep), #6755ed); transform: translateY(-1px); }
.primary-action svg, .secondary-action svg { width: 20px; height: 20px; }
.transport-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 9px; }
.secondary-action { padding: 0 12px; color: #434559; background: var(--surface-soft); border: 1px solid var(--line); }
.secondary-action:hover:not(:disabled) { background: #f0eff8; }

.field-group { margin-top: 20px; }
.field-group > label, .label-row label { color: #343649; font-size: 12px; font-weight: 800; }
.label-row { justify-content: space-between; gap: 12px; }
.label-row output { color: var(--brand); font-size: 12px; font-weight: 850; }
select, input[type="number"] {
  width: 100%; min-height: 43px; border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); background: #fff; padding: 9px 11px; outline: none;
}
select { margin-top: 8px; }
select:focus, input[type="number"]:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(91,74,230,.1); }
input[type="range"] { width: 100%; margin: 12px 0 0; accent-color: var(--brand); }
.range-labels { display: flex; justify-content: space-between; margin-top: 2px; color: #999aad; font-size: 10px; }
.page-picker { gap: 8px; margin-top: 8px; }
.page-button { width: 43px; height: 43px; flex: 0 0 43px; border-radius: 12px; }
.page-input-wrap { min-width: 0; flex: 1; display: flex; align-items: center; gap: 7px; }
.page-input-wrap input { min-width: 0; text-align: center; }
.page-input-wrap span { white-space: nowrap; color: var(--muted); font-size: 12px; }

.status-card { gap: 11px; margin-top: 21px; padding: 12px 13px; border: 1px solid #dfeae5; border-radius: 14px; background: #f6fbf8; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; background: var(--success); box-shadow: 0 0 0 5px rgba(39,164,109,.11); }
.status-card strong { display: block; margin-top: 3px; color: #35433c; font-size: 12px; line-height: 1.45; }
.status-card.error { border-color: #f0d5d9; background: #fff7f8; }
.status-card.error .status-dot { background: var(--danger); box-shadow: 0 0 0 5px rgba(197,65,85,.1); }
.compatibility-note { margin: 16px 2px 0; color: #9293a5; font-size: 10.5px; line-height: 1.55; }

.reader-card { min-width: 0; overflow: hidden; }
.reader-header { min-height: 78px; justify-content: space-between; gap: 16px; padding: 15px 21px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #fff, #fbfbfe); }
.document-info { min-width: 0; gap: 12px; }
.document-icon { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; border-radius: 12px; color: var(--brand); background: var(--brand-soft); }
.document-icon svg { width: 23px; height: 23px; }
.document-info > div { min-width: 0; }
.document-info strong { display: block; max-width: 690px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.document-info small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.page-badge { flex: 0 0 auto; padding: 8px 11px; border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-size: 11px; font-weight: 750; }
.reader-guide { min-height: 46px; display: flex; align-items: center; gap: 9px; padding: 10px 21px; border-bottom: 1px solid #ebe9ff; background: #f7f6ff; color: #5c5d72; font-size: 11px; line-height: 1.45; }
.reader-guide svg { width: 19px; height: 19px; flex: 0 0 19px; color: var(--brand); }
.reader {
  min-height: 590px; max-height: calc(100vh - 185px); overflow: auto;
  padding: clamp(28px, 5vw, 62px); outline: none;
  direction: ltr; text-align: left; color: #25263a; background: #fff;
  font-family: Georgia, "Times New Roman", serif; font-size: 22px; line-height: 1.95;
  scrollbar-color: #cbc8e8 transparent; scrollbar-width: thin;
}
.reader::-webkit-scrollbar { width: 10px; }
.reader::-webkit-scrollbar-thumb { background: #cbc8e8; border-radius: 999px; border: 3px solid white; }
.empty-state { min-height: 440px; display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted); font-family: Inter, ui-sans-serif, sans-serif; }
.empty-icon { width: 78px; height: 78px; display: block; margin: 0 auto 13px; color: var(--brand); }
.empty-icon svg { width: 100%; height: 100%; }
.empty-state h3 { margin: 0; color: var(--text); font-size: 19px; }
.empty-state p { max-width: 430px; margin: 8px 0 0; font-size: 13px; line-height: 1.6; }
.word {
  display: inline; position: relative; padding: 2px 3px; margin: 0 1px; border-radius: 6px;
  cursor: pointer; transition: color .08s linear, background .08s linear, box-shadow .08s linear;
}
.word:hover { background: #f0efff; }
.word.selected { background: rgba(91,74,230,.08); box-shadow: inset 0 0 0 2px var(--brand); }
.word.selected::after {
  content: "START"; position: absolute; left: 50%; bottom: calc(100% + 7px); transform: translateX(-50%);
  padding: 3px 5px; border-radius: 5px; color: white; background: var(--brand);
  font-family: Inter, ui-sans-serif, sans-serif; font-size: 7px; line-height: 1; font-weight: 900; letter-spacing: .08em;
  pointer-events: none;
}
.word.spoken { color: #2d2508; background: var(--accent-soft); box-shadow: 0 0 0 2px rgba(246,201,76,.54), 0 4px 10px rgba(95,76,17,.12); }
.word.spoken.selected::after { display: none; }
.reader-footer { padding: 14px 21px 18px; border-top: 1px solid var(--line); background: #fff; }
.progress-meta { justify-content: space-between; gap: 12px; color: var(--muted); font-size: 10px; font-weight: 700; }
.progress-track { height: 7px; margin-top: 9px; border-radius: 999px; overflow: hidden; background: #ececf3; }
.progress-bar { width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), #8171ff); transition: width .18s ease; }

.site-footer { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; color: #9495a6; font-size: 11px; }
.site-footer span:first-child { color: #65677a; font-weight: 800; }

.loading-overlay { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; padding: 20px; background: rgba(20,21,42,.46); backdrop-filter: blur(7px); }
.loading-overlay.show { display: grid; }
.loading-card { width: min(400px, 100%); padding: 30px; border-radius: 22px; text-align: center; background: white; box-shadow: var(--shadow-lg); }
.loader { width: 52px; height: 52px; display: block; margin: 0 auto 16px; border-radius: 50%; border: 5px solid #eceaff; border-top-color: var(--brand); animation: spin .8s linear infinite; }
.loading-card h3 { margin: 0; font-size: 19px; }
.loading-card p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; z-index: 70; right: 20px; bottom: 20px; max-width: min(410px, calc(100% - 40px)); padding: 13px 16px; border-radius: 13px; color: white; background: #26273b; box-shadow: var(--shadow-md); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; font-size: 13px; font-weight: 650; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

@media (max-width: 1040px) {
  .hero-card { grid-template-columns: 1fr; }
  .hero-copy { text-align: center; }
  .hero-copy > p { margin-left: auto; margin-right: auto; }
  .hero-features { justify-content: center; }
  .drop-zone { max-width: 650px; width: 100%; margin: 0 auto; }
  .workspace { grid-template-columns: 290px minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .workspace { grid-template-columns: 1fr; }
  .control-panel { position: static; }
  .reader { max-height: none; min-height: 520px; }
  .app-shell { width: min(100% - 22px, 1440px); }
}
@media (max-width: 620px) {
  .topbar { min-height: 78px; }
  .privacy-pill { display: none; }
  .brand-mark { width: 44px; height: 44px; border-radius: 14px; }
  .brand strong { font-size: 18px; }
  .brand small { display: none; }
  .hero-card { min-height: 0; padding: 27px 20px; border-radius: 22px; }
  .hero-copy h1 { font-size: 36px; }
  .hero-copy > p { font-size: 15px; }
  .hero-features { display: grid; justify-content: start; text-align: left; }
  .drop-zone { min-height: 240px; padding: 24px 15px; }
  .reader-header { align-items: flex-start; }
  .page-badge { display: none; }
  .reader-guide { align-items: flex-start; }
  .reader { padding: 32px 20px; font-size: 20px; }
  .site-footer { justify-content: center; }
  .site-footer span:last-child { display: none; }
}
