:root {
  color-scheme: light;
  --ink: #101827;
  --muted: #526174;
  --line: #cfd9e5;
  --line-strong: #aebdcd;
  --paper: #ffffff;
  --wash: #f2f7f8;
  --navy: #08111f;
  --navy-soft: #142137;
  --blue: #1769e0;
  --blue-dark: #0d4eaf;
  --cyan: #00a7b5;
  --mint: #dff7ef;
  --coral: #ff725e;
  --amber: #f3ad2e;
  --success: #087a59;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(13, 31, 52, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--wash);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.58;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input[type="file"] {
  cursor: pointer;
}

a {
  color: var(--blue-dark);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--blue);
}

img {
  display: block;
  max-width: 100%;
}

.page {
  min-height: 100vh;
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 32px));
  min-height: 68px;
  margin: 0 auto;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  width: 42px;
  height: 42px;
}

.brand-text {
  display: grid;
  line-height: 1.15;
}

.brand-name {
  font-weight: 800;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.72rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

.language-menu {
  position: relative;
}

.language-menu summary {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 4px 14px rgba(13, 31, 52, 0.1);
  cursor: pointer;
  list-style: none;
}

.language-menu summary::-webkit-details-marker {
  display: none;
}

.language-menu[open] summary {
  border-color: var(--blue);
  outline: 3px solid rgba(23, 105, 224, 0.14);
}

.language-menu-list {
  position: absolute;
  top: 48px;
  left: 50%;
  display: grid;
  width: 50px;
  padding: 6px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--navy);
  box-shadow: var(--shadow);
}

.language-menu-list a {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
}

.language-menu-list a:hover,
.language-menu-list a[aria-current="true"] {
  background: var(--navy-soft);
  outline: 2px solid rgba(255, 255, 255, 0.25);
}

.flag-circle {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  overflow: hidden;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.24);
  font-size: 21px;
  line-height: 1;
}

.flag-circle::before { content: none; }
.flag-en {
  background:
    linear-gradient(33deg, transparent 0 42%, #fff 42% 47%, #c8102e 47% 53%, #fff 53% 58%, transparent 58%),
    linear-gradient(-33deg, transparent 0 42%, #fff 42% 47%, #c8102e 47% 53%, #fff 53% 58%, transparent 58%),
    linear-gradient(90deg, transparent 0 42%, #fff 42% 46%, #c8102e 46% 54%, #fff 54% 58%, transparent 58%),
    linear-gradient(0deg, transparent 0 38%, #fff 38% 44%, #c8102e 44% 56%, #fff 56% 62%, transparent 62%),
    #012169;
}
.flag-de { background: linear-gradient(#000 0 33.33%, #dd0000 33.33% 66.66%, #ffce00 66.66%); }
.flag-fr { background: linear-gradient(90deg, #0055a4 0 33.33%, #fff 33.33% 66.66%, #ef4135 66.66%); }
.flag-es { background: linear-gradient(#aa151b 0 25%, #f1bf00 25% 75%, #aa151b 75%); }
.flag-zh { background: radial-gradient(circle at 35% 35%, #ffde00 0 3px, transparent 3.5px), #de2910; }
.flag-ru { background: linear-gradient(#fff 0 33.33%, #0039a6 33.33% 66.66%, #d52b1e 66.66%); }
.flag-bg { background: linear-gradient(#fff 0 33.33%, #00966e 33.33% 66.66%, #d62612 66.66%); }

.tool-intro {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(400px, 1.1fr);
  align-items: center;
  min-height: 340px;
  overflow: hidden;
  background: var(--navy);
  color: #fff;
}

.tool-intro > div {
  width: min(560px, calc(100% - 48px));
  margin-left: max(32px, calc((100vw - 1180px) / 2));
  padding: 36px 0;
}

.tool-intro picture {
  align-self: stretch;
  min-height: 340px;
}

.tool-intro img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.eyebrow,
.section-label {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.tool-intro h1 {
  max-width: 720px;
  margin: 0;
  font-size: 2.9rem;
  line-height: 1.08;
  letter-spacing: 0;
}

.lead {
  max-width: 640px;
  margin: 16px 0;
  color: #cfdae9;
  font-size: 0.96rem;
}

.trust {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.trust span {
  padding: 6px 10px;
  border: 1px solid #3d4c64;
  border-radius: 999px;
  color: #e6edf7;
  font-size: 0.78rem;
  font-weight: 700;
}

.privacy-callout {
  width: min(1180px, calc(100% - 32px));
  margin: 22px auto 0;
  padding: 12px 16px;
  border-left: 4px solid var(--success);
  background: var(--mint);
  color: #084f3d;
}

.workspace {
  width: min(1180px, calc(100% - 32px));
  margin: 22px auto 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.workspace-heading,
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
}

.workspace-heading {
  padding: 26px 28px;
  border-bottom: 1px solid var(--line);
}

.workspace-heading h2,
.section-heading h3,
.input-column h3,
.count-column h3 {
  margin: 0;
  line-height: 1.2;
}

.workspace-heading > p,
.section-heading > p,
.section-heading > div + p {
  max-width: 540px;
  margin: 0;
  color: var(--muted);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

.input-column,
.count-column {
  padding: 28px;
}

.count-column {
  border-left: 1px solid var(--line);
  background: #f7fafc;
}

.column-intro {
  min-height: 50px;
  margin: 8px 0 20px;
  color: var(--muted);
  font-size: 0.91rem;
}

.field-label,
.pricing-inputs label > span,
.preview-controls label > span {
  display: block;
  margin-bottom: 6px;
  color: #28384c;
  font-size: 0.78rem;
  font-weight: 800;
}

textarea {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  padding: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fbfdff;
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.55;
}

textarea:focus,
input:focus,
select:focus,
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(23, 105, 224, 0.22);
  outline-offset: 2px;
}

.input-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.file-button,
button.secondary {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 750;
}

.file-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.file-button small {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 500;
}

button.secondary {
  padding: 8px 14px;
}

.file-button:hover,
button.secondary:hover {
  border-color: var(--blue);
  color: var(--blue-dark);
}

.text-metrics,
.count-results,
.cost-metrics,
.example-metrics {
  display: grid;
  gap: 8px;
}

.text-metrics {
  grid-template-columns: repeat(4, 1fr);
  margin-top: 14px;
}

.text-metrics div,
.cost-metrics div,
.example-metrics div {
  display: grid;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7fafc;
}

.text-metrics strong,
.cost-metrics strong,
.example-metrics strong {
  overflow-wrap: anywhere;
  font-size: 1.08rem;
}

.text-metrics span,
.cost-metrics span,
.example-metrics span {
  color: var(--muted);
  font-size: 0.72rem;
}

.status,
.pricing-status {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.status[data-state="error"],
.pricing-status[data-state="error"] {
  color: var(--danger);
}

.count-results {
  gap: 10px;
}

.count-results > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  background: var(--paper);
}

.count-results .estimate-result {
  border-left-color: var(--amber);
}

.count-results code {
  align-self: center;
  color: #2e4058;
  font-weight: 750;
}

.count-results strong {
  font-size: 1.6rem;
  line-height: 1;
}

.count-results span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.76rem;
}

.preview-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  gap: 14px;
  margin-top: 18px;
}

.check-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.check-control span {
  margin: 0;
}

.check-control input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

select,
input[type="number"] {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}

input:disabled {
  background: #eef2f5;
  color: #5b6673;
  cursor: not-allowed;
}

.preview-section,
.pricing-planner {
  padding: 28px;
  border-top: 1px solid var(--line);
}

.token-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 320px;
  margin-top: 18px;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b1422;
  color: #eef5ff;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.79rem;
}

.token-preview span {
  padding: 2px 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #173967;
}

.token-preview span:nth-child(3n + 2) { background: #385071; }
.token-preview span:nth-child(3n + 3) { background: #006e76; }

.preview-note,
.cost-caveat {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.pricing-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 0.75fr);
  gap: 28px;
  margin-top: 20px;
}

.pricing-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 14px;
}

.source-row {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.pricing-results {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7fafc;
}

.accuracy-badge {
  display: inline-flex;
  margin: 0 0 12px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--mint);
  color: #085f48;
  font-size: 0.72rem;
  font-weight: 800;
}

.accuracy-badge[data-mode="estimate"] {
  background: #fff0cc;
  color: #75500b;
}

.cost-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cost-metrics .total {
  border-color: var(--blue);
  background: #eaf2ff;
}

.context-meter {
  margin: 18px 0 0;
}

.context-meter > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 0.79rem;
}

.context-meter progress {
  width: 100%;
  height: 14px;
  accent-color: var(--cyan);
}

.content-section {
  width: min(980px, calc(100% - 32px));
  margin: 72px auto;
}

.content-section > section {
  padding: 38px 0;
  border-top: 1px solid var(--line);
}

.content-section > section:first-child {
  border-top: 0;
}

.content-section h2 {
  max-width: 820px;
  margin: 0 0 16px;
  font-size: 1.75rem;
  line-height: 1.2;
}

.content-section p,
.content-section li {
  color: #35475c;
}

.content-section p {
  max-width: 820px;
}

.table-wrap {
  margin-top: 20px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  background: var(--paper);
  font-size: 0.88rem;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

thead th {
  background: var(--navy);
  color: #fff;
  font-size: 0.76rem;
}

tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: 0;
}

.numbered-steps ol {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 0;
  counter-reset: workflow;
  list-style: none;
}

.numbered-steps li {
  position: relative;
  min-height: 150px;
  padding: 48px 16px 16px;
  border-top: 3px solid var(--cyan);
  background: var(--paper);
}

.numbered-steps li::before {
  position: absolute;
  top: 12px;
  left: 16px;
  color: var(--coral);
  font-size: 1.3rem;
  font-weight: 900;
  counter-increment: workflow;
  content: counter(workflow, decimal-leading-zero);
}

.worked-example,
.content-split {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 36px;
  align-items: start;
}

.example-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.safety-callout {
  padding-right: 24px !important;
  padding-left: 24px !important;
  border-right: 1px solid #a8dfce;
  border-left: 5px solid var(--success);
  background: var(--mint);
}

.sources-section ul {
  display: grid;
  gap: 9px;
  padding-left: 20px;
}

.sources-section li span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.faq-list {
  border-top: 1px solid var(--line);
}

.faq-list details {
  border-bottom: 1px solid var(--line);
}

.faq-list summary {
  padding: 18px 40px 18px 0;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.faq-list p {
  margin: 0 0 20px;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px max(16px, calc((100vw - 1180px) / 2));
  background: var(--navy);
  color: #cbd6e6;
  font-size: 0.8rem;
}

.footer p {
  margin: 0;
}

.footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.footer a,
.privacy-settings {
  border: 0;
  background: none;
  color: #e9f2ff;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .tool-intro {
    grid-template-columns: 1fr;
  }

  .tool-intro > div {
    width: min(720px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0 26px;
  }

  .tool-intro picture {
    min-height: 210px;
    max-height: 280px;
  }

  .workspace-grid,
  .pricing-grid,
  .worked-example,
  .content-split {
    grid-template-columns: 1fr;
  }

  .count-column {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .numbered-steps ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .topbar {
    width: calc(100% - 20px);
    min-height: 60px;
    gap: 8px;
  }

  .brand-sub {
    display: none;
  }

  .nav-link {
    min-height: 36px;
    padding: 0 9px;
    white-space: nowrap;
    font-size: 0.68rem;
  }

  .top-actions {
    gap: 6px;
  }

  .language-menu summary {
    width: 38px;
    height: 38px;
  }

  .brand img {
    width: 36px;
    height: 36px;
  }

  .brand-name {
    font-size: 0.86rem;
  }

  .tool-intro {
    min-height: auto;
  }

  .tool-intro > div {
    padding: 26px 0 20px;
  }

  .tool-intro h1 {
    font-size: 1.9rem;
  }

  .lead {
    margin: 12px 0;
    font-size: 0.9rem;
    line-height: 1.45;
  }

  .trust {
    gap: 6px;
  }

  .trust span {
    padding: 4px 7px;
    font-size: 0.68rem;
  }

  .tool-intro picture {
    min-height: 110px;
    max-height: 130px;
  }

  .privacy-callout,
  .workspace,
  .content-section {
    width: calc(100% - 20px);
  }

  .privacy-callout {
    padding: 9px 11px;
    font-size: 0.8rem;
    line-height: 1.45;
  }

  .workspace-heading,
  .section-heading,
  .footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace-heading,
  .input-column,
  .count-column,
  .preview-section,
  .pricing-planner {
    padding: 20px 16px;
  }

  .text-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .preview-controls,
  .pricing-inputs,
  .cost-metrics,
  .example-metrics,
  .numbered-steps ol {
    grid-template-columns: 1fr;
  }

  .source-row {
    flex-direction: column;
  }

  .numbered-steps li {
    min-height: 0;
  }

  .content-section {
    margin-top: 48px;
  }

  .content-section h2 {
    font-size: 1.45rem;
  }

  .footer {
    padding: 24px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
