:root {
  --bg: #ffffff;
  --fg: #1c2733;
  --muted: #61707f;
  --line: #dfe6ec;
  --accent: #2e9bd6;
  --script-bg: #eaf4fb;
  --script-line: #2e9bd6;
  --important-bg: #fdf2ec;
  --important-line: #e07a3c;
  --warn-bg: #fff8e6;
  --ins: #1f7a35;
  --ins-bg: #e6f5ea;
  --del: #b3261e;
  --del-bg: #fbeae9;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12181f;
    --fg: #e4ebf2;
    --muted: #97a6b5;
    --line: #26313d;
    --script-bg: #122c3d;
    --important-bg: #3a2416;
    --warn-bg: #33290f;
    --ins-bg: #12301c;
    --del-bg: #351513;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main { max-width: 46rem; margin: 0 auto; padding: 1rem 1rem 4rem; }

/* --- шапка --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center;
  padding: .6rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; text-decoration: none; color: var(--fg); }
.searchbox { flex: 1 1 12rem; }
.searchbox input {
  width: 100%; padding: .45rem .6rem;
  border: 1px solid var(--line); border-radius: .4rem;
  background: var(--bg); color: var(--fg); font-size: 1rem;
}
.navlink { color: var(--accent); text-decoration: none; font-size: .9rem; }

/* --- вкладки --- */
.tabs {
  display: flex; gap: .25rem; max-width: 46rem; margin: 0 auto;
  padding: 0 1rem; border-bottom: 1px solid var(--line);
}
.tab {
  padding: .6rem .9rem; text-decoration: none; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600;
}
.tab--active { color: var(--fg); border-bottom-color: var(--accent); }

h1 { font-size: 1.5rem; line-height: 1.3; }
h2 { font-size: 1.15rem; margin-top: 2rem; }
h3 { font-size: 1rem; }

a { color: var(--accent); }
.muted { color: var(--muted); font-size: .9rem; }
.crumbs { font-size: .85rem; color: var(--muted); }

/* --- коды и статусы --- */
.code {
  font: 600 .82rem/1.2 ui-monospace, "SF Mono", Consolas, monospace;
  color: var(--accent); white-space: nowrap;
}
.code--big { font-size: 1rem; }
.ref { text-decoration: none; border-bottom: 1px dotted var(--accent); white-space: nowrap; }

.badge {
  display: inline-block; padding: .1rem .45rem; border-radius: .7rem;
  font-size: .72rem; border: 1px solid var(--line); color: var(--muted);
}
.badge--active { color: var(--ins); border-color: var(--ins); }
.badge--pending_approval { color: var(--important-line); border-color: var(--important-line); }
.badge--archived, .badge--draft { color: var(--muted); }

/* --- содержание --- */
.section { border-top: 1px solid var(--line); }
ul.items, ul.results { list-style: none; padding: 0; }
ul.items li { padding: .3rem 0; border-bottom: 1px solid var(--line); }
ul.items a { text-decoration: none; }
ul.results li { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.snippet { margin: .25rem 0 0; color: var(--muted); font-size: .88rem; }

/* --- тело пункта --- */
.item .meta { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.body h4 { margin-bottom: .2rem; }
.body ul, .body ol { padding-left: 1.3rem; }
.body li { margin: .25rem 0; }

.callout {
  margin: 1rem 0; padding: .7rem .9rem;
  border-left: 3px solid var(--script-line); background: var(--script-bg);
  border-radius: 0 .3rem .3rem 0;
}
.callout--important { border-left-color: var(--important-line); background: var(--important-bg); }
.callout__label {
  margin: 0 0 .3rem; font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}
.callout p:last-child { margin-bottom: 0; }

/* --- таблицы --- */
.table-wrap { overflow-x: auto; margin: 1rem 0; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; vertical-align: top; padding: .45rem .6rem; border: 1px solid var(--line); }
th { background: color-mix(in srgb, var(--line) 40%, transparent); font-weight: 600; }

.grid td, .grid th { font-size: .88rem; }
.grid tr.current { background: var(--ins-bg); }

/* --- ссылки внизу пункта --- */
.links { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-top: 2rem;
         padding-top: 1rem; border-top: 1px solid var(--line); }
.links h4 { margin: 0 0 .2rem; font-size: .8rem; color: var(--muted); text-transform: uppercase; }

/* --- формы --- */
.editor { display: flex; flex-direction: column; gap: .9rem; }
.editor label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
input[type=text], input[type=date], select, textarea {
  padding: .45rem .6rem; border: 1px solid var(--line); border-radius: .4rem;
  background: var(--bg); color: var(--fg); font-size: 1rem; font-family: inherit;
}
textarea { font: .9rem/1.5 ui-monospace, Consolas, monospace; resize: vertical; }
button {
  padding: .4rem .8rem; border: 1px solid var(--accent); border-radius: .4rem;
  background: var(--accent); color: #fff; font-size: .9rem; cursor: pointer;
}
.inline { display: inline-flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .5rem 0; }
.inline button { background: transparent; color: var(--accent); }

.warn {
  padding: .6rem .8rem; background: var(--warn-bg);
  border-left: 3px solid var(--important-line); border-radius: 0 .3rem .3rem 0;
  font-size: .9rem;
}
.ok {
  padding: .6rem .8rem; background: var(--ins-bg);
  border-left: 3px solid var(--ins); border-radius: 0 .3rem .3rem 0;
  font-size: .9rem;
}
.banner {
  margin: 0; padding: .5rem 1rem; text-align: center;
  background: var(--warn-bg); border-bottom: 1px solid var(--line); font-size: .9rem;
}

/* --- вход --- */
body.centered { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login {
  display: flex; flex-direction: column; gap: .8rem;
  width: min(22rem, 92vw); padding: 1.6rem;
  border: 1px solid var(--line); border-radius: .6rem;
}
.login h1 { margin: 0; font-size: 1.2rem; }
.login label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
.login input {
  padding: .5rem .6rem; border: 1px solid var(--line); border-radius: .4rem;
  background: var(--bg); color: var(--fg); font-size: 1rem;
}

/* --- сравнение редакций --- */
.diff {
  white-space: pre-wrap; word-wrap: break-word;
  font: .88rem/1.6 ui-monospace, Consolas, monospace;
  padding: .8rem; border: 1px solid var(--line); border-radius: .4rem;
}
ins { background: var(--ins-bg); color: var(--ins); text-decoration: none; }
del { background: var(--del-bg); color: var(--del); }

/* --- каталог игр --- */
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.head-actions { display: inline-flex; gap: .75rem; align-items: center; }
.btn-link {
  padding: .35rem .7rem; border: 1px solid var(--accent); border-radius: .4rem;
  color: var(--accent); text-decoration: none; font-size: .85rem; white-space: nowrap;
}
button.danger { border-color: var(--del); color: var(--del); background: transparent; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .8rem 0; }
.chip {
  padding: .25rem .6rem; border: 1px solid var(--line); border-radius: 1rem;
  text-decoration: none; color: var(--muted); font-size: .82rem;
}
.chip--on { color: #fff; background: var(--accent); border-color: var(--accent); }

table.games { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.games th, table.games td {
  text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.games th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; }
.game-row { cursor: pointer; }
.game-row:hover, .game-row:focus { background: var(--script-bg); outline: none; }
.g-name { font-weight: 600; white-space: normal; }
.g-note { color: var(--important-line); cursor: help; }

/* --- карточка игры --- */
.specs { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
         gap: .5rem 1rem; margin: 1rem 0; }
.specs > div { border-left: 2px solid var(--line); padding-left: .6rem; }
.specs dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; }
.specs dd { margin: 0; font-weight: 600; }
.walkthrough { line-height: 1.7; }

.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .6rem; }
.shots img {
  width: 100%; height: 110px; object-fit: cover; border-radius: .4rem;
  border: 1px solid var(--line); display: block;
}
.video { position: relative; padding-top: 56.25%; margin: .5rem 0 1rem; }
.video iframe {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: 0; border-radius: .5rem;
}
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .6rem 1rem; }
