/* ============================================================================
   Дизайн-система инбокса.

   Слои объявлены явно: базовые стили элементов (input, button) физически не
   могут перебить компонентные, даже при равной специфичности. Именно на этом
   раньше ломалось поле поиска — общее правило input[type=search] затирало
   .topsearch input, потому что шло ниже по файлу.

   Два режима: «просто» прячет .pro-only, но не убирает из DOM — скрытые поля
   продолжают отправляться формой, поэтому сохранение ничего не затирает.
   ========================================================================= */

@layer base, components, utilities;

/* --------------------------------------------------------------- токены */

:root {
  color-scheme: light;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e5e8ed;
  --line: #e4e7ec;
  --line-strong: #ccd2db;

  --text: #101319;
  --text-2: #454d5d;
  --muted: #79818f;

  --accent: #3b6ef6;
  --accent-soft: #e9f0ff;
  --accent-text: #1c4ed0;
  --ok: #0f9d58;
  --ok-soft: #e3f6ec;
  --warn: #c07a08;
  --warn-soft: #fdf2df;
  --danger: #d93a51;
  --danger-soft: #fdebee;
  --star: #9a6c05;
  --star-soft: #fbf1d8;

  --shadow-sm: 0 1px 2px rgba(16, 20, 30, .05);
  --shadow: 0 4px 16px rgba(16, 20, 30, .08);
  --shadow-lg: 0 16px 40px rgba(16, 20, 30, .18);

  --r-sm: 9px;
  --r: 13px;
  --r-lg: 18px;
  --tap: 40px;
  --header-h: 58px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #13161b;
  --surface: #1b1f26;
  --surface-2: #222731;
  --surface-3: #2b313b;
  --line: #262b34;
  --line-strong: #39404c;
  --text: #e9ecf1;
  --text-2: #b3bbc8;
  --muted: #848d9b;
  --accent: #6d99ff;
  --accent-soft: #1d2740;
  --accent-text: #a8c2ff;
  --ok: #35c07f;
  --ok-soft: #13301f;
  --warn: #d9a44a;
  --warn-soft: #2f2617;
  --danger: #ef6b80;
  --danger-soft: #331920;
  --star: #d7a63c;
  --star-soft: #2e2716;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 4px 18px rgba(0, 0, 0, .4);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, .55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #13161b;
    --surface: #1b1f26;
    --surface-2: #222731;
    --surface-3: #2b313b;
    --line: #262b34;
    --line-strong: #39404c;
    --text: #e9ecf1;
    --text-2: #b3bbc8;
    --muted: #848d9b;
    --accent: #6d99ff;
    --accent-soft: #1d2740;
    --accent-text: #a8c2ff;
    --ok: #35c07f;
    --ok-soft: #13301f;
    --warn: #d9a44a;
    --warn-soft: #2f2617;
    --danger: #ef6b80;
    --danger-soft: #331920;
    --star: #d7a63c;
    --star-soft: #2e2716;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow: 0 4px 18px rgba(0, 0, 0, .4);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, .55);
  }
}

/* =========================================================== СЛОЙ: БАЗА */

@layer base {
  * { box-sizing: border-box; }

  body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
  }

  a { color: var(--accent); text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { font-size: 21px; line-height: 1.3; margin: 0 0 6px; font-weight: 650;
       letter-spacing: -.01em; }
  h2 { font-size: 12px; margin: 0 0 12px; color: var(--muted); font-weight: 600;
       text-transform: uppercase; letter-spacing: .06em; }
  h3 { font-size: 17px; margin: 0 0 8px; font-weight: 620; }
  p { margin: 0 0 10px; }

  code {
    background: var(--surface-2); border-radius: 5px; padding: 1.5px 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .86em; color: var(--text-2);
  }

  input, select, textarea, button { font: inherit; color: var(--text); }

  input[type="text"], input[type="search"], input[type="password"],
  input[type="datetime-local"], select, textarea {
    width: 100%; min-height: var(--tap); padding: 9px 12px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--line-strong); border-radius: var(--r-sm);
    transition: border-color .12s, box-shadow .12s;
  }
  input:focus-visible, select:focus-visible, textarea:focus-visible,
  input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
  input::placeholder, textarea::placeholder { color: var(--muted); }
  textarea { resize: vertical; min-height: 84px; line-height: 1.55; }

  select {
    appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%2379818f' stroke-width='1.7' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    padding-right: 34px;
  }

  input[type="color"] {
    width: 46px; height: var(--tap); padding: 3px; cursor: pointer;
    background: var(--surface); border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
  }
  input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }

  button {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-height: var(--tap); padding: 0 15px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--line-strong); border-radius: var(--r-sm);
    font-size: 14px; font-weight: 500; cursor: pointer;
    transition: background .12s, border-color .12s, transform .06s;
  }
  button:hover { background: var(--surface-2); }
  button:active { transform: scale(.985); }

  ul, ol { margin: 0; padding: 0; }
  dl { margin: 0; }
  form { margin: 0; }
  summary { cursor: pointer; }
}

/* ==================================================== СЛОЙ: КОМПОНЕНТЫ */

@layer components {

/* --------------------------------------------------------------- иконки */

.ic {
  width: 18px; height: 18px; flex: none; display: inline-block;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.ic-brand { width: 23px; height: 23px; color: var(--accent); }

/* --------------------------------------------------------------- кнопки */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--tap); padding: 0 15px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500; cursor: pointer;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }

button.primary, .btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
button.primary:hover, .btn.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
button.ghost:hover { background: var(--surface-2); }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.danger:hover { background: var(--danger-soft); }
button.sm, .btn.sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-width: var(--tap); height: var(--tap); padding: 0 12px;
  background: transparent; border: 1px solid var(--line);
  border-radius: var(--r-sm); color: var(--text-2);
  font-size: 13.5px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.on {
  background: var(--accent-soft); border-color: transparent; color: var(--accent-text);
}

/* --------------------------------------------------------------- шапка */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  height: var(--header-h); padding: 0 18px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}

.brand {
  flex: none; display: flex; align-items: center; gap: 9px;
  font-weight: 650; font-size: 15.5px; color: var(--text); white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.topsearch { flex: 1 1 auto; min-width: 0; max-width: 400px; position: relative; }
.topsearch input[type="search"] {
  height: 38px; min-height: 38px;
  padding: 0 40px 0 38px;
  background: var(--surface-2); border-color: transparent;
  border-radius: 999px; font-size: 14px;
}
.topsearch input[type="search"]:focus { background: var(--surface); }
.topsearch .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none; width: 17px; height: 17px;
}
.topsearch .search-kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  pointer-events: none;
}
.topsearch input[type="search"]:focus ~ .search-kbd { opacity: 0; }

.topnav { flex: none; margin-left: auto; display: flex; gap: 2px; }
.topnav a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: 14px; white-space: nowrap;
}
.topnav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topnav a.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 550; }
.topnav .ic { width: 17px; height: 17px; }

.topactions { flex: none; display: flex; align-items: center; gap: 6px; }
.burger { display: none; }

/* --------------------------------------------------------------- каркас */

main { max-width: 1060px; margin: 0 auto; padding: 22px 18px 60px; }
footer { padding: 0 18px 30px; text-align: center; color: var(--muted); font-size: 12px; }

/* --------------------------------------------------------------- быстрый ввод */

.quickadd {
  display: flex; gap: 8px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 8px 8px 8px 6px;
  box-shadow: var(--shadow-sm); margin-bottom: 18px;
  transition: border-color .15s, box-shadow .15s;
}
.quickadd:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.qa-field { flex: 1; min-width: 0; }
.qa-field input[type="text"] {
  border: none; background: transparent; padding: 0 12px; height: var(--tap);
  font-size: 15.5px;
}
.qa-field input[type="text"]:focus { box-shadow: none; border-color: transparent; }
.qa-btn { flex: none; }
.qa-hint { padding: 0 12px 4px; color: var(--muted); font-size: 12.5px; }
.qa-hint code { margin-right: 2px; }

/* --------------------------------------------------------------- вкладки */

/* Разделы — крупные блоки со счётчиком. Цвет несёт только «Просрочено»:
   красный и золотой при дальтонизме почти неразличимы (ΔE 4.2), поэтому
   статусный оттенок здесь ровно один, остальное — нейтральные чернила. */
.sections {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 10px; margin-bottom: 20px;
}
.sec {
  display: flex; flex-direction: column; gap: 3px;
  padding: 14px 15px 13px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text);
  transition: border-color .13s, background .13s, transform .13s;
}
.sec:hover {
  border-color: var(--line-strong); text-decoration: none;
  transform: translateY(-1px);
}
.sec .ic { width: 18px; height: 18px; color: var(--muted); margin-bottom: 7px; }
.sec-n { font-size: 23px; font-weight: 650; line-height: 1.05; letter-spacing: -.02em; }
.sec-l { font-size: 13px; color: var(--muted); }
.sec.on { border-color: var(--accent); background: var(--accent-soft); }
.sec.on .ic, .sec.on .sec-l { color: var(--accent-text); }
.sec.on .sec-n { color: var(--accent-text); }
.sec.alarm .sec-n, .sec.alarm .ic { color: var(--danger); }
.sec.alarm.on .sec-n, .sec.alarm.on .ic { color: var(--danger); }
.sec.star .ic { color: var(--star); fill: var(--star); }
.sec.zero { opacity: .5; }
.sec.zero:hover { opacity: 1; }

.toolbar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
  justify-content: flex-end;
}
.toolbar .now { margin-right: auto; font-size: 15px; font-weight: 600; }

/* --------------------------------------------------------------- фильтры */

.applied-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.applied {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 8px 5px 13px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-text); font-size: 13px;
}
.applied a { color: inherit; opacity: .55; display: inline-flex; }
.applied a:hover { opacity: 1; }
.applied .ic { width: 14px; height: 14px; stroke-width: 2.2; }

.filters {
  display: none; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 12px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
}
.filters.open { display: flex; }
/* без сброса ширины select растянется на 100% и фильтры лягут по одному в строку */
.filters select { width: auto; flex: 1 1 165px; min-width: 145px; max-width: 250px; }
.filters .reset { color: var(--muted); font-size: 13px; padding: 0 4px; }

/* --------------------------------------------------------------- список */

.list {
  list-style: none;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden;
}

.item {
  display: flex; align-items: flex-start; gap: 13px;
  padding: 15px 16px; border-bottom: 1px solid var(--line);
  transition: background .12s;
}
.item:last-child { border-bottom: none; }
.item:hover { background: var(--surface-2); }

.check-form { flex: none; display: flex; }
.check {
  width: 22px; height: 22px; min-height: 22px; margin-top: 2px; padding: 0;
  border: 1.8px solid var(--line-strong); border-radius: 50%;
  background: transparent; color: transparent;
  display: grid; place-items: center;
  transition: border-color .12s, background .12s, color .12s;
}
.check .ic { width: 13px; height: 13px; stroke-width: 2.6; }
.check:hover { border-color: var(--ok); color: var(--ok); background: transparent; }
.check.done { background: var(--ok); border-color: var(--ok); color: #fff; }

.item-main { flex: 1; min-width: 0; }

.item-title {
  display: flex; align-items: flex-start; gap: 8px;
  color: var(--text); font-weight: 520; font-size: 15px; line-height: 1.4;
  overflow-wrap: anywhere;
}
.item-title:hover { color: var(--accent); text-decoration: none; }
.kind-ic { margin-top: 2px; width: 16px; height: 16px; }
.kind-ic.note { color: var(--warn); }
.kind-ic.task { color: var(--ok); }

.item-sub {
  margin: 3px 0 0 24px; color: var(--muted); font-size: 13px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-sub.warn { color: var(--danger); }

/* Метаданные строки — по умолчанию приглушённый текст, а не гирлянда плашек.
   Плашку получает только то, что требует внимания: просроченный срок и «срочно». */
.item-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 6px 0 0 24px; font-size: 12.5px; color: var(--muted);
}
.meta-txt { display: inline-flex; align-items: center; gap: 5px; }
.meta-txt .ic { width: 14px; height: 14px; opacity: .8; }
.meta-txt .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--tag); }
.meta-txt.late { color: var(--danger); font-weight: 550; }
.meta-txt.soon { color: var(--warn); font-weight: 550; }

.item.is-done .item-title { color: var(--muted); }
.item.is-done .item-title span { text-decoration: line-through; }
.item.is-done .item-sub { display: none; }

.item-actions { flex: none; display: flex; gap: 1px; align-items: center; }
.item-actions form { display: flex; }
/* показываем действия только по наведению, но звезда закреплённой записи видна всегда */
.item-actions > *:not(.star-form) { opacity: 0; transition: opacity .12s; }
.item-actions .star-form .mini:not(.on) { opacity: 0; transition: opacity .12s; }
.item:hover .item-actions > *,
.item:focus-within .item-actions > *,
.item:hover .item-actions .star-form .mini,
.item:focus-within .item-actions .star-form .mini { opacity: 1; }
@media (hover: none) {
  .item-actions > *, .item-actions .star-form .mini { opacity: 1; }
}

.mini {
  width: 32px; height: 32px; min-height: 32px; padding: 0;
  display: grid; place-items: center;
  background: transparent; border: none; border-radius: var(--r-sm);
  color: var(--muted); cursor: pointer;
}
.mini .ic { width: 16px; height: 16px; }
.mini:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.mini.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* звёздочка: закреплённая видна всегда, у остальных проявляется по наведению */
.mini.star:hover { color: var(--star); background: var(--star-soft); }
.mini.star.on { color: var(--star); opacity: 1; }
.item .star-form { opacity: 1; }
.mini.star.on .ic { fill: var(--star); }
button.sm.star-on { color: var(--star); border-color: var(--star); }
button.sm.star-on .ic { fill: var(--star); }

/* --------------------------------------------------------------- метки */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 550; line-height: 1.5;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.pill .ic { width: 13px; height: 13px; stroke-width: 2; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--tag); }
.pill.project { background: color-mix(in srgb, var(--tag) 14%, transparent); color: var(--tag); }
[data-theme="dark"] .pill.project { color: color-mix(in srgb, var(--tag) 62%, white); }

.pill.starred { background: var(--star-soft); color: var(--star); }
.pill.starred .ic { fill: currentColor; }
.pill.due.soon { background: var(--warn-soft); color: var(--warn); }
.pill.due.late { background: var(--danger-soft); color: var(--danger); }
.pill.prio-urgent { background: var(--danger-soft); color: var(--danger); }
.pill.prio-high { background: var(--warn-soft); color: var(--warn); }
.pill.kind-note { background: var(--warn-soft); color: var(--warn); }
.pill.kind-task { background: var(--ok-soft); color: var(--ok); }
.pill.s-in_progress { background: var(--accent-soft); color: var(--accent-text); }
.pill.s-waiting { background: var(--warn-soft); color: var(--warn); }
.pill.s-done { background: var(--ok-soft); color: var(--ok); }
.pill.s-cancelled { text-decoration: line-through; }

/* три точки «идёт расшифровка» */
.dots { display: inline-flex; gap: 3px; align-items: center; margin-right: 3px; }
.dots i {
  width: 4px; height: 4px; border-radius: 50%; background: currentColor;
  animation: blink 1.4s infinite both;
}
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25 } 40% { opacity: 1 } }

/* --------------------------------------------------------------- пусто */

.empty {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 52px 28px; text-align: center;
}
.empty-ic { width: 44px; height: 44px; stroke-width: 1.3; color: var(--muted); opacity: .7; }
.empty h3 { margin: 16px 0 8px; }
.empty p { color: var(--muted); max-width: 470px; margin: 0 auto 6px; }
.empty .hint { margin-top: 18px; }
.empty .steps {
  display: inline-block; text-align: left; list-style: none; counter-reset: s;
  margin: 20px 0 0; color: var(--text-2); font-size: 14px;
}
.empty .steps li { counter-increment: s; padding: 6px 0 6px 30px; position: relative; }
.empty .steps li::before {
  content: counter(s); position: absolute; left: 0; top: 6px;
  width: 21px; height: 21px; border-radius: 50%;
  background: var(--surface-3); color: var(--text-2);
  font-size: 12px; font-weight: 650; line-height: 21px; text-align: center;
}
.empty .steps b { color: var(--text); font-weight: 600; }

/* --------------------------------------------------------------- карточки */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 20px; margin-bottom: 16px;
}
.card.narrow { max-width: 380px; margin: 72px auto; }

.cols {
  display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(300px, 1fr);
  gap: 16px; align-items: start;
}
.crumbs { margin-bottom: 14px; font-size: 14px; }
.crumbs a { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }
.crumbs a:hover { color: var(--accent); text-decoration: none; }
.crumbs .ic { width: 16px; height: 16px; }

label.field { display: block; margin-bottom: 14px; }
label.field > .lbl {
  display: block; margin-bottom: 5px; font-size: 13px; font-weight: 550; color: var(--text-2);
}
label.field .help { display: block; margin-top: 5px; font-size: 12px; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.title-edit {
  font-size: 20px; font-weight: 650; line-height: 1.35;
  padding: 8px 10px; margin: -8px -10px 4px; min-height: auto;
  background: transparent; border-color: transparent;
}
.title-edit:hover { background: var(--surface-2); }
.title-edit:focus { background: var(--surface); }

.body-edit {
  border-color: transparent; background: transparent;
  padding: 8px 10px; margin: 0 -10px;
}
.body-edit:hover { background: var(--surface-2); }
.body-edit:focus { background: var(--surface); }

.entry-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.savebar { display: flex; gap: 10px; align-items: center; padding-top: 14px; }
.danger-zone { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 9px 14px; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; font-size: 14px; }

.quick-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-actions form { display: contents; }

/* --------------------------------------------------------------- голосовое */

.player { width: 100%; height: 40px; margin-bottom: 10px; }
.transcript {
  margin: 10px 0 0; padding: 12px 14px;
  background: var(--surface-2); border-radius: var(--r-sm);
  font-size: 14px; line-height: 1.6; white-space: pre-wrap;
  max-height: 320px; overflow-y: auto;
}
details > summary { color: var(--muted); font-size: 13px; list-style: none; padding: 4px 0; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸ "; }
details[open] > summary::before { content: "▾ "; }

.attachments { display: flex; flex-wrap: wrap; gap: 8px; }
.attachments img {
  max-width: 120px; max-height: 120px; border-radius: var(--r-sm);
  border: 1px solid var(--line); display: block;
}
.attachments .file {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 12px; background: var(--surface-2);
  border-radius: var(--r-sm); font-size: 13px; color: var(--text-2);
}

/* --------------------------------------------------------------- история */

.comment { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 14px; }
.comment textarea { flex: 1; min-height: 40px; }

.timeline { list-style: none; }
.timeline li { position: relative; padding: 7px 0 7px 18px; font-size: 13.5px; color: var(--text-2); }
.timeline li::before {
  content: ""; position: absolute; left: 3px; top: 15px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong);
}
.timeline li::after {
  content: ""; position: absolute; left: 6px; top: 22px; bottom: -7px;
  width: 1px; background: var(--line);
}
.timeline li:last-child::after { display: none; }
.timeline li.k-comment::before { background: var(--accent); }
.timeline li.k-created::before { background: var(--ok); }
.timeline li.k-transcript::before { background: var(--warn); }
.timeline .when { display: block; color: var(--muted); font-size: 11.5px; }
.timeline .who { color: var(--muted); font-size: 11.5px; }

/* --------------------------------------------------------------- справочники */

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 12px; }
.mini-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 15px 16px;
}
.mini-card .head { display: flex; align-items: center; gap: 9px; margin-bottom: 5px; }
.mini-card .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.mini-card .name { font-weight: 570; overflow-wrap: anywhere; }
.mini-card .sub { color: var(--muted); font-size: 13px; }
.mini-card details[open] .edit-form {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
}
.edit-form label.field { margin-bottom: 10px; }

/* --------------------------------------------------------------- прочее */

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  background: var(--text); color: var(--bg);
  border-radius: 999px; box-shadow: var(--shadow-lg); font-size: 14px;
  animation: rise .25s ease-out;
}
.toast a { color: inherit; text-decoration: underline; opacity: .85; }
@keyframes rise {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.kbd {
  display: inline-block; padding: 1px 6px; min-width: 20px; text-align: center;
  background: var(--surface-3); border-radius: 5px;
  font-size: 11.5px; font-family: inherit; color: var(--muted);
}

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; margin-top: 18px;
  background: var(--warn-soft); color: var(--warn);
  border-radius: var(--r); font-size: 13.5px;
}
.notice .ic { margin-top: 1px; }
.notice.info { background: var(--accent-soft); color: var(--accent-text); }

.err { color: var(--danger); font-size: 13.5px; margin: 0 0 12px; }

/* --------------------------------------------------------------- мини-приложение */

/* Внутри Telegram своя шапка с названием и крестиком — свою дублировать незачем */
.in-tma .brand-name,
.in-tma .crumbs { display: none; }
.in-tma .topbar { padding: 0 12px; }
.in-tma main { padding-top: 14px; padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
.in-tma footer { display: none; }

/* --------------------------------------------------------------- мобильный */

@media (max-width: 900px) {
  .topbar { gap: 8px; padding: 0 12px; }
  .topnav {
    display: none; position: absolute; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; gap: 2px; margin: 0; padding: 8px;
    background: var(--surface); border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
  }
  .topnav.open { display: flex; }
  .topnav a { padding: 12px 14px; }
  .burger { display: inline-flex; }
  .brand-name { display: none; }
  .topsearch { max-width: none; }
  .search-kbd { display: none; }
  .mode-btn span[data-mode-label] { display: none; }

  main { padding: 14px 12px 52px; }
  .card { padding: 16px; border-radius: var(--r); }
  .list { border-radius: var(--r); }
  .item { padding: 12px; gap: 10px; }
  .quickadd { border-radius: var(--r); }
  .cols { grid-template-columns: 1fr; gap: 12px; }
  .row2 { grid-template-columns: 1fr; }
  .empty { padding: 40px 20px; }
  .btn-label { display: none; }
  .toast { left: 12px; right: 12px; bottom: 12px; transform: none; border-radius: var(--r); }
  @keyframes rise { from { opacity: 0; transform: translateY(12px) } to { opacity: 1 } }
}

@media (max-width: 640px) {
  .quickadd { flex-direction: column; gap: 4px; }
  .qa-btn { width: 100%; }
  h1 { font-size: 19px; }
}

} /* /layer components */

/* ==================================================== СЛОЙ: УТИЛИТЫ */

@layer utilities {
  .mode-simple .pro-only { display: none !important; }
  .muted { color: var(--muted); }
  .small { font-size: 13px; }
  .spacer { flex: 1; }
  .nowrap { white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; transition-duration: .01ms !important;
  }
}
