/* keyboard.webtech360.com — fast, friendly, responsive (mobile / tablet / desktop) */

:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #eef2fb;
  --text: #1a2233;
  --muted: #5b6677;
  --border: #dbe2ef;
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --primary-soft: #e6efff;
  --key-bg: #ffffff;
  --key-shadow: 0 1px 0 #c9d4ea;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow: 0 6px 24px rgba(20, 40, 90, 0.08);
  --maxw: 880px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}
[data-theme="dark"] {
  --bg: #0f1420;
  --surface: #171e2e;
  --surface-2: #1f283b;
  --text: #e8edf7;
  --muted: #9aa7bd;
  --border: #2a3548;
  --primary: #4f8cff;
  --primary-ink: #0b1020;
  --primary-soft: #1c2942;
  --key-bg: #202a3d;
  --key-shadow: 0 1px 0 #0c1220;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 17px;
}
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.55rem, 4vw, 2.3rem); margin: 0 0 .5rem; }
h2 { font-size: clamp(1.25rem, 3vw, 1.6rem); margin: 2rem 0 1rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 1rem; }
.section { padding: 2rem 1rem 3rem; }

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--primary); color: var(--primary-ink); padding: .5rem 1rem; border-radius: 0 0 8px 0; z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---------- header ---------- */
.site-header {
  position: relative; z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 1rem; min-height: 58px; }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 1.25rem; }
.brand-name { font-size: 1.02rem; }
.main-nav { margin-inline-start: auto; display: flex; gap: 1rem; font-size: .95rem; }
.main-nav a { color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: .5rem; }
.lang-switch { display: flex; gap: .15rem; background: var(--surface-2); border-radius: 999px; padding: .15rem; }
.lang-switch a {
  font-size: .82rem; padding: .3rem .6rem; border-radius: 999px; color: var(--muted);
}
.lang-switch a[aria-current="true"] { background: var(--primary); color: var(--primary-ink); }
.lang-switch a:hover { text-decoration: none; }
.theme-toggle {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  width: 36px; height: 36px; border-radius: 999px; cursor: pointer; font-size: 1rem;
}
.theme-toggle:hover { background: var(--surface-2); }

/* ---------- hero ---------- */
.hero { padding: 3rem 0 1.5rem; text-align: center; }
.hero .lead { color: var(--muted); max-width: 620px; margin: 0 auto 1.4rem; font-size: 1.08rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 700; color: var(--primary); margin: 0 0 .4rem; }
.lead { font-size: 1.05rem; }
.btn-primary {
  display: inline-block; background: var(--primary); color: var(--primary-ink);
  padding: .7rem 1.4rem; border-radius: 999px; font-weight: 600;
}
.btn-primary:hover { text-decoration: none; filter: brightness(1.05); }

/* ---------- cards ---------- */
.card-grid {
  display: grid; gap: .8rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.kb-card {
  display: flex; align-items: center; gap: .75rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .9rem 1rem; color: var(--text); transition: transform .12s, box-shadow .12s, border-color .12s;
}
.kb-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary); }
.kb-card-icon { font-size: 1.5rem; }
.kb-card-body { display: flex; flex-direction: column; }
.kb-card-title { font-weight: 600; }
.kb-card-cat { font-size: .8rem; color: var(--muted); }

/* ---------- keyboard page ---------- */
.kb-page { padding: 1.5rem 1rem 3rem; }
.breadcrumb { font-size: .85rem; color: var(--muted); margin: .5rem 0 1.2rem; }
.breadcrumb a { color: var(--muted); }
.kb-head { margin-bottom: 1.2rem; }
.kb-head .lead { color: var(--muted); }

/* widget */
.kb-widget { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.kb-output {
  width: 100%; resize: vertical; min-height: 60px;
  font-size: 1.3rem; line-height: 1.45; padding: .7rem .9rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
}
.kb-output:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.kb-tools { display: flex; gap: .5rem; margin: .55rem 0 .7rem; }
.kb-btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: .5rem 1.1rem; border-radius: 999px; font-weight: 600; cursor: pointer; font-size: .95rem;
}
.kb-btn:hover { background: var(--primary-soft); }
.kb-copy.is-ok { background: #16a34a; color: #fff; border-color: #16a34a; }

.kb-keys { display: flex; flex-direction: column; gap: .35rem; }
.kb-row { display: flex; gap: .3rem; justify-content: center; flex-wrap: wrap; }
.kb-key {
  flex: 1 1 auto; min-width: 30px; min-height: 42px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.1rem; padding: .35rem;
  background: var(--key-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--key-shadow);
  cursor: pointer; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: transform .05s, background .12s;
}
.kb-key:hover { background: var(--primary-soft); }
.kb-key:active { transform: translateY(1px); background: var(--primary); color: var(--primary-ink); }
.kb-key-mod { flex: 1 1 64px; font-size: .82rem; color: var(--muted); }
.kb-key-sym { flex: 0 1 54px; font-weight: 600; color: var(--primary); }
.kb-key-punct { flex: 0 1 44px; }
.kb-key-space { flex: 6 1 180px; }
.kb-key-mod.is-active { background: var(--primary); color: var(--primary-ink); }
.kb-key-cn { color: var(--primary); font-weight: 600; flex-basis: 56px; }
/* pinyin candidate bar (Chinese IME) */
.kb-cands { display: flex; align-items: center; gap: .3rem; flex-wrap: nowrap; overflow-x: auto; min-height: 46px; margin-bottom: .5rem; }
.kb-cands-py { color: var(--muted); font-size: .9rem; padding: 0 .45rem; white-space: nowrap; }
.kb-cand { flex: 0 0 auto; min-width: 42px; min-height: 40px; padding: .2rem .55rem; font-size: 1.3rem; background: var(--key-bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--key-shadow); cursor: pointer; }
.kb-cand:hover { background: var(--primary-soft); }

/* howto / faq */
.howto-list { padding-inline-start: 1.2rem; }
.howto-list li { margin: .35rem 0; }
.faq details {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); padding: .2rem .4rem; margin: .5rem 0;
}
.faq summary { cursor: pointer; font-weight: 600; padding: .7rem .6rem; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary { display: flex; justify-content: space-between; align-items: center; }
.faq summary::after { content: "+"; color: var(--muted); }
.faq details[open] summary::after { content: "–"; }
.faq-a { padding: 0 .6rem .6rem; color: var(--muted); }

/* worked example + rules cheat sheet + about */
.kb-example, .kb-rules, .kb-about { margin-top: 2rem; }
.kb-example-phrase {
  font-size: 1.6rem; font-weight: 600; margin: .3rem 0 .2rem;
  padding: .6rem .9rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); display: inline-block;
}
.kb-steps { padding-inline-start: 1.3rem; margin: .6rem 0 0; }
.kb-steps li { margin: .25rem 0; font-variant-numeric: tabular-nums; }
.rule-grid { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .6rem; }
.rule-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: .28rem .7rem; font-size: .95rem;
}
.rule-chip b { color: var(--primary); font-weight: 700; }
.rule-chip span[aria-hidden] { color: var(--muted); }
.kb-about p { max-width: 70ch; }

.related { margin-top: 2.5rem; }
.notice { padding: 1rem; background: var(--surface-2); border-radius: var(--radius-sm); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 3rem; background: var(--surface); }
.footer-inner { display: flex; flex-wrap: wrap; gap: 1.5rem; justify-content: space-between; padding: 2rem 1rem; }
.footer-brand { max-width: 360px; }
.footer-brand p { margin: .4rem 0 0; }
.footer-meta { text-align: end; }
.footer-links { display: flex; flex-wrap: wrap; gap: .2rem 1.1rem; align-items: center; }
.footer-links a { color: var(--muted); font-size: .9rem; }

/* static / legal pages */
.static-page { padding: 1.5rem 1rem 3rem; }
.static-head { margin-bottom: 1rem; }
.prose { max-width: 760px; }
.prose h2 { font-size: 1.2rem; margin: 1.8rem 0 .6rem; }
.prose p { margin: 0 0 1rem; }
.prose ul { padding-inline-start: 1.3rem; margin: 0 0 1rem; }
.prose li { margin: .35rem 0; }
.prose a { text-decoration: underline; }

/* cookie consent banner (Consent Mode v2) */
.consent {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%);
  z-index: 80; width: min(720px, calc(100% - 1.5rem));
  display: flex; flex-wrap: wrap; align-items: center; gap: .7rem 1rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem 1.1rem;
}
.consent[hidden] { display: none; }
.consent-text { margin: 0; font-size: .9rem; flex: 1 1 320px; color: var(--muted); }
.consent-text a { color: var(--primary); }
.consent-actions { display: flex; gap: .5rem; margin-inline-start: auto; }
@media (max-width: 600px) {
  .consent { left: 0; bottom: 0; transform: none; width: 100%; border-radius: var(--radius) var(--radius) 0 0; }
  .consent-actions { width: 100%; }
  .consent-actions .kb-btn, .consent-actions .btn-primary { flex: 1; text-align: center; }
}

/* ---------- adjacent tools (tester / typing) ---------- */
.tool-widget { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }

.tester-status { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin-bottom: 1rem; }
.tester-last { font-weight: 600; }
.tester-count { color: var(--muted); }
.tester-status .kb-btn { margin-inline-start: auto; }
/* unit-based board: each cell = units × --tu; keys line up like a real keyboard */
.tester-board { --tu: 2.55rem; display: flex; flex-direction: column; gap: 0; overflow-x: auto; padding-bottom: .3rem; width: max-content; max-width: 100%; margin-inline: auto; }
.tester-row { display: flex; gap: 0; }
.tester-cell { box-sizing: border-box; flex: 0 0 auto; padding: 2px; height: calc(var(--tu) + .35rem); }
.tester-cell.is-spacer { background: none; }
.tester-key {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; line-height: 1.05; padding: .15rem; text-align: center; white-space: nowrap; overflow: hidden;
  background: var(--key-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--key-shadow);
  -webkit-user-select: none; user-select: none; transition: background .08s, color .08s, transform .05s;
}
.tester-key.is-tested { border-color: #16a34a; }
.tester-key.is-down { background: var(--primary); color: var(--primary-ink); transform: translateY(1px); }
.tester-key.is-tested:not(.is-down) { background: color-mix(in srgb, #16a34a 16%, var(--key-bg)); }
/* sectioned full-size: main | nav | numpad columns line up; numpad is a grid with tall +/Enter */
.tester-body { display: flex; align-items: flex-start; }
.tester-col { display: flex; flex-direction: column; }
.tester-nav { margin-inline-start: calc(var(--tu) * 1); }
.tester-numpad { margin-inline-start: calc(var(--tu) * 0.5); display: grid; grid-template-columns: repeat(4, var(--tu)); grid-auto-rows: calc(var(--tu) + .35rem); }
.tester-numpad .tester-cell { width: auto; height: auto; }
.tester-key.is-notest { opacity: .5; }
.tester-sound { padding-inline: .6rem; font-size: 1rem; }
.tester-sound.is-off { opacity: .6; }
@media (max-width: 900px) { .tester-board { --tu: 1.9rem; } .tester-key { font-size: .62rem; } }

.typing-display {
  font-size: 1.25rem; line-height: 1.9; letter-spacing: .01em;
  padding: 1rem; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--border);
  white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.typing-display span.is-correct { color: #16a34a; }
.typing-display span.is-wrong { color: #fff; background: #dc2626; border-radius: 3px; }
.typing-display span.is-current { background: var(--primary-soft); border-bottom: 2px solid var(--primary); }
.typing-input {
  width: 100%; margin-top: .8rem; resize: none; overflow: auto; box-sizing: border-box;
  font-size: 1.1rem; line-height: 1.6; padding: .7rem .9rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-family: inherit;
}
.typing-input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
/* custom-text editor + toolbar */
.typing-toolbar { display: flex; justify-content: flex-end; margin-bottom: .7rem; }
.typing-edit-area {
  width: 100%; box-sizing: border-box; min-height: 130px; resize: vertical;
  font-size: 1rem; line-height: 1.6; padding: .7rem .9rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-family: inherit;
}
.typing-edit-actions { display: flex; gap: .5rem; margin-top: .7rem; }
.typing-stats { display: flex; gap: .7rem; margin: 1rem 0 .8rem; }
.typing-stats .stat {
  flex: 1; text-align: center; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .6rem .4rem;
}
.typing-stats .stat strong { display: block; font-size: 1.5rem; color: var(--primary); line-height: 1.1; }
.typing-stats .stat span { font-size: .8rem; color: var(--muted); }
.typing-stats .stat.is-done strong { color: #16a34a; }

/* tester: layout picker + progress + typing result panel */
.tester-pick-label { margin: 0 0 .4rem; }
.tester-layouts { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.tester-layout-btn {
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .5rem .7rem; cursor: pointer; color: var(--muted); min-width: 84px;
}
.tester-layout-btn:hover { border-color: var(--primary); }
.tester-layout-btn.is-active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.tester-thumb { display: block; width: 56px; height: 26px; color: currentColor; }
.tester-thumb svg { width: 100%; height: 100%; }
.tester-layout-name { font-size: .82rem; font-weight: 600; }

.tester-bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: 1rem; }
.tester-bar span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .15s; }
.tester-bar span.is-full { background: #16a34a; }

.typing-result {
  margin-top: 1rem; padding: 1.1rem 1.2rem; border-radius: var(--radius-sm);
  background: var(--primary-soft); border: 1px solid var(--primary);
}
.typing-result h3 { margin: 0 0 .4rem; }
.result-big { font-size: 1.15rem; margin: 0 0 .3rem; }
.result-big strong { font-size: 1.6rem; color: var(--primary); }
.rating-badge { display: inline-block; background: var(--primary); color: var(--primary-ink); padding: .1rem .6rem; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.result-pctl { font-size: 1.1rem; font-weight: 600; margin: .2rem 0; }

/* wider page for tools so the full keyboard fits on desktop; keep prose readable */
.tool-page.container { max-width: 1060px; }
.tool-page .breadcrumb, .tool-page .kb-head, .tool-page .kb-about, .tool-page .kb-howto, .tool-page .faq, .tool-page .related { max-width: 820px; }

/* ---------- responsive ---------- */
@media (max-width: 600px) {
  body { font-size: 16px; }
  .brand-name { display: none; }
  .main-nav { font-size: .9rem; }
  .kb-widget { padding: .7rem; }
  .kb-output { font-size: 1.15rem; min-height: 52px; }
  .kb-keys { gap: .28rem; }
  .kb-row { gap: .26rem; }
  .kb-key { min-width: 24px; min-height: 38px; font-size: 1rem; padding: .25rem; border-radius: 7px; }
  .kb-key-mod, .kb-key-sym { font-size: .72rem; flex-basis: 48px; }
  .kb-key-punct { flex-basis: 34px; }
  .footer-inner { flex-direction: column; }
  .footer-meta { text-align: start; }
}
@media (min-width: 1024px) {
  .kb-widget { padding: 1.3rem; }
  .kb-key { min-height: 48px; font-size: 1.2rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
