:root {
  --bg: #f7f3ec;
  --surface: #ffffff;
  --surface-2: #f1ebe0;
  --text: #22201c;
  --muted: #6c665c;
  --border: #e3dccf;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe9;
  --ru: #7a3b1d;
  --mark: #fde7a6;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 6px 24px rgba(40, 30, 10, .06);
  --radius: 12px;
  --serif: "PT Serif", Georgia, "Times New Roman", serif;
  --sans: "PT Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171614; --surface: #211f1c; --surface-2: #2a2824; --text: #ece7de; --muted: #a39d92;
    --border: #3a3631; --accent: #5cc0a2; --accent-ink: #10201b; --accent-soft: #1f3530;
    --ru: #f0a679; --mark: #5a4a12; --danger: #ff8a80; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171614; --surface: #211f1c; --surface-2: #2a2824; --text: #ece7de; --muted: #a39d92;
  --border: #3a3631; --accent: #5cc0a2; --accent-ink: #10201b; --accent-soft: #1f3530;
  --ru: #f0a679; --mark: #5a4a12; --danger: #ff8a80; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.55 var(--sans);
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
.wrap { width: 100%; max-width: 920px; margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 11px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font: 700 26px/1 var(--serif); flex: none;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font: 700 20px/1.2 var(--serif); }
.brand-sub { color: var(--muted); font-size: 13px; }
.header-nav { display: flex; align-items: center; gap: 4px; }
.nav-link { padding: 6px 10px; border-radius: 8px; color: var(--muted); font-size: 15px; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.icon-btn { border: 0; background: none; width: 36px; height: 36px; border-radius: 8px; font-size: 18px; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); }

/* ---------- search ---------- */
.search-box { position: relative; display: flex; }
.search-box input {
  flex: 1; min-width: 0; font: 19px var(--sans); padding: 12px 14px; color: var(--text);
  border: 1.5px solid var(--border); border-right: 0; border-radius: var(--radius) 0 0 var(--radius);
  background: var(--bg); outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.search-btn {
  border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700;
  padding: 0 20px; border-radius: 0 var(--radius) var(--radius) 0;
}
.search-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-top: 8px; }
.modes { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 15px; color: var(--muted); }
.modes label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.modes input { accent-color: var(--accent); }
.keyboard { display: flex; gap: 4px; flex-wrap: wrap; }
.keyboard button {
  width: 32px; height: 30px; border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 7px; font: 17px var(--serif);
}
.keyboard button:hover { border-color: var(--accent); color: var(--accent); }

.suggest {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 4px;
  list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); max-height: 60vh; overflow-y: auto;
}
.suggest li { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--accent-soft); }
.suggest .s-word { font: 700 16px var(--serif); white-space: nowrap; }
.suggest .s-short { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.alphabet { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 10px; }
.alphabet a {
  min-width: 30px; text-align: center; padding: 3px 4px; border-radius: 6px; font: 15px var(--serif); color: var(--muted);
}
.alphabet a:hover, .alphabet a.active { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

/* ---------- main ---------- */
main { flex: 1; padding-top: 24px; padding-bottom: 40px; outline: none; }
.loading, .empty { color: var(--muted); padding: 24px 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.section-title { font: 700 13px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

.daily .hw { font: 700 30px/1.2 var(--serif); margin: 4px 0 8px; display: inline-block; color: var(--text); }
.daily p { margin: 0 0 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface);
  padding: 8px 14px; border-radius: 9px; font-size: 15px; color: var(--text);
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.help-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 15px; }
.help-list li { margin-bottom: 4px; }

/* ---------- results ---------- */
.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.results-head h1 { font: 700 24px var(--serif); margin: 0; }
.results-head .count { color: var(--muted); font-size: 15px; }
.results { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.results li + li { border-top: 1px solid var(--border); }
.results a { display: block; padding: 12px 18px; color: var(--text); }
.results a:hover { background: var(--surface-2); text-decoration: none; }
.results .r-word { font: 700 18px var(--serif); margin-right: 8px; }
.results .r-short { color: var(--muted); font-size: 15px; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.more { margin-top: 14px; text-align: center; }
.maybe { margin-top: 20px; }
.maybe h2 { font: 700 18px var(--serif); margin: 0 0 10px; }

/* ---------- entry ---------- */
.entry { padding: 26px 28px; }
.entry-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.entry h1 { font: 700 36px/1.15 var(--serif); margin: 0 0 10px; overflow-wrap: anywhere; }
.labels { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.label {
  font: italic 14px var(--serif); background: var(--accent-soft); color: var(--accent);
  padding: 2px 9px; border-radius: 999px; cursor: default;
}
.label[title] { border-bottom: 1px dotted transparent; }
.intro { margin: 0 0 12px; }
.meanings { margin: 0; padding-left: 0; list-style: none; counter-reset: m; }
.meanings > li { position: relative; padding-left: 34px; margin-bottom: 14px; counter-increment: m; }
.meanings > li::before {
  content: counter(m); position: absolute; left: 0; top: 1px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface-2); color: var(--muted); font: 700 13px/24px var(--sans); text-align: center;
}
.tr { font: 19px/1.5 var(--serif); }
.examples { list-style: none; margin: 6px 0 0; padding: 0; }
.examples li { padding: 3px 0 3px 14px; border-left: 2px solid var(--border); margin-bottom: 4px; font: 16.5px/1.5 var(--serif); }
.ru { color: var(--ru); font-style: italic; }
.phrases { margin-top: 22px; padding-top: 16px; border-top: 1px dashed var(--border); }
.phrases ul { list-style: none; margin: 0; padding: 0; }
.phrases li { margin-bottom: 6px; font: 16.5px/1.5 var(--serif); }
.phrases li::before { content: "◆"; color: var(--accent); font-size: 10px; margin-right: 8px; vertical-align: 2px; }
.xref { font-style: italic; }
.entry-actions { display: flex; gap: 6px; flex: none; }
.homonyms { margin-top: 16px; font-size: 15px; color: var(--muted); }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; }
.pager a { max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.raw { margin-top: 18px; font-size: 14px; color: var(--muted); }
.raw summary { cursor: pointer; }
.raw p { white-space: pre-wrap; margin: 8px 0 0; font-family: var(--serif); }

/* ---------- forms ---------- */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 700; font-size: 15px; }
.form input, .form textarea {
  font: 17px var(--serif); padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text); width: 100%;
}
.form textarea { min-height: 240px; resize: vertical; line-height: 1.5; }
.form input:focus, .form textarea:focus { outline: none; border-color: var(--accent); }
.hint { color: var(--muted); font-size: 14px; font-weight: 400; }
.notice { padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); margin-bottom: 14px; }
.notice.error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }

.site-footer { color: var(--muted); font-size: 14px; padding-bottom: 24px; }
.site-footer p { margin: 0; border-top: 1px solid var(--border); padding-top: 16px; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .brand-title { font-size: 17px; }
  .brand-mark { width: 36px; height: 36px; font-size: 22px; }
  .nav-link { padding: 6px 6px; font-size: 14px; }
  #admin-link { display: none; }
  .entry { padding: 18px 16px; }
  .entry h1 { font-size: 28px; }
  .keyboard button { width: 30px; }
  .search-btn { padding: 0 14px; }
}
