:root {
  color-scheme: light;
  --ink: #14201d;
  --muted: #66736f;
  --soft: #f1f4ef;
  --paper: #fffdf8;
  --surface: #ffffff;
  --line: #dfe6e1;
  --brand: #0b6b57;
  --brand-strong: #075345;
  --brand-soft: #e3f3ed;
  --accent: #d69236;
  --accent-soft: #fff1d9;
  --danger: #a83d3d;
  --danger-soft: #fff0ed;
  --shadow: 0 18px 55px rgba(22, 52, 43, .09);
  --radius-lg: 26px;
  --radius-md: 17px;
  --radius-sm: 12px;
}

:root.dark {
  color-scheme: dark;
  --ink: #eef5f1;
  --muted: #aab8b3;
  --soft: #15201d;
  --paper: #0c1412;
  --surface: #121d1a;
  --line: #293b36;
  --brand: #52b69b;
  --brand-strong: #73c7b1;
  --brand-soft: #16352e;
  --accent: #e4ad61;
  --accent-soft: #382d1c;
  --danger: #ff9690;
  --danger-soft: #3a2221;
  --shadow: 0 20px 60px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }

html {
  max-width: 100%;
  overflow-x: clip;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  max-width: 100%;
  overflow-x: clip;
  background:
    radial-gradient(circle at 7% 5%, rgba(214, 146, 54, .12), transparent 26rem),
    radial-gradient(circle at 93% 18%, rgba(11, 107, 87, .11), transparent 30rem),
    var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  line-height: 1.65;
}

button,
select,
textarea { font: inherit; }

button,
select { cursor: pointer; }

button:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 48%, transparent);
  outline-offset: 3px;
}

.shell { width: min(1160px, calc(100% - 32px)); margin-inline: auto; }

.skip-link {
  position: fixed;
  inset: 10px auto auto 10px;
  z-index: 1000;
  transform: translateY(-160%);
  border-radius: 8px;
  background: var(--brand-strong);
  color: white;
  padding: 8px 14px;
}

.skip-link:focus { transform: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(16px);
}

.topbar-inner,
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-inner { min-height: 72px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px 14px 14px 5px;
  background: var(--brand);
  color: white;
  font-size: 23px;
  font-weight: 800;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--brand) 22%, transparent);
}

.brand strong { display: block; font-size: 18px; line-height: 1.2; }
.brand small { display: block; color: var(--muted); font-size: 11px; }

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

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  transition: transform .2s ease, border-color .2s ease;
}

.icon-button:hover { transform: rotate(-7deg); border-color: var(--brand); }
.dark .theme-light, :root:not(.dark) .theme-dark { display: none; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 650;
}

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #c99a31; }
.status-pill.online .status-dot { background: #20a26e; box-shadow: 0 0 0 4px rgba(32, 162, 110, .12); }
.status-pill.offline .status-dot { background: #c94e48; }
.status-pill.checking .status-dot { animation: pulse 1.2s infinite; }

@keyframes pulse { 50% { opacity: .35; } }

.page { padding-block: 76px 64px; }

.hero { max-width: 820px; margin: 0 auto 48px; text-align: center; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--line));
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  padding: 6px 13px;
  font-size: 13px;
  font-weight: 750;
}

.eyebrow.small { padding: 4px 10px; font-size: 11px; }

.hero h1 {
  margin: 20px 0 14px;
  font-size: clamp(36px, 6vw, 67px);
  line-height: 1.17;
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
}

.hero h1 span { color: var(--brand); }
.hero > p { max-width: 720px; margin: 0 auto; color: var(--muted); font-size: clamp(15px, 2vw, 18px); }

.hero-stats {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin: 30px 0 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  box-shadow: 0 8px 30px rgba(34, 70, 60, .04);
  overflow: hidden;
}

.hero-stats div { min-width: 126px; padding: 12px 22px; }
.hero-stats div + div { border-inline-start: 1px solid var(--line); }
.hero-stats dt { color: var(--brand); font-size: 22px; font-weight: 850; line-height: 1.2; }
.hero-stats dd { margin: 3px 0 0; color: var(--muted); font-size: 11px; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(330px, .92fr);
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow);
  padding: clamp(20px, 3vw, 30px);
}

.input-panel { min-height: 465px; }
.target-panel { min-height: 465px; }
.controls-panel { grid-column: 1 / -1; }

.panel-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.panel-heading.compact { margin-bottom: 18px; }
.panel-heading h2 { margin: 0; font-size: 20px; line-height: 1.35; }
.panel-heading p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.step-number {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 13px;
  background: var(--soft);
  color: var(--brand);
  font-weight: 850;
}

.text-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--soft);
  padding: 2px;
  transition: box-shadow .2s ease, border-color .2s ease;
}

.text-wrap:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 12%, transparent); }

textarea {
  display: block;
  width: 100%;
  min-height: 270px;
  border: 0;
  border-radius: calc(var(--radius-md) - 2px);
  outline: 0;
  resize: vertical;
  background: transparent;
  color: var(--ink);
  padding: 18px 18px 6px;
  font-size: 17px;
  line-height: 1.95;
}

textarea::placeholder { color: color-mix(in srgb, var(--muted) 72%, transparent); }

.text-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px 11px;
  color: var(--muted);
  font-size: 11px;
}

.sample-row { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 15px; color: var(--muted); font-size: 11px; }

.sample {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 5px 10px;
  font-size: 11px;
}

.sample:hover { border-color: var(--brand); color: var(--brand); }

.field-label,
.dialect-fieldset legend,
.intensity-fieldset legend {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.select-wrap { position: relative; }
.select-wrap::after { content: "⌄"; position: absolute; top: 50%; left: 15px; transform: translateY(-54%); color: var(--muted); pointer-events: none; }

select {
  width: 100%;
  min-height: 45px;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
  color: var(--ink);
  padding: 9px 13px 9px 38px;
}

.country-note {
  margin: 12px 0 16px;
  border-inline-start: 3px solid var(--accent);
  border-radius: 7px;
  background: var(--accent-soft);
  color: color-mix(in srgb, var(--ink) 82%, var(--muted));
  padding: 9px 12px;
  font-size: 11px;
  line-height: 1.7;
}

.country-note.limited { border-inline-start-color: var(--danger); background: var(--danger-soft); }

.dialect-fieldset,
.intensity-fieldset { min-width: 0; margin: 0; border: 0; padding: 0; }
.dialect-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-height: 230px; overflow: auto; padding: 2px; }

.dialect-option { position: relative; }
.dialect-option input { position: absolute; opacity: 0; pointer-events: none; }
.dialect-option span {
  display: block;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  padding: 10px 11px;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.dialect-option b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.dialect-option small { display: block; overflow: hidden; margin-top: 1px; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.dialect-option:hover span { transform: translateY(-1px); border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); }
.dialect-option input:checked + span { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.dialect-option input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--brand) 42%, transparent); outline-offset: 2px; }

.control-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.control-field > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 750; }

.intensity-fieldset { margin-top: 18px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--soft);
  padding: 9px;
  text-align: center;
}
.segmented b { font-size: 12px; }
.segmented small { color: var(--muted); font-size: 9px; }
.segmented input:checked + span { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); box-shadow: inset 0 0 0 1px var(--brand); }
.segmented input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--brand) 42%, transparent); outline-offset: 2px; }

.advanced { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.advanced summary { color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 750; }
.check-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.check-grid label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.check-grid input { width: 16px; height: 16px; accent-color: var(--brand); }

.action-panel {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-radius: 20px;
  background: var(--ink);
  color: var(--surface);
  padding: 15px 17px 15px 24px;
  box-shadow: var(--shadow);
}

.dark .action-panel { background: #e7f1ed; color: #13201c; }
.action-panel strong { display: block; font-size: 13px; }
.action-panel > div > span { display: block; opacity: .66; font-size: 10px; }

.primary-button {
  display: inline-flex;
  min-width: 180px;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 13px;
  border: 0;
  border-radius: 15px;
  background: var(--accent);
  color: #1e170e;
  padding: 10px 20px;
  font-weight: 850;
  transition: transform .18s ease, filter .18s ease;
}

.primary-button:hover { transform: translateY(-2px); filter: brightness(1.04); }
.primary-button:active { transform: none; }
.primary-button:disabled { cursor: wait; opacity: .72; }
.button-arrow { font-size: 20px; }

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(20, 20, 20, .2);
  border-top-color: #19130b;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.primary-button.loading .spinner { display: inline-block; }
.primary-button.loading .button-arrow { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.error-box { margin-top: 18px; border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line)); border-radius: 15px; background: var(--danger-soft); color: var(--danger); padding: 13px 16px; font-size: 13px; }

.result-section {
  margin-top: 34px;
  border-top: 1px solid var(--line);
  padding-top: 34px;
  animation: enter .45s ease both;
}

@keyframes enter { from { opacity: 0; transform: translateY(12px); } }

.result-topline { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.result-topline h2 { margin: 8px 0 0; font-size: 24px; }
.result-actions { display: flex; gap: 7px; }
.secondary-button { border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--ink); padding: 8px 12px; font-size: 11px; font-weight: 700; }
.secondary-button:hover { border-color: var(--brand); color: var(--brand); }

.result-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(290px, .6fr); gap: 16px; }
.output-card,
.analysis-card { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.output-card { min-height: 280px; padding: clamp(24px, 4vw, 42px); }
.output-card-head { display: flex; justify-content: space-between; gap: 12px; }
.target-badge,
.quality-badge { display: inline-flex; border-radius: 999px; padding: 5px 9px; font-size: 10px; font-weight: 750; }
.target-badge { background: var(--brand-soft); color: var(--brand-strong); }
.quality-badge { background: var(--soft); color: var(--muted); }
.output-text { margin: 38px 0 0; font-size: clamp(22px, 3vw, 33px); font-weight: 750; line-height: 1.85; white-space: pre-wrap; }

.analysis-card { padding: 24px; }
.analysis-card h3 { margin: 0 0 17px; font-size: 17px; }
.analysis-card h4 { margin: 20px 0 8px; color: var(--muted); font-size: 11px; }
.analysis-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.analysis-meta div { border-radius: 11px; background: var(--soft); padding: 8px 10px; }
.analysis-meta dt { color: var(--muted); font-size: 9px; }
.analysis-meta dd { margin: 2px 0 0; font-size: 11px; font-weight: 750; }
.notes-list,
.warnings-list { display: grid; gap: 8px; margin: 0; padding: 0 17px 0 0; }
.notes-list li,
.warnings-list li { padding-inline-start: 2px; color: var(--muted); font-size: 11px; }
.notes-list strong { display: block; color: var(--ink); font-size: 11px; }
.warnings-list li::marker { color: var(--accent); }

.method-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 17px;
  max-width: 900px;
  margin: 40px auto 0;
  border: 1px dashed color-mix(in srgb, var(--brand) 35%, var(--line));
  border-radius: 20px;
  background: color-mix(in srgb, var(--brand-soft) 60%, transparent);
  padding: 19px 22px;
}

.method-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 12px; background: var(--surface); color: var(--brand); font-weight: 900; }
.method-card h2 { margin: 0; font-size: 15px; }
.method-card p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }

.footer { border-top: 1px solid var(--line); color: var(--muted); padding-block: 22px; font-size: 11px; }
.footer p { margin: 0; }

@media (max-width: 840px) {
  .shell { width: min(calc(100% - 24px), 1160px); }
  .hero h1 { font-size: clamp(34px, 7vw, 46px); }
  .hero-stats { width: 100%; }
  .hero-stats div { min-width: 0; padding: 10px 8px; }
  .workspace { grid-template-columns: 1fr; }
  .controls-panel,
  .action-panel { grid-column: auto; }
  .control-grid { grid-template-columns: 1fr 1fr; }
  .check-grid { grid-template-columns: 1fr 1fr; }
  .result-grid { grid-template-columns: 1fr; }
}

@media (max-width: 580px) {
  .shell { width: min(calc(100% - 22px), 1160px); }
  .topbar-inner { min-height: 62px; }
  .status-pill span:last-child { display: none; }
  .status-pill { width: 31px; height: 31px; justify-content: center; padding: 0; }
  .icon-button { width: 38px; height: 38px; }
  .page { padding-block: 48px; }
  .hero { margin-bottom: 32px; }
  .hero h1 { font-size: clamp(30px, 9.2vw, 38px); letter-spacing: -.02em; }
  .hero-stats { width: 100%; }
  .hero-stats div { min-width: 0; padding: 10px 5px; }
  .panel { padding: 18px; border-radius: 21px; }
  textarea { min-height: 230px; font-size: 16px; }
  .text-meta span:first-child { display: none; }
  .text-meta { justify-content: flex-end; }
  .dialect-list { grid-template-columns: 1fr; }
  .control-grid { grid-template-columns: 1fr; }
  .segmented { gap: 5px; }
  .check-grid { grid-template-columns: 1fr; }
  .action-panel { align-items: stretch; flex-direction: column; padding: 16px; }
  .primary-button { width: 100%; }
  .result-topline { align-items: stretch; flex-direction: column; }
  .result-actions button { flex: 1; }
  .output-card-head { align-items: flex-start; flex-direction: column; }
  .output-text { margin-top: 24px; }
  .method-card { grid-template-columns: 1fr; }
  .footer-inner { align-items: flex-start; flex-direction: column; gap: 4px; }
}

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