@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/inter-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/inter-latin-700-normal.woff2") format("woff2");
}

:root {
  /* Brand — sampled from the HUIYE logo */
  --brand: #114b9f;
  --brand-600: #0d3f88;
  --brand-700: #0a316b;
  --brand-900: #071f44;
  --brand-50: #eef4fc;
  --brand-100: #dbe7f8;
  --brand-200: #b9cff0;
  --sky: #4f8be0;

  --ink: #0f1b2d;
  --ink-2: #3d4a5c;
  --ink-3: #6b7789;
  --line: #e3e8f0;
  --line-2: #d1d9e5;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --danger: #c2372b;
  --danger-bg: #fdf0ee;
  --success: #12805c;
  --warn: #b26a00;

  /* Fluid rhythm: spacing and control sizes follow the viewport height so the
     desktop workspace fits one screen without fixed pixel heights. */
  --bar: clamp(52px, 8vh, 68px);
  --sp: clamp(10px, 2.4vh, 22px);
  --ctl: clamp(30px, 4.6vh, 36px);
  --field: clamp(38px, 5.8vh, 46px);
  --cta: clamp(42px, 6.6vh, 52px);
  --head: clamp(48px, 7.4vh, 60px);

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, .05);
  --shadow: 0 1px 2px rgba(15, 27, 45, .04), 0 8px 24px -8px rgba(17, 75, 159, .12);
  --shadow-lg: 0 24px 60px -20px rgba(7, 31, 68, .35);

  --sans: Inter, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(1200px 420px at 85% -120px, rgba(79, 139, 224, .14), transparent 70%),
    radial-gradient(900px 380px at -10% -80px, rgba(17, 75, 159, .10), transparent 70%),
    var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }

.sprite { position: absolute; }
.icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 16px; top: -60px; z-index: 100;
  padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--brand); color: #fff; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(209, 217, 229, .7);
}
.topbar-inner {
  max-width: 1360px; margin: 0 auto; height: var(--bar); padding: 0 32px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 16px; text-decoration: none; color: inherit; min-width: 0; }
.brand-logo { height: 32px; width: auto; }
.brand-divider { width: 1px; height: 22px; background: var(--line-2); }
.brand-product { font-size: 14px; font-weight: 600; color: var(--ink-2); letter-spacing: .02em; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.service-status {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px; border-radius: 999px;
  font-size: 13px; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line);
}
.service-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.service-status[data-state="ok"] i { background: var(--success); box-shadow: 0 0 0 3px rgba(18, 128, 92, .15); }
.service-status[data-state="off"] { color: var(--warn); }
.service-status[data-state="off"] i { background: var(--warn); box-shadow: 0 0 0 3px rgba(178, 106, 0, .15); }
.service-status[data-state="error"] { color: var(--danger); }
.service-status[data-state="error"] i { background: var(--danger); }

.ghost-button {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent;
  font-size: 14px; font-weight: 500; color: var(--ink-2);
  transition: background .15s, color .15s;
}
.ghost-button:hover:not(:disabled) { background: var(--brand-50); color: var(--brand); }
.ghost-button:disabled { opacity: .45; }
.ghost-button.small { height: 32px; padding: 0 10px; font-size: 13px; }
.ghost-button.small .icon { width: 16px; height: 16px; }

/* ---------- Page ---------- */
.page {
  flex: 1; width: 100%; max-width: 1360px; margin: 0 auto;
  padding: clamp(14px, 3vh, 36px) 32px 24px; outline: none;
}
.intro { max-width: 760px; margin-bottom: clamp(14px, 2.6vh, 28px); }
.intro h1 {
  font-size: clamp(24px, min(3vw, 4vh), 36px);
  line-height: 1.2; font-weight: 600; letter-spacing: -.01em;
  color: var(--brand-900);
}
.lede { margin-top: 6px; font-size: 15px; color: var(--ink-2); }

.workspace {
  display: grid;
  grid-template-columns: clamp(416px, 40vw, 500px) minmax(0, 1fr);
  gap: 24px; align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: var(--head); padding: 8px 16px 8px 24px;
  border-bottom: 1px solid var(--line);
}
.card-head h2 {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 600;
}

/* ---------- Form ---------- */
.form-card { border-color: var(--line-2); }
#newsletter-form { padding: 4px 24px 20px; }
.group { margin: 0; padding: var(--sp) 0 0; border: 0; min-width: 0; }
.group > legend + * { clear: both; }
.group legend {
  float: left; width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 0; margin: 0 0 clamp(8px, 1.4vh, 12px);
  font-size: 14px; font-weight: 600; color: var(--ink);
}
.step {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  font-size: 12px; font-weight: 700; font-family: Inter, var(--sans);
  color: var(--brand); background: var(--brand-50); border: 1px solid var(--brand-100);
}
.optional { font-size: 12px; font-weight: 400; color: var(--ink-3); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input, .segmented input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center;
  height: var(--ctl); padding: 0 clamp(10px, 1vw, 14px); border-radius: 999px;
  font-size: 14px; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line-2);
  cursor: pointer; user-select: none;
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
}
.chip span:hover { border-color: var(--brand-200); color: var(--brand); }
.chip input:checked + span {
  color: #fff; background: var(--brand); border-color: var(--brand);
  box-shadow: 0 4px 12px -4px rgba(17, 75, 159, .5);
}
.chip input:focus-visible + span, .segmented input:focus-visible + span { outline: 2px solid var(--sky); outline-offset: 2px; }
.chips.is-invalid .chip span { border-color: rgba(194, 55, 43, .55); }

.custom-industry { margin-top: 10px; }

.segmented {
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 4px; gap: 4px; border-radius: var(--radius-sm);
  background: var(--canvas); border: 1px solid var(--line);
}
.segmented label { position: relative; }
.segmented span {
  display: grid; place-items: center; height: calc(var(--ctl) - 2px); border-radius: 7px;
  font-size: 14px; color: var(--ink-2); cursor: pointer; user-select: none;
  transition: background .15s, color .15s, box-shadow .15s;
}
.segmented span:hover { color: var(--brand); }
.segmented input:checked + span {
  background: var(--surface); color: var(--brand); font-weight: 600;
  box-shadow: 0 1px 3px rgba(15, 27, 45, .12), 0 0 0 1px rgba(17, 75, 159, .08);
}

.source-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: clamp(8px, 1.4vh, 12px);
}
.source-tabs button {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--field); border-radius: var(--radius-sm);
  font-size: 14px; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line-2);
  transition: border-color .15s, background .15s, color .15s;
}
.source-tabs button:hover { border-color: var(--brand-200); color: var(--brand); }
.source-tabs button[aria-selected="true"] {
  color: var(--brand); font-weight: 600;
  background: var(--brand-50); border-color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}

input[type="text"], input[type="url"], textarea {
  width: 100%; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line-2);
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"], input[type="url"] { height: var(--field); padding: 0 14px; }
input::placeholder, textarea::placeholder { color: #9aa5b5; }
input[type="text"]:hover, input[type="url"]:hover, textarea:hover { border-color: var(--brand-200); }
input[type="text"]:focus, input[type="url"]:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(17, 75, 159, .12);
}
.is-invalid, input.is-invalid, textarea.is-invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 4px rgba(194, 55, 43, .1) !important; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.input-icon input { padding-left: 42px; }
textarea {
  display: block; min-height: 200px; max-height: 50vh; padding: 12px 14px;
  resize: vertical; line-height: 1.7;
}
.field-help { margin-top: 6px; font-size: 13px; color: var(--ink-3); }
/* The character count sits inside the textarea corner instead of taking a row. */
#source-text { position: relative; }
#source-text textarea { padding-bottom: 30px; }
#source-text .field-help {
  position: absolute; right: 10px; bottom: 7px; margin: 0; padding: 0 4px;
  font-size: 12px; font-family: Inter, var(--sans); font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, .9); border-radius: 4px; pointer-events: none;
}

.upload-zone {
  position: relative; display: flex; align-items: center; gap: 16px;
  min-height: clamp(84px, 14vh, 112px); padding: 16px 20px;
  border-radius: var(--radius-sm); border: 1.5px dashed var(--line-2);
  background: linear-gradient(180deg, var(--surface), var(--canvas));
  cursor: pointer; transition: border-color .15s, background .15s;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--brand); background: var(--brand-50); }
.upload-zone:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(17, 75, 159, .12); }
.upload-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-zone.is-invalid { border-style: dashed; }
.upload-icon {
  display: grid; place-items: center; flex: none;
  width: 48px; height: 48px; border-radius: 12px;
  color: var(--brand); background: var(--brand-50); border: 1px solid var(--brand-100);
}
.upload-icon .icon { width: 22px; height: 22px; }
.upload-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.upload-text strong { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.upload-text span { font-size: 13px; color: var(--ink-3); }
.upload-zone.has-file { border-style: solid; border-color: var(--brand-200); background: var(--brand-50); }
.upload-zone.has-file .upload-icon { color: #fff; background: var(--brand); border-color: var(--brand); }
.link-button {
  margin-top: 8px; padding: 0; border: 0; background: none;
  font-size: 13px; color: var(--ink-3); text-decoration: underline; text-underline-offset: 3px;
}
.link-button:hover { color: var(--danger); }

.submit-area { margin-top: var(--sp); padding-top: var(--sp); border-top: 1px solid var(--line); }
.form-error {
  margin-bottom: 12px; padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 14px; color: var(--danger); background: var(--danger-bg); border: 1px solid rgba(194, 55, 43, .2);
}
.primary-button {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: var(--cta); border: 0; border-radius: 12px;
  font-size: 16px; font-weight: 600; color: #fff; letter-spacing: .02em;
  background: linear-gradient(135deg, #1a5cb8 0%, var(--brand) 45%, var(--brand-700) 100%);
  box-shadow: 0 3px 8px -3px rgba(17, 75, 159, .32), inset 0 1px 0 rgba(255, 255, 255, .15);
  transition: transform .15s, box-shadow .15s, filter .15s;
}
.primary-button:hover:not(:disabled) { filter: brightness(1.08); box-shadow: 0 4px 9px -3px rgba(17, 75, 159, .36), inset 0 1px 0 rgba(255, 255, 255, .15); }
.primary-button:active:not(:disabled) { transform: translateY(1px); }
.primary-button:disabled { filter: saturate(.6) brightness(1.1); }
.primary-button.is-busy::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, .22) 50%, transparent 80%);
  animation: sheen 1.4s linear infinite;
}

/* ---------- Output ---------- */
.output-card { display: flex; flex-direction: column; min-height: 520px; }
.output-card .card-head { flex: none; }
.result-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.output-card .card-head { flex-wrap: wrap; }
.edition-switch { display: inline-flex; padding: 2px; border: 1px solid var(--line-2); border-radius: 9px; }
.edition-switch button { display: inline-flex; gap: 5px; justify-content: center; align-items: center; width: 42px; min-height: 28px; padding: 0; border: 0; border-radius: 6px; background: transparent; font-size: 13px; white-space: nowrap; }
.edition-switch #result-tab-infographic { width: 84px; }
.edition-switch button[aria-selected="true"] { color: var(--brand); background: var(--brand-50); font-weight: 700; }
.edition-switch .icon { width: 14px; height: 14px; }
#infographic-tab-state { visibility: hidden; flex: 0 0 7px; height: 7px; border-radius: 50%; }
#infographic-tab-state[data-state="running"] { visibility: visible; background: #93b8e9; }
#infographic-tab-state[data-state="succeeded"] { visibility: visible; background: var(--success); }
.translation-error { padding: 16px; border-left: 2px solid var(--brand-200); font-size: 14px; color: var(--ink-2); background: var(--surface); }
.translation-error button { margin-top: 8px; padding: 3px 0; border: 0; background: transparent; color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }
.tool-button {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 9px;
  font-size: 13px; font-weight: 500; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line-2);
  transition: border-color .15s, color .15s, background .15s;
}
.tool-button .icon { width: 16px; height: 16px; }
.tool-button:hover:not(:disabled):not([aria-disabled="true"]) { color: var(--brand); border-color: var(--brand-200); background: var(--brand-50); }
.tool-button.solid { color: #fff; background: var(--brand); border-color: var(--brand); }
.tool-button.solid:hover:not(:disabled):not([aria-disabled="true"]) { color: #fff; background: var(--brand-600); }
.tool-button:disabled { opacity: .55; }
.download-menu { position: relative; }
.download-menu summary { cursor: pointer; list-style: none; }
.download-menu summary::-webkit-details-marker { display: none; }
.download-menu summary::after {
  content: ""; width: 6px; height: 6px; margin: -3px 1px 0 3px;
  border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg);
}
.download-menu[open] summary::after { margin-top: 3px; transform: rotate(225deg); }
.result-actions > .tool-button:disabled, .download-menu summary[aria-disabled="true"] {
  opacity: 1; color: var(--ink-3); background: var(--canvas); border-color: var(--line); cursor: not-allowed;
}
.download-options {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 2; width: 148px;
  padding: 4px; background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.download-options button {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  min-height: 40px; padding: 6px 10px; border: 0; border-radius: 6px;
  font-size: 14px; text-align: left; background: transparent;
}
.download-options button:is(:hover, :focus-visible) { color: var(--brand); background: var(--brand-50); }
.download-options small { color: var(--ink-3); }

.result-body {
  flex: 1; min-height: 0;
  padding: clamp(16px, 3vh, 28px);
  background:
    linear-gradient(var(--canvas), var(--canvas)) padding-box;
  border-radius: 0 0 var(--radius) var(--radius);
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}

.infographic-panel { display: grid; align-items: start; justify-items: center; min-height: 100%; }
.infographic-intro { display: grid; justify-items: center; align-self: center; gap: 10px; width: min(100%, 430px); padding-block: 12px; text-align: center; }
.infographic-placeholder {
  display: grid; gap: 7px; width: clamp(72px, 12vh, 102px); aspect-ratio: 9 / 16; padding: 10px;
  border: 1px solid var(--brand-100); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow);
  grid-template-rows: 6px repeat(3, 1fr); margin-bottom: 6px;
}
.infographic-placeholder span { width: 73%; border-radius: 3px; background: var(--brand); }
.infographic-placeholder i {
  border: 1px solid var(--brand-100); border-radius: 4px;
  background: linear-gradient(135deg, var(--brand-100) 36%, var(--brand-50) 36%);
}
.infographic-panel h3 { font-size: 17px; color: var(--brand-900); }
.infographic-intro p { font-size: 14px; color: var(--ink-3); }
.infographic-intro .primary-button { width: auto; min-height: 40px; padding-inline: 18px; }
.infographic-status:empty { display: none; }
.infographic-status[data-error="true"] { color: var(--danger); }
.infographic-progress {
  width: min(100%, 560px); padding: clamp(16px, 3vh, 24px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.infographic-progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 12px; flex-wrap: wrap; }
.infographic-progress-head h3 { color: var(--ink); }
.infographic-timer { font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.infographic-bar { height: 6px; margin: 13px 0 16px; overflow: hidden; border-radius: 4px; background: var(--brand-50); }
.infographic-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--sky)); transition: width .2s ease; }
.infographic-steps { display: grid; gap: 10px; list-style: none; margin: 0; padding: 0; }
.infographic-steps li { display: grid; grid-template-columns: 22px 1fr; align-items: start; gap: 1px 12px; font-size: 14px; color: var(--ink-3); }
.infographic-marker { grid-row: span 2; display: grid; place-items: center; width: 20px; height: 20px; margin-top: 1px; border-radius: 50%; border: 1.5px solid var(--line-2); }
.infographic-marker .icon { display: none; width: 12px; height: 12px; stroke-width: 2.6; color: #fff; }
.infographic-steps li[data-state="done"] { color: var(--ink); }
.infographic-steps li[data-state="done"] .infographic-marker { background: var(--success); border-color: var(--success); }
.infographic-steps li[data-state="done"] .icon { display: block; }
.infographic-steps li[aria-current="step"] { color: var(--brand); font-weight: 700; }
.infographic-steps li[aria-current="step"] .infographic-marker { border-color: var(--brand-100); border-top-color: var(--brand); animation: infographic-spin .9s linear infinite; }
.infographic-steps small { display: none; grid-column: 2; color: var(--ink-3); font-size: 12px; font-weight: 400; }
.infographic-steps li[data-state] small, .infographic-steps li[aria-current="step"] small { display: block; }
.infographic-progress-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); }
.infographic-progress-foot button { margin: 0; flex-shrink: 0; }
.infographic-cancel-error { margin-top: 8px; font-size: 13px; color: var(--danger); }
.infographic-cancel-error:empty { display: none; }
@keyframes infographic-spin { to { transform: rotate(360deg); } }
.infographic-result {
  display: grid; grid-template-columns: minmax(0, 38%) minmax(0, 1fr); align-items: start;
  gap: clamp(16px, 2.4vw, 32px); width: min(100%, 850px);
}
.infographic-image {
  display: block; overflow: hidden; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); box-shadow: 0 20px 40px -28px rgba(7, 31, 68, .35);
}
.infographic-image img { display: block; width: 100%; height: auto; }
.infographic-details { display: grid; gap: 10px; overflow-wrap: anywhere; }
.infographic-details h3 { font-size: 18px; line-height: 1.4; }
.infographic-badge { justify-self: start; display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 10px; border-radius: 999px; background: #e8f5ef; color: var(--success); font-size: 13px; font-weight: 700; }
.infographic-badge .icon { width: 14px; height: 14px; }
.infographic-meta { display: grid; gap: 7px; margin: 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); font-size: 13px; }
.infographic-meta div { display: grid; grid-template-columns: 4.5em minmax(0, 1fr); gap: 8px; }
.infographic-meta dt { color: var(--ink-3); }
.infographic-meta dd { margin: 0; }
.infographic-source { color: var(--brand); text-underline-offset: 3px; }
.infographic-downloads { display: flex; flex-wrap: wrap; gap: 6px; }
.infographic-downloads a { text-decoration: none; }
.infographic-warning { padding: 10px 12px; border-radius: var(--radius-sm); background: #fff6e8; color: var(--warn); font-size: 13px; line-height: 1.6; }
#regenerate-infographic { justify-self: start; margin: 0; }
@media (max-width: 560px) {
  .infographic-result { grid-template-columns: minmax(0, 1fr); }
  .infographic-image { width: min(100%, 300px); justify-self: center; }
}
@media (prefers-reduced-motion: reduce) {
  .infographic-steps li[aria-current="step"] .infographic-marker { animation: none; }
  .infographic-bar i { transition: none; }
}

/* Empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100%; text-align: center; padding: 8px 4px;
}
/* The whole illustration is sized in em, so one font-size scales it with the
   available height. The back sheet lives on the wrapper so it is a true sibling
   behind the front sheet; a transformed .paper would trap its ::before above it. */
.paper-stack {
  position: relative; isolation: isolate;
  font-size: clamp(9px, 2.1vh, 15px);
  width: min(21em, 100%);
}
.paper-stack::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  border-radius: .8em; background: var(--brand-50); border: 1px solid var(--brand-100);
  transform: translate(.6em, .4em) rotate(4deg); transform-origin: 50% 100%;
}
.paper {
  position: relative; z-index: 1; padding: 1.25em 1.4em 1.4em;
  border-radius: .8em; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 1.8em 3em -1.8em rgba(7, 31, 68, .35);
  text-align: left;
}
.paper-head {
  display: flex; align-items: center; gap: .5em; padding-bottom: .9em; margin-bottom: 1em;
  border-bottom: 1px solid var(--line);
  font-size: .65em; font-weight: 700; letter-spacing: .2em; color: var(--brand);
}
.paper-head img { width: 2em; height: 2em; }
.paper .line { height: .5em; margin-bottom: .56em; border-radius: .25em; }
.paper .line.strong { height: .75em; }
.line { display: block; height: 8px; margin-bottom: 9px; border-radius: 4px; background: var(--line); }
.line.strong { height: 12px; background: var(--brand-900); opacity: .85; }
.line.big { height: 16px; }
.paper-callout { margin: .9em 0; padding: .6em .75em .1em; border-left: 3px solid var(--brand); background: var(--brand-50); border-radius: 0 .4em .4em 0; }
.paper-callout .line { background: var(--brand-200); }
.w30 { width: 30%; } .w40 { width: 40%; } .w55 { width: 55%; } .w60 { width: 60%; } .w70 { width: 70%; }
.w80 { width: 80%; } .w85 { width: 85%; } .w90 { width: 90%; } .w95 { width: 95%; } .w100 { width: 100%; }
.empty-state h3 { margin-top: clamp(16px, 3.6vh, 32px); font-size: 17px; font-weight: 600; color: var(--ink); }
.empty-state > p { margin-top: 4px; font-size: 14px; color: var(--ink-3); }
.empty-steps {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  width: 100%; max-width: 620px; margin: clamp(14px, 3.2vh, 28px) 0 0; padding: 0; list-style: none;
}
.empty-steps li {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 14px 16px; border-radius: var(--radius-sm); text-align: left;
  background: var(--surface); border: 1px solid var(--line);
}
.empty-steps .icon { margin-bottom: 8px; color: var(--brand); }
.empty-steps b { font-size: 14px; font-weight: 600; }
.empty-steps span { font-size: 12px; color: var(--ink-3); }

/* Loading state */
.loading-state { max-width: 720px; margin: 0 auto; }
.skeleton { padding: 28px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.skeleton .line {
  height: 10px; margin-bottom: 14px;
  background: linear-gradient(90deg, var(--line) 0%, var(--brand-50) 40%, var(--line) 80%);
  background-size: 200% 100%; animation: shimmer 1.6s linear infinite;
}
.skeleton .line.big { height: 22px; margin-bottom: 12px; }
.skeleton .line.w30 { margin-bottom: 20px; }
.skeleton .line.w60 { margin-bottom: 28px; }
.loading-note { margin-bottom: 14px; font-size: 14px; color: var(--ink-2); }

/* Result document */
.doc {
  max-width: 760px; margin: 0 auto; overflow: hidden;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 20px 40px -28px rgba(7, 31, 68, .3);
  animation: rise .35s ease-out;
}
.doc-masthead {
  position: relative; overflow: hidden;
  padding: 22px 32px 20px; color: #fff;
  background: linear-gradient(120deg, var(--brand-900) 0%, var(--brand) 70%, #2a6cc8 100%);
}
.doc-masthead::after {
  content: ""; position: absolute; right: -40px; bottom: -70px;
  width: 220px; height: 190px; opacity: .1;
  background: #fff; clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.doc-brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 11px; font-weight: 700; letter-spacing: .22em; }
.doc-brand time { font-weight: 500; letter-spacing: .06em; opacity: .75; font-family: Inter, var(--sans); }
.doc-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.doc-tags span {
  height: 24px; padding: 0 10px; border-radius: 999px; line-height: 22px;
  font-size: 12px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .22);
}
.doc-content { padding: 28px 32px 36px; font-size: 15.5px; line-height: 1.85; color: var(--ink); outline: none; }
.doc-content:focus-visible { box-shadow: inset 0 0 0 2px var(--sky); }
.doc-content > :first-child { margin-top: 0; }
.doc-content h1, .doc-content h2, .doc-content h3, .doc-content h4 { color: var(--brand-900); line-height: 1.35; letter-spacing: -.005em; }
.doc-content .doc-title { margin: 0 0 18px; font-size: 24px; font-weight: 700; }
.doc-content h2 { margin: 26px 0 10px; font-size: 18px; font-weight: 700; }
.doc-content h3, .doc-content h4 { margin: 22px 0 8px; font-size: 16px; font-weight: 700; }
.doc-content h2::before, .doc-content h3.section::before {
  content: ""; display: inline-block; width: 4px; height: .9em; margin-right: 10px;
  vertical-align: -1px; border-radius: 2px; background: var(--brand);
}
.doc-content p { margin: 0 0 12px; }
.doc-content strong { font-weight: 700; color: var(--brand-900); }
.doc-content em { font-style: normal; color: var(--ink-2); }
.doc-content code { font-family: var(--mono); font-size: .9em; padding: 1px 5px; border-radius: 4px; background: var(--canvas); }
.doc-content .point {
  margin: 14px 0 4px; padding: 12px 16px; border-radius: 10px;
  background: var(--canvas); border: 1px solid var(--line);
}
.doc-content .impact {
  margin: 0 0 12px; padding: 10px 16px 10px 14px; border-radius: 0 10px 10px 0;
  border-left: 3px solid var(--brand); background: var(--brand-50); color: var(--brand-700);
}
.doc-content .impact em { color: var(--brand-700); }
.doc-content ul, .doc-content ol { margin: 0 0 12px; padding-left: 1.4em; }
.doc-content li { margin: 4px 0; }
.doc-content li::marker { color: var(--brand); }
.doc-content hr { margin: 22px 0; border: 0; border-top: 1px dashed var(--line-2); }
.doc-content blockquote { margin: 0 0 12px; padding: 4px 16px; border-left: 3px solid var(--line-2); color: var(--ink-2); }
.doc-foot {
  display: flex; justify-content: space-between; gap: 12px; padding: 14px 32px;
  font-size: 12px; color: var(--ink-3); background: var(--canvas); border-top: 1px solid var(--line);
}

/* ---------- Footer ---------- */
.footer {
  width: 100%; max-width: 1360px; margin: 0 auto; padding: 0 32px clamp(10px, 2vh, 20px);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  font-size: 12px; color: var(--ink-3);
}

/* ---------- Toast & dialog ---------- */
/* In-flow feedback sits below the result tools without covering the manuscript. */
.toast { flex: none; }
.toast:not(:empty) {
  display: flex; align-items: center; gap: 9px;
  padding: 7px clamp(16px, 3vh, 28px); border-bottom: 1px solid var(--brand-100);
  font-size: 13px; line-height: 1.5; color: var(--brand-600); background: rgba(17, 75, 159, .045);
  overflow-wrap: anywhere;
}
.toast:not(:empty)::before { content: ""; flex: none; width: 2px; height: 12px; background: currentColor; }
.toast[data-kind="error"]:not(:empty) { color: var(--danger); background: var(--danger-bg); border-color: #f0d9d6; }

dialog {
  width: min(520px, calc(100vw - 32px)); padding: 28px; border: 0; border-radius: 18px;
  color: var(--ink); background: var(--surface); box-shadow: var(--shadow-lg);
}
dialog[open] { animation: rise .25s ease-out; }
dialog::backdrop { background: rgba(7, 31, 68, .45); backdrop-filter: blur(4px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.dialog-head h2 { font-size: 20px; font-weight: 600; color: var(--brand-900); }
.icon-button {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: 0; background: transparent; color: var(--ink-3);
}
.icon-button:hover { background: var(--canvas); color: var(--ink); }
.help-steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.help-steps li { position: relative; padding: 0 0 18px 44px; counter-increment: step; }
.help-steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  font-size: 13px; font-weight: 700; color: #fff; background: var(--brand);
}
.help-steps li:not(:last-child)::after {
  content: ""; position: absolute; left: 13.5px; top: 32px; bottom: 4px; width: 1px; background: var(--brand-100);
}
.help-steps strong { display: block; font-size: 15px; line-height: 28px; }
.help-steps p { margin-top: 2px; font-size: 14px; color: var(--ink-2); }
.help-note { margin-top: 8px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; color: var(--ink-2); background: var(--canvas); }
.help-note.warn { color: var(--warn); background: #fff6e8; }

/* ---------- Motion ---------- */
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes sheen { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- One-screen desktop layout ----------
   On desktop-sized windows the page is locked to the viewport: the workspace takes
   whatever height is left, the output card fills it, and only a long generated
   document scrolls inside the result panel. Smaller windows fall back to normal
   page scrolling below. */
@media (min-width: 1041px) and (min-height: 600px) {
  body { height: 100vh; height: 100dvh; min-height: 0; }
  .page { display: flex; flex-direction: column; min-height: 0; padding-bottom: clamp(12px, 2.2vh, 24px); }
  .intro { flex: none; }
  .workspace { flex: 1; min-height: 0; align-items: stretch; grid-template-rows: minmax(0, 1fr); }
  /* Both cards share the row height; the source group absorbs the free space so
     the generate button sits at the bottom, and in text mode the textarea grows. */
  .form-card {
    height: 100%; overflow: auto;
    display: flex; flex-direction: column;
    scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
  }
  .form-card .card-head, .submit-area, .source-tabs { flex: none; }
  #newsletter-form, .group:last-of-type, #source-text:not([hidden]) {
    flex: 1 0 auto; display: flex; flex-direction: column;
  }
  #source-text textarea { flex: 1 1 0; height: 72px; min-height: 72px; max-height: none; resize: none; }
  .upload-zone { min-height: 0; height: clamp(72px, 10vh, 112px); padding: 10px 18px; }
  .output-card { min-height: 0; height: 100%; }
  .result-body { overflow: auto; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
  .empty-state { padding: 0; }
}
/* Short desktop windows: drop the decorative extras before anything scrolls. */
@media (min-width: 1041px) and (max-height: 880px) {
  .intro { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (min-width: 1041px) and (max-height: 760px) {
  .empty-steps { display: none; }
  #newsletter-form { padding-bottom: 16px; }
  .submit-area { margin-top: 10px; padding-top: 12px; }
  .page { padding-bottom: 10px; }
  .field-help { margin-top: 4px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1040px) {
  .workspace { grid-template-columns: 1fr; }
  .output-card { min-height: 480px; }
}
@media (max-width: 640px) {
  .topbar-inner { height: 58px; padding: 0 16px; }
  .brand-logo { height: 26px; }
  .brand-divider, .brand-product { display: none; }
  .service-status span { display: none; }
  .service-status { width: 32px; padding: 0; justify-content: center; }
  #open-help { padding: 0 10px; }
  .page { padding: 28px 16px 20px; }
  .intro { margin-bottom: 22px; }
  .lede { font-size: 15px; }
  #newsletter-form { padding: 4px 18px 20px; }
  .card-head { padding: 10px 12px 10px 18px; }
  .source-tabs button { flex-direction: column; gap: 2px; height: 58px; font-size: 13px; }
  .result-body { padding: 16px; }
  .output-card .card-head { flex-wrap: wrap; }
  .doc-masthead, .doc-content, .doc-foot { padding-left: 20px; padding-right: 20px; }
  .empty-steps { grid-template-columns: 1fr; }
  .footer { padding: 16px; flex-direction: column; gap: 4px; }
}

/* Let the full manuscript flow across A4 pages, including the off-screen text. */
@page { size: A4; margin: 13mm 14mm; }
@media (max-width: 480px) {
  .result-actions .tool-button { padding-inline: 8px; }
  .result-actions .tool-button > .icon, .edition-switch .icon { display: none; }
  .edition-switch button { width: 36px; }
  .edition-switch #result-tab-infographic { width: 66px; }
}
@media print {
  html, body { background: white; }
  body:has(.doc) {
    display: block; margin: 0; padding: 0; min-height: 0; height: auto;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  body:has(.doc) :is(.topbar, .skip-link, .sprite, .intro, .form-card, .card-head, .translation-error, .footer, dialog, .toast) { display: none !important; }
  body:has(.doc) :is(.page, .workspace, .output-card, .result-body, .doc) {
    position: static; display: block; width: auto; max-width: none;
    height: auto; min-height: 0; max-height: none; overflow: visible;
    margin: 0; padding: 0; border: 0; border-radius: 0;
    background: transparent; box-shadow: none; animation: none;
  }
  .doc { overflow-wrap: anywhere; }
  .doc-masthead { padding: 5mm 7mm; break-inside: avoid; break-after: avoid; }
  .doc-content { padding: 5mm 7mm 3mm; font-size: 11pt; line-height: 1.65; }
  .doc-content .doc-title { margin-bottom: 12px; }
  .doc-content p { margin-bottom: 8px; }
  .doc-content .point { margin: 10px 0 3px; padding-block: 9px; }
  .doc-content .impact { margin-bottom: 8px; padding-block: 8px; }
  .doc-content :is(h1, h2, h3, h4) { break-after: avoid; }
  .doc-content :is(p, li, .point, .impact) { orphans: 2; widows: 2; }
  .doc-content :is(.point, .impact, blockquote), .doc-foot { break-inside: avoid; }
  .doc-content > :last-child { margin-bottom: 0; }
  .doc-foot { padding: 3mm 7mm; break-before: avoid; }
}
