:root {
  --paper: #fbfaf8;
  --surface: #ffffff;
  --warm: #f4f1ec;
  --ink: #242321;
  --muted: #625e59;
  --quiet: #756f68;
  --line: #dcd6cf;
  --blue: #0769c3;
  --blue-dark: #0057a7;
  --blue-soft: #eaf4ff;
  --focus: #005fcc;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at 85% 0%, #edf6ff 0, transparent 29rem), var(--paper); }
button, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.shell { width: min(1050px, calc(100% - 2rem)); margin: 0 auto; padding: clamp(1.25rem, 3vw, 2rem) 0 3rem; }
.hero { max-width: 720px; margin: 0 auto 1.6rem; text-align: center; }
.eyebrow, .section-label, .mode-kicker { margin: 0; color: var(--blue); font-size: .75rem; font-weight: 750; letter-spacing: .12em; }
.hero h1 { margin: .55rem 0 0; font-size: clamp(1.8rem, 3.3vw, 2.8rem); line-height: 1.08; letter-spacing: -.04em; }
.intro { max-width: 550px; margin: .7rem auto 0; color: var(--muted); font-size: 1rem; line-height: 1.5; }

.tool { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 4px 18px rgba(36, 35, 33, .04), 0 2px 8px rgba(36, 35, 33, .025), 0 .8px 3px rgba(36, 35, 33, .02); }
.mode-picker { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; padding: .7rem; border-bottom: 1px solid var(--line); background: var(--warm); }
.mode { display: grid; gap: .26rem; min-height: 58px; border: 1px solid transparent; border-radius: 11px; padding: .65rem .85rem; background: transparent; color: var(--muted); text-align: left; font-size: .95rem; font-weight: 650; transition: background .16s ease, border-color .16s ease, color .16s ease; }
.mode:hover { background: rgba(255, 255, 255, .68); color: var(--ink); }
.mode.active { border-color: #b5d7f6; background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(36, 35, 33, .05); }
.mode:not(.active) .mode-kicker { color: var(--quiet); }

.converter { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; gap: 1rem; padding: clamp(1rem, 3vw, 1.6rem); }
.field { display: grid; gap: .55rem; color: var(--ink); font-size: .94rem; font-weight: 700; }
.field-meta { display: flex; justify-content: space-between; gap: .65rem; color: var(--quiet); font-size: .76rem; font-weight: 600; }
#limit-status { color: var(--blue-dark); text-align: right; }
textarea { width: 100%; min-height: 148px; resize: vertical; border: 1px solid #cfc8c0; border-radius: 12px; padding: .8rem .9rem; background: #fff; color: var(--ink); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1rem; line-height: 1.5; transition: border-color .16s ease, box-shadow .16s ease; }
textarea::placeholder { color: var(--quiet); }
textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #d9edff; }
#output { background: #f8fbfe; border-color: #c8dfef; color: #1a344a; }
.flow-arrow { display: grid; align-self: center; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: var(--blue-soft); color: var(--blue); font-size: 1.25rem; font-weight: 800; }
.copy-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem clamp(1rem, 3vw, 1.6rem); border-top: 1px solid var(--line); background: #fdfcfb; }
.privacy { margin: 0; color: var(--muted); font-size: .88rem; }
.privacy span { color: var(--blue); font-size: 1.15rem; font-weight: 900; vertical-align: -1px; }
.copy-actions { display: flex; align-items: center; justify-content: flex-end; gap: .7rem; }
.copy-status { max-width: 290px; margin: 0; color: var(--muted); font-size: .76rem; line-height: 1.35; text-align: right; }
.copy { min-height: 44px; border: 1px solid var(--blue); border-radius: 8px; padding: .65rem 1.15rem; background: var(--blue); color: #fff; font-weight: 700; transition: background .16s ease, transform .16s ease; }
.copy:disabled { cursor: not-allowed; border-color: #9da9b5; background: #9da9b5; }
.copy:hover:not(:disabled) { background: var(--blue-dark); transform: translateY(-1px); }
.copy:active:not(:disabled) { transform: translateY(0); }

.keyboard-help { padding: .85rem clamp(1rem, 3vw, 1.6rem) 1rem; border-bottom: 1px solid var(--line); background: #fdfcfb; }
.help-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .7rem; }
h2 { margin: 0; font-size: 1rem; letter-spacing: -.015em; }
.help-heading > p { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.4; }
.key-table { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: .35rem; }
.key { display: flex; min-height: 44px; align-items: center; justify-content: center; gap: .3rem; border: 1px solid #ddd7d0; border-radius: 8px; padding: .25rem .15rem; background: #fff; color: var(--ink); text-align: center; transition: background .14s ease, border-color .14s ease, transform .14s ease; }
.key:hover { border-color: #87bfe9; background: var(--blue-soft); transform: translateY(-1px); }
.key:active { transform: translateY(0); }
.key-latin { color: var(--blue-dark); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; font-weight: 750; }
.key-cyrillic { font-size: .88rem; font-weight: 750; }
.tool[data-direction="latin-to-cyrillic"] .key-latin { color: var(--muted); font-size: .72rem; font-weight: 650; }
.tool[data-direction="latin-to-cyrillic"] .key-cyrillic { color: var(--blue-dark); font-size: 1.04rem; }
.tool[data-direction="cyrillic-to-latin"] .key-latin { color: var(--blue-dark); font-size: .98rem; }
.tool[data-direction="cyrillic-to-latin"] .key-cyrillic { color: var(--muted); font-size: .74rem; font-weight: 650; }
.note { display: flex; align-items: baseline; flex-wrap: wrap; gap: .45rem .75rem; margin-top: 1.25rem; padding: 1rem 1.1rem; border-radius: 12px; background: var(--warm); color: var(--muted); font-size: .9rem; line-height: 1.5; }
.note strong { color: var(--ink); }
code { padding: .1rem .25rem; border-radius: 4px; background: #e8e4df; color: #38342f; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86em; }
a { color: var(--blue-dark); text-underline-offset: .16em; }
a:hover { color: var(--blue); }
a:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.site-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; max-width: 920px; margin: 0 auto 2rem; }
.brand { color: var(--ink); font-size: 1.05rem; font-weight: 800; letter-spacing: -.025em; text-decoration: none; }
.site-links { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: .5rem 1rem; }
.site-links a { font-size: .9rem; font-weight: 650; }

.guide-shell { width: min(800px, calc(100% - 2rem)); }
.guide-content { max-width: 720px; margin: 0 auto; }
.guide-header { margin-bottom: 2rem; }
.guide-content h1 { margin: .55rem 0 0; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.08; letter-spacing: -.04em; }
.guide-content h2 { margin-top: 2.2rem; font-size: clamp(1.15rem, 2.5vw, 1.4rem); }
.guide-content p, .guide-content li { color: var(--muted); font-size: 1rem; line-height: 1.65; }
.guide-content li + li { margin-top: .55rem; }
.steps { margin: 1rem 0 0; padding-left: 1.4rem; }
.table-wrap { overflow-x: auto; margin-top: 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { width: 100%; min-width: 520px; border-collapse: collapse; }
caption { padding: .85rem 1rem; color: var(--muted); font-size: .88rem; font-weight: 650; text-align: left; }
th, td { border-top: 1px solid var(--line); padding: .7rem .85rem; text-align: left; }
th { color: var(--ink); background: var(--warm); font-size: .87rem; }
td { color: var(--muted); }
.guide-cta { margin-top: 2.5rem; padding: 1.3rem; border: 1px solid #b5d7f6; border-radius: 14px; background: var(--blue-soft); }
.guide-cta h2 { margin-top: 0; }
.guide-button { display: inline-flex; align-items: center; justify-content: center; margin-top: .55rem; text-decoration: none; }

@media (min-width: 1080px) {
  .key-table { grid-template-columns: repeat(17, minmax(0, 1fr)); gap: .3rem; }
}

@media (max-width: 740px) {
  .shell { width: min(100% - 1.25rem, 620px); padding-top: 2.2rem; }
  .hero { margin-bottom: 1.6rem; text-align: left; }
  .site-nav { align-items: flex-start; flex-direction: column; margin-bottom: 1.6rem; }
  .site-links { justify-content: flex-start; }
  .intro { margin-left: 0; }
  .converter { grid-template-columns: 1fr; gap: .75rem; }
  .flow-arrow { transform: rotate(90deg); justify-self: center; }
  textarea { min-height: 150px; }
  .help-heading { display: block; }
  .help-heading > p { margin-top: .25rem; }
  .key-table { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}

@media (max-width: 410px) {
  .mode-picker { grid-template-columns: 1fr; }
  .key-table { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .32rem; }
  .key { min-height: 44px; }
  .copy-row { align-items: stretch; flex-direction: column; }
  .copy-actions { align-items: stretch; flex-direction: column-reverse; }
  .copy-status { max-width: none; text-align: left; }
  .copy { width: 100%; }
}

@media (max-width: 319px) {
  .shell { width: min(100% - 1rem, 620px); }
  .key-table { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
