:root {
  --bg: #fbfaf7;
  --text: #1d1d1b;
  --muted: #5d5b55;
  --line: #dedad1;
  --panel: #ffffff;
  --code-bg: #f2efe8;
  --accent: #1f5f8b;
  --accent-text: #ffffff;
  --good: #2c6e3f;
  --problem-bg: #fff4e5;
  --problem-line: #b85c00;
  --focus: #f2b134;
  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161614;
    --text: #ecebe6;
    --muted: #aaa79e;
    --line: #34332f;
    --panel: #1e1e1b;
    --code-bg: #24231f;
    --accent: #7db7e0;
    --accent-text: #0e2232;
    --good: #8fcf9e;
    --problem-bg: #33240f;
    --problem-line: #f0a24e;
  }
}

* { box-sizing: border-box; }

html { font-size: 112.5%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
}

a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--panel); padding: .5rem 1rem; z-index: 10; }
.hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem 1.5rem;
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { font-weight: 700; font-size: 1.3rem; color: var(--text); text-decoration: none; }
.top nav { display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; }
.top nav a { color: var(--text); text-decoration: none; padding: .2rem 0; border-bottom: 2px solid transparent; }
.top nav a:hover, .top nav a[aria-current="page"] { border-bottom-color: var(--accent); }
.search { margin-left: auto; }
.search input { font: inherit; font-size: .9rem; padding: .3rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); width: 11rem; }

main { max-width: 46rem; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
main:has(.playground) { max-width: 72rem; }
footer { border-top: 1px solid var(--line); color: var(--muted); text-align: center; padding: 1rem; font-size: .9rem; }

h1 { font-size: 2rem; line-height: 1.2; margin: .5rem 0 1rem; }
h2 { font-size: 1.4rem; margin-top: 2.2rem; }
h3 { font-size: 1.1rem; margin-top: 1.6rem; }

code { font-family: var(--mono); font-size: .92em; background: var(--code-bg); padding: .05em .3em; border-radius: 4px; }
pre { background: var(--code-bg); padding: .8rem 1rem; border-radius: 8px; overflow-x: auto; line-height: 1.5; }
pre code { background: none; padding: 0; font-size: .9rem; }
pre.output { background: var(--panel); border: 1px solid var(--line); }
pre.problem { background: var(--problem-bg); border-left: 4px solid var(--problem-line); white-space: pre-wrap; }
pre.answers { background: var(--panel); border: 1px dashed var(--line); }
.label { color: var(--muted); font-size: .85rem; margin: .6rem 0 -.5rem; }

.example { position: relative; }
.example .try {
  position: absolute; top: .5rem; right: .5rem;
  background: var(--accent); color: var(--accent-text); text-decoration: none;
  padding: .15rem .7rem; border-radius: 6px; font-size: .85rem; font-weight: 600;
}

button, .button {
  font: inherit; font-size: .95rem; cursor: pointer;
  padding: .4rem .9rem; border-radius: 7px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  text-decoration: none; display: inline-block;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 700; }
button:disabled { opacity: .5; cursor: default; }

/* Home and playground */
.hero { max-width: 46rem; }
.hero h1 { font-size: 2.4rem; }
.hero p { font-size: 1.15rem; color: var(--muted); }

.playground { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
.bar select { font: inherit; font-size: .95rem; padding: .3rem; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.grow { flex: 1; }

.editor { display: flex; min-height: 18rem; max-height: 60vh; overflow: auto; border-bottom: 1px solid var(--line); background: var(--bg); }
.gutter {
  margin: 0; padding: .8rem .6rem; min-width: 3rem; text-align: right;
  color: var(--muted); background: var(--code-bg); border-radius: 0; user-select: none;
  font-family: var(--mono); font-size: .95rem; line-height: 1.5; overflow: hidden;
}
.gutter .bad { color: var(--problem-line); font-weight: 700; }
#code {
  flex: 1; border: 0; resize: none; padding: .8rem 1rem; background: transparent; color: var(--text);
  font-family: var(--mono); font-size: .95rem; line-height: 1.5; white-space: pre; overflow: hidden; tab-size: 4;
}
#code:focus { outline: none; }

.tabs { display: flex; gap: .25rem; padding: .4rem .6rem 0; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; }
.tabs button[aria-selected="true"] { border-bottom-color: var(--accent); font-weight: 700; }

.panel { padding: .8rem 1rem; min-height: 8rem; max-height: 50vh; overflow: auto; }
#output { font-family: var(--mono); font-size: .95rem; white-space: pre-wrap; }
#output .asked { color: var(--muted); }
#output .answer { color: var(--good); }
#output .problem { background: var(--problem-bg); border-left: 4px solid var(--problem-line); padding: .6rem .8rem; margin: .5rem 0; white-space: pre-wrap; font-family: var(--mono); }
#output .idea { margin: .3rem .4rem 0 0; font-family: var(--font); }
#output .stopped { color: var(--muted); font-style: italic; }
#output input.answer-box { font: inherit; padding: .2rem .4rem; border: 2px solid var(--accent); border-radius: 5px; background: var(--bg); color: var(--text); min-width: 14rem; }
#status { margin: 0; padding: .5rem 1rem; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--line); }

#files .note { color: var(--muted); font-size: .9rem; }
#file-list { list-style: none; padding: 0; }
#file-list li { display: flex; gap: .5rem; align-items: center; padding: .2rem 0; }
#file-list button.link { border: 0; background: none; color: var(--accent); text-decoration: underline; padding: 0; }
#file-text { width: 100%; min-height: 10rem; font-family: var(--mono); font-size: .9rem; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: .5rem; }
.file-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* Lessons, examples, phrases */
.lesson-nav { font-size: .9rem; color: var(--muted); margin: .5rem 0 1.5rem; }
.lesson-nav:last-child { margin-top: 2.5rem; }
.example-card { border-top: 1px solid var(--line); padding-top: .5rem; }
dl.phrases { margin: 0; }
.phrase { border-top: 1px solid var(--line); padding: .6rem 0; }
.phrase dt { font-weight: 600; }
.phrase dd { margin: .2rem 0 0; }
.phrase .also { color: var(--muted); font-size: .9rem; }
.tag { font-size: .75rem; font-weight: 600; background: var(--code-bg); color: var(--muted); padding: .1rem .45rem; border-radius: 999px; margin-left: .4rem; }
.words code { display: inline-block; margin: .15rem; }
#filter { font: inherit; padding: .35rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); width: 100%; max-width: 22rem; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }

@media (max-width: 40rem) {
  html { font-size: 106%; }
  .search { margin-left: 0; width: 100%; }
  .search input { width: 100%; }
  .hero h1 { font-size: 1.9rem; }
}
