/* Design tokens follow Yandex's public Gravity UI language: white surfaces, thin
   translucent lines, 13/18 body text, quiet gray controls and a single blue action. */

:root {
  --font: "YS Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --text: rgba(0, 0, 0, 0.85);
  --text-secondary: rgba(0, 0, 0, 0.7);
  --text-hint: rgba(0, 0, 0, 0.5);
  --text-faint: rgba(0, 0, 0, 0.3);
  --line: rgba(0, 0, 0, 0.1);
  --line-strong: rgba(0, 0, 0, 0.15);
  --bg: #fff;
  --bg-generic: rgba(0, 0, 0, 0.05);
  --bg-generic-hover: rgba(0, 0, 0, 0.1);
  --bg-float: #fff;
  --bg-soft: #f7f8f9;

  --link: #2f6fe4;
  --link-hover: #1d55bf;
  --action: #2f6fe4;
  --action-hover: #2a63cc;

  --success: #2e9a4f;
  --success-bg: rgba(50, 190, 90, 0.14);
  --warning: #b97300;
  --warning-bg: rgba(255, 190, 92, 0.32);
  --danger: #d6373f;
  --danger-bg: rgba(255, 4, 0, 0.11);
  --info: #2f6fe4;
  --info-bg: rgba(82, 130, 255, 0.16);
  --dark: #1f2126;

  --diff-add: rgba(50, 190, 90, 0.13);
  --diff-add-gutter: rgba(50, 190, 90, 0.28);
  --diff-remove: rgba(255, 4, 0, 0.09);
  --diff-remove-gutter: rgba(255, 4, 0, 0.2);

  --radius: 8px;
  --radius-s: 5px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 2px 10px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font: 13px/18px var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 24px; line-height: 28px; }
h2 { font-size: 15px; line-height: 20px; }
h3 { font-size: 13px; line-height: 18px; }
p { margin: 0 0 8px; }
p:last-child { margin-bottom: 0; }

code, .mono { font-family: var(--mono); font-size: 12px; }
code.inline { background: var(--bg-generic); padding: 1px 5px; border-radius: 4px; }
code.copyable { display: inline-block; max-width: 100%; overflow-wrap: anywhere; background: var(--bg-generic); padding: 4px 8px; border-radius: var(--radius-s); cursor: copy; }
code.copyable:hover { background: var(--bg-generic-hover); }

/* Layout */

.topbar { height: 52px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 20; }
.topbar-inner { height: 100%; max-width: 1240px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 28px; }
body.wide .topbar-inner { max-width: 1560px; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: 24px; border-radius: 7px; background: var(--dark); color: #ffdb4d; display: grid; place-items: center; font: 700 13px/1 var(--mono); }
.brand-sub { color: var(--text-hint); font-weight: 400; }

.nav { display: flex; align-items: stretch; gap: 4px; height: 100%; }
.nav a { display: flex; align-items: center; padding: 0 10px; color: var(--text-secondary); position: relative; }
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.active { color: var(--text); }
.nav a.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--dark); border-radius: 2px 2px 0 0; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); }

.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--info-bg); color: var(--info); display: inline-grid; place-items: center; font-weight: 600; font-size: 11px; flex: none; }
.avatar-admin { background: var(--dark); color: #ffdb4d; }
.avatar-muted { background: var(--bg-generic); color: var(--text-secondary); }
.avatar-sm { width: 20px; height: 20px; font-size: 10px; }

.page { max-width: 1240px; margin: 0 auto; padding: 24px 24px 64px; }
.page-wide { max-width: 1560px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.page-head .meta { color: var(--text-hint); margin-top: 4px; }
.page-head .meta a { color: var(--text-secondary); }
.breadcrumbs { color: var(--text-hint); margin-bottom: 4px; }
.breadcrumbs a { color: var(--text-hint); }
.breadcrumbs a:hover { color: var(--text); }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.actions-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: none; }

.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stack { display: flex; flex-direction: column; gap: var(--gap, 20px); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { justify-content: space-between; }
.inline { display: inline; }

@media (max-width: 960px) {
  .grid-main, .grid-2 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .nav { display: none; }
}

/* Text utilities */

.muted { color: var(--text-secondary); }
.hint { color: var(--text-hint); }
.faint { color: var(--text-faint); }
.small { font-size: 12px; line-height: 16px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.danger-text { color: var(--danger); }
.success-text { color: var(--success); }
.warning-text { color: var(--warning); }

/* Cards */

.card { background: var(--bg-float); border: 1px solid var(--line); border-radius: var(--radius); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 44px; }
.card-head .row { gap: 10px; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 10px 16px; border-top: 1px solid var(--line); background: var(--bg-soft); border-radius: 0 0 var(--radius) var(--radius); }
details.card > summary { list-style: none; cursor: pointer; }
details.card > summary::-webkit-details-marker { display: none; }
details.card:not([open]) > summary { border-bottom: 0; }

.empty { padding: 28px 16px; text-align: center; color: var(--text-hint); }
.empty.small { padding: 14px 16px; }

/* Stats */

.stat { padding: 14px 16px; }
.stat .caption { color: var(--text-hint); }
.stat .value { font-size: 24px; line-height: 28px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .value .sub { font-size: 15px; color: var(--text-hint); font-weight: 400; }
.stat .note { color: var(--text-hint); margin-top: 2px; }

/* Tables */

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 400; color: var(--text-hint); padding: 8px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--bg-soft); }
.table td .subtle, .subtle { color: var(--text-hint); font-size: 12px; line-height: 16px; margin-top: 2px; }
.table .actions { text-align: right; white-space: nowrap; }
.table-compact td { padding: 8px 16px; }
.table .row-inactive td { color: var(--text-hint); }
.cell-stack { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }

/* Labels */

.label { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 4px; font-size: 12px; line-height: 16px; white-space: nowrap; background: var(--bg-generic); color: var(--text-secondary); }
a.label:hover { text-decoration: none; filter: brightness(0.96); }
.label-success { background: var(--success-bg); color: var(--success); }
.label-warning { background: var(--warning-bg); color: var(--warning); }
.label-danger { background: var(--danger-bg); color: var(--danger); }
.label-info { background: var(--info-bg); color: var(--info); }
.label-dark { background: var(--dark); color: #fff; }
.label-outline { background: transparent; border: 1px solid var(--line-strong); }
.label .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chip { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex: none; }
.chip .dot.done { background: var(--success); }
.chip .dot.overdue { background: var(--danger); }
.chip .dot.expired { background: var(--warning); }

/* Buttons */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 28px; padding: 0 12px; border: 0; border-radius: var(--radius-s); background: var(--bg-generic); color: var(--text); font: inherit; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background 0.12s; }
.btn:hover { background: var(--bg-generic-hover); color: var(--text); text-decoration: none; }
.btn-action { background: var(--action); color: #fff; }
.btn-action:hover { background: var(--action-hover); color: #fff; }
.btn-outlined { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn-outlined:hover { background: var(--bg-generic); }
.btn-flat { background: transparent; color: var(--text-secondary); }
.btn-flat:hover { background: var(--bg-generic); }
.btn-danger { color: var(--danger); }
.btn-danger.btn-flat:hover { background: var(--danger-bg); }
.btn-l { height: 36px; padding: 0 16px; font-size: 13px; }
.btn-s { height: 24px; padding: 0 8px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* Forms */

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label { color: var(--text-hint); font-size: 12px; line-height: 16px; }
.field .help { color: var(--text-hint); font-size: 12px; line-height: 16px; }
.input, .select, .textarea { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 0 10px; height: 28px; outline: none; }
.textarea { height: auto; min-height: 84px; padding: 6px 10px; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: rgba(0, 0, 0, 0.3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--action); box-shadow: 0 0 0 2px var(--info-bg); }
.select { appearance: none; padding-right: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%23666' stroke-width='1.4' d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--action); }
.checks { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.check .path { color: var(--text-hint); }

/* Key-value list */

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 0; }
.kv dt { color: var(--text-hint); }
.kv dd { margin: 0; min-width: 0; }

/* Flashes */

.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.flash { padding: 10px 14px; border-radius: var(--radius-s); background: var(--bg-generic); color: var(--text); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.flash-success { background: var(--success-bg); }
.flash-warning { background: var(--warning-bg); }
.flash-danger { background: var(--danger-bg); }
.flash-info, .flash-link { background: var(--info-bg); }

/* Tabs */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs a { padding: 8px 12px; color: var(--text-secondary); position: relative; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); font-weight: 600; }
.tabs a.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--dark); }

/* Timeline */

.timeline { list-style: none; margin: 0; padding: 4px 0; }
.timeline li { display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 6px 16px; }
.timeline li + li { border-top: 1px solid var(--line); }
.timeline .when { color: var(--text-hint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.timeline .kind { display: block; font-family: var(--mono); font-size: 11px; color: var(--text-hint); }
.timeline-scroll { max-height: 560px; overflow: auto; }

/* Deadline informer */

.informer { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 20px; }
.deadline { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-float); color: var(--text); }
.deadline:hover { text-decoration: none; border-color: var(--line-strong); }
.deadline .days { min-width: 44px; text-align: center; font-size: 20px; line-height: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.deadline .days small { display: block; font-size: 11px; line-height: 14px; font-weight: 400; color: var(--text-hint); }
.deadline .what { min-width: 0; }
.deadline .what strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deadline .what span { color: var(--text-hint); font-size: 12px; }
.deadline-soon { border-color: rgba(255, 190, 92, 0.8); background: rgba(255, 190, 92, 0.12); }
.deadline-soon .days { color: var(--warning); }
.deadline-over { border-color: rgba(255, 4, 0, 0.35); background: rgba(255, 4, 0, 0.05); }
.deadline-over .days { color: var(--danger); }
.deadline-review .days { color: var(--info); }

/* Markdown */

.markdown { line-height: 1.55; }
.markdown h1, .markdown h2, .markdown h3 { margin: 16px 0 8px; }
.markdown h1 { font-size: 18px; line-height: 24px; }
.markdown h2 { font-size: 15px; }
.markdown h3 { font-size: 13px; }
.markdown h1:first-child, .markdown h2:first-child { margin-top: 0; }
.markdown p, .markdown ul, .markdown ol { margin: 0 0 10px; }
.markdown ul, .markdown ol { padding-left: 22px; }
.markdown pre { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px; overflow: auto; font-size: 12px; line-height: 18px; }
.markdown code { background: var(--bg-generic); padding: 1px 5px; border-radius: 4px; }
.markdown pre code { background: none; padding: 0; }
.markdown table { border-collapse: collapse; margin-bottom: 10px; }
.markdown th, .markdown td { border: 1px solid var(--line); padding: 4px 8px; }
.markdown blockquote { margin: 0 0 10px; padding: 4px 12px; border-left: 3px solid var(--line-strong); color: var(--text-secondary); }

/* Review page */

.review-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.review-side { position: sticky; top: 72px; }
.review-side.stack { --gap: 16px; }
@media (max-width: 1200px) {
  .review-layout { grid-template-columns: minmax(0, 1fr) 320px; }
  .review-files { display: none; }
}
@media (max-width: 900px) {
  .review-layout { grid-template-columns: 1fr; }
  .review-side { position: static; }
}

.compare { display: flex; align-items: center; gap: 8px; }
.compare label { color: var(--text-hint); white-space: nowrap; }
.compare .select { width: auto; max-width: 320px; }

.files-nav { list-style: none; margin: 0; padding: 6px 0; }
.files-nav a { display: flex; align-items: center; gap: 8px; padding: 6px 16px; color: var(--text); }
.files-nav a:hover { background: var(--bg-soft); text-decoration: none; }
.files-nav .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12px; }
.files-nav .delta { font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.files-nav .delta .plus { color: var(--success); }
.files-nav .delta .minus { color: var(--danger); }
.files-nav .count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--warning-bg); color: var(--warning); font-size: 11px; line-height: 18px; text-align: center; }

.file { overflow: hidden; }
.file + .file { margin-top: 16px; }
.file-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px 8px 16px; border-bottom: 1px solid var(--line); background: var(--bg-soft); }
.file-head .path { font-family: var(--mono); font-size: 12px; font-weight: 600; }
.file-head .tag { margin-left: 8px; }
.file-head .delta { font-family: var(--mono); font-size: 12px; color: var(--text-hint); }
.file-head .delta .plus { color: var(--success); }
.file-head .delta .minus { color: var(--danger); }
details.file > summary { list-style: none; cursor: pointer; }
details.file > summary::-webkit-details-marker { display: none; }
details.file:not([open]) .file-head { border-bottom: 0; }

.code-scroll { overflow-x: auto; }
.code { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12px; line-height: 20px; tab-size: 4; }
.code td { padding: 0; vertical-align: top; }
.code .gutter { width: 44px; min-width: 44px; text-align: right; padding-right: 8px; color: var(--text-faint); user-select: none; white-space: nowrap; background: var(--bg-soft); border-right: 1px solid var(--line); position: relative; font-variant-numeric: tabular-nums; }
.code .gutter.gutter-old { border-right: 0; }
.code .src { padding: 0 16px 0 12px; white-space: pre; }
.code .src.blank { width: 100%; }
.code .marker { width: 18px; min-width: 18px; text-align: center; color: var(--text-faint); user-select: none; }
.code-line.add td.src, .code-line.add td.marker { background: var(--diff-add); }
.code-line.add td.gutter { background: var(--diff-add-gutter); color: var(--text-secondary); }
.code-line.add td.marker { color: var(--success); }
.code-line.remove td.src, .code-line.remove td.marker { background: var(--diff-remove); }
.code-line.remove td.gutter { background: var(--diff-remove-gutter); color: var(--text-secondary); }
.code-line.remove td.marker { color: var(--danger); }
.code-line.remove .src { color: var(--text-secondary); }
.code-line:hover td.src { background-color: rgba(47, 111, 228, 0.06); }
.code-line.has-thread td.gutter-new { box-shadow: inset 3px 0 0 var(--warning); }

.code .add-comment { position: absolute; left: 4px; top: 2px; width: 16px; height: 16px; border: 0; border-radius: 4px; background: var(--action); color: #fff; font: 600 12px/16px var(--mono); cursor: pointer; opacity: 0; transition: opacity 0.1s; padding: 0; }
.code-line:hover .add-comment { opacity: 1; }
.code-line.remove .add-comment { display: none; }

.thread-row td { padding: 0; }
.thread-row.empty { display: none; }
.thread { margin: 6px 12px 10px 62px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-float); box-shadow: var(--shadow); font-family: var(--font); font-size: 13px; line-height: 18px; overflow: hidden; }
.thread-general { margin: 0; border: 0; box-shadow: none; }
.comment { padding: 10px 12px; }
.comment + .comment { border-top: 1px solid var(--line); }
.thread-general .comment { padding: 8px 0; }
.comment-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.comment-head .who { color: var(--text); font-weight: 600; }
.comment-head .when { color: var(--text-hint); font-size: 12px; margin-left: auto; }
.comment-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { padding: 10px 12px; border-top: 1px solid var(--line); background: var(--bg-soft); }
.thread-general .comment-form { padding: 0; border: 0; background: none; }
.comment-form .textarea { min-height: 64px; background: var(--bg); }
.thread-actions { display: flex; gap: 8px; margin-top: 8px; }
.thread-reply { margin: 8px 12px 10px; }
.thread-general .thread-reply { margin: 8px 0 0; }

.verdict-options { display: flex; flex-direction: column; gap: 8px; }
.verdict-option { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); cursor: pointer; }
.verdict-option:hover { border-color: var(--line-strong); background: var(--bg-soft); }
.verdict-option:has(input:checked) { border-color: var(--action); box-shadow: 0 0 0 1px var(--action); }
.verdict-option input { margin: 3px 0 0; accent-color: var(--action); }
.verdict-option .title { font-weight: 600; }
.verdict-option .desc { color: var(--text-hint); font-size: 12px; line-height: 16px; margin-top: 2px; }

.summary-box { white-space: pre-wrap; overflow-wrap: anywhere; padding: 10px 12px; background: var(--bg-soft); border-radius: var(--radius-s); }

.notice { padding: 10px 14px; border-radius: var(--radius-s); background: var(--warning-bg); color: var(--text); margin-bottom: 16px; }
.notice-danger { background: var(--danger-bg); }
.notice-info { background: var(--info-bg); }

/* Syntax highlighting */

.pygments .k { color: #a626a4; }
.pygments .nb { color: #0f7e8b; }
.pygments .nf { color: #2f6fe4; }
.pygments .nc { color: #c18401; }
.pygments .nd { color: #c18401; }
.pygments .s { color: #3a8b39; }
.pygments .m { color: #b25c00; }
.pygments .c { color: var(--text-hint); font-style: italic; }
.pygments .o { color: var(--text-secondary); }
.pygments .gh { font-weight: 600; }

/* Login */

.login-card { max-width: 440px; margin: 64px auto 0; }
.login-card h1 { font-size: 20px; line-height: 24px; margin-bottom: 12px; }
.login-card ol { padding-left: 20px; line-height: 1.7; margin: 0 0 12px; }
