/* Light by default. Dark is opt-in via the toggle in the header (data-theme="dark"). */
:root {
  --bg: #ffffff;
  --panel: #f6f7f9;
  --ink: #1b1f24;
  --muted: #5b6470;
  --line: #d3d8de;
  --link: #0b5cad;
  --btn: #0b5cad;
  --btn-ink: #ffffff;
  --head-bg: #16365c;
  --head-ink: #ffffff;
  --head-muted: #b9c8dc;
  --note-bg: #fff8e1;
  --note-line: #e6c75a;
  --ok: #17692f;
  --ok-bg: #e0f3e5;
  --bad: #b3261e;
  --bad-bg: #fbe4e2;
  --focus: #1a73e8;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", "Noto Sans Devanagari", "Nirmala UI", "Mangal", Arial, sans-serif;
  --mono: Consolas, "Liberation Mono", Menlo, monospace;
}

:root[data-theme="dark"] {
  --bg: #15181c;
  --panel: #1d2127;
  --ink: #e6e8eb;
  --muted: #a0a8b3;
  --line: #333a43;
  --link: #7db4ee;
  --btn: #3b82d6;
  --btn-ink: #ffffff;
  --head-bg: #0f2540;
  --head-ink: #ffffff;
  --head-muted: #a9bcd4;
  --note-bg: #2b2613;
  --note-line: #7a6a24;
  --ok: #8fd6a2;
  --ok-bg: #173323;
  --bad: #f2a29c;
  --bad-bg: #3a1c1a;
  --focus: #7db4ee;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
}

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

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

/* header */
.site-header { background: var(--head-bg); color: var(--head-ink); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.brand { color: var(--head-ink); font-weight: 700; font-size: 1.25rem; text-decoration: none; }
.nav { display: flex; align-items: center; gap: 2px 14px; flex-wrap: wrap; }
.nav a { color: var(--head-muted); text-decoration: none; padding: 4px 0; font-size: 0.95rem; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--head-ink); }
.nav a[aria-current="page"] { color: var(--head-ink); border-bottom-color: var(--head-ink); }
.theme-btn { font: inherit; font-size: 0.85rem; color: var(--head-ink); background: transparent; border: 1px solid var(--head-muted); border-radius: 3px; padding: 2px 10px; cursor: pointer; }
.theme-btn:hover { border-color: var(--head-ink); }

.site-footer { margin-top: 40px; border-top: 1px solid var(--line); padding: 16px 0 28px; color: var(--muted); font-size: 0.88rem; }

/* headings */
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
.page-head { padding: 24px 0 4px; }
.page-head p { margin: 0; color: var(--muted); max-width: 65ch; }

/* home: plain directory list */
.intro { padding: 28px 0 8px; }
.intro p { margin: 0; color: var(--muted); max-width: 62ch; }
.tool-list { list-style: none; margin: 8px 0 0; padding: 0; border-top: 1px solid var(--line); }
.tool-list li { border-bottom: 1px solid var(--line); padding: 14px 0; }
.tool-list a { font-size: 1.1rem; font-weight: 600; }
.tool-list p { margin: 2px 0 0; color: var(--muted); }
.plain-list { margin: 8px 0 0; padding-left: 20px; color: var(--muted); }
.section-title { margin: 32px 0 0; font-size: 1.05rem; }

/* boxes */
.panel { border: 1px solid var(--line); background: var(--panel); padding: 16px; margin-top: 16px; }
.panel h2 { font-size: 1.05rem; }

.row { display: flex; gap: 10px 14px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field label { font-size: 0.88rem; color: var(--muted); }

input[type="number"], input[type="text"], select, textarea {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 3px; padding: 6px 8px; min-width: 0;
}
input[type="number"] { width: 100px; }
input[type="file"] { font: inherit; max-width: 100%; }
input[type="range"] { width: 100%; accent-color: var(--btn); }
textarea { width: 100%; resize: vertical; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.btn {
  font: inherit; cursor: pointer;
  background: var(--btn); color: var(--btn-ink);
  border: 1px solid var(--btn); border-radius: 3px; padding: 7px 16px;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { background: var(--bg); color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--muted); filter: none; }

.notice { border: 1px solid var(--note-line); background: var(--note-bg); padding: 10px 14px; font-size: 0.92rem; margin-top: 16px; }
.hint { color: var(--muted); font-size: 0.88rem; margin: 6px 0 0; }
.status { margin: 8px 0 0; min-height: 1.4em; font-size: 0.95rem; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }

.mt { margin-top: 14px; }
.mt0 { margin-top: 0; }

/* photo resizer */
.stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 720px) { .stage { grid-template-columns: 1fr; } }
.canvas-box { background: #e9ecef; border: 1px solid var(--line); display: flex; justify-content: center; padding: 8px; }
.canvas-box canvas { max-width: 100%; height: auto; touch-action: none; cursor: grab; background: #fff; }
.canvas-box canvas:active { cursor: grabbing; }
.result-img { max-width: 100%; height: auto; border: 1px solid var(--line); background: #fff; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.stat { background: var(--bg); border: 1px solid var(--line); padding: 4px 10px; font-size: 0.9rem; }
.stat b { font-variant-numeric: tabular-nums; }

/* typing test */
.passage { font-size: 1.3rem; line-height: 2; padding: 12px 14px; max-height: 280px; overflow-y: auto; background: var(--bg); border: 1px solid var(--line); user-select: none; }
.passage span { padding: 1px 2px; }
.passage .w-ok { background: var(--ok-bg); color: var(--ok); }
.passage .w-bad { background: var(--bad-bg); color: var(--bad); }
.passage .w-cur { outline: 2px solid var(--link); }
.typebox { font-size: 1.3rem; line-height: 1.7; min-height: 150px; margin-top: 12px; }
.timer { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; }
.result-grid .stat { text-align: center; padding: 10px; }
.result-grid .stat b { display: block; font-size: 1.5rem; }

/* converter */
.panes { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .panes { grid-template-columns: 1fr; } }
.panes textarea { min-height: 220px; font-size: 1.1rem; }
.kruti-out { font-family: var(--mono); }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
