:root {
  --bg: #ffffff;
  --surface: #f6f7f8;
  --border: #e3e5e8;
  --text: #333333;
  --muted: #8a8d93;
  --link: #3b6ef5;
  --accent: #ffdd2d;
  --chip: #eef2fe;
  --radius: 24px;
  --g0: #ebedf0; --g1: #9be9a8; --g2: #40c463; --g3: #30a14e; --g4: #216e39;
  --icon-bg: #fff6c4; --icon-fg: #b58a00; --go-bg: #e3f6fb;
  color-scheme: light;
}
/* Тёмная тема: явный выбор пользователя (data-theme) или системная настройка */
:root[data-theme="dark"] {
  --bg: #15171a; --surface: #1e2125; --border: #2e3237; --text: #e6e7e9;
  --muted: #9196a0; --link: #7a9bff; --chip: #23304f;
  --g0: #22272e; --g1: #0e4429; --g2: #006d32; --g3: #26a641; --g4: #39d353;
  --icon-bg: #3a3215; --icon-fg: var(--accent); --go-bg: #0e2f38;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a; --surface: #1e2125; --border: #2e3237; --text: #e6e7e9;
    --muted: #9196a0; --link: #7a9bff; --chip: #23304f;
    --g0: #22272e; --g1: #0e4429; --g2: #006d32; --g3: #26a641; --g4: #39d353;
    --icon-bg: #3a3215; --icon-fg: var(--accent); --go-bg: #0e2f38;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 1em; height: 1em; fill: currentColor; flex-shrink: 0; }
.muted { color: var(--muted); }

.layout {
  max-width: 1180px; margin: 0 auto; padding: 20px 36px 40px;
  display: grid; grid-template-columns: 336px minmax(0, 1fr); gap: 48px; align-items: start;
}
.sidebar, .main, .card { min-width: 0; }
.sidebar { display: flex; flex-direction: column; gap: 24px; position: sticky; top: 20px; }

/* Карточки */
.card { border-radius: var(--radius); padding: 24px 20px; }
.card--bordered { border: 1px solid var(--border); background: var(--bg); }
.card--profile { background: var(--surface); text-align: center; padding: 32px 20px 24px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-title { margin: 0; font-size: 18px; font-weight: 600; }
.more-link { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; }

.avatar {
  width: 200px; height: 200px; border-radius: 50%; object-fit: cover; object-position: 50% 18%;
  display: block; margin: 0 auto 20px; box-shadow: 0 6px 24px rgba(0,0,0,.12);
}
.profile-name { font-size: 22px; line-height: 1.3; margin: 0; font-weight: 700; }
.profile-title { margin: 6px 0 16px; color: var(--muted); }
.profile-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; }
.profile-links a, .profile-links span { display: inline-flex; align-items: center; gap: 4px; }
.profile-links .is-disabled { color: var(--muted); cursor: default; }
.profile-actions { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }
.round-btn {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--chip); color: var(--link); font-size: 17px; transition: transform .15s;
}
.round-btn:hover { transform: translateY(-2px); text-decoration: none; }

/* Activity */
.activity-total { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.activity-total span { color: var(--text); font-weight: 600; }
.activity-scroll { overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.activity-grid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 10px); gap: 3px; width: max-content; min-height: 88px; }
.activity-grid i, .legend i { width: 10px; height: 10px; border-radius: 2px; display: block; background: var(--g0); }
.l1 { background: var(--g1) !important; } .l2 { background: var(--g2) !important; }
.l3 { background: var(--g3) !important; } .l4 { background: var(--g4) !important; }
.activity-legend { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 12px; color: var(--muted); gap: 8px; }
.legend { display: inline-flex; align-items: center; gap: 3px; }

/* Вкладки */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 40px; }

/* Переключатель темы */
.theme-toggle {
  margin-left: auto; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  font-size: 16px; transition: color .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--muted); }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
.tab {
  font: inherit; font-size: 13px; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; cursor: pointer;
}
.tab:hover { border-color: var(--muted); text-decoration: none; }
.tab.is-active { border: 2px solid var(--accent); padding: 5px 9px; }
.panel[hidden] { display: none; }
.panel { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.section-title { font-size: 22px; font-weight: 600; margin: 0 0 20px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-top: 48px; }
.count { color: var(--muted); }
.about { margin: 0 0 40px; max-width: 720px; font-size: 14px; line-height: 1.65; }

/* Ключ — значение, как в макете */
.kv { margin: 0 0 8px; }
.kv-row { display: grid; grid-template-columns: 240px 1fr; gap: 16px; padding: 10px 0; }
.kv-row dt { color: var(--muted); }
.kv-row dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1px 8px; font-size: 13px; }

/* Expertise */
.tech-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tech-card { border: 1px solid var(--border); border-radius: 20px; padding: 20px; }
.tech-card-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.tech-card h3 { margin: 0; font-size: 16px; }
.tech-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--icon-bg); color: var(--icon-fg); font-size: 18px; flex-shrink: 0; }
.tech-icon svg { width: 24px; height: 24px; }
.tech-icon[data-icon="go.svg"] { background: var(--go-bg); }
.tech-icon[data-icon="go.svg"] svg { width: 30px; height: 15px; }
.badge { font-size: 12px; color: var(--muted); }
.tech-card p { margin: 0 0 10px; font-size: 14px; }
.section-note { margin: 20px 0 0; font-size: 13px; color: var(--muted); }
.section-note a { white-space: nowrap; }
.tech-card ul, .tech-card ol { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); }

/* Карьера */
.kv-row dd.kv-block { display: block; }
.timeline { list-style: none; margin: 0 0 24px; padding: 0; }
.job { display: grid; grid-template-columns: 140px 1fr; gap: 24px; position: relative; padding-bottom: 32px; }
.job--nodate { grid-template-columns: 1fr; }
.job-period { color: var(--muted); font-size: 14px; padding-top: 2px; }
.job-body { grid-column: -2 / -1; border-left: 2px solid var(--border); padding-left: 24px; position: relative; }
.job-body::before {
  content: ""; position: absolute; left: -7px; top: 6px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--bg);
}
.job-position { margin: 0; font-size: 18px; }
.job-company { margin: 2px 0 10px; }
.job-body p { margin: 0 0 8px; }
.job-achievements { margin: 0 0 12px; padding-left: 18px; }
.job-achievements li { margin-bottom: 4px; }
.job-stack { display: flex; flex-wrap: wrap; gap: 6px; }
/* Сворачиваемые блоки: высоту задаёт --collapsed-h */
[data-collapsible] { position: relative; }
.is-collapsible { overflow: hidden; transition: max-height .35s ease; }
.is-collapsed { max-height: var(--collapsed-h, 220px); }
.is-collapsed::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 64px;
  background: linear-gradient(to bottom, transparent, var(--bg)); pointer-events: none;
}
.stack-overview + .collapse-toggle { margin-top: 4px; }
.collapse-toggle {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px;
  font: inherit; font-size: 14px; color: var(--link); background: var(--chip);
  border: 0; border-radius: 999px; padding: 4px 12px; cursor: pointer;
}
.collapse-toggle[hidden] { display: none; }
.collapse-toggle svg { font-size: 16px; transition: transform .25s; }
.collapse-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.project { background: var(--surface); border-radius: 16px; padding: 16px 18px; margin: 12px 0; }
.project h4, .job-subtitle { margin: 0 0 6px; font-size: 15px; }
.job-subtitle { margin-top: 16px; }
.project p { color: var(--muted); }
.job-skills { margin-top: 12px; }
.job-skills summary { cursor: pointer; color: var(--link); font-size: 14px; }
.job-skills .kv { margin-top: 8px; }
.kv--compact .kv-row { grid-template-columns: 180px 1fr; padding: 6px 0; }
@media (max-width: 900px) { .kv--compact .kv-row { grid-template-columns: 1fr; } }

/* Посты */
.tag-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tag-filter button { font: inherit; font-size: 13px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 999px; padding: 2px 10px; cursor: pointer; }
.tag-filter button.is-active { border-color: var(--accent); background: var(--accent); color: #333; }
.posts { display: grid; gap: 12px; }
.post-card { display: block; border: 1px solid var(--border); border-radius: 20px; padding: 18px 20px; color: inherit; transition: border-color .15s; }
.post-card:hover { border-color: var(--accent); text-decoration: none; }
.post-card time, .post-meta { color: var(--muted); font-size: 13px; }
.post-card h3 { margin: 4px 0 6px; font-size: 18px; }
.post-card p { margin: 0 0 8px; }
.post-tags, .post-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--link); }
.post-meta time { color: var(--muted); }
.back-link { font-size: 14px; }
.post-title { font-size: 30px; margin: 12px 0 8px; line-height: 1.25; }
.prose { margin-top: 24px; max-width: 720px; font-size: 16px; line-height: 1.7; }
.prose pre { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; overflow-x: auto; font-size: 14px; }
.prose code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.prose :not(pre) > code { background: var(--surface); padding: 1px 5px; border-radius: 4px; }
.prose img { max-width: 100%; border-radius: 12px; }
.prose blockquote { margin: 0; padding-left: 16px; border-left: 3px solid var(--accent); color: var(--muted); }

.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 0 16px 32px; }

/* Адаптив */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 32px; padding: 16px; }
  .avatar { width: 180px; height: 180px; }
  .sidebar { position: static; }
  .kv-row { grid-template-columns: 1fr; gap: 6px; }
  .job { grid-template-columns: 1fr; gap: 4px; }
  .job-period { padding-left: 26px; }
  .tabs { margin-bottom: 28px; }
}
