/* ============================================================
   CORRECT KEYBOARD — THE SITE'S DRAWING OF THE PRODUCT
   The flat "ergonomics pass" the product ships today, drawn from
   the product's own numbers rather than from the older design
   master (design/README.md still describes the machined v1.3
   material, and is stale):

     colours    android/.../keyboard/KeyboardTheme.kt:247-383
                ios/Sources/CorrectKit/Keyboard/KeyboardTheme.swift:218-300
     geometry   KeyboardGeometry.kt:151-178, ToolbarLayout.kt:119-177
     marks      KeyIcons.kt:202-430 (drawFormatMark, drawFormulateMark,
                drawWriteMark, drawTranslateMark)

   "One flat face per key role — no gradient, no chamfer band, no
   light catch, no sheen. One hairline of shadow under each cap. A
   pressed key is a change of value, not travel. A flat deck, one
   colour top to bottom." (KeyboardTheme.kt:262-273)

   Everything is drawn at a phone's own width (--kb-w, 390px — a
   phone in dp) and scaled into whatever box the page gives it.
   ============================================================ */

@import url("./fonts/fonts.css");

:root{
  --kb-w:390px;
  --kh:47px;              /* row pitch, portrait: clamp(h × .058, 44, 50) × size */
  --gap:6px;              /* horizontal gap, KeyboardGeometry */
  --vgap:9px;             /* vertical gap, portrait */
  --kr:6px;               /* Themes.KEY_RADIUS_DP — every key, both themes */
  --deck-px:4px;
  --strip-h:30px;         /* suggestion strip, portrait */
  --ai-h:36px;            /* AI row; its keys fill 84% of it */
  --label:20px;           /* clamp(row × .44, 17, 22) */
  --digit:18px;
  --ai-label:13px;        /* clamp(base × .60, 12, 14) */
  --sans:"Inter",-apple-system,"Segoe UI",Roboto,sans-serif;
  --hebrew:"Heebo","Inter",-apple-system,sans-serif;
}

/* ============================================================
   THEMES — the product's two, by value
   ============================================================ */
[data-theme="dark"]{
  --deck:#151618;
  --key:#424448;       --key-press:#5C5E62;  --key-shadow:#08090A;
  --mod:#2A2C30;       --mod-press:#424448;  --mod-shadow:#08090A;
  --chip:#2C2F33;      --chip-press:#45474B;
  --ink:#F1F2F4;       --ink-soft:#C9CCD0;   --ink-dim:#8C9096;
  --hint:rgba(241,242,244,.36);
  --predict-ink:#E6E8EB;
  --rule:rgba(255,255,255,.12);
  --wash:rgba(255,255,255,.14);
  --card:#1C1E21;      --card-rim:rgba(255,255,255,.08);
  --well:#151618;
  --accent:#8FA9CF;    --running:#6FB58C;
  --pop:#4C4F55;
}
[data-theme="light"]{
  --deck:#D5D2CD;
  --key:#FCFBF8;       --key-press:#E2DFD9;  --key-shadow:#A8A49D;
  --mod:#BAB6AF;       --mod-press:#FCFBF8;  --mod-shadow:#A09C95;
  --chip:#EEECE8;      --chip-press:#D9D6D0;
  --ink:#1B1A18;       --ink-soft:#3A3834;   --ink-dim:#6E6B65;
  --hint:rgba(27,26,24,.36);
  --predict-ink:#232220;
  --rule:rgba(62,59,53,.20);
  --wash:rgba(62,59,53,.12);
  --card:linear-gradient(180deg,#FBFAF7,#F4F2EC);
  --card-rim:rgba(62,59,53,.12);
  --well:#ECEAE4;
  --accent:#35598C;    --running:#2E7D57;
  --pop:#FCFBF8;
}

/* ============================================================
   THE DECK
   ============================================================ */
.kb{
  width:var(--kb-w);
  background:var(--deck);
  padding:4px var(--deck-px) 8px;
  display:flex;flex-direction:column;
  font-family:var(--sans);
  -webkit-font-smoothing:antialiased;
  position:relative;
  border-radius:0;
}
.kb.rounded{border-radius:14px}

/* ---- suggestion strip: words, hairlines, nothing else ---- */
.strip{
  height:var(--strip-h);display:flex;align-items:stretch;
  margin:0 2px 2px;
}
.strip .p{
  flex:1 1 0;min-width:0;display:grid;place-items:center;position:relative;
  font-size:15px;font-weight:450;color:var(--predict-ink);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding:0 6px;
  border-radius:6px;
  transition:background-color .18s ease,color .18s ease;
}
.strip .p + .p::before{
  content:"";position:absolute;inset-inline-start:0;top:28%;bottom:28%;
  width:1px;background:var(--rule);
}
.strip .p.best{font-weight:600}
.strip .p.on{background:var(--wash)}
.strip .p.learned::after{
  content:"";position:absolute;bottom:3px;left:50%;transform:translateX(-50%);
  width:4px;height:4px;border-radius:50%;background:var(--running);
}

/* ---- the AI row: three equal keys, then Translate ---- */
.ai{
  height:var(--ai-h);display:flex;align-items:center;gap:var(--gap);
  margin-bottom:6px;
}
.chip{
  flex:1 1 0;min-width:0;height:84%;
  border-radius:calc(var(--kr) * .8);
  background:var(--chip);
  display:flex;align-items:center;justify-content:center;gap:6px;
  color:var(--ink-soft);font-size:var(--ai-label);font-weight:500;letter-spacing:.005em;
  position:relative;white-space:nowrap;
  transition:background-color .16s ease,color .16s ease;
}
.chip > svg{width:calc(var(--ai-label) * 1.08);height:calc(var(--ai-label) * 1.08);flex:none;opacity:.92;overflow:visible}
.chip.on{background:var(--chip-press);color:var(--ink)}
/* in flight: three pulsing dots inside the key that was tapped (AiToolbarView:790-805) */
.chip .busy{display:none;gap:3px;align-items:center}
.chip.busy > :not(.busy){display:none}
.chip.busy .busy{display:inline-flex}
.chip .busy i{width:4px;height:4px;border-radius:50%;background:currentColor;opacity:.35;animation:kb-busy 1s infinite ease-in-out}
.chip .busy i:nth-child(2){animation-delay:.15s}
.chip .busy i:nth-child(3){animation-delay:.3s}
@keyframes kb-busy{0%,80%,100%{opacity:.3}40%{opacity:1}}

/* the compact Translate key: the A/文 mark and the target's badge */
.chip.tr{
  flex:0 0 auto;width:62px;gap:5px;padding:0 6px;
}
.chip.tr > svg{width:15px;height:15px}
.chip.tr .badge{font-size:11px;font-weight:600;letter-spacing:.04em;color:var(--ink-soft);direction:ltr}
/* translating: a green hairline runs round the key (runningAccent, 1600ms a lap) */
.chip.tr.running{box-shadow:0 0 0 1.5px var(--running)}
.chip.tr.running::after{
  content:"";position:absolute;inset:-1.5px;border-radius:inherit;pointer-events:none;
  background:conic-gradient(from var(--lap,0deg),transparent 0 70%,var(--running) 85%,transparent 100%);
  -webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);
  -webkit-mask-composite:xor;mask-composite:exclude;padding:1.5px;
  animation:kb-lap 1.6s linear infinite;
}
@property --lap{syntax:'<angle>';inherits:false;initial-value:0deg}
@keyframes kb-lap{to{--lap:360deg}}

/* ---- the result card sits between the AI row and the keys ---- */
.kb-card{
  margin:0 0 8px;padding:10px 10px 10px;
  border-radius:calc(var(--kr) * 1.4);
  background:var(--card);box-shadow:inset 0 0 0 1px var(--card-rim);
  color:var(--ink);
}
.kb-card[hidden]{display:none}
.kb-card-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:0 2px 7px}
.kb-card-label{font-size:12px;font-weight:600;color:var(--ink-dim);letter-spacing:.01em;display:inline-flex;align-items:center;gap:6px}
.kb-card-label svg{width:13px;height:13px}
.kb-card-headline{font-size:14px;font-weight:600;margin:0 2px 3px;color:var(--ink)}
.kb-card-reason{font-size:12.5px;margin:0 2px 8px;color:var(--ink-dim)}
.kb-card-body{
  background:var(--well);border-radius:calc(var(--kr) * 1.4);
  padding:9px 11px;font-size:15px;line-height:1.35;color:var(--ink);
  margin:0 0 9px;white-space:pre-line;
}
.kb-card-actions{display:flex;gap:var(--gap)}
.kb-btn{
  flex:1 1 0;min-height:40px;border-radius:calc(var(--kr) * 1.2);
  display:grid;place-items:center;padding:0 10px;
  font-size:14px;font-weight:600;color:var(--ink);
  background:var(--chip);border:0;font-family:inherit;
  transition:background-color .16s ease;
}
.kb-btn.primary{background:var(--key);box-shadow:0 1px 0 var(--key-shadow)}
.kb-btn.on{background:var(--key-press)}

/* ---- rows and keys ---- */
.rows{display:flex;flex-direction:column;gap:var(--vgap)}
.row{display:flex;gap:var(--gap);height:calc(var(--kh) - var(--vgap))}
.sp{flex:var(--u,1) 1 0;pointer-events:none}
.key{
  flex:var(--u,1) 1 0;min-width:0;position:relative;
  border-radius:var(--kr);
  background:var(--key);
  box-shadow:0 1px 0 var(--key-shadow);
  display:grid;place-items:center;
  color:var(--ink);font-size:var(--label);font-weight:400;line-height:1;
  transition:background-color .12s ease;
}
.key > .g{display:grid;place-items:center;line-height:1}
.key.mod{background:var(--mod);box-shadow:0 1px 0 var(--mod-shadow);color:var(--ink)}
.key.mod svg{width:21px;height:21px;stroke:currentColor;fill:none;display:block}
.key.mod svg [fill="currentColor"]{fill:currentColor;stroke:none}
.key.on{background:var(--key-press)}
.key.mod.on{background:var(--mod-press)}
.key.num{font-size:15px;font-weight:500}
.key.digit{font-size:var(--digit)}
.key.space{font-size:14px;font-weight:450;color:var(--ink-soft)}
.key.punct{font-size:calc(var(--label) + 2px)}
.key.punct > .g{transform:translateY(-3px)}
/* the long-press corner hint */
.key .alt{
  position:absolute;top:3px;inset-inline-end:5px;
  font-size:10px;font-weight:500;line-height:1;color:var(--hint);
}
.key .dot{
  position:absolute;top:5px;inset-inline-end:5px;
  width:3px;height:3px;border-radius:50%;background:var(--hint);
}

/* ============================================================
   SCRIPT OPTICS — the same key, three scripts
   ============================================================ */
.kb[data-lang="en"]{--label:21px}
.kb[data-lang="he"]{--label:21px;--digit:18px}
[data-lang="he"] .key,[data-lang="he"] .chip,[data-lang="he"] .strip .p,
[data-lang="he"] .kb-card{font-family:var(--hebrew)}
[data-lang="he"] .key.digit,[data-lang="he"] .key.num,[data-lang="he"] .key.space,
[data-lang="he"] .key.punct,[data-lang="he"] .chip .badge{font-family:var(--sans)}
[data-lang="he"] .chip{font-size:14px}

/* RTL: the whole instrument turns, numerals do not */
.kb.rtl{direction:rtl}
.kb.rtl .row.ltr{direction:ltr}
.kb.rtl .key.mod.mirror svg{transform:scaleX(-1)}

/* ============================================================
   QUICK SETTINGS — the panel a hold on the globe opens
   Two theme tiles and one row through to everything else
   (SettingsSheet.kt, QuickSettingsView.swift).
   ============================================================ */
.qs{
  background:var(--deck);color:var(--ink);font-family:var(--sans);
  padding:12px 10px 12px;border-radius:14px;width:100%;
}
[data-lang="he"] .qs,.qs[dir="rtl"]{font-family:var(--hebrew)}
.qs-head{display:flex;align-items:center;justify-content:space-between;margin:0 4px 10px}
.qs-title{font-size:15px;font-weight:600}
.qs-done{font-size:14px;font-weight:600;color:var(--accent);background:none;border:0;padding:4px 2px;font-family:inherit}
.qs-tiles{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:8px}
.qs-tile{
  border:0;font-family:inherit;text-align:start;cursor:pointer;
  border-radius:calc(var(--kr) * 1.4);padding:9px 9px 10px;
  background:var(--chip);color:var(--ink-soft);
  box-shadow:inset 0 0 0 1.5px transparent;
  display:flex;flex-direction:column;gap:8px;min-height:44px;
  transition:box-shadow .16s ease,color .16s ease;
}
.qs-tile.on{box-shadow:inset 0 0 0 1.5px var(--accent);color:var(--ink)}
.qs-swatch{display:grid;grid-template-columns:repeat(4,1fr);gap:3px;padding:5px;border-radius:6px}
.qs-swatch i{height:9px;border-radius:2px}
.qs-tile[data-value="dark"] .qs-swatch{background:#151618}
.qs-tile[data-value="dark"] .qs-swatch i{background:#424448}
.qs-tile[data-value="light"] .qs-swatch{background:#D5D2CD}
.qs-tile[data-value="light"] .qs-swatch i{background:#FCFBF8}
.qs-name{font-size:13.5px;font-weight:600}
.qs-name em{font-style:normal;font-weight:450;color:var(--ink-dim)}
.qs-row{
  display:flex;align-items:center;justify-content:space-between;
  padding:11px 10px;border-radius:calc(var(--kr) * 1.4);background:var(--chip);
  font-size:13.5px;font-weight:500;color:var(--ink);
}
.qs-row svg{width:14px;height:14px;stroke:currentColor;fill:none;opacity:.6}
.qs[dir="rtl"] .qs-row svg{transform:scaleX(-1)}

@media (prefers-reduced-motion:reduce){
  .chip .busy i,.chip.tr.running::after{animation:none}
  .chip,.key,.strip .p,.qs-tile,.kb-btn{transition:none}
}
