/* Uzbek Latin ⇄ Cyrillic converter */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #edf3f9;
  --panel: #ffffff;
  --field: #f8fafd;
  --field-result: #eff9fd;
  --border: #d8e2ee;
  --text: #172234;
  --muted: #5d6b81;
  --accent: #0b7fa8;
  --accent-strong: #076385;
  --accent-soft: #ddf0f9;
  --on-accent: #ffffff;
  --ok: #17843c;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(23 34 52 / 0.05), 0 10px 30px rgb(23 34 52 / 0.07);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1322;
    --panel: #141d30;
    --field: #0f1728;
    --field-result: #0f2233;
    --border: #273549;
    --text: #e7eef9;
    --muted: #8fa0b8;
    --accent: #45b6e4;
    --accent-strong: #7cd0f4;
    --accent-soft: #12344a;
    --on-accent: #062736;
    --ok: #4ade80;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.5), 0 14px 34px rgb(0 0 0 / 0.4);
  }
}

html { color-scheme: light dark; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(1200px 420px at 50% -160px, var(--accent-soft), transparent 70%),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.page { max-width: 1120px; margin: 0 auto; padding: 40px 20px 56px; }

/* ---------- header ---------- */

.header { text-align: center; margin-bottom: 26px; }
.header h1 {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.header .accent { color: var(--accent-strong); }
.tagline { margin: 0 auto; max-width: 46rem; color: var(--muted); font-size: 1rem; }

/* ---------- direction controls ---------- */

.controls {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 12px; margin-bottom: 20px;
}

.segmented {
  display: inline-flex; gap: 4px; padding: 4px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; box-shadow: var(--shadow);
}
.seg {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 0.92rem; font-weight: 500;
  padding: 8px 16px; border-radius: 999px; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.seg:hover { color: var(--text); }
.seg.active { background: var(--accent); color: var(--on-accent); font-weight: 600; }

.detected {
  margin: 0; font-size: 0.85rem; font-weight: 600;
  color: var(--accent-strong); background: var(--accent-soft);
  border-radius: 999px; padding: 6px 14px;
}

/* ---------- panels ---------- */

.panels { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: stretch; }

.panel {
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 16px 12px;
}

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-title { margin: 0; font-size: 0.95rem; font-weight: 700; }
.panel-tools { display: flex; gap: 8px; }

textarea {
  width: 100%; min-height: 190px; max-height: 55vh;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--field); color: var(--text);
  font: inherit; font-size: 1rem; line-height: 1.6;
  resize: none; overflow-y: auto; outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#target { background: var(--field-result); }
textarea:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea::placeholder { color: var(--muted); opacity: 0.75; }

.stats { margin: 0; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- buttons ---------- */

.btn { appearance: none; font: inherit; cursor: pointer; border-radius: 999px; }
.btn.ghost {
  border: 1px solid var(--border); background: transparent; color: var(--muted);
  font-size: 0.85rem; font-weight: 500; padding: 6px 14px;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.btn.ghost:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.btn.ghost.ok { color: var(--ok); border-color: var(--ok); background: transparent; }
.btn:focus-visible, .seg:focus-visible, .swap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.swap-wrap { display: flex; align-items: center; }
.swap {
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--panel); color: var(--accent-strong);
  font-size: 1.2rem; line-height: 1; box-shadow: var(--shadow); cursor: pointer;
  transition: transform 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.swap:hover { transform: rotate(180deg); color: var(--accent); border-color: var(--accent); }

/* ---------- exceptions ---------- */

.exceptions {
  margin-top: 18px; padding: 14px 18px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.exceptions label { display: block; font-size: 0.85rem; font-weight: 700; margin-bottom: 8px; }
.exceptions input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--field); color: var(--text); font: inherit; font-size: 0.92rem;
  outline: none; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.exceptions input:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.exceptions .hint { margin: 8px 0 0; font-size: 0.8rem; color: var(--muted); }

/* ---------- letter reference ---------- */

.reference {
  margin-top: 18px; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.reference summary {
  cursor: pointer; padding: 15px 20px; font-weight: 700; font-size: 0.98rem;
  list-style: none; display: flex; align-items: center; justify-content: space-between;
}
.reference summary::-webkit-details-marker { display: none; }
.reference summary::after { content: "▾"; color: var(--muted); transition: transform 0.2s ease; }
.reference[open] summary::after { transform: rotate(180deg); }
#referenceBody { padding: 2px 20px 20px; }

.ref-title {
  margin: 16px 0 8px; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: var(--mono); font-size: 0.82rem;
  border: 1px solid var(--border); background: var(--field);
  border-radius: 10px; padding: 5px 10px; white-space: nowrap;
}
.chip b { color: var(--accent-strong); font-weight: 600; }
.chip .arrow { color: var(--muted); margin: 0 6px; }
.chip.has-note { border-style: dashed; cursor: help; }

.ref-notes { margin: 16px 0 0; padding-left: 18px; color: var(--muted); font-size: 0.86rem; }
.ref-notes li { margin: 5px 0; }
.ref-notes code { font-family: var(--mono); font-size: 0.82rem; color: var(--accent-strong); }

/* ---------- footer ---------- */

.footer { margin-top: 26px; text-align: center; color: var(--muted); font-size: 0.83rem; }

/* ---------- responsive ---------- */

@media (max-width: 880px) {
  .page { padding-top: 28px; }
  .panels { grid-template-columns: 1fr; }
  .swap-wrap { justify-content: center; }
}
