:root {
  --ink: #edeDEC;
  --ink-soft: #b8b1a7;
  --ink-muted: #958d82;
  --void: #0e1312;
  --void-deep: #090d0c;
  --surface: #141a18;
  --surface-lift: #19211e;
  --line-soft: rgb(237 237 236 / 0.08);
  --line: #1e2623;
  --line-bright: rgb(237 237 236 / 0.18);
  --accent: #ffdb2a;
  --accent-ink: #17170f;
  --cyan: #8df0cc;
  --code-blue: #a9b1d6;
  --mono: "Geist Mono", "SFMono-Regular", Consolas, monospace;
  --sans: "Avenir Next", "TASA Orbiter", Inter, ui-sans-serif, system-ui, sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgb(237 237 236 / 0.018) 1px, transparent 1px),
    linear-gradient(180deg, rgb(237 237 236 / 0.014) 1px, transparent 1px),
    radial-gradient(circle at 80% -10%, rgb(141 240 204 / 0.08), transparent 28rem),
    var(--void);
  background-size: 80px 80px, 80px 80px, auto, auto;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
label {
  font: inherit;
}

button,
label[for] {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.shell {
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 24px;
  height: 76px;
  padding: 0 clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line-soft);
  background: rgb(14 19 18 / 0.82);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 3px;
  border: 1px solid var(--line-bright);
  border-radius: 4px;
  background: rgb(237 237 236 / 0.028);
}

.lang-option {
  min-width: 42px;
  min-height: 32px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: transform 160ms ease, color 160ms ease, background 160ms ease;
}

.lang-option:hover,
.lang-option:focus-visible {
  color: var(--ink);
}

.lang-option.is-active {
  background:
    repeating-linear-gradient(135deg, transparent 0 7px, rgb(14 19 18 / 0.16) 7px 9px),
    var(--accent);
  color: var(--accent-ink);
}

.lang-option:active {
  transform: scale(0.96);
}

#fileInput {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.ghost-btn,
.stripe-btn,
.drop-action,
.copy-btn {
  border: 1px solid var(--line-bright);
  border-radius: 4px;
  background: rgb(237 237 236 / 0.035);
  color: var(--ink);
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.ghost-btn:hover,
.ghost-btn:focus-visible,
.drop-action:hover,
.drop-action:focus-visible,
.copy-btn:hover,
.copy-btn:focus-visible {
  border-color: rgb(237 237 236 / 0.34);
  background: rgb(237 237 236 / 0.07);
}

.stripe-btn {
  position: relative;
  overflow: hidden;
  border-color: rgb(255 219 42 / 0.7);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 750;
}

.stripe-btn::before {
  content: "";
  position: absolute;
  inset: -1px;
  background: repeating-linear-gradient(135deg, transparent 0 7px, rgb(14 19 18 / 0.16) 7px 9px);
  opacity: 0.55;
}

.stripe-btn span,
.stripe-btn {
  isolation: isolate;
}

.ghost-btn:active,
.stripe-btn:active,
.drop-action:active,
.copy-btn:active,
.platform:active {
  transform: translateY(1px);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(190px, 240px);
  gap: clamp(28px, 4vw, 58px);
  max-width: 1540px;
  margin: 0 auto;
  padding: 40px clamp(18px, 4vw, 48px) 72px;
}

.workspace.is-outline-collapsed {
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) 72px;
}

.console-panel,
.toc-panel {
  position: sticky;
  top: 116px;
  align-self: start;
}

.platform-row {
  display: flex;
  gap: 10px;
  margin-bottom: 26px;
}

.platform {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.platform.is-active {
  color: var(--accent);
  border-color: var(--accent);
}

.dropzone,
.meta-card,
.settings-card,
.toc-inner {
  border-top: 1px solid var(--line);
  padding: 22px 0;
}

.dropzone {
  min-height: 236px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: border-color 160ms ease, background 160ms ease;
}

.dropzone.is-dragging {
  border-color: var(--cyan);
  background: rgb(141 240 204 / 0.04);
}

.panel-kicker,
.crumbs {
  margin: 0 0 16px;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.dropzone h2 {
  margin: 0 0 10px;
  font-size: 24px;
  line-height: 1.08;
}

.dropzone p,
.hero-card p,
.article-card p,
.article-card li,
.article-card td,
.article-card th {
  color: var(--ink-soft);
}

.dropzone p {
  margin: 0 0 18px;
  line-height: 1.55;
}

.drop-action {
  width: max-content;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin: 0;
}

.stats-grid div {
  display: grid;
  gap: 4px;
}

.stats-grid dt,
.range-row span {
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stats-grid dd {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.35;
}

.range-row {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

input[type="range"] {
  accent-color: var(--accent);
}

.document-stage {
  min-width: 0;
}

.hero-card {
  position: relative;
  min-height: 430px;
  padding: clamp(34px, 6vw, 70px) clamp(26px, 5vw, 62px);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgb(237 237 236 / 0.018), transparent 46%),
    repeating-linear-gradient(120deg, rgb(237 237 236 / 0.025) 0 1px, transparent 1px 7px),
    rgb(10 15 14 / 0.54);
}

.hero-card h1 {
  max-width: 860px;
  margin: 0;
  color: var(--ink);
  font-size: clamp(40px, 5.6vw, 66px);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-card p {
  max-width: 560px;
  margin: 28px 0 0;
  font-size: 17px;
  line-height: 1.55;
}

.copy-btn {
  position: absolute;
  right: 30px;
  bottom: 38px;
}

.article-card,
.source-pane {
  width: min(100%, calc(var(--reader-width, 72) * 1ch));
  margin: 34px auto 0;
}

.article-card {
  font-size: calc(var(--reader-size, 17) * 1px);
  line-height: 1.72;
}

.article-card > *:first-child {
  margin-top: 0;
}

.article-card h1,
.article-card h2,
.article-card h3,
.article-card h4 {
  color: var(--ink);
  line-height: 1.08;
  letter-spacing: 0;
}

.article-card h1 {
  font-size: 2.45em;
  margin: 1.2em 0 0.45em;
}

.article-card h2 {
  font-size: 1.75em;
  margin: 2em 0 0.5em;
  padding-top: 0.25em;
  border-top: 1px solid var(--line);
}

.article-card h3 {
  font-size: 1.18em;
  margin: 1.6em 0 0.4em;
}

.article-card p {
  margin: 0.85em 0;
}

.article-card a {
  color: var(--cyan);
  text-decoration: underline;
  text-decoration-color: rgb(141 240 204 / 0.34);
  text-underline-offset: 0.22em;
}

.article-card code {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.12em 0.34em;
  background: var(--surface);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.85em;
}

.article-card pre,
.source-pane {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #141a18;
  color: var(--code-blue);
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.65;
}

.article-card pre {
  padding: 18px;
}

.article-card pre code {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
}

.article-card blockquote {
  margin: 1.3em 0;
  padding: 0.1em 0 0.1em 1em;
  border-left: 2px solid var(--accent);
  color: var(--ink);
}

.article-card ul,
.article-card ol {
  padding-left: 1.35em;
}

.article-card li + li {
  margin-top: 0.35em;
}

.article-card table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4em 0;
  font-size: 0.94em;
}

.article-card th,
.article-card td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.article-card th {
  color: var(--ink);
  background: rgb(237 237 236 / 0.035);
}

.article-card img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.source-pane {
  min-height: 520px;
  padding: 22px;
  white-space: pre-wrap;
}

.is-hidden {
  display: none;
}

.toc-inner {
  max-height: calc(100dvh - 140px);
  overflow: auto;
}

.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.toc-header .panel-kicker {
  margin: 0;
}

.toc-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 40px;
  min-height: 40px;
  border: 1px solid var(--line-bright);
  border-radius: 4px;
  background: rgb(237 237 236 / 0.025);
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.toc-toggle:hover,
.toc-toggle:focus-visible {
  border-color: rgb(237 237 236 / 0.34);
  background: rgb(237 237 236 / 0.06);
  color: var(--ink);
}

.toc-toggle:active {
  transform: scale(0.96);
}

.toc-toggle-mark {
  display: inline-grid;
  place-items: center;
  width: 14px;
  color: var(--accent);
  font-size: 14px;
  line-height: 1;
}

.workspace.is-outline-collapsed .toc-inner {
  overflow: visible;
}

.workspace.is-outline-collapsed .toc-header {
  flex-direction: column;
  align-items: center;
  margin-bottom: 0;
}

.workspace.is-outline-collapsed .toc-header .panel-kicker {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  margin: 0 auto;
}

.workspace.is-outline-collapsed .toc-toggle {
  width: 40px;
  padding: 0;
}

.workspace.is-outline-collapsed .toc-toggle-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.workspace.is-outline-collapsed #tocList {
  display: none;
}

#tocList {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 9px;
}

#tocList a {
  display: block;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.35;
  transition: color 160ms ease, transform 160ms ease;
}

#tocList a:hover,
#tocList a:focus-visible {
  color: var(--ink);
  transform: translateX(3px);
}

#tocList .level-2 {
  padding-left: 14px;
}

#tocList .level-3,
#tocList .level-4,
#tocList .level-5,
#tocList .level-6 {
  padding-left: 28px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 48px));
  padding: 12px 14px;
  border: 1px solid var(--line-bright);
  border-radius: 4px;
  background: rgb(20 26 24 / 0.94);
  color: var(--ink);
  box-shadow: 0 18px 70px rgb(0 0 0 / 0.28);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.seo-summary {
  max-width: 820px;
  margin: 0 auto;
  padding: 28px clamp(18px, 4vw, 48px) 56px;
  color: var(--ink-muted);
}

.seo-summary h2 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.2;
}

.seo-summary p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.65;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace.is-outline-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  .console-panel,
  .toc-panel {
    position: static;
  }

  .console-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
  }

  .platform-row {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  .toc-inner {
    max-height: none;
  }

  .workspace.is-outline-collapsed .toc-header {
    flex-direction: row;
    align-items: center;
  }

  .workspace.is-outline-collapsed .toc-header .panel-kicker {
    writing-mode: horizontal-tb;
    margin: 0;
  }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 1fr;
    height: auto;
    gap: 16px;
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .top-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .lang-switch {
    order: -1;
  }

  .workspace {
    padding-top: 24px;
  }

  .console-panel {
    grid-template-columns: 1fr;
  }

  .hero-card {
    min-height: 360px;
    padding: 30px 22px 86px;
  }

  .hero-card h1 {
    font-size: clamp(38px, 13vw, 56px);
  }

  .copy-btn {
    left: 22px;
    right: auto;
    bottom: 28px;
  }

  .toc-panel {
    position: fixed;
    inset: auto 12px 14px;
    z-index: 8;
    pointer-events: none;
  }

  .toc-panel::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: rgb(9 13 12 / 0);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease, background 180ms ease;
  }

  .toc-inner {
    max-height: 48px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    box-shadow: none;
    pointer-events: none;
    transition: max-height 180ms ease, padding 180ms ease, border-color 180ms ease, background 180ms ease;
  }

  .toc-header {
    margin-bottom: 0;
  }

  .toc-header .panel-kicker {
    color: rgb(237 237 236 / 0.72);
  }

  .toc-toggle {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 9;
    min-width: 112px;
    min-height: 48px;
    padding: 0 14px;
    border-color: rgb(237 237 236 / 0.22);
    background: rgb(20 26 24 / 0.64);
    color: rgb(237 237 236 / 0.78);
    backdrop-filter: blur(16px);
    box-shadow: 0 14px 46px rgb(0 0 0 / 0.28);
    pointer-events: auto;
  }

  .toc-toggle:hover,
  .toc-toggle:focus-visible {
    background: rgb(20 26 24 / 0.82);
  }

  .toc-toggle-mark {
    color: var(--accent);
  }

  #tocList {
    max-height: calc(min(58dvh, 460px) - 74px);
    overflow: auto;
    padding-top: 14px;
  }

  #tocList a {
    min-height: 40px;
    display: flex;
    align-items: center;
    padding: 8px 2px;
    color: rgb(237 237 236 / 0.72);
  }

  .workspace.is-mobile-outline-open .toc-panel {
    pointer-events: auto;
  }

  .workspace.is-mobile-outline-open .toc-panel::before {
    background: rgb(9 13 12 / 0.22);
    opacity: 1;
  }

  .workspace.is-mobile-outline-open .toc-inner {
    max-height: min(58dvh, 460px);
    padding: 14px;
    border-color: rgb(237 237 236 / 0.16);
    background:
      linear-gradient(135deg, rgb(237 237 236 / 0.055), transparent 48%),
      rgb(14 19 18 / 0.82);
    backdrop-filter: blur(18px);
    box-shadow: 0 18px 70px rgb(0 0 0 / 0.34);
    pointer-events: auto;
  }

  .workspace.is-mobile-outline-open .toc-header {
    margin-bottom: 0;
  }

  .workspace.is-mobile-outline-open .toc-toggle {
    bottom: calc(min(58dvh, 460px) + 28px);
    background: rgb(20 26 24 / 0.78);
  }

  .workspace.is-outline-collapsed .toc-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .workspace.is-outline-collapsed .toc-header .panel-kicker {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .workspace.is-mobile-outline-open .toc-header .panel-kicker {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
    writing-mode: horizontal-tb;
    margin: 0;
  }

  .workspace.is-outline-collapsed .toc-toggle {
    width: auto;
  }

  .workspace.is-outline-collapsed .toc-toggle-text {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
  }
}
