:root {
  --bg: #ffffff;
  --bg-alt: #f5f7fb;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #5b6475;
  --border: #e3e8f0;
  --accent: #1a8cff;
  --accent-strong: #0b6fd6;
  --accent-soft: #e6f2ff;
  --code-bg: #eef2f7;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-si: "Noto Sans Sinhala", "Sinhala Sangam MN", "Iskoola Pota", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --bg-alt: #0f172a;
    --surface: #131c2e;
    --text: #e6ebf3;
    --muted: #96a0b3;
    --border: #233047;
    --accent: #4aa8ff;
    --accent-strong: #79bfff;
    --accent-soft: #13294a;
    --code-bg: #1b2539;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { display: block; }
button { -webkit-tap-highlight-color: transparent; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, kbd {
  font-family: var(--font-mono);
  font-size: .88em;
  background: var(--code-bg);
  padding: .12em .4em;
  border-radius: 6px;
}

kbd { border: 1px solid var(--border); border-bottom-width: 2px; }

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

.container { max-width: 1040px; margin: 0 auto; padding: 0 20px; }

/* Nav */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 7px; }
.brand { flex-shrink: 0; }
.nav-links { display: flex; gap: 22px; font-size: .95rem; }
.nav-links a { color: var(--muted); }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links .gh { color: var(--text); font-weight: 600; }

/* Hero */
.hero { padding: 88px 0 72px; text-align: center; background: radial-gradient(ellipse 80% 60% at 50% 0%, var(--accent-soft), transparent 70%); }
.hero-icon { margin: 0 auto 28px; border-radius: 26px; box-shadow: 0 12px 40px rgba(26, 140, 255, .3); }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.15; letter-spacing: -.02em; margin: 0 0 20px; }
.accent { color: var(--accent); }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 640px; margin: 0 auto 32px; }
.lead .si { color: var(--text); font-weight: 600; }
.cta { display: flex; justify-content: center; align-items: stretch; gap: 12px; flex-wrap: wrap; }
.meta { margin: 20px 0 0; color: var(--muted); font-size: .9rem; }

.btn {
  display: inline-flex; align-items: center;
  height: 52px; padding: 0 28px;
  background: var(--accent); color: #fff; font-weight: 600;
  border-radius: 12px;
  transition: background .15s;
}
.btn:hover { background: var(--accent-strong); text-decoration: none; }

.cmd {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 6px 6px 16px;
  min-height: 52px;
  max-width: 100%;
  min-width: 0;
  box-shadow: var(--shadow);
}
.cmd code {
  flex: 1;
  min-width: 0;
  background: none;
  padding: 4px 0;
  text-align: left;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.cmd code::-webkit-scrollbar { display: none; }
.cmd.block { display: flex; margin: 12px 0 0; }

.copy {
  flex-shrink: 0;
  font: 500 .85rem var(--font);
  color: var(--accent);
  background: var(--accent-soft);
  border: 0; border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}
.copy:hover { filter: brightness(.96); }

/* Sections */
.section { padding: 80px 0; }
.section.alt { background: var(--bg-alt); }
h2 { font-size: clamp(1.6rem, 4vw, 2rem); line-height: 1.25; letter-spacing: -.01em; margin: 0 0 8px; }
h3 { font-size: 1.1rem; line-height: 1.4; margin: 40px 0 14px; }
.sub { color: var(--muted); margin: 0 0 32px; }
.note { color: var(--muted); font-size: .92rem; margin: 16px 0 0; }

/* Demo */
.demo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.demo-pane {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  min-width: 0;
  min-height: 180px;
}
.demo-pane:focus-within { border-color: var(--accent); }
.pane-label { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
#demo-input {
  flex: 1; width: 100%;
  border: 0; outline: 0; resize: none;
  padding: 0;
  font: 1.1rem/1.6 var(--font-mono);
  color: var(--text); background: transparent;
}
#demo-output { flex: 1; font-size: 1.5rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chips::before { content: "Examples"; align-self: center; margin-right: 4px; font-size: .85rem; color: var(--muted); }
.chip {
  font: .88rem var(--font-mono);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}
.chip { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0 8px; max-width: 100%; text-align: left; }
.chip-keys, .chip-out { white-space: nowrap; }
.chip:hover { border-color: var(--accent); }
.chip:hover .chip-keys { color: var(--accent); }
.chip-out { font-size: .95rem; color: var(--muted); }

.layout-switch { margin-bottom: 12px; }
.layout-hint { color: var(--muted); font-size: .92rem; margin: 0 0 20px; }

/* On-screen Wijesekara keyboard */
.keyboard {
  display: grid;
  gap: 6px;
  margin-top: 24px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  user-select: none;
  -webkit-user-select: none;
}
.keyboard[hidden] { display: none; }
.kb-row { display: flex; justify-content: center; gap: 6px; min-width: min-content; }
.kb-key {
  flex: 0 0 auto;
  width: 56px; height: 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 0;
  font: 500 .85rem var(--font);
  color: var(--text);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 9px;
  cursor: pointer;
  touch-action: manipulation;
}
.kb-key:hover { border-color: var(--accent); }
.kb-key:active { transform: translateY(1px); }
.kb-si { font-size: 1.25rem; line-height: 1.2; min-height: 1.2em; }
.kb-latin { font: .7rem var(--font-mono); color: var(--muted); }
.kb-wide { width: 92px; }
.kb-space { width: 320px; }
.kb-key[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Features */
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 16px 0 6px; }
.card p { margin: 0; color: var(--muted); font-size: .95rem; }
.card-icon {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  font-size: 1.35rem; font-weight: 600; line-height: 1;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 11px;
}

.table-wrap { overflow-x: auto; margin-top: 16px; border-radius: var(--radius); }
.english-table { width: 100%; table-layout: fixed; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.english-table th, .english-table td { text-align: left; vertical-align: middle; padding: 12px 24px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.english-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.english-table tr:last-child td { border-bottom: 0; }
.english-table td.si { font-size: 1.1rem; }

/* Install */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 12px; margin: 0 0 20px; max-width: 100%; }
.tab {
  font: 500 .92rem var(--font);
  color: var(--muted);
  background: transparent;
  border: 0; border-radius: 9px;
  padding: 8px 16px;
  white-space: nowrap;
  cursor: pointer;
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tab-panel { display: none; min-width: 0; }
.tab-panel.active { display: block; }
.tab-panel p { margin: 0; }
.tab-panel ol { margin: 0; padding-left: 22px; }
.tab-panel li + li { margin-top: 6px; }

.steps-title { margin-top: 48px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.steps li {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.steps li p { margin: 0; min-width: 0; }
.step-num {
  flex-shrink: 0;
  width: 26px; height: 26px;
  margin-top: -1px;
  display: grid; place-items: center;
  font-size: .85rem; font-weight: 700;
  color: #fff; background: var(--accent);
  border-radius: 50%;
}

/* Cheat sheet */
.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.key {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 6px;
}
.key .si { font-size: 1.5rem; line-height: 1.4; }
.key code { background: none; padding: 0; color: var(--muted); font-size: .85rem; }

/* Footer */
.footer { border-top: 1px solid var(--border); padding: 32px 0; font-size: .92rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer p { margin: 0; }
.muted { color: var(--muted); }

@media (max-width: 860px) {
  .kb-key { width: 48px; height: 52px; }
  .kb-wide { width: 80px; }
  .kb-space { width: 260px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-links { gap: 16px; }
}

@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .nav-inner { height: 56px; }
  .nav-links a:not(.gh) { display: none; }
  .hero { padding: 48px 0 56px; }
  .hero-icon { width: 88px; height: 88px; border-radius: 20px; margin-bottom: 24px; }
  h1 br { display: none; }
  .lead { font-size: 1.05rem; margin-bottom: 28px; }
  .section { padding: 56px 0; }
  .sub { margin-bottom: 24px; }
  h3 { margin-top: 32px; }
  .demo, .grid { grid-template-columns: minmax(0, 1fr); }
  .demo-pane { min-height: 130px; }
  .keyboard { padding: 8px 6px; gap: 6px; overflow: hidden; }
  .kb-row { gap: 3px; min-width: 0; }
  /* 13 keys fit across the widest row */
  .kb-key { width: calc((100% - 36px) / 13); height: 48px; border-radius: 6px; }
  .kb-si { font-size: .95rem; }
  .kb-latin { font-size: .6rem; }
  .kb-wide { width: calc((100% - 36px) / 13 * 2.5); font-size: .75rem; }
  .kb-space { flex: 1; max-width: 50%; font-size: .75rem; }
  #demo-output { font-size: 1.35rem; }
  .card { padding: 20px; }
  .english-table { table-layout: auto; }
  .english-table th, .english-table td { padding: 10px 14px; }
  .english-table code { white-space: nowrap; font-size: .8em; }
  .cmd code { white-space: normal; overflow-wrap: anywhere; line-height: 1.5; }
  .cta { flex-direction: column; }
  .cta .cmd { width: 100%; }
  .btn { width: 100%; justify-content: center; }
  .tabs { display: flex; }
  .tab { flex: 1; min-width: 0; padding: 8px 6px; font-size: .875rem; }
  .steps li { padding: 14px 16px; gap: 12px; }
  .keys { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .key .si { font-size: 1.35rem; }
  .footer { padding: 24px 0; }
}
