:root {
  --bg: #fbf9f7;
  --surface: #ffffff;
  --surface-2: #f2eeea;
  --text: #1d1b1a;
  --muted: #5f5955;
  --border: #e3ddd7;
  --accent: #9c1c2b;
  --accent-ink: #ffffff;
  --accent-soft: #f7e6e8;
  --key: #ffffff;
  --key-mod: #ebe6e1;
  --key-shadow: #d6cfc8;
  --altgr: #b3261e;
  --flash: #ffd9dd;
  --radius: 14px;
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-si: "Noto Sans Sinhala", "Nirmala UI", "Iskoola Pota", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161414;
    --surface: #1f1c1c;
    --surface-2: #282424;
    --text: #f1ece8;
    --muted: #b0a8a2;
    --border: #3a3433;
    --accent: #e0566a;
    --accent-ink: #1a0b0d;
    --accent-soft: #3a1f23;
    --key: #2b2727;
    --key-mod: #221f1f;
    --key-shadow: #121010;
    --altgr: #ff8a8a;
    --flash: #5a2a31;
  }
}

:root[data-theme="dark"] {
  --bg: #161414;
  --surface: #1f1c1c;
  --surface-2: #282424;
  --text: #f1ece8;
  --muted: #b0a8a2;
  --border: #3a3433;
  --accent: #e0566a;
  --accent-ink: #1a0b0d;
  --accent-soft: #3a1f23;
  --key: #2b2727;
  --key-mod: #221f1f;
  --key-shadow: #121010;
  --altgr: #ff8a8a;
  --flash: #5a2a31;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

.si { font-family: var(--font-si); }

a { color: var(--accent); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap { display: flex; align-items: center; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; }
.brand img { width: 30px; height: 30px; }
.nav { margin-left: auto; display: flex; gap: 20px; font-size: 15px; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--text); }
@media (max-width: 720px) { .nav .hide-sm { display: none; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 22px; border-radius: 999px;
  font-weight: 600; text-decoration: none; border: 1px solid transparent;
  cursor: pointer; font-size: 16px; font-family: inherit;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { border-color: var(--border); color: var(--text); background: var(--surface); }
.btn svg { width: 18px; height: 18px; }

/* Hero */
.hero { padding: 72px 0 48px; text-align: center; }
.hero img.logo { width: 88px; height: 88px; border-radius: 22px; box-shadow: 0 10px 30px rgb(156 28 43 / 25%); }
.hero h1 { font-size: clamp(32px, 6vw, 52px); line-height: 1.1; margin: 24px 0 8px; letter-spacing: -0.02em; }
.hero .si-title { font-size: clamp(20px, 3.5vw, 28px); color: var(--accent); margin: 0 0 18px; }
.hero p.lead { font-size: 19px; color: var(--muted); max-width: 640px; margin: 0 auto 30px; }
.hero .actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.hero .meta { margin-top: 16px; font-size: 14px; color: var(--muted); }

.screenshot { margin: 48px auto 0; max-width: 900px; }
.screenshot img { width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--border); box-shadow: 0 20px 50px rgb(0 0 0 / 12%); display: block; }

/* Sections */
section { padding: 64px 0; }
section.alt { background: var(--surface-2); }
h2 { font-size: clamp(26px, 4vw, 34px); margin: 0 0 8px; letter-spacing: -0.01em; }
.section-lead { color: var(--muted); margin: 0 0 32px; max-width: 680px; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.card h3 { margin: 0 0 6px; font-size: 17px; }
.card p { margin: 0; color: var(--muted); font-size: 15px; }
.card .ic { font-size: 26px; margin-bottom: 8px; display: block; }

/* Try-it */
.try { display: grid; gap: 16px; }
.try textarea {
  width: 100%; min-height: 110px; resize: vertical;
  font: 22px/1.6 var(--font-si); padding: 14px 16px;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}
.try textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: 600 14px var(--font); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.toolbar .hint { color: var(--muted); font-size: 14px; margin-left: auto; }

/* Keyboard */
.kb-scroll { overflow-x: auto; padding-bottom: 6px; }
.kb { min-width: 760px; display: grid; gap: 6px; user-select: none; }
.kb-row { display: flex; gap: 6px; }
.key {
  flex: var(--w, 1) 1 0; height: 58px; position: relative;
  background: var(--key); border: 1px solid var(--border);
  border-radius: 9px; box-shadow: 0 2px 0 var(--key-shadow);
  font-family: var(--font-si); cursor: pointer; padding: 0;
  color: var(--text); transition: background .12s, transform .05s;
}
.key:active, .key.flash { background: var(--flash); transform: translateY(1px); }
.key.mod { background: var(--key-mod); cursor: default; color: var(--muted); font: 12px var(--font); text-align: left; padding: 0 8px; }
.key span { position: absolute; line-height: 1; white-space: nowrap; }
.key .n { left: 7px; bottom: 7px; font-size: 21px; }
.key .s { left: 7px; top: 6px; font-size: 14px; color: var(--muted); }
.key .a { right: 6px; top: 6px; font-size: 13px; color: var(--altgr); }
.key .l { right: 6px; bottom: 5px; font: 10px var(--font); color: var(--muted); opacity: .8; }
.kb.layer-shift .key .s, .kb.layer-altgr .key .a { font-weight: 700; }
.kb.layer-shift .key .n, .kb.layer-altgr .key .n { opacity: .45; }
.legend { display: flex; flex-wrap: wrap; gap: 18px; font-size: 13px; color: var(--muted); margin-top: 10px; }
.legend b { color: var(--text); }
.legend .red { color: var(--altgr); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); font-size: 14px; color: var(--muted); font-weight: 600; }
td.out { font-family: var(--font-si); font-size: 22px; }
kbd {
  font: 600 13px var(--font); padding: 2px 7px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px;
}
.two-col { display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* Steps */
ol.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
ol.steps li { counter-increment: step; position: relative; padding: 18px 20px 18px 64px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
ol.steps li::before {
  content: counter(step); position: absolute; left: 18px; top: 16px;
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.note { background: var(--accent-soft); border-radius: var(--radius); padding: 14px 18px; margin-top: 18px; font-size: 15px; }

/* FAQ */
details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 20px; margin-bottom: 10px; }
summary { cursor: pointer; padding: 16px 0; font-weight: 600; }
details p { margin: 0 0 16px; color: var(--muted); }

/* Footer */
footer { border-top: 1px solid var(--border); padding: 32px 0 48px; color: var(--muted); font-size: 14px; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: center; }
footer nav { display: flex; flex-wrap: wrap; gap: 18px; }
footer a { color: var(--muted); }
footer .credit { flex-basis: 100%; font-size: 13px; }

/* Legal pages */
.legal { max-width: 760px; padding: 48px 16px 72px; }
.legal h1 { font-size: 36px; margin: 0 0 4px; }
.legal .updated { color: var(--muted); margin: 0 0 32px; }
.legal h2 { font-size: 21px; margin: 32px 0 8px; }
.legal p, .legal li { color: var(--text); }
.legal .summary { background: var(--surface-2); border-radius: var(--radius); padding: 16px 20px; }
