:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1c2733;
  --muted: #7a8794;
  --line: #e3e7ec;
  --accent: #2563eb;
  --accent-soft: #eaf0fe;
  --gold: #d97706;
  --known: #c9daf8;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
main { max-width: 1000px; margin: 0 auto; padding: 16px; }

/* шапка */
.top {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 14px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-size: 22px; font-weight: 800; color: var(--ink); text-decoration: none; }
.brand i { color: var(--accent); font-style: normal; }
.tabs { display: flex; gap: 4px; margin-right: 8px; }
.tabs a {
  padding: 7px 13px; border-radius: 8px; text-decoration: none;
  color: var(--muted); font-weight: 600; font-size: 15px;
}
.tabs a:hover { color: var(--accent); }
.tabs a.active { background: var(--accent-soft); color: var(--accent); }
.spacer { flex: 1; }

/* меню пользователя справа */
.usermenu { position: relative; }
.userbtn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-size: 14.5px;
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.userbtn:hover { border-color: var(--accent); color: var(--accent); }
.userbtn .caret { color: var(--muted); font-size: 11px; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 280px; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(20, 30, 50, .14); padding: 6px;
}
.dd-head {
  padding: 8px 12px; color: var(--muted); font-size: 13px;
  border-bottom: 1px solid var(--line); margin-bottom: 4px;
  overflow: hidden; text-overflow: ellipsis;
}
.dd-item {
  display: flex; align-items: flex-start; gap: 9px; width: 100%;
  padding: 9px 12px; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 14.5px; color: var(--ink); text-align: left;
  border-radius: 7px;
}
.dd-item:hover { background: var(--accent-soft); }
.dd-item.setting { cursor: pointer; line-height: 1.35; }
.dd-item input[type="checkbox"] { margin-top: 2px; }

/* страницы входа/регистрации */
.authcard {
  max-width: 400px; margin: 8vh auto 0; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 26px 28px;
  display: flex; flex-direction: column; gap: 12px;
}
.authcard h1 { margin: 0 0 4px; font-size: 24px; }
.authcard form { display: flex; flex-direction: column; gap: 10px; }
.authcard input {
  padding: 10px 13px; font: inherit; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg);
}
.authcard button {
  padding: 10px 16px; font: inherit; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; cursor: pointer; margin-top: 4px;
}
.autherr { background: #fdecec; color: #b42318; padding: 9px 13px;
           border-radius: 8px; font-size: 14px; }
.authcard a { color: var(--accent); }

/* ассоциации к другим словам — раскрывающийся список со стрелкой */
details.otherkeys { padding: 0; }
details.otherkeys summary {
  cursor: pointer; list-style: none; user-select: none;
  display: flex; align-items: center; gap: 8px;
  padding: 14px 18px; font-size: 18px; font-weight: 600;
}
details.otherkeys summary::-webkit-details-marker { display: none; }
details.otherkeys summary::before {
  content: '▸'; color: var(--muted); font-size: 22px; line-height: 1;
  transition: transform .15s ease;
}
details.otherkeys[open] summary::before { transform: rotate(90deg); }
details.otherkeys summary:hover::before { color: var(--accent); }
.otherkeys .ok-hint, .otherkeys .ok-hint-open {
  font-size: 13px; color: var(--muted); font-weight: 400;
}
details.otherkeys[open] .ok-hint { display: none; }
details.otherkeys:not([open]) .ok-hint-open { display: none; }
details.otherkeys .ok-body { padding: 0 18px 10px; }
details.otherkeys .ok-body .anchor:first-child { border-top: 0; }
.otherkeys .ok-type { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.otherkeys .ok-mark { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.otherkeys .ok-mark a { color: var(--muted); text-decoration: underline dotted; }

.page-title { margin: 18px 2px 6px; font-size: 24px; }
.badge.todo-badge { background: #fff3c2; color: #7a5b00; }

/* главная: поиск по центру */
.hero {
  min-height: 64vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; text-align: center; padding: 20px 0;
}
.hero-title { font-size: 46px; font-weight: 800; margin: 0; }
.hero-title i { color: var(--accent); font-style: normal; }
.hero-sub { color: var(--muted); margin: 0; font-size: 17px; }
.hero-search { display: flex; gap: 8px; width: min(640px, 92vw); }
.hero-search input {
  width: 100%; padding: 13px 18px; font-size: 17px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  box-shadow: 0 2px 10px rgba(20, 30, 50, .06);
}
.hero-search button {
  padding: 13px 24px; font-size: 16px; border: 0; border-radius: 10px;
  background: var(--accent); color: #fff; cursor: pointer; white-space: nowrap;
}
.hero-examples { color: var(--muted); font-size: 15px; }
.hero-examples a { color: var(--accent); text-decoration: none; font-weight: 600; }
.hero-examples a:hover { text-decoration: underline; }
.hero-stats { color: var(--muted); font-size: 14.5px; }
.hero-legend span { margin-left: 10px; white-space: nowrap; }
.search { display: flex; gap: 8px; flex: 1; min-width: 260px; position: relative; }
.searchbox { position: relative; flex: 1; }
.search input {
  width: 100%; padding: 9px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.search button, .addbox button, .filters button {
  padding: 9px 16px; font-size: 15px; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; cursor: pointer;
}
.suggest {
  position: absolute; top: 42px; left: 0; right: 0; z-index: 5;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 18px rgba(20, 30, 50, .12); overflow: hidden;
}
.suggest a { display: block; padding: 8px 12px; color: var(--ink); text-decoration: none; }
.suggest a:hover { background: var(--accent-soft); }

/* фильтры */
.filters { display: flex; align-items: center; gap: 16px; margin: 14px 2px; }
.muted { color: var(--muted); font-size: 14px; }

/* таблица */
.tablewrap { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tbody tr:hover { background: #fafbfd; }
tbody tr[data-href] { cursor: pointer; }
tbody tr[data-href]:hover { background: var(--accent-soft); }
tbody tr:last-child td { border-bottom: 0; }
td.rank { color: var(--muted); white-space: nowrap; }
td.word a { font-weight: 600; color: var(--accent); text-decoration: none; }
td.meanings { max-width: 340px; }
td.forms { max-width: 200px; color: var(--muted); font-size: 13.5px; overflow: hidden;
           text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.trans { color: var(--muted); font-family: "Segoe UI", sans-serif; }
.trans.big { font-size: 20px; }
.chip { margin-right: 6px; white-space: nowrap; }

.badge {
  display: inline-block; padding: 1px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 600; background: var(--known); color: #24406e;
}
.badge.slang { background: #ffe3b3; color: #7a4a00; }
.badge.familiar { background: #d9f2dd; color: #1b5e20; }

.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin: 18px 0; }
.pager a, .pager b { padding: 4px 9px; border-radius: 6px; text-decoration: none; color: var(--accent); }
.pager b { background: var(--accent-soft); }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* селектор размера страницы */
.perpick { font-size: 14px; color: var(--muted); }
.perpick select {
  font: inherit; font-size: 14px; padding: 3px 6px; margin-left: 4px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--ink);
}

/* страница слова */
.wordhead { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
            padding: 18px 20px; margin-bottom: 18px; }
.wh-line { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.wh-line h1 { margin: 0; font-size: 30px; }
.wh-line .rank { color: var(--muted); font-size: 18px; }
.meanings-block { margin-top: 10px; }
.mgroup { margin-top: 3px; }
.note { margin-top: 10px; color: var(--muted); }
.wforms { margin-top: 8px; font-size: 14px; }

.cat { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
       padding: 14px 18px 8px; margin-bottom: 16px; }
.cat h2 { font-size: 18px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.cat h2 .count { color: var(--muted); font-weight: 400; font-size: 14px; }
.anchor { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0;
          border-top: 1px solid var(--line); }
.anchor:first-of-type { border-top: 0; }
.abody { flex: 1; }
.atext { white-space: pre-line; }
.asource { color: var(--muted); font-size: 14px; margin-top: 2px; }
.fav {
  border: 1px solid var(--line); background: var(--bg); border-radius: 8px;
  padding: 5px 10px; cursor: pointer; font-size: 15px; color: var(--muted); white-space: nowrap;
}
.fav:hover { border-color: var(--gold); color: var(--gold); }
.fav.on { background: #fff7e8; border-color: var(--gold); color: var(--gold); }
.fav .fc { font-size: 13px; margin-left: 3px; }
.anchor.pending .atext { color: #5a6b7d; }
.pbadge { display: inline-block; margin-top: 4px; font-size: 12px; color: var(--muted);
          border: 1px dashed var(--line); padding: 0 8px; border-radius: 20px; }

/* цветные метки якорей (точка в правом верхнем углу) */
.mark { cursor: pointer; padding-top: 7px; }
.mark:hover .markdot { border-color: var(--accent); }
.markdot {
  display: inline-block; width: 15px; height: 15px; border-radius: 4px;
  border: 1px solid #b6c2cf; background: #fff;
}
.m-yellow { background: #ffd54f; } .m-orange { background: #fb8c00; }
.m-red { background: #e57373; } .m-green { background: #81c784; }
.m-blue { background: #64b5f6; } .m-purple { background: #ba68c8; }
.markpal {
  position: absolute; display: flex; gap: 6px; padding: 7px; z-index: 60;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 6px 18px rgba(15, 30, 50, .18);
}
.markpal .markdot { width: 21px; height: 21px; cursor: pointer; }
.markpal .markdot:hover { border-color: var(--ink); }
.markpal .markdot.cur { outline: 2px solid var(--accent); outline-offset: 1px; }

/* форма добавления */
.addbox { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
          padding: 14px 18px 18px; }
.addbox h2 { font-size: 18px; margin: 0 0 10px; }
.addbox form { display: flex; flex-direction: column; gap: 10px; max-width: 640px; }
.addbox textarea, .addbox input[type="text"] {
  padding: 9px 12px; font: inherit; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg);
}
.addbox textarea { min-height: 70px; resize: vertical; }
.addbox button { align-self: flex-start; }

/* категории в форме «предложить якорь» — кнопки-переключатели */
.typebtns { display: flex; flex-wrap: wrap; gap: 8px; }
.typehint { font-size: 13px; color: var(--muted); margin-top: -2px; }
.typebtn { cursor: pointer; }
.typebtn input {
  position: absolute; opacity: 0; pointer-events: none;
}
.typebtn span {
  display: inline-block; padding: 6px 13px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--muted);
  transition: color .12s, background .12s, border-color .12s;
}
.typebtn:hover span { color: var(--ink); border-color: var(--muted); }
.typebtn input:checked + span {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.typebtn input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
#addmsg { font-size: 14px; }

footer { text-align: center; color: var(--muted); font-size: 13.5px; padding: 26px 0 34px; }

@media (max-width: 640px) {
  .top { gap: 10px; }
  th, td { padding: 7px 8px; font-size: 14px; }
  td.forms { display: none; }
  th:nth-child(4) { display: none; }
}
