:root {
  color-scheme: light;
  --bg: #fbf8f3;
  --surface: #ffffff;
  --surface-alt: #fcfbf8;
  --hover: #eef2f3;
  --text: #1f2933;
  --muted: #52606d;
  --primary: #0f5c63;
  --primary-hover: #0a444a;
  --on-primary: #ffffff;
  --border: #6b7280;
  --soft-border: #d9d3c7;
  --mark: #ffd45e;
  --on-mark: #1f2933;
  --ok-bg: #e3f4e8;
  --ok-text: #0f5a26;
  --bad-bg: #fde8e8;
  --bad-text: #9b1c1c;
  --focus: #1d4ed8;
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(255, 255, 255, 0.75);
  --glass-shadow: 0 8px 32px rgba(15, 92, 99, 0.14);
  --backdrop: radial-gradient(60rem 40rem at 8% -5%, rgba(15, 140, 150, 0.28), transparent 60%),
              radial-gradient(50rem 36rem at 100% 10%, rgba(255, 190, 70, 0.30), transparent 60%),
              radial-gradient(46rem 40rem at 40% 105%, rgba(110, 150, 255, 0.20), transparent 60%),
              linear-gradient(180deg, #e6f3f3 0%, #fbf6ec 100%);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12181b;
  --surface: #1b2428;
  --surface-alt: #172023;
  --hover: #26343a;
  --text: #e6ebee;
  --muted: #a9b6bd;
  --primary: #5fc1c9;
  --primary-hover: #86d3d9;
  --on-primary: #0b2a2e;
  --border: #8a98a1;
  --soft-border: #33414a;
  --ok-bg: #12301c;
  --ok-text: #7be29b;
  --bad-bg: #3a1517;
  --bad-text: #ff9b9b;
  --focus: #8ab4ff;
  --glass: rgba(30, 42, 48, 0.55);
  --glass-strong: rgba(24, 34, 39, 0.82);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --backdrop: radial-gradient(60rem 40rem at 8% -5%, rgba(40, 170, 180, 0.28), transparent 60%),
              radial-gradient(50rem 36rem at 100% 10%, rgba(200, 140, 40, 0.20), transparent 60%),
              radial-gradient(46rem 40rem at 40% 105%, rgba(90, 110, 220, 0.22), transparent 60%),
              linear-gradient(180deg, #0d1417 0%, #131c20 100%);
}

* { box-sizing: border-box; }

/* Author styles like display:flex on buttons would otherwise defeat the hidden attribute. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image: var(--backdrop);
  background-attachment: fixed;
  color: var(--text);
  font: 1.0625rem/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  background: var(--primary);
  color: var(--on-primary);
  padding: 0.6rem 1rem;
  border-radius: 0.4rem;
  z-index: 10;
}
.skip-link:focus { top: 0.5rem; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

header.site {
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}
header.site .inner {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  min-height: 44px;
}
.brand img { width: 2.2rem; height: 2.2rem; }
nav.main ul { display: flex; gap: 0.25rem; margin: 0; padding: 0; list-style: none; flex-wrap: wrap; align-items: center; }
nav.main a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1rem;
  border-radius: 0.4rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
nav.main a:hover { background: var(--hover); }
nav.main a[aria-current="page"] { background: var(--primary); color: var(--on-primary); }

/* theme toggle: shows the moon in light mode and the sun in dark mode */
.theme-toggle {
  width: 44px;
  padding: 0;
  background: transparent;
  color: var(--text);
  border-color: transparent;
}
.theme-toggle:hover { background: var(--hover); border-color: transparent; }
.theme-toggle svg { width: 1.6rem; height: 1.6rem; fill: currentColor; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }

main { max-width: 56rem; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
h1 { font-size: 1.7rem; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 0.75rem; }
p { margin: 0.5rem 0; }
.muted { color: var(--muted); }

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

.card {
  position: relative;
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 1rem;
  padding: 1rem;
  margin: 0 0 1rem;
}

label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
input[type="text"], input[type="search"], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.65rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 0.4rem;
}
textarea { min-height: 7rem; resize: vertical; }
input[type="text"], input[type="search"], select, textarea { background: var(--glass-strong); }
input[type="checkbox"], input[type="radio"] { width: 1.4rem; height: 1.4rem; vertical-align: middle; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0 1.1rem;
  font: inherit;
  font-weight: 600;
  color: var(--on-primary);
  background: var(--primary);
  border: 2px solid var(--primary);
  border-radius: 0.4rem;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button.secondary, .button.secondary { background: var(--surface); color: var(--primary); }
button.secondary:hover, .button.secondary:hover { background: var(--hover); }
button.danger { background: var(--surface); color: var(--bad-text); border-color: var(--bad-text); }
button.danger:hover { background: var(--bad-bg); }
button.small, .button.small { min-height: 36px; min-width: 36px; padding: 0 0.7rem; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

/* round icon buttons (x and +) */
.icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
}
.icon-btn.corner { position: absolute; top: 0.5rem; right: 0.5rem; }
.icon-btn.corner-border { position: absolute; top: -1.15rem; right: 0.75rem; }

.row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; }
.row > .grow { flex: 1 1 14rem; }
.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.75rem; }

mark { background: var(--mark); color: var(--on-mark); padding: 0 0.15em; border-radius: 0.2em; text-decoration: underline; text-decoration-thickness: 2px; }

.sample-text { white-space: pre-wrap; font-size: 1.1rem; }

.item { border-left: 4px solid var(--primary); padding: 0.25rem 0 0.25rem 0.75rem; margin: 0.75rem 0; }
.item .phrase { font-weight: 700; }
.correlations { margin: 0.2rem 0 0; padding: 0; list-style: none; }
.correlations .arrow { color: var(--muted); margin-right: 0.4rem; }
.tag {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  color: var(--muted);
  margin-left: 0.4rem;
}

/* editor */
.editor-item {
  position: relative;
  border: 1px solid var(--soft-border);
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin: 1.25rem 0 0.75rem;
  background: var(--glass);
  border-color: var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-border);
}
.editor-item legend { font-weight: 600; padding: 0 0.4rem; }
.editor-corr { display: flex; gap: 0.5rem; margin: 0.4rem 0; align-items: flex-end; }
.editor-corr .type { flex: 0 0 9.5rem; }
.editor-corr .text { flex: 1 1 auto; }
.badge-dup { color: var(--bad-text); font-weight: 700; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* admin editor */
.lookup-row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin: 0.5rem 0; }
.lookup-row input[type="text"] { flex: 1 1 12rem; width: auto; }
.lookup-row .default { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 600; margin: 0; }

/* practice */
.question { font-size: 1.6rem; font-weight: 700; margin: 0.25rem 0 1rem; }
.result { border-radius: 0.5rem; padding: 0.75rem 1rem; margin: 1rem 0; font-weight: 700; border: 2px solid; }
.result.ok { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-text); }
.result.bad { background: var(--bad-bg); color: var(--bad-text); border-color: var(--bad-text); }
.result .icon { font-size: 1.3em; margin-right: 0.4rem; }
.result .detail { font-weight: 400; color: var(--text); margin-top: 0.3rem; }
input.ok { border-color: var(--ok-text); border-width: 3px; }
input.bad { border-color: var(--bad-text); border-width: 3px; }

.pager { display: flex; gap: 0.75rem; align-items: center; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }

@media (max-width: 600px) {
  body { font-size: 1rem; }
  h1 { font-size: 1.45rem; }
  .question { font-size: 1.3rem; }
  header.site .inner { justify-content: center; }
  nav.main ul { justify-content: center; }
  .actions button, .actions .button, .row > button { flex: 1 1 100%; }
  .editor-corr { flex-wrap: wrap; }
  .editor-corr .type { flex: 1 1 100%; }
  .editor-corr .text { flex: 1 1 60%; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Glass needs backdrop-filter; without it (or when the user asks for less transparency) use solid surfaces. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass: var(--surface); --glass-strong: var(--surface); }
}
@media (prefers-reduced-transparency: reduce) {
  :root, :root[data-theme="dark"] { --glass: var(--surface); --glass-strong: var(--surface); --backdrop: none; }
  header.site, .card { -webkit-backdrop-filter: none; backdrop-filter: none; }
}
