/* ---------- тема ---------- */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f0f2f5; --hover: #eef1f5;
  --text: #1c2229; --muted: #687280; --faint: #9aa3ae;
  --border: #e3e6ea; --border-strong: #cfd5dc;
  --accent: #2f6fde; --accent-hover: #2560c7; --accent-soft: #e8f0fd; --on-accent: #fff;
  --danger: #cf3f34; --danger-soft: #fdecea; --warn: #b7791f; --ok: #2f855a;
  --mark: #ffe58a; --code-bg: #f0f2f5;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg: 0 8px 24px rgba(16,24,40,.12);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121519; --surface: #1a1e24; --surface-2: #22272f; --hover: #262c35;
    --text: #e3e7ec; --muted: #9098a4; --faint: #6b7380;
    --border: #2b313a; --border-strong: #3a424d;
    --accent: #6ea2ff; --accent-hover: #8cb5ff; --accent-soft: #1d2a40; --on-accent: #0d1420;
    --danger: #f07167; --danger-soft: #3a1f1d; --warn: #e0b050; --ok: #5fc08a;
    --mark: #6a5714; --code-bg: #232830;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 8px 28px rgba(0,0,0,.5);
    --box-success-bg: #14281c; --box-success-bd: #2d5a3c; --box-success-fg: #6fd19a;
    --box-info-bg: #16233a; --box-info-bd: #2e4c7c; --box-info-fg: #8db8ff;
    --box-warning-bg: #2a2412; --box-warning-bd: #6a5520; --box-warning-fg: #e8c060;
    --box-danger-bg: #2e1716; --box-danger-bd: #733430; --box-danger-fg: #f3908a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121519; --surface: #1a1e24; --surface-2: #22272f; --hover: #262c35;
  --text: #e3e7ec; --muted: #9098a4; --faint: #6b7380;
  --border: #2b313a; --border-strong: #3a424d;
  --accent: #6ea2ff; --accent-hover: #8cb5ff; --accent-soft: #1d2a40; --on-accent: #0d1420;
  --danger: #f07167; --danger-soft: #3a1f1d; --warn: #e0b050; --ok: #5fc08a;
  --mark: #6a5714; --code-bg: #232830;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 8px 28px rgba(0,0,0,.5);
  --box-success-bg: #14281c; --box-success-bd: #2d5a3c; --box-success-fg: #6fd19a;
  --box-info-bg: #16233a; --box-info-bd: #2e4c7c; --box-info-fg: #8db8ff;
  --box-warning-bg: #2a2412; --box-warning-bd: #6a5520; --box-warning-fg: #e8c060;
  --box-danger-bg: #2e1716; --box-danger-bd: #733430; --box-danger-fg: #f3908a;
  color-scheme: dark;
}

/* ---------- основа ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; font-weight: 650; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 .8rem; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--border); margin: .4rem 0; }
.muted { color: var(--muted); }
small { font-size: .82em; }
.sprite { display: none; }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
[hidden] { display: none !important; }
.container { max-width: 1280px; margin: 0 auto; padding: 20px 20px 60px; }
.container.narrow { max-width: 760px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- кнопки и поля ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none; user-select: none;
  transition: background .12s, border-color .12s; }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--hover); }
.btn-icon { width: 36px; padding: 0; justify-content: center; }
.btn-sm { height: 30px; padding: 0 10px; font-size: .9em; }
.btn-block { width: 100%; justify-content: center; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px; }
.linkish:hover { text-decoration: underline; }
input, select, textarea { font: inherit; color: var(--text); }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select {
  height: 38px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled { opacity: .6; }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 5px; font-size: .9em; color: var(--muted); }
.form label input { color: var(--text); font-size: 1rem; }
.form .check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.form.grid2 { grid-template-columns: 1fr 1fr; align-items: end; }
.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.inline input { width: 170px; height: 30px; }

/* ---------- шапка ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  height: 58px; padding: 0 20px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 1.05rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand { min-width: 0; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* длинное название блога — в одну строку */
.brand .i { width: 24px; height: 24px; color: var(--accent); }
.search { flex: 1; max-width: 560px; margin: 0 auto; position: relative; display: flex; align-items: center; }
.search .i { position: absolute; left: 11px; color: var(--faint); pointer-events: none; }
.search input { padding-left: 36px !important; padding-right: 34px !important; background: var(--surface-2) !important; border-color: transparent !important; }
.search input:focus { background: var(--surface) !important; border-color: var(--accent) !important; }
.search kbd { position: absolute; right: 9px; font: 11px/1 ui-monospace, monospace; color: var(--faint);
  border: 1px solid var(--border-strong); border-radius: 4px; padding: 3px 5px; pointer-events: none; }
.search input:focus + kbd { display: none; }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.top-actions form { margin: 0; }
[data-theme-toggle] .i:last-child { display: none; }
:root[data-theme="dark"] [data-theme-toggle] .i:first-child { display: none; }
:root[data-theme="dark"] [data-theme-toggle] .i:last-child { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) [data-theme-toggle] .i:first-child { display: none; }
  :root:not([data-theme]) [data-theme-toggle] .i:last-child { display: inline; }
}

/* выпадающее меню на <details> */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  border: 0; background: none; border-radius: 6px; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--hover); text-decoration: none; }
.menu-pop .danger { color: var(--danger); }
.menu-pop form { margin: 0; }
.menu-head { padding: 8px 10px 10px; font-weight: 600; display: grid; }
.menu-head small { color: var(--muted); font-weight: 400; }

.flash { max-width: 760px; margin: 14px auto 0; padding: 10px 12px 10px 16px; display: flex; align-items: center; gap: 10px;
  background: var(--accent-soft); color: var(--text); border-radius: 8px; border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.flash-x { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; }

/* ---------- главная ---------- */
/* общая раскладка: меню слева, справа колонка одной ширины на всех страницах */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.shell-main { min-width: 0; }
.scopes-sep { height: 1px; background: var(--border); margin: 8px 10px; }
.sidebar { position: sticky; top: 78px; display: grid; gap: 18px; max-height: calc(100vh - 100px); overflow-y: auto; overflow-x: hidden;
  scrollbar-width: none; overscroll-behavior: contain; } /* длинный список тегов листается колёсиком, без полосы прокрутки */
.sidebar::-webkit-scrollbar { display: none; }
.scopes { display: grid; gap: 2px; }
.scopes a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text); }
.scopes a:hover { background: var(--hover); text-decoration: none; }
.scopes a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tagbox summary { cursor: pointer; display: flex; align-items: center; gap: 8px; color: var(--muted);
  font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; padding: 0 10px 6px; list-style: none; }
.tagbox summary::-webkit-details-marker { display: none; }
.taglist { display: grid; gap: 1px; }
.tag-link { display: flex; justify-content: space-between; gap: 8px; padding: 2px 10px; line-height: 1.4; border-radius: 6px; color: var(--text); font-size: .93em; }
.tag-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-link small { color: var(--faint); }
.tag-link:hover { background: var(--hover); text-decoration: none; }
.tag-link.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tag-link.on small { color: var(--accent); }

.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; min-height: 36px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.list-title { font-size: 1.25rem; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); font-weight: 500; font-size: .92em; }
.chip-x .i { width: 14px; height: 14px; vertical-align: -2px; }
.chip-x:hover { text-decoration: none; filter: brightness(.95); }
.chip-clear { font-size: .9em; color: var(--muted); }

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; flex: none; background: var(--surface); }
.seg a, .seg button { display: grid; place-items: center; width: 36px; height: 32px; color: var(--muted); border: 0; background: none; cursor: pointer; }
.seg > * + * { border-left: 1px solid var(--border-strong) !important; }
.seg a:hover, .seg button:hover { background: var(--hover); }
.seg .on { background: var(--accent-soft); color: var(--accent); }

.tags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: .8em; padding: 1px 7px; border-radius: 5px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge { display: inline-grid; place-items: center; color: var(--muted); }
.badge .i { width: 15px; height: 15px; }
.badge.warn { color: var(--warn); }
.meta-icons { display: inline-flex; align-items: center; gap: 7px; }
.owner { display: inline-flex; align-items: center; gap: 3px; font-size: .9em; color: var(--muted); }
.owner .i { width: 14px; height: 14px; }

/* карточки */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; align-items: start; }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; color: var(--text); box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s, border-color .12s; }
.card:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.card-img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--surface-2); display: block; border-bottom: 1px solid var(--border); }
.card-body { padding: 13px 15px 8px; display: grid; gap: 7px; align-content: start; flex: 1; }
.card-title { font-weight: 620; font-size: 1.02rem; line-height: 1.35; padding-right: 30px; }
.card-img + .card-body .card-title { padding-right: 0; }
.card-text { color: var(--muted); font-size: .9em; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.card-img + .card-body .card-text { -webkit-line-clamp: 3; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 15px 11px; font-size: .82em; color: var(--faint); }
mark { background: var(--mark); color: inherit; border-radius: 2px; }

/* список */
.rows { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 16px; align-items: center; padding: 11px 16px; color: var(--text); }
.row + .row { border-top: 1px solid var(--border); }
.row:hover { background: var(--hover); text-decoration: none; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: .88em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-tags { max-width: 260px; overflow: hidden; }
.row-tags .tags { flex-wrap: nowrap; }
.row-meta { display: flex; align-items: center; gap: 10px; font-size: .85em; color: var(--faint); white-space: nowrap; }
.row-meta time { min-width: 92px; text-align: right; }
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty form { margin-top: 12px; }
.more { text-align: center; margin: 22px 0; }

/* ---------- заметка ---------- */
.note-page { width: 100%; }
.note-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 18px; }
.note-bar form { margin: 0; }
.note-actions { display: flex; gap: 8px; align-items: center; }
.menu-pop.right { right: 0; }
.note-head { margin-bottom: 26px; }
.note-head h1 { font-size: 2rem; line-height: 1.25; margin-bottom: 10px; overflow-wrap: anywhere; }
.note-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; color: var(--muted); font-size: .9em; }
.note-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.note-meta .spacer { flex: 1; }
.note-meta a { display: inline-flex; align-items: center; gap: 4px; }
.note-page > .md { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 34px; box-shadow: var(--shadow); }
.note-page > .md:empty { display: none; }

/* ---------- страницы-формы ---------- */
.page-head { display: grid; gap: 10px; margin-bottom: 20px; justify-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.panel p:first-child { margin-top: 0; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 30px; max-width: 420px;
  margin: 8vh auto 0; box-shadow: var(--shadow-lg); }
.auth-card h1 { margin-bottom: 18px; display: flex; align-items: center; gap: 10px; }
.auth-card.center { text-align: center; }
.auth-card .force { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.err-code { font-size: 3.5rem; font-weight: 700; color: var(--faint); line-height: 1; }
.alert { padding: 10px 14px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); margin-bottom: 16px; }
.alert.info { background: var(--accent-soft); color: var(--text); }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.tabs a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; background: var(--hover); }

.vis-options { display: grid; gap: 8px; }
.opt { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.opt input { margin-top: 4px; accent-color: var(--accent); }
.opt span { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; }
.opt small { grid-column: 2; color: var(--muted); }
.copyline { display: flex; gap: 8px; margin: 14px 0 10px; }
.copyline input { font-family: ui-monospace, monospace; font-size: .88em !important; }
.pubslug { margin: 16px 0 6px; }
.pubslug > label { font-weight: 600; }
.pubslug .copyline { align-items: center; margin: 6px 0 6px; }
.pubslug-base { color: var(--muted); font: .88em ui-monospace, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.pubslug p { margin: 4px 0; font-size: .9em; }
.share-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 6px; }
.share-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; }
.share-list .who { flex: 1; display: flex; align-items: center; gap: 6px; }
.share-list .who small { color: var(--muted); }
.share-list select { width: auto; height: 32px; }
.add-share { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
.add-share select:last-of-type { width: auto; }

.rev-list { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.rev-list li { display: grid; grid-template-columns: 1fr 150px 140px; gap: 12px; padding: 10px 16px; align-items: center; }
.rev-list li + li { border-top: 1px solid var(--border); }
.rev-list li > span:not(:first-child) { color: var(--muted); font-size: .9em; }
.rev-list a, .rev-list .current > span:first-child { display: inline-flex; align-items: center; gap: 8px; }
.rev-list .current { background: var(--accent-soft); }

.table-wrap { overflow-x: auto; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); }
.table td { border-top: 1px solid var(--border); }
.table tr:first-child td { border-top: 0; }
.table tr.dim td { opacity: .55; }
.table form { margin: 0; }
.table select { width: auto; height: 32px; }

/* ---------- редактор ---------- */
body.editing { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body.editing .topbar { display: none; }
.editor-main { flex: 1; min-height: 0; display: flex; }
.editor { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.ed-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.ed-title { flex: 1; min-width: 0; border: 0 !important; box-shadow: none !important; background: transparent !important;
  font-size: 1.35rem !important; font-weight: 650; height: 42px !important; padding: 0 4px !important; }
.ed-status { font-size: .85em; color: var(--muted); white-space: nowrap; }
.ed-status.dirty { color: var(--warn); }
.ed-status.err { color: var(--danger); font-weight: 600; }
.ed-tags { display: flex; align-items: center; gap: 8px; padding: 6px 16px 6px 22px; border-bottom: 1px solid var(--border); color: var(--faint); }
.ed-tags .ac { flex: 1; position: relative; }
.ed-tags input { border: 0 !important; box-shadow: none !important; background: transparent !important; height: 32px !important; padding: 0 4px !important; }
.ac-list { position: absolute; left: 0; top: 100%; z-index: 20; list-style: none; margin: 4px 0 0; padding: 4px; min-width: 220px; max-height: 260px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); color: var(--text); }
.ac-list li { padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.ac-list li.on, .ac-list li:hover { background: var(--accent-soft); color: var(--accent); }
.ed-toolbar { display: flex; align-items: center; gap: 2px; padding: 5px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); overflow-x: auto; }
.ed-toolbar > button, .tb-file { min-width: 32px; height: 30px; padding: 0 7px; border: 0; border-radius: 6px; background: none; color: var(--text);
  cursor: pointer; font: 14px/1 system-ui, sans-serif; display: inline-grid; place-items: center; flex: none; }
.ed-toolbar > button:hover, .tb-file:hover { background: var(--hover); }
.tb-file input { display: none; }
.ed-toolbar .sep { width: 1px; height: 18px; background: var(--border-strong); margin: 0 5px; flex: none; }
.ed-toolbar .grow { flex: 1; }
.ed-toolbar .seg button { height: 28px; }
.ed-banner { padding: 10px 16px; background: var(--danger-soft); color: var(--danger); font-weight: 500; border-bottom: 1px solid var(--border); }
.ed-banner.info { background: var(--accent-soft); color: var(--text); }
.ed-panes { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; }
/* Поле ввода и раскрашенная копия под ним должны совпадать до пикселя: общие
   шрифт, отступы и правила переноса строк задаются одним правилом. */
.ed-code { position: relative; min-height: 0; overflow: hidden; background: var(--surface); }
.ed-code > .ed-body, .ed-code > .ed-hl {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; box-sizing: border-box; border: 0;
  padding: 20px 24px 40vh; font: 15px/1.65 ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  letter-spacing: normal; word-spacing: normal; tab-size: 4; -moz-tab-size: 4;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; text-align: left; }
.ed-body { resize: none; background: transparent; color: var(--text); overflow-y: auto; }
.ed-body:focus { box-shadow: none; }
.ed-code > pre.ed-hl { background: transparent; color: var(--text); overflow: hidden; pointer-events: none; border-radius: 0; }
/* Цвета разметки в редакторе. Жирный и курсив ширину знаков моноширинного
   шрифта не меняют, поэтому копия не расходится с полем ввода. */
.ed-hl {
  --m-h: #c4520f; --m-mark: #9aa3ae; --m-link: #2f6fde; --m-url: #7b8491; --m-ttl: #8a6100;
  --m-alt: #7a3fc4; --m-li: #c4520f; --m-code: #b3261e; --m-pipe: #2f6fde;
}
:root[data-theme="dark"] .ed-hl {
  --m-h: #f0883e; --m-mark: #6b7380; --m-link: #79b0ff; --m-url: #8b949e; --m-ttl: #d4a94e;
  --m-alt: #c59cff; --m-li: #f0883e; --m-code: #ff9e8f; --m-pipe: #79b0ff;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .ed-hl {
  --m-h: #f0883e; --m-mark: #6b7380; --m-link: #79b0ff; --m-url: #8b949e; --m-ttl: #d4a94e;
  --m-alt: #c59cff; --m-li: #f0883e; --m-code: #ff9e8f; --m-pipe: #79b0ff;
} }
.ed-hl .m-h, .ed-hl .m-hm { color: var(--m-h); font-weight: 700; }
.ed-hl .m-h .m-mk { color: inherit; }
.ed-hl .m-mk, .ed-hl .m-hr, .ed-hl .m-qm { color: var(--m-mark); }
.ed-hl .m-b { font-weight: 700; }
.ed-hl .m-i { font-style: italic; }
.ed-hl .m-s, .ed-hl .m-doneT { text-decoration: line-through; color: var(--muted); }
.ed-hl .m-q { color: var(--muted); font-style: italic; }
.ed-hl .m-lt { color: var(--m-link); }
.ed-hl .m-alt { color: var(--m-alt); }
.ed-hl .m-url { color: var(--m-url); text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
.ed-hl .m-ttl { color: var(--m-ttl); }
.ed-hl .m-code { color: var(--m-code); }
.ed-hl .m-pipe { color: var(--m-pipe); font-weight: 700; }
.ed-hl .m-li, .ed-hl .m-todo { color: var(--m-li); font-weight: 700; }
.ed-hl .m-done { color: var(--ok); font-weight: 700; }
.ed-hl .m-fence, .ed-hl .m-lang { color: var(--m-mark); font-style: italic; }
.ed-hl .m-pre { color: var(--text); }
.ed-hl .m-cut { color: var(--ok); font-weight: 700; background: color-mix(in srgb, var(--ok) 12%, transparent); }
.ed-hl .m-cutarg { color: var(--ok); font-weight: 700; background: color-mix(in srgb, var(--ok) 22%, transparent); }
.ed-hl .m-bad { color: var(--danger); font-weight: 700; text-decoration: wavy underline; text-decoration-color: var(--danger); }
.ed-hl .m-cmt { color: var(--faint); }
.ed-hl .m-boxe { color: var(--m-mark); font-weight: 700; }
.ed-hl .m-boxt { font-weight: 700; }
.ed-hl .m-box-success { color: var(--box-success-fg, #1f7a45); font-weight: 700; }
.ed-hl .m-box-info    { color: var(--box-info-fg, #1f5bbf); font-weight: 700; }
.ed-hl .m-box-layout  { color: var(--accent); font-weight: 700; }
.ed-hl .m-box-warning { color: var(--box-warning-fg, #8a6100); font-weight: 700; }
.ed-hl .m-box-danger  { color: var(--box-danger-fg, #b3261e); font-weight: 700; }
.ed-hl .m-box-spoiler { color: var(--muted); font-weight: 700; }
.ed-code:not(.hl-on) > .ed-hl { display: none; }
.ed-code.hl-on > .ed-body { color: transparent; caret-color: var(--text); }
.ed-code.hl-on > .ed-body::placeholder { color: var(--faint); }
.ed-code.hl-on > .ed-body::selection { color: transparent; background: color-mix(in srgb, var(--accent) 32%, transparent); }
.ed-panes.drag .ed-code { background: var(--accent-soft); }
.tb-toggle { min-width: 32px; height: 30px; padding: 0 7px; border: 0; border-radius: 6px; background: none; color: var(--muted);
  cursor: pointer; display: inline-grid; place-items: center; flex: none; margin-right: 6px; }
.tb-toggle:hover { background: var(--hover); }
.tb-toggle.on { color: var(--accent); background: var(--accent-soft); }
.ed-preview { overflow: auto; padding: 20px 28px 40vh; border-left: 1px solid var(--border); background: var(--bg); min-height: 0; }
.ed-panes.mode-edit { grid-template-columns: 1fr; }
.ed-panes.mode-edit .ed-preview { display: none; }
.ed-panes.mode-edit .ed-code { max-width: 900px; width: 100%; margin: 0 auto; }
.ed-panes.mode-preview { grid-template-columns: 1fr; }
.ed-panes.mode-preview .ed-code { display: none; }
.ed-panes.mode-preview .ed-preview { border: 0; }
.ed-panes.mode-preview .ed-preview > * { max-width: 860px; margin-left: auto; margin-right: auto; }
.editor.readonly .ed-code { opacity: .7; }

/* ---------- мобильные ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; gap: 14px; }
  .scopes-sep { width: 1px; height: auto; margin: 4px 2px; flex: none; }
  .sidebar { position: static; max-height: none; overflow: visible; gap: 10px; }
  .scopes { display: flex; gap: 6px; overflow-x: auto; }
  .scopes a { white-space: nowrap; border: 1px solid var(--border); background: var(--surface); }
  .tagbox:not([open]) + * { display: none; }
  .taglist { display: flex; flex-wrap: wrap; gap: 6px; }
  .tag-link { border: 1px solid var(--border); background: var(--surface); padding: 4px 10px; }
  .row { grid-template-columns: minmax(0, 1fr) auto; }
  .row-tags { display: none; }
  .ed-panes, .ed-panes.mode-split { grid-template-columns: 1fr; }
  .ed-panes.mode-split .ed-preview { display: none; }
  .note-page > .md { padding: 18px; }
  .note-head h1 { font-size: 1.6rem; }
  .rev-list li { grid-template-columns: 1fr auto; }
  .rev-list li > span:last-child { display: none; }
  .form.grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .hide-sm { display: none; }
  .topbar { gap: 8px; padding: 0 10px; }
  .brand span { display: none; }
  .search kbd { display: none; }
  .container { padding: 14px 12px 50px; }
  .cards { grid-template-columns: 1fr; }
  .add-share { grid-template-columns: 1fr; }
  .ed-top { padding: 8px 10px; }
  .ed-code > .ed-body, .ed-code > .ed-hl { padding: 14px 14px 40vh; font-size: 14px; }
}

/* ---------- чек-листы в режиме просмотра ---------- */
.md input.task { width: 1.2em; height: 1.2em; cursor: pointer; vertical-align: -3px; }
.md li.task-li { cursor: pointer; -webkit-tap-highlight-color: transparent; border-radius: 6px; padding: 1px 4px; margin-left: calc(-1.4em - 4px); }
@media (hover: hover) { .md li.task-li:hover { background: var(--hover); } }
.md li.task-li li.task-li { margin-left: -1.4em; }
.task-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -.3em 0 1.4em; }
.task-add { display: flex; gap: 6px; flex: 1; min-width: 220px; max-width: 480px; margin: 0; }
.task-add input { flex: 1; min-width: 0; height: 34px !important; background: var(--bg) !important; }
.task-clear { color: var(--muted); }
.lock-hint { display: flex; align-items: center; gap: 8px; margin: -12px 0 14px; padding: 8px 12px; border-radius: 8px;
  background: var(--surface-2); color: var(--muted); font-size: .9em; }
.lock-hint[hidden] { display: none; }

/* прогресс чек-листа на карточке */
.prog { display: flex; align-items: center; gap: 8px; font-size: .8em; color: var(--muted); font-variant-numeric: tabular-nums; }
.prog meter { flex: 1; height: 6px; border: 0; border-radius: 3px; background: var(--surface-2); -webkit-appearance: none; appearance: none; }
.prog meter::-webkit-meter-bar { background: var(--surface-2); border: 0; border-radius: 3px; height: 6px; }
.prog meter::-webkit-meter-optimum-value, .prog meter::-webkit-meter-suboptimum-value, .prog meter::-webkit-meter-even-less-good-value { background: var(--accent); border-radius: 3px; }
.prog meter::-moz-meter-bar { background: var(--accent); border-radius: 3px; }
.prog.done { color: var(--ok); }
.prog.done meter::-webkit-meter-optimum-value { background: var(--ok); }
.prog.done meter::-moz-meter-bar { background: var(--ok); }
.prog-text { display: inline-flex; align-items: center; gap: 3px; font-size: .8em; color: var(--muted); margin-right: 6px; font-variant-numeric: tabular-nums; }
.prog-text .i { width: 14px; height: 14px; }
.prog-text.done { color: var(--ok); }

@media (max-width: 600px) {
  .md li.task-li { padding: 5px 4px; }
  .md input.task { width: 1.35em; height: 1.35em; vertical-align: -5px; }
  .task-add { flex: 1 1 100%; min-width: 0; max-width: none; }
  .task-add input { flex: 1; }
  .task-add input { font-size: 16px !important; } /* iOS не зумит поле при фокусе */
}

/* меню блоков в панели редактора */
.tb-menu { position: relative; flex: none; }
.tb-menu > summary { list-style: none; min-width: 32px; height: 30px; padding: 0 7px; border-radius: 6px; cursor: pointer;
  display: grid; place-items: center; font: 14px/1 system-ui, sans-serif; }
.tb-menu > summary::-webkit-details-marker { display: none; }
.tb-menu > summary:hover, .tb-menu[open] > summary { background: var(--hover); }
.tb-menu-pop { position: fixed; z-index: 40; margin-top: 4px; padding: 5px; min-width: 190px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow-lg); }
.tb-menu-pop button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; border: 0; background: none;
  border-radius: 6px; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.tb-menu-pop button:hover { background: var(--hover); }
.tb-menu-pop hr { margin: 4px 6px; border: 0; border-top: 1px solid var(--border); }
.tb-menu-pop .sw-layout   { border-style: dashed; border-color: var(--muted); }
.tb-menu-pop .sw-download { background: var(--accent); border-color: var(--accent); border-radius: 50%; }
.tb-menu-pop i { width: 12px; height: 12px; border-radius: 3px; flex: none; border: 1px solid; }
.tb-menu-pop .sw-success { background: var(--box-success-bg, #ecf8f0); border-color: var(--box-success-bd, #9fd8b3); }
.tb-menu-pop .sw-info    { background: var(--box-info-bg, #eaf2fe); border-color: var(--box-info-bd, #a9c7f5); }
.tb-menu-pop .sw-warning { background: var(--box-warning-bg, #fdf6e3); border-color: var(--box-warning-bd, #ecd08a); }
.tb-menu-pop .sw-danger  { background: var(--box-danger-bg, #fdeeee); border-color: var(--box-danger-bd, #f0b0ab); }
.tb-menu-pop .sw-spoiler { background: var(--surface-2); border-color: var(--border-strong); }

/* ---------- закреплённые ---------- */
.group-title { display: flex; align-items: center; gap: 7px; margin: 4px 0 10px; font-size: .78rem; font-weight: 650;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.group-title .i { width: 15px; height: 15px; }
.cards + .group-title, .rows + .group-title { margin-top: 26px; }
.item { position: relative; min-width: 0; }
.cards > .item > .card { height: 100%; }
.rows > .item + .item { border-top: 1px solid var(--border); }
.rows .row { padding-right: 52px; }
.pin-form { position: absolute; top: 8px; right: 8px; margin: 0; }
.rows .pin-form { top: 50%; transform: translateY(-50%); }
.pin-btn { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; cursor: pointer;
  background: color-mix(in srgb, var(--surface) 85%, transparent); color: var(--faint); opacity: 0; transition: opacity .12s; }
.pin-btn .i { width: 17px; height: 17px; }
.item:hover .pin-btn, .pin-btn:focus-visible { opacity: 1; }
.pin-btn:hover { color: var(--accent); background: var(--accent-soft); }
.is-pinned .pin-btn { opacity: 1; color: var(--accent); }
.is-pinned .pin-btn .i { fill: currentColor; }
.card-img + .card-body { position: relative; }
@media (hover: none) { .pin-btn { opacity: .55; } .is-pinned .pin-btn { opacity: 1; } }
.is-pinned > .card { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.btn.pinned { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border-strong)); background: var(--accent-soft); }
.btn.pinned .i { fill: currentColor; }

/* кнопка «Копировать» у блоков кода: в обёртке, которая не прокручивается */
.md .code-wrap { position: relative; margin: 0 0 1em; }
.md .code-wrap > pre { margin: 0; }
.code-copy { position: absolute; top: 6px; right: 6px; display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 8px;
  border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--muted); font: 12px/1 system-ui, sans-serif;
  cursor: pointer; opacity: 0; transition: opacity .12s; }
.code-copy .i { width: 14px; height: 14px; }
.md .code-wrap:hover .code-copy, .code-copy:focus-visible, .code-copy.done { opacity: 1; }
.code-copy.done { color: var(--ok); border-color: var(--ok); }
@media (hover: none) { .code-copy { opacity: .8; } }
@media print { .code-copy { display: none; } }

/* ---------- настройки: темы подсветки ---------- */
.code-themes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.code-themes select { width: 100%; }
.pv-col { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; align-content: start; min-width: 0; }
.pv-col > * { min-width: 0; }
.pv-col label { font-size: .9em; color: var(--muted); }
.pv .md, .pv { font-size: .88rem; }
.pv pre { margin: 0 0 8px; border: 1px solid var(--border); }
.pv pre:last-child { margin-bottom: 0; }
.pv.pv-light pre:not(.chroma) { background: #f6f8fa; color: #1f2328; }
.pv.pv-dark pre:not(.chroma) { background: #161b22; color: #e6edf3; }
.pv-actions { grid-column: 1 / -1; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
@media (max-width: 700px) { .code-themes { grid-template-columns: 1fr; } }
.pv .code-copy { display: none; }

/* ---------- десктоп: карточки одинаковой высоты, без картинок ----------
   На телефоне карточки идут в одну колонку — там картинка и высота по
   содержимому смотрятся хорошо, а в сетке разная высота рвёт ряды. */
@media (min-width: 861px) {
  .cards { align-items: stretch; grid-auto-rows: 1fr; }
  .cards > .item > .card { height: 100%; }
  .cards .card-img { display: none; }
  .cards .card-img + .card-body .card-title { padding-right: 30px; }
  .cards .card-img + .card-body .card-text { -webkit-line-clamp: 5; }
  .cards .card-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .cards .card-body { display: flex; flex-direction: column; gap: 7px; }
  .cards .card-text { flex: 1 1 auto; }   /* растягивается — теги и прогресс прижаты к низу */
  .cards .card-body > .tags { flex-wrap: nowrap; overflow: hidden; mask-image: linear-gradient(to right, #000 85%, transparent); }
}

/* ---------- телефон: «Копировать» — только иконка ---------- */
@media (hover: none), (max-width: 600px) {
  .code-copy { width: 30px; height: 30px; padding: 0; justify-content: center; opacity: .7;
    background: color-mix(in srgb, var(--surface) 85%, transparent); }
  .code-copy span { display: none; }
  .code-copy.done { opacity: 1; }
}

/* ---------- теги в боковой панели ---------- */
.tagbox summary .tag-scope { margin-left: auto; font-size: .72rem; text-transform: none; letter-spacing: 0; font-weight: 500;
  color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 99px; }
.tag-tools { display: flex; gap: 6px; padding: 0 0 6px; }
.tag-tools[hidden] { display: none; }
.tag-filter { height: 30px !important; font-size: .88em !important; padding: 0 9px !important; }
.tag-sort { flex: none; height: 30px; padding: 0 9px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--muted); font: inherit; font-size: .8em; cursor: pointer; white-space: nowrap; }
.tag-sort:hover { background: var(--hover); color: var(--text); }
.tag-link[hidden] { display: none; }
.tag-more { padding: 4px 10px; font-size: .88em; }
.tag-none { padding: 4px 10px; margin: 0; font-size: .88em; }
@media (max-width: 860px) {
  .tag-tools { padding: 8px 0; }
  .tag-more { padding: 6px 2px; }
}

/* ---------- блог ---------- */
.blog { max-width: 860px; margin: 0 auto; } /* как у статьи — ширина не скачет */
.blog-head { margin: 6px 0 22px; }
.blog-head h1 { font-size: 1.9rem; line-height: 1.2; margin: 0; }
.blog-head h1 a { color: var(--text); }
.blog-head h1 a:hover { text-decoration: none; color: var(--accent); }
.blog-head p { margin: 6px 0 0; color: var(--muted); font-size: 1.05em; }
.blog-filters { margin-bottom: 16px; }
.post { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 28px 20px; margin-bottom: 18px; }
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; color: var(--muted); font-size: .88em; }
.post-author { display: inline-flex; align-items: center; gap: 5px; color: var(--text); font-weight: 600; }
.post-author .i { width: 15px; height: 15px; color: var(--muted); }
.post-title { font-size: 1.5rem; line-height: 1.3; margin: 8px 0 8px; overflow-wrap: anywhere; }
.post-title a { color: var(--text); }
.post-title a:hover { color: var(--accent); text-decoration: none; }
.post-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.note-meta .post-tags { margin: 0; }
.post-tags .tag { font-size: .84em; color: var(--muted); }
.post-tags .tag:hover { color: var(--accent); text-decoration: none; }
.post-tags .tag.on { background: var(--accent-soft); color: var(--accent); }
.post-cover { display: block; margin: 4px 0 14px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.post-cover img { display: block; width: 100%; max-height: 420px; object-fit: cover; }
/* <!--cover fit …-->: обложка целиком, без обрезки */
.post-cover.post-cover-fit img { height: auto; object-fit: contain; }
.post-cover.post-cover-fit-width img { max-height: none; }
.post-cover.post-cover-fit-height img { height: min(420px, 56vw); }
.post-lead { font-size: 1rem; }
.post-lead > :first-child { margin-top: 0; }
.post-lead > :last-child { margin-bottom: 0; }
.post-lead img { max-height: 360px; }
.post-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 16px; }
.post-foot .btn .i { width: 16px; height: 16px; }
.post-info { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: .88em; }
.post-info .i { width: 15px; height: 15px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 24px 0 8px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: .92em; margin-bottom: 14px; }
.back-link .i { width: 16px; height: 16px; }
.hint-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
@media (max-width: 600px) {
  .blog-head h1 { font-size: 1.5rem; }
  .post { padding: 16px 16px 16px; border-radius: 0; border-left: 0; border-right: 0; margin: 0 -12px 12px; }
  .post-title { font-size: 1.25rem; }
  .post-cover { margin-left: -16px; margin-right: -16px; border-radius: 0; }
}
.small-note { font-size: .88em; margin: 10px 2px 18px; }
.stub { display: grid; place-items: center; min-height: 50vh; color: var(--faint); }
.stub .i { width: 56px; height: 56px; opacity: .5; }
.blog-hint { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.blog-hint p { margin: 0 0 8px; }

/* ---------- статистика ---------- */
.stats-head { grid-template-columns: 1fr auto; align-items: center; justify-items: stretch; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; }
.tile b { display: block; font-size: 1.9rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: .9em; }
.chart { display: flex; align-items: flex-end; gap: 2px; height: 160px; padding-top: 6px; border-bottom: 1px solid var(--border-strong); }
.chart .bar { position: relative; flex: 1; height: 100%; min-width: 2px; outline: none; }
.chart .bar:hover, .chart .bar:focus-visible { background: var(--hover); border-radius: 4px 4px 0 0; }
.chart .bar.we { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.chart .bar span { position: absolute; left: 12%; right: 12%; bottom: 0; border-radius: 4px 4px 0 0; }
.chart .bar .v { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.chart .bar .u { background: var(--accent); }
.chart .bar.today .v { outline: 1px dashed var(--accent); outline-offset: 1px; }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .8em; margin-top: 4px; }
.legend { display: flex; gap: 16px; color: var(--muted); font-size: .85em; margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.lg-v { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.lg-u { background: var(--accent); }
.srows { display: grid; gap: 2px; }
.srow { display: grid; grid-template-columns: minmax(0, 1fr) 64px 48px; gap: 10px; align-items: center; padding: 5px 0; font-variant-numeric: tabular-nums; }
.srow.two { grid-template-columns: minmax(0, 1fr) 56px; }
.srow > span:not(.sname) { text-align: right; }
.shead { color: var(--faint); font-size: .8em; padding: 0; }
.sname { position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 8px; border-radius: 5px; }
.sname a { position: relative; z-index: 1; color: var(--text); }
.sname .sbar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-soft); border-radius: 5px; z-index: 0; }
.sname > :not(.sbar) { position: relative; z-index: 1; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.stats-grid .panel { margin-bottom: 0; }
.panel h2.mt { margin-top: 22px; }
@media (max-width: 700px) {
  .stats-grid { grid-template-columns: 1fr; gap: 0; }
  .stats-grid .panel { margin-bottom: 18px; }
  .tile b { font-size: 1.5rem; }
  .tile { padding: 10px 12px; }
  .stats-head { grid-template-columns: 1fr; }
}

/* ---------- файлы ---------- */
.files-page { max-width: 1100px; margin: 0 auto; }
.files-head { grid-template-columns: 1fr auto; align-items: center; justify-items: stretch; }
.files-tools { display: flex; gap: 10px; align-items: center; }
.files-search { position: relative; }
.files-search .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.files-tools .files-search input[type=search] { height: 36px; padding-left: 34px; width: 220px; } /* специфичнее общего правила input:not(...) — иначе лупа наезжает на текст */
.files-add { cursor: pointer; }
.files-drop { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px; color: var(--text); background: var(--surface); }
.files-drop p { margin: 0; }
.files-drop .muted { display: block; font-size: .88em; margin-top: 4px; }
.files-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.files-drop.busy { opacity: .7; }
.files-status { margin-top: 8px !important; font-weight: 500; color: var(--ok); }
.files-status.bad { color: var(--danger); }
.files-usage { font-size: .88em; margin: 0 0 10px; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.file { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: visible; }
.file.fresh { outline: 2px solid var(--accent); outline-offset: 2px; }
.file.private .file-thumb { opacity: .75; }
.file-thumb { display: grid; place-items: center; height: 150px; background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-ext { font: 600 1.1rem ui-monospace, monospace; text-transform: uppercase; color: var(--muted); border: 2px solid var(--border-strong); border-radius: 8px; padding: 10px 14px; }
.file-body { padding: 10px 12px 12px; display: grid; gap: 6px; min-width: 0; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 26px; }
.file-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: .84em; align-items: center; }
.file-meta span { display: inline-flex; align-items: center; gap: 4px; }
.file-meta .i { width: 14px; height: 14px; }
.file-copy { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 6px; padding: 3px 9px; font-size: .84em; cursor: pointer; }
.chip-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.file-menu { position: absolute; right: 6px; top: 158px; }
.file-menu > summary { width: 28px; height: 28px; font-size: 18px; line-height: 1; list-style: none; }
.file-menu > summary::-webkit-details-marker { display: none; }
.file-menu .menu-pop { min-width: 250px; }
.file-rename { display: flex; gap: 6px; padding: 6px 6px 8px; }
.file-rename input { flex: 1; min-width: 0; height: 30px; }
.menu-pop button.danger { color: var(--danger); }
@media (max-width: 600px) {
  .files-head { grid-template-columns: 1fr; }
  .files-tools { flex-wrap: wrap; }
  .files-search { flex: 1; }
  .files-tools .files-search input[type=search] { width: 100%; }
  .files { grid-template-columns: 1fr 1fr; gap: 10px; }
  .file-thumb { height: 110px; }
  .file-menu { top: 116px; }
  .file-copy .chip-btn:nth-child(n+3) { display: none; } /* на телефоне — ссылка и BBCode */
}
.menu-pop .file-rename button { width: auto; flex: none; padding: 0 10px; border: 1px solid var(--border-strong); justify-content: center; }

/* Шапка выровнена по той же сетке, что и страница: логотип — над меню слева,
   поиск начинается ровно там, где начинается список заметок, и не шире его. */
@media (min-width: 861px) {
  .topbar { display: grid; grid-template-columns: 220px minmax(0, 1fr) auto; column-gap: 28px;
    padding-inline: max(20px, calc((100% - 1240px) / 2)); }
  .topbar .search { margin: 0; max-width: 620px; width: 100%; justify-self: start; }
  .topbar .top-actions { grid-column: 3; }
  .topbar .brand { padding-left: 10px; } /* значок — ровно над значками меню слева */
}

/* ---------- Файлы: папки ---------- */
.file-rename select { flex: 1; min-width: 0; height: 30px; padding: 0 6px; }
.menu .menu-pop.right { right: 0; }
.folder-new .menu-pop, .folder-menu .menu-pop { min-width: 280px; }
.folder-menu .menu-pop { left: 0; right: auto; }
.folder-form { display: flex; gap: 6px; padding: 6px; }
.folder-form input { flex: 1; min-width: 0; height: 32px; }
.folder-form.stack { flex-direction: column; gap: 10px; }
.folder-form.stack label { display: grid; gap: 4px; font-size: .88em; color: var(--muted); }
.folder-form.stack input, .folder-form.stack select { height: 32px; color: var(--text); }
.menu-pop .folder-form button.btn { width: auto; justify-content: center; border: 1px solid var(--accent); }
.folder-form .small { margin: 0; font-size: .8em; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 0 0 14px; font-size: .95em; }
.crumbs > a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; padding: 3px 6px; border-radius: 6px; }
.crumbs > a:hover { background: var(--hover); color: var(--text); }
.crumbs > a[aria-current] { color: var(--text); font-weight: 600; }
.crumbs .i { width: 16px; height: 16px; }
.crumb-sep { color: var(--faint); }
.crumbs .folder-menu { position: relative; }
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin: 0 0 16px; }
.folder { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.folder:hover { border-color: var(--accent); text-decoration: none; }
.folder > .i { grid-row: 1 / 3; width: 28px; height: 28px; color: var(--accent); }
.folder-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder small { font-size: .8em; }
.file-folder { display: inline-flex; align-items: center; gap: 4px; font-size: .82em; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-folder .i { width: 13px; height: 13px; }
.latest-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: -4px 0 14px; font-size: .9em; }
.latest-links code { font-size: .92em; }
.latest-links .chip-btn { display: inline-flex; align-items: center; gap: 5px; }
.latest-links .chip-btn .i { width: 13px; height: 13px; }

/* ---------- Кнопка «наверх» ---------- */
.to-top {
  position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, calc(env(safe-area-inset-bottom) + 10px)); z-index: 40;
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  cursor: pointer; opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s, transform .2s;
}
.to-top.on { opacity: .92; transform: none; pointer-events: auto; }
.to-top:hover { opacity: 1; border-color: var(--accent); color: var(--accent); }
.to-top .i { width: 20px; height: 20px; }
@media print { .to-top { display: none; } }
@media (prefers-reduced-motion: reduce) { .to-top { transition: none; } }

/* ---------- Срок жизни ---------- */
.ttl-badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 999px; white-space: nowrap;
  background: color-mix(in srgb, var(--warn, #b7791f) 14%, transparent); color: var(--warn, #b7791f); font-size: .82em; font-weight: 600; }
.ttl-badge .i { width: 13px; height: 13px; }
.ed-ttl { width: auto !important; height: 32px !important; padding: 0 8px !important; font-size: .85em; color: var(--muted); }
.ed-top .ttl-badge { font-size: .8em; }
.ttl-note { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 16px; padding: 10px 14px; border-radius: 8px;
  background: color-mix(in srgb, var(--warn, #b7791f) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn, #b7791f) 35%, transparent); }
.ttl-note .i { flex: none; width: 18px; height: 18px; margin-top: 2px; color: var(--warn, #b7791f); }
.files-ttl { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; color: var(--muted); font-size: .88em; }
.files-ttl .i { width: 15px; height: 15px; }
.files-ttl select { width: auto !important; height: 30px !important; padding: 0 8px !important; }
@media (max-width: 600px) { .ed-ttl { max-width: 110px; } }

/* ====================================================================== */
/* ---------- календарь, задачи, контакты ---------- */
.small { font-size: .85em; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-head h1 small, .contacts-head h1 small, .task-group h2 small { font-weight: 500; font-size: .7em; }
.btn-danger-ghost { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border-strong)); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.danger-zone { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.danger-zone p { flex-basis: 100%; margin: 0; }
.seg-text a { width: auto; padding: 0 14px; font-weight: 500; font-size: .92em; }

/* шапка календаря */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-nav { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cal-nav h1 { margin-left: 8px; font-size: 1.45rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-tools { display: flex; align-items: center; gap: 8px; }

/* месяц */
.month { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.month-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.month-row + .month-row { border-top: 1px solid var(--border); }
.month-wd > div { padding: 8px 10px; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.month-wd > div:nth-child(n+6) { color: var(--danger); }
.mday { position: relative; min-height: 118px; padding: 6px 6px 8px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mday + .mday { border-left: 1px solid var(--border); }
.mday.off { background: color-mix(in srgb, var(--danger) 4%, var(--surface)); }
.mday.out { background: var(--surface-2); }
.mday.out .mday-num, .mday.out .ev { opacity: .5; }
.mday-head { display: flex; align-items: center; gap: 6px; }
.mday-num { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 4px; border-radius: 99px; color: var(--text); font-weight: 600; font-size: .92em; }
.mday-num:hover { background: var(--hover); text-decoration: none; }
.mday.off .mday-num { color: var(--danger); }
.mday.today .mday-num { background: var(--accent); color: var(--on-accent); }
.mday-short { font-size: .68rem; color: var(--warn); font-weight: 600; }
.mday-add { margin-left: auto; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; color: var(--faint); opacity: 0; transition: opacity .12s; }
.mday:hover .mday-add, .mday-add:focus-visible { opacity: 1; }
.mday-add:hover { background: var(--hover); color: var(--accent); }
.mday-add .i { width: 16px; height: 16px; }
.mday-hol { font-size: .72rem; line-height: 1.25; color: var(--danger); padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mday-hol.note { color: var(--muted); }
.mday-items { display: grid; gap: 2px; min-width: 0; }
.ev { display: block; font-size: .8rem; line-height: 1.35; padding: 2px 6px; border-radius: 5px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--accent); background: var(--accent-soft); }
.ev:hover { text-decoration: none; filter: brightness(.97); }
.ev b { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent); }
.ev.allday, .ev.cont { background: var(--accent); color: var(--on-accent); border-left-color: var(--accent); }
.ev.cont { border-top-left-radius: 0; border-bottom-left-radius: 0; opacity: .85; }
.ev-task { background: color-mix(in srgb, var(--ok) 12%, var(--surface)); border-left-color: var(--ok); }
.ev-task.overdue { background: var(--danger-soft); border-left-color: var(--danger); }
.ev-box { display: inline-block; width: 10px; height: 10px; border: 1.6px solid currentColor; border-radius: 3px; margin-right: 5px; vertical-align: -1px; opacity: .7; }
.ev-more { font-size: .76rem; color: var(--muted); padding: 0 6px; }
.mday-dots { display: none; }
.mday.past:not(.out) .ev:not(.ev-task) { opacity: .7; }

/* неделя и список */
.agenda { display: grid; gap: 12px; }
.aday { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.aday.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.aday-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.aday-head h2 { margin: 0; font-size: 1rem; }
.aday.off .aday-head h2 { color: var(--danger); }
.aday.today .aday-head h2 { color: var(--accent); }
.hol-chip { font-size: .78rem; padding: 2px 9px; border-radius: 99px; background: var(--danger-soft); color: var(--danger); font-weight: 500; }
.hol-chip.short { background: color-mix(in srgb, var(--warn) 15%, var(--surface)); color: var(--warn); }
.hol-chip.note { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.aday-add { margin-left: auto; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; color: var(--muted); }
.aday-add:hover { background: var(--hover); color: var(--accent); }
.aday-items { list-style: none; margin: 0; padding: 4px 0; }
.arow { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; padding: 8px 14px; color: var(--text); align-items: baseline; }
.arow:hover { background: var(--hover); text-decoration: none; }
.arow-time { color: var(--accent); font-weight: 600; font-size: .9em; font-variant-numeric: tabular-nums; }
.arow-task .arow-time { color: var(--ok); }
.arow.overdue .arow-time, .arow.overdue .arow-title { color: var(--danger); }
.arow-main { display: grid; gap: 1px; min-width: 0; }
.arow-title { font-weight: 550; }
.arow-title .i { width: 14px; height: 14px; color: var(--faint); vertical-align: -2px; }
.aday-empty { margin: 0; padding: 10px 14px; font-size: .9em; }

/* формы */
.pim-form textarea, .quick-task input, .add-pass input { font: inherit; }
.pim-form textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); resize: vertical; color: var(--text); }
.pim-form label { position: relative; }
.pim-form label > .i { position: absolute; right: 0; top: 0; width: 15px; height: 15px; color: var(--faint); }
.when, .pim-form .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.pim-form label { align-content: start; }
.pim-form .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.dt { display: flex; gap: 8px; align-items: center; }
.dt input[type=time] { max-width: 130px; }
.dt .check { white-space: nowrap; font-size: .95em; }
.repeat { display: grid; gap: 12px; }
.repeat-more { display: grid; gap: 12px; grid-template-columns: auto 1fr; align-items: start; }
.repeat-more > label:last-child { grid-column: 1 / -1; max-width: 260px; }
.repeat-every > span { display: flex; align-items: center; gap: 8px; color: var(--text); }
.repeat-every input { width: 80px !important; text-align: center; }
.wd-pick { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: end; }
.wd-pick legend { font-size: .9em; color: var(--muted); padding: 0; margin-bottom: 5px; float: left; width: 100%; }
.wd-pick label { display: inline-flex; cursor: pointer; }
.wd-pick input { position: absolute; opacity: 0; pointer-events: none; }
.wd-pick span { display: grid; place-items: center; width: 40px; height: 36px; border: 1px solid var(--border-strong); border-radius: 8px; color: var(--text); font-size: .92em; }
.wd-pick input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.wd-pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.rmode { border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px; margin: 0; display: grid; gap: 8px; }
.rmode legend { padding: 0 6px; font-size: .9em; color: var(--muted); }
.rmode-box { margin: 2px 0 6px 26px; padding: 12px; border-radius: 8px; background: var(--surface-2); }
.after-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.after-box input { width: 90px !important; text-align: center; }
.after-box select { width: auto; }
.rmode p { margin: 4px 0 0; }
.history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.history-list li { display: flex; align-items: center; gap: 8px; }
.history-list .i { color: var(--ok); }

/* задачи */
.quick-task { display: grid; grid-template-columns: 1fr 160px auto; gap: 8px; padding: 10px; margin-bottom: 22px; }
.task-group { margin-bottom: 22px; }
.task-group h2 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px 4px; }
.g-overdue h2 { color: var(--danger); }
.g-today h2 { color: var(--accent); }
.done-group summary { cursor: pointer; list-style: none; }
.done-group summary::-webkit-details-marker { display: none; }
.done-group summary h2::before { content: "▸ "; }
.done-group[open] summary h2::before { content: "▾ "; }
.task-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.task { display: flex; align-items: flex-start; gap: 4px; padding: 4px 8px; }
.task + .task { border-top: 1px solid var(--border); }
.task-check { margin: 0; padding: 7px 4px 7px 6px; }
.tick { display: grid; place-items: center; width: 22px; height: 22px; border: 2px solid var(--border-strong); border-radius: 7px; background: var(--surface); cursor: pointer; color: var(--on-accent); padding: 0; transition: border-color .12s, background .12s; }
.tick:hover { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--surface)); }
.tick .i { width: 14px; height: 14px; stroke-width: 3; }
.is-done .tick { background: var(--ok); border-color: var(--ok); }
.task-main { flex: 1; min-width: 0; display: grid; gap: 3px; padding: 7px 6px; color: var(--text); border-radius: 7px; }
.task-main:hover { text-decoration: none; background: var(--hover); }
.task-title { font-weight: 520; overflow-wrap: anywhere; }
.is-done .task-title { color: var(--muted); text-decoration: line-through; }
.prio { color: var(--danger); font-weight: 800; margin-right: 6px; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .82em; color: var(--muted); }
.task-meta > span { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.task-meta .i { width: 14px; height: 14px; }
.task-meta .note { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.due.overdue { color: var(--danger); font-weight: 600; }
.due.today { color: var(--accent); font-weight: 600; }
.rep { color: var(--ok); }

/* контакты */
.contacts-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.contacts-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.contacts-head .files-search { max-width: 420px; }
.contacts-head form.inline { margin: 0; }
label.btn.busy { opacity: .6; pointer-events: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chips .chip { color: var(--text); background: var(--surface); border: 1px solid var(--border); }
.chips .chip:hover { text-decoration: none; background: var(--hover); }
.chips .chip.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.chips .chip small { color: var(--faint); }
.bulk-bar { position: sticky; top: 58px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.bulk-bar .check { display: inline-flex; align-items: center; gap: 6px; }
.bulk-actions { display: none; flex-wrap: wrap; gap: 6px; align-items: center; margin-left: auto; }
.bulk-bar.active .bulk-actions { display: flex; }
.group-act { display: inline-flex; gap: 4px; align-items: center; }
.group-act input { width: 130px !important; height: 30px !important; }
.letter { font-size: .85rem; color: var(--accent); margin: 14px 0 6px 6px; }
.contact-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.contact { display: flex; align-items: center; gap: 4px; padding-left: 12px; }
.contact + .contact { border-top: 1px solid var(--border); }
.contact > input { flex: none; width: 17px; height: 17px; accent-color: var(--accent); }
.contact-main { flex: 1; min-width: 0; display: grid; grid-template-columns: 40px minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: center; padding: 8px 14px 8px 8px; color: var(--text); }
.contact-main:hover { text-decoration: none; background: var(--hover); }
.contact-list.compact { margin-bottom: 18px; }
.contact-list.compact .contact-main { grid-template-columns: 40px minmax(0, 1fr) auto; }
.avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 650; font-size: .9em; object-fit: cover; flex: none; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.2em; }
.contact-name { display: grid; min-width: 0; }
.contact-name b, .contact-name small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 560; }
.contact-name small { font-weight: 400; }
.contact-tel { font-variant-numeric: tabular-nums; white-space: nowrap; }
.contact-mail { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .92em; }
.contact-h1 { display: flex; align-items: center; gap: 14px; }
.multi { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.multi legend { display: flex; align-items: center; gap: 6px; font-size: .9em; color: var(--muted); padding: 0; margin-bottom: 6px; }
.multi-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 36px; gap: 8px; }
.multi .linkish { justify-self: start; font-size: .92em; }
.readonly-info { padding: 10px 14px; border-radius: 8px; background: var(--surface-2); }
.readonly-info p { margin: 4px 0; display: flex; gap: 8px; align-items: flex-start; }
.readonly-info .i { color: var(--faint); margin-top: 3px; }

/* порядок в контактах */
.dup { padding: 14px 0; }
.dup + .dup { border-top: 1px solid var(--border); }
.dup-why { margin: 0 0 8px; font-size: .88em; }
.dup-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-bottom: 10px; }
.dup-card { display: grid; gap: 3px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: .9em; align-content: start; }
.dup-card span { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dup-card .i { width: 14px; height: 14px; color: var(--faint); }
.panel h2 { display: flex; align-items: center; gap: 8px; }
.panel h2 small { font-weight: 500; }
.panel h3 { font-size: .98rem; margin: 22px 0 10px; }
.fix-list { margin: 8px 0 12px; padding-left: 20px; font-size: .92em; display: grid; gap: 4px; }
.merge-form fieldset { border: 1px solid var(--border); border-radius: 9px; padding: 10px 14px; margin: 0; display: grid; gap: 6px; }
.merge-form legend { display: flex; align-items: center; gap: 6px; padding: 0 6px; font-size: .9em; color: var(--muted); }
.photo-pick { display: flex; gap: 14px; flex-wrap: wrap; }
.photo-pick label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* настройки: телефоны */
.newpass { padding: 12px 14px; border-radius: 9px; background: color-mix(in srgb, var(--ok) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ok) 40%, var(--border)); margin-bottom: 14px; }
.newpass p { margin: 0 0 4px; font-weight: 500; }
.newpass .copyline { margin: 6px 0 0; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace !important; font-size: 1.05em !important; letter-spacing: .04em; }
.dav-info { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 14px 0; }
.dav-info dt { color: var(--muted); }
.dav-info dd { margin: 0; overflow-wrap: anywhere; }
.howto { border: 1px solid var(--border); border-radius: 9px; padding: 10px 14px; margin-bottom: 8px; }
.howto summary { cursor: pointer; font-weight: 550; }
.howto ol { margin: 10px 0 2px; padding-left: 20px; display: grid; gap: 6px; }
.howto p { margin: 10px 0 2px; }
.add-pass { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

@media (max-width: 860px) {
  .contacts-head .files-search { grid-column: 1 / -1; grid-row: 2; max-width: none; }
  .contact-main { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .contact-mail { display: none; }
  .mday { min-height: 96px; }
}
@media (max-width: 600px) {
  .cal-nav h1 { font-size: 1.1rem; margin-left: 4px; white-space: normal; line-height: 1.2; }
  .arow-time { font-size: .82em; }
  .cal-head { gap: 8px; }
  .seg-text a { padding: 0 10px; }
  .month-wd > div { padding: 6px 0; text-align: center; font-size: .68rem; }
  .mday { min-height: 58px; padding: 4px 2px; align-items: center; }
  .mday-head { justify-content: center; }
  .mday-add, .mday-hol, .mday-items, .mday-short { display: none; }
  .mday-num { min-width: 30px; height: 30px; }
  .mday-dots { display: flex; gap: 3px; justify-content: center; flex-wrap: wrap; max-width: 34px; }
  .mday-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
  .mday-dots i.dot-task { background: var(--ok); }
  .mday-dots i:nth-child(n+5) { display: none; }
  .arow { grid-template-columns: 78px minmax(0, 1fr); gap: 8px; padding: 8px 12px; }
  .when, .pim-form .grid2, .pim-form .grid3 { grid-template-columns: 1fr; }
  .repeat-more { grid-template-columns: 1fr; }
  .quick-task { grid-template-columns: 1fr auto; }
  .quick-task input[type=date] { grid-row: 2; grid-column: 1 / -1; }
  .multi-row { grid-template-columns: 112px minmax(0, 1fr) 36px; }
  .contact { padding-left: 8px; }
  .contact-main { gap: 10px; padding-right: 10px; }
  .contact-tel { font-size: .85em; }
  .dav-info { grid-template-columns: 1fr; gap: 0; }
  .dav-info dd { margin-bottom: 8px; }
  .add-pass { grid-template-columns: 1fr; }
  .group-act input { width: 100px !important; }
      .mday-num::after { content: ""; position: absolute; inset: 0; } /* на телефоне вся клетка — ссылка на день */
  .bulk-bar [data-bulk-count]:not(:empty) { font-size: .85em; }
  .bulk-bar:not(.active) [data-bulk-count] { display: none; }
}
.pim .contacts-head .files-search input[type=search] { height: 36px; padding-left: 34px; } /* лупа не наезжает на текст */

/* настройки по вкладкам */
.settings-tabs { flex-wrap: wrap; gap: 4px; margin: -6px 0 18px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.settings-tabs a { display: inline-flex; align-items: center; gap: 7px; }
.settings-tabs .i { width: 16px; height: 16px; }
@media (max-width: 600px) { .settings-tabs { flex-wrap: nowrap; overflow-x: auto; } .settings-tabs a { white-space: nowrap; } }

/* фото контакта */
.avatar.xl { width: 96px; height: 96px; font-size: 1.8em; }
.photo-edit { display: flex; align-items: center; gap: 18px; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.photo-actions small { flex-basis: 100%; }
.photo-dlg { width: min(420px, calc(100vw - 24px)); padding: 18px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.photo-dlg::backdrop { background: rgba(10, 14, 20, .55); }
.photo-dlg h2 { margin: 0 0 12px; }
.photo-dlg .btn-row { margin-top: 14px; }
.photo-dlg .grow { flex: 1; }
.crop { position: relative; width: 100%; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2);
  border: 1px dashed var(--border-strong); }
.crop.over { border-color: var(--accent); background: var(--accent-soft); }
.crop canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.crop canvas:active { cursor: grabbing; }
.crop-empty { position: absolute; inset: 0; margin: 0; display: grid; place-content: center; gap: 8px; justify-items: center;
  text-align: center; color: var(--muted); padding: 20px; cursor: pointer; }
.crop-empty .i { width: 34px; height: 34px; color: var(--faint); }
.crop-tools { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.crop-tools .zoom { flex: 1; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.photo-dlg .crop-tools input[type=range] { flex: 1; accent-color: var(--accent); height: auto; padding: 0; border: 0; background: none; }
.crop-hint { margin: 8px 0 0; }
@media (max-width: 600px) { .avatar.xl { width: 72px; height: 72px; font-size: 1.4em; } }
/* окно фото лежит внутри формы контакта — общие правила подписей формы ему не годятся */
.photo-dlg label > .i { position: static; width: 18px; height: 18px; color: inherit; }
.photo-dlg label.btn { display: inline-flex; font-size: inherit; color: var(--text); gap: 6px; }
.photo-dlg .crop-tools .zoom { display: flex; font-size: inherit; }
.photo-dlg .crop-tools .zoom > .i { color: var(--faint); }
.dlg-actions { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-top: 14px; }
.dlg-actions .btn { justify-content: center; }
.dlg-actions label.btn { justify-self: start; }
@media (max-width: 600px) { .dlg-actions { grid-template-columns: 1fr 1fr; } .dlg-actions label.btn { grid-column: 1 / -1; justify-self: stretch; } }

/* дни рождения из контактов */
.ev-bday { background: color-mix(in srgb, #d6457a 13%, var(--surface)); border-left-color: #d6457a; color: var(--text); }
.ev.ev-bday.allday { background: color-mix(in srgb, #d6457a 13%, var(--surface)); color: var(--text); }
.ev-bday .i { width: 13px; height: 13px; color: #d6457a; vertical-align: -2px; margin-right: 3px; }
.arow-bday .arow-time { color: #d6457a; }
.arow-bday .arow-title .i { width: 15px; height: 15px; color: #d6457a; }
.mday-dots i.dot-bday { background: #d6457a; }
