:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #242347;
  background: #f7f6f1;
  --ink: #26245a;
  --mint: #a4e7cd;
  --muted: #605e77;
  --line: #dedbe7;
  --paper: #fffefa;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
[hidden] { display: none !important; }
.masthead { color: #fff; background: var(--ink); padding-top: env(safe-area-inset-top); }
.masthead-inner, main, .nav-inner {
  width: min(100% - 32px, 680px);
  margin-inline: auto;
}
.masthead-inner { min-height: 71px; display: flex; align-items: center; gap: 12px; }
.masthead img { border-radius: 12px; box-shadow: 0 0 0 1px #fff3; }
h1 { margin: 0; font-size: 1.18rem; font-weight: 720; margin-right: auto; }
h2 { font-size: clamp(1.7rem, 6vw, 2.4rem); line-height: 1.1; letter-spacing: -.045em; margin: 0 0 18px; }
h3 { font-size: 1.15rem; margin: 26px 0 12px; }
main { padding: clamp(24px, 6vw, 48px) 0 120px; }
label { display: block; font-size: .92rem; font-weight: 640; }
p { line-height: 1.5; margin: 0; }
a { color: var(--ink); text-underline-offset: .18em; }
button, input, textarea { font: inherit; }
button {
  cursor: pointer; min-height: 44px; padding: 8px 13px;
  border: 1px solid var(--line); border-radius: 12px;
  color: var(--ink); background: var(--paper); font-weight: 650;
}
button:disabled { opacity: .52; cursor: default; }
.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.header-button { background: transparent; color: #fff; border-color: #ffffff5c; }
input:not([type="checkbox"]), textarea {
  width: 100%; margin-top: 6px; min-height: 46px; color: var(--ink); background: #fff;
  padding: 10px 12px; border: 1px solid #bbb8cd; border-radius: 12px; font-size: 16px;
}
textarea { display: block; resize: vertical; }
input[type="file"] { padding: 12px; }
input[type="file"]::file-selector-button { font: inherit; margin-right: 8px; }
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #4f5bda; outline-offset: 3px; }
.section-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-heading h2 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.panel, .entry, dialog {
  background: var(--paper); border: 1px solid var(--line); border-radius: 19px;
  box-shadow: 0 5px 16px #2b254508;
}
.panel, .entry { padding: clamp(16px, 4vw, 24px); }
.panel > * + * { margin-top: 14px; }
.list { display: grid; gap: 10px; margin: 16px 0; }
.entry { display: flex; align-items: flex-start; justify-content: space-between; gap: 9px; }
.entry .text { min-width: 0; overflow-wrap: anywhere; }
.expression { margin: 0 0 7px; color: var(--ink); font-size: 1.22rem; letter-spacing: -.02em; }
.definition, .example { white-space: pre-wrap; }
.example { display: block; margin-top: 7px; color: var(--muted); font-style: italic; }
.empty { color: var(--muted); padding: 18px 0; }
.exports { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 20px; font-size: .92rem; }
.check { display: flex; align-items: center; gap: 8px; }
progress { display: block; width: 100%; accent-color: var(--ink); }
.notice {
  position: fixed; z-index: 2; bottom: calc(76px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); width: min(calc(100% - 28px), 540px);
  padding: 12px 16px; background: var(--ink); color: #fff; border-radius: 12px;
}
nav { position: fixed; inset: auto 0 0; background: #fffefa; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav-inner { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 8px 0; }
.nav-inner button { border-color: transparent; background: transparent; }
button[aria-current="page"] { background: var(--mint); }
dialog { padding: 20px; width: min(calc(100% - 24px), 520px); max-height: 90dvh; color: var(--ink); }
dialog::backdrop { background: #1b194d81; }
dialog label { margin-bottom: 12px; }
.danger, #edit-error { color: #9c2143; }
.editor-actions { margin-top: 14px; }
#source-preview img { max-width: 100%; max-height: 35vh; border-radius: 10px; display: block; margin-top: 8px; }
#source-preview { margin-bottom: 14px; }
#study-card .expression { font-size: clamp(1.6rem, 8vw, 2.55rem); }
#study-card .answer { border-top: 1px solid var(--line); padding-top: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
