/* Layout: stage + previews on the left, a control panel on the right; on phones the panel follows and the stage sticks to the top. */
:root {
  --paper: #f6f5ef; --card: #fffdf6; --ink: #1f2a2e; --muted: #5d6b6e;
  --line: #d6dbd4; --accent: #c34e24; --dark: #1a2e33; --sel: #2f6fd1;
  --check-a: #e9e9e4; --check-b: #ffffff;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 14px/1.45 var(--sans); }
button, input { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--sel); outline-offset: 2px; }

.app { display: grid; grid-template-columns: minmax(0, 1fr) 360px; min-height: 100vh; }
main { padding: 18px 20px 32px; min-width: 0; }
aside { background: var(--card); border-left: 1px solid var(--line); padding: 16px; overflow-y: auto; max-height: 100vh; position: sticky; top: 0; }

.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
h1 { font: 400 1.9rem/1.1 "Rozha One", Georgia, serif; margin: 0; }
h1 .tagline { display: block; font: 600 .95rem/1.3 var(--sans); color: var(--muted); margin-top: 4px; }
.lang { font-weight: 600; text-decoration: none; border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; background: var(--card); white-space: nowrap; }
.hint { color: var(--muted); margin: 10px 0 12px; max-width: 65ch; }
.hint.small { font-size: 12.5px; margin: 4px 0 10px; }

.textrow { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.textrow input { flex: 1; min-width: 0; font-size: 18px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }

.stage { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 36px 20px; min-height: 230px;
  display: flex; align-items: center; justify-content: center; overflow: auto; }
.stage.bg-white { background: #ffffff; }
.stage.bg-dark { background: var(--dark); }
.stage.bg-clear { background: repeating-conic-gradient(var(--check-a) 0 25%, var(--check-b) 0 50%) 0 0 / 18px 18px; }
.logo { display: flex; align-items: baseline; white-space: nowrap; user-select: none; -webkit-user-select: none; }
.logo .bl { display: inline-block; width: 0; height: 0; }
.ch { position: relative; display: inline-block; cursor: pointer; border-radius: 4px; line-height: 1; padding: 0 1px; white-space: pre; }
.ch:hover { background: rgba(47, 111, 209, .08); }
.ch.sel { box-shadow: 0 0 0 2px var(--sel); background: rgba(47, 111, 209, .1); }
.clean .ch.sel, .clean .ch:hover { box-shadow: none; background: none; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.row.tools { margin-top: 14px; }
.push { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
button { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
button:hover { border-color: var(--ink); }
button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

.minis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 14px; }
.mini { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; overflow: hidden; background: var(--card); }
.mini.d { background: var(--dark); }
.mini small { display: block; color: var(--muted); margin-bottom: 8px; font-size: 11px; }
.mini.d small { color: #b9c6c8; }
.mini .ch { cursor: default; padding: 0; }

aside h2 { font-size: .95rem; margin: 18px 0 6px; }
aside h2:first-child { margin-top: 0; }
.selinfo { color: var(--muted); margin: 0 0 8px; }
.letters { display: flex; gap: 4px; flex-wrap: wrap; }
.letters button { min-width: 30px; padding: 5px 6px; }
#fontSearch { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: #fff; }
.fonts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; max-height: 440px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.fonts h3 { grid-column: 1 / -1; margin: 10px 4px 2px; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.fonts h3:first-child { margin-top: 4px; }
.fonts p { grid-column: 1 / -1; color: var(--muted); margin: 8px; }
.fonts button { overflow: hidden; text-align: left; padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; border-color: transparent; min-height: 52px; }
.fonts button span { font-size: 22px; line-height: 1.15; white-space: nowrap; }
.fonts button small { font-size: 10px; color: var(--muted); font-family: var(--sans); }
.fonts button.on small { color: #dfe7e8; }
.fonts button.mixed { border-color: var(--sel); }

.ctl { display: grid; grid-template-columns: 76px minmax(0, 1fr) 48px; gap: 8px; align-items: center; margin: 6px 0; }
.ctl output { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; }
.pairs { max-height: 260px; overflow-y: auto; }
.swatches { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.swatches button { width: 28px; height: 28px; padding: 0; border-radius: 50%; }
.swatches input[type=color] { width: 36px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; }
#linkOut { width: 100%; padding: 6px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; }
.saved { display: flex; flex-direction: column; gap: 6px; }
.saved .item { display: flex; gap: 6px; }
.saved .item button:first-child { flex: 1; text-align: left; }

.about { max-width: 760px; margin: 0 auto; padding: 32px 16px 8px; }
.about h2 { font-size: 1.1rem; margin: 22px 0 8px; }
.about h3 { font-size: 1rem; margin: 16px 0 4px; }
.about p { margin: 0 0 8px; max-width: 65ch; color: var(--ink); }
.licence { color: var(--muted) !important; }
footer { max-width: 760px; margin: 0 auto; padding: 16px 16px 40px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }

@media (max-width: 860px) {
  /* main becomes transparent so the sticky stage is bounded by the whole app, not by main */
  .app { display: block; padding: 16px 16px 32px; }
  main { display: contents; }
  aside { position: static; max-height: none; border-left: 0; border-top: 1px solid var(--line); margin: 16px -16px 0; }
  .stage { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 3; padding: 18px 12px; min-height: 110px;
    box-shadow: 0 6px 16px rgba(26, 46, 51, .12); }
  .push { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
