/* Карточки, кнопки, уведомления и диалоги. */

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card__title {
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.card__text {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Настройки: выбор палитры */

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.theme-option:hover {
  border-color: var(--accent);
}

.theme-option.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.theme-option__swatch {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  overflow: hidden;
}

.theme-option__swatch-accent {
  position: absolute;
  inset: 0;
  background: var(--accent);
}

.theme-option__swatch-page {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg);
  transform: translate(-50%, -50%);
}

/* Зелёная тема описана в base.css, а не в themes.css, поэтому образец
   получает её цвета явно. Значения должны совпадать с base.css. */
.theme-option__swatch--green {
  --bg: #f5f4ef;
  --accent: #2f6f5e;
}

@media (prefers-color-scheme: dark) {
  .theme-option__swatch--green {
    --bg: #141513;
    --accent: #7fc7ae;
  }
}

.theme-option__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.theme-option__name {
  font-size: 0.95rem;
  font-weight: 650;
}

.theme-option__hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.theme-option__check {
  margin-left: auto;
  color: var(--accent);
  font-weight: 700;
  opacity: 0;
}

.theme-option.is-active .theme-option__check {
  opacity: 1;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.stat__value {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat__label {
  color: var(--muted);
  font-size: 0.76rem;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.button:active {
  transform: translateY(1px);
}

.button:disabled {
  opacity: 0.5;
}

.button--primary {
  background: var(--accent);
  color: var(--on-accent);
}

.button--primary:hover {
  background: var(--accent-strong);
  color: var(--on-accent);
}

.button--ghost {
  border-color: var(--border);
  background: transparent;
  color: var(--text);
}

.button--ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.button--danger {
  background: var(--danger);
  color: var(--on-danger);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  font-size: 1.3rem;
  line-height: 1;
}

.icon-button:hover {
  background: var(--surface-2);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.status__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.badge {
  align-self: flex-start;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.notice {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.9rem;
}

.notice > * + * {
  margin-top: 6px;
}

.notice--spaced {
  margin-top: 16px;
}

.noscript-note {
  margin: 16px;
}

.notice--success {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.notice--warning {
  border-color: var(--warning);
  background: var(--warning-soft);
}

.notice--danger {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.notice ul {
  display: grid;
  gap: 4px;
  padding-left: 20px;
  list-style: disc;
}

/* Раскрывающиеся блоки: подсказки и диагностика на экране ошибки */

.details {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.9rem;
}

.details > summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}

.details[open] > summary {
  margin-bottom: 10px;
}

.hint-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding-left: 20px;
  list-style: disc;
}

.hint-list code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface);
  font-size: 0.86em;
}

.details__pre {
  margin-top: 12px;
  padding: 10px 12px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.78rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.boot-help {
  margin-top: 8px;
}

.dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  font-size: 0.9rem;
}

.dl dt {
  color: var(--muted);
}

.dl dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.list {
  display: grid;
  gap: 0;
}

.list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.list__item:last-child {
  border-bottom: 0;
}

.list__item:first-child {
  padding-top: 0;
}

.checklist {
  display: grid;
  gap: 10px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.check__mark {
  display: grid;
  place-items: center;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
}

.check--ok .check__mark {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.check--bad .check__mark {
  background: var(--danger-soft);
  color: var(--danger);
}

.check p {
  color: var(--muted);
  font-size: 0.85rem;
}

.self-test-result:empty {
  display: none;
}

.field {
  display: grid;
  gap: 6px;
}

.field__label {
  font-size: 0.9rem;
  font-weight: 600;
}

.radio-row {
  display: grid;
  gap: 8px;
}

.radio {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.radio:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.radio input {
  margin-top: 4px;
}

.radio__text {
  display: grid;
  gap: 2px;
}

.radio__text strong {
  font-size: 0.9rem;
}

.radio__text span {
  color: var(--muted);
  font-size: 0.82rem;
}

.file-input {
  display: block;
  width: 100%;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.loading {
  display: grid;
  place-items: center;
  min-height: 30vh;
  color: var(--muted);
}

.empty {
  padding: 12px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.dialog {
  width: min(580px, calc(100% - 24px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  background: transparent;
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.dialog__card {
  display: grid;
  gap: 16px;
  max-height: calc(100dvh - 32px);
  padding: 18px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog__title {
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.dialog__body {
  display: grid;
  gap: 14px;
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: min(520px, calc(100% - 24px));
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  text-align: center;
  transform: translateX(-50%);
}

.toast__action {
  flex: 0 0 auto;
  padding: 6px 14px;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 0.86rem;
  font-weight: 650;
}

.toast__action:hover {
  background: rgba(255, 255, 255, 0.16);
}

.toast__close {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 1.15rem;
  line-height: 1;
  opacity: 0.75;
}

.toast__close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.16);
}

.toast--success {
  background: var(--accent-strong);
  color: var(--on-accent);
}

.toast--error {
  background: var(--danger);
  color: var(--on-danger);
}

.toast--warning {
  background: var(--warning);
  color: var(--on-warning);
}

/* Заметки и проекты */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-head--editor {
  margin-bottom: 14px;
}

.page-title {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.page-subtitle {
  max-width: 65ch;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.94rem;
}

.page-meta {
  margin: 10px 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.page-head__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.back-link {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  text-decoration: none;
}

.back-link:hover {
  color: var(--accent);
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.input:focus {
  border-color: var(--accent);
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.input--title {
  font-size: 1.15rem;
  font-weight: 650;
}

.textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.55;
}

.textarea--short {
  min-height: 110px;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-bar__icon {
  color: var(--muted);
  font-size: 1.15rem;
}

.search-input {
  flex: 1;
  min-height: 48px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.search-input:focus {
  outline: none;
}

.note-list {
  display: grid;
  gap: 10px;
}

.note-card {
  display: grid;
  gap: 7px;
  padding: 14px 16px 14px 18px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--note-color, transparent);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.note-card:hover {
  border-color: var(--accent);
  background: var(--surface);
  color: var(--text);
}

.note-card__head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.note-card__title {
  overflow-wrap: anywhere;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.note-card__snippet {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.9rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.note-card__snippet--empty {
  font-style: italic;
  opacity: 0.75;
}

.note-card__meta,
.project-card__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.78rem;
}

.note-card__project {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.note-card__project--muted {
  background: var(--warning-soft);
  color: var(--warning);
}

.note-card__category {
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.note-card__date {
  margin-left: auto;
}

.color-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--note-color, var(--border));
}

.color-dot.note-color--none {
  border: 1px solid var(--border);
}

.note-color--none {
  --note-color: transparent;
}

.note-color--red {
  --note-color: var(--color-red);
}

.note-color--orange {
  --note-color: var(--color-orange);
}

.note-color--yellow {
  --note-color: var(--color-yellow);
}

.note-color--green {
  --note-color: var(--color-green);
}

.note-color--blue {
  --note-color: var(--color-blue);
}

.note-color--purple {
  --note-color: var(--color-purple);
}

.note-color--gray {
  --note-color: var(--color-gray);
}

.trash-link {
  display: inline-block;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.86rem;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 12px;
}

.project-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--note-color, transparent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease;
}

.project-card:hover {
  border-color: var(--accent);
  color: var(--text);
}

.project-card__head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-card__title {
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.project-card__snippet {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.88rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.project-card__snippet--empty {
  font-style: italic;
  opacity: 0.75;
}

.project-card__meta {
  justify-content: space-between;
}

.editor-form {
  display: grid;
  gap: 16px;
  max-width: 820px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.editor-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.form-error {
  padding: 10px 12px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.9rem;
}

.button--danger-text {
  border-color: var(--danger);
  color: var(--danger);
}

.button--danger-text:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.color-field {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.color-field legend {
  padding: 0;
}

.color-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.82rem;
}

.color-option:hover {
  background: var(--surface-2);
}

.color-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.color-option:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.color-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.color-option .color-dot {
  width: 12px;
  height: 12px;
}

.mini-list {
  display: grid;
  gap: 8px;
}

.mini-note {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.mini-note:hover {
  border-color: var(--accent);
  color: var(--text);
}

.mini-note__text {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

.mini-note__text strong {
  overflow-wrap: anywhere;
  font-size: 0.92rem;
}

.mini-note__text span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-note__date {
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.empty-state {
  display: grid;
  gap: 8px;
  justify-items: start;
  padding: 28px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.empty-state--compact {
  padding: 18px;
}

.empty-state__title {
  font-weight: 650;
}

.empty-state__text {
  max-width: 60ch;
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-state .button {
  margin-top: 4px;
}

.trash-list {
  display: grid;
  gap: 8px;
}

.trash-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.trash-row__text {
  flex: 1;
  min-width: 0;
}

.trash-row__text strong {
  overflow-wrap: anywhere;
}

.trash-row .button {
  flex: 0 0 auto;
}

/* Задачи */

.field__hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.quick-add {
  display: grid;
  gap: 10px;
  margin-bottom: 6px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.quick-add__row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.quick-add__title,
.quick-add__date,
.quick-add__project {
  min-width: 0;
}

.quick-add__due {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.check--compact {
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
}

.check--compact input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.task-section {
  margin-top: 22px;
}

.task-section--overdue .section__title {
  color: var(--danger);
}

.task-list {
  display: grid;
  gap: 8px;
}

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.task-row--overdue {
  border-left-color: var(--danger);
}

.task-row--done {
  opacity: 0.72;
}

.task-row__check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-top: 2px;
  cursor: pointer;
}

.task-check {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.task-row__main {
  display: grid;
  flex: 1;
  gap: 4px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.task-row__main:hover .task-row__title {
  color: var(--accent);
}

.task-row__title {
  overflow-wrap: anywhere;
  font-size: 0.98rem;
  font-weight: 650;
}

.task-row--done .task-row__title {
  text-decoration: line-through;
  text-decoration-color: var(--muted);
}

.task-row__desc {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.86rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.task-row__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.76rem;
}

.task-row__due--overdue {
  color: var(--danger);
  font-weight: 600;
}

.task-row__project {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.task-row__note {
  color: var(--accent-strong);
  text-decoration: none;
}

.task-row__note:hover {
  text-decoration: underline;
}

.done-section {
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.done-section__summary {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.task-list--done {
  margin-top: 10px;
}

/* Связи */

.links-section {
  margin-top: 28px;
}

.links-list {
  display: grid;
  gap: 8px;
}

.link-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.link-row--muted {
  opacity: 0.7;
}

.link-row__main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.link-row__main strong {
  overflow-wrap: anywhere;
}

.link-row__main:hover strong {
  color: var(--accent);
}

.link-row__type {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.76rem;
}

.link-row__remove {
  flex: 0 0 auto;
}

.links-add {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.links-add__select {
  flex: 1 1 240px;
  min-width: 0;
}

.links-hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.links-hint a {
  color: var(--accent-strong);
}

/* Карта связей и главная страница */

.home-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.hero--home {
  flex: 1 1 380px;
  margin-bottom: 4px;
}

.home-actions {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.home-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
  font-size: 0.86rem;
}

.home-links a {
  color: var(--muted);
  text-decoration: none;
}

.home-links a:hover {
  color: var(--accent-strong);
}

.map-view {
  margin-top: 8px;
}

.map-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.map-search {
  position: relative;
  flex: 1 1 260px;
  max-width: 420px;
}

.map-search__input {
  width: 100%;
}

.map-search__results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: grid;
  gap: 2px;
  max-height: 260px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.map-search__results[hidden] {
  display: none;
}

.map-search__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.map-search__item:hover,
.map-search__item:focus-visible {
  background: var(--surface-2);
}

.map-search__dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--note-color, var(--border));
}

.map-search__dot.note-color--none {
  border: 1px solid var(--border);
}

.map-search__title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-search__kind {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.78rem;
}

.map-search__empty {
  margin: 6px 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.map-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.map-controls__button,
.map-controls__scale {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.map-controls__button {
  min-width: 38px;
  font-size: 1.05rem;
}

.map-controls__button--wide {
  font-size: 0.86rem;
}

.map-controls__scale {
  min-width: 64px;
  color: var(--muted);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.map-controls__button:hover,
.map-controls__scale:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.map-frame {
  width: 100%;
  max-width: calc(1.6129 * min(66vh, 560px));
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.link-map {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1000 / 620;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.link-map.is-panning {
  cursor: grabbing;
}

.link-map__bg {
  fill: var(--surface);
}

.link-map__edge {
  stroke: var(--note-color, var(--border));
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
  transition: stroke 0.15s ease, stroke-width 0.15s ease;
}

.link-map__edge.is-active {
  stroke: var(--accent);
  stroke-width: 3.5;
}

.link-map__node {
  cursor: grab;
  outline: none;
}

.link-map__node.is-dragging {
  cursor: grabbing;
}

.link-map__shape {
  fill: var(--surface);
  stroke: var(--note-color, var(--border));
  stroke-width: 3;
  transition: stroke-width 0.15s ease;
}

.link-map__node.note-color--none .link-map__shape {
  stroke: var(--border);
}

.link-map__node.is-active .link-map__shape,
.link-map__node:focus-visible .link-map__shape,
.link-map__node.is-selected .link-map__shape,
.link-map__node.is-match .link-map__shape {
  stroke-width: 5;
}

.link-map__node.is-selected .link-map__shape,
.link-map__node.is-match .link-map__shape {
  stroke: var(--accent);
}

.link-map__node.is-dim {
  opacity: 0.32;
}

.link-map__node.is-linking {
  cursor: crosshair;
}

.link-map__node.is-link-target {
  opacity: 1;
}

.link-map__node.is-link-target .link-map__shape {
  stroke: var(--accent);
  stroke-width: 6;
  filter: drop-shadow(0 0 6px var(--accent));
}

.link-map__label {
  fill: var(--text);
  font-size: 13px;
  font-weight: 650;
  pointer-events: none;
}

.link-map__kind {
  fill: var(--muted);
  font-size: 10px;
  pointer-events: none;
}

.link-map__legend {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.link-map__legend > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.link-map__count {
  margin-left: auto;
}

.map-hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.legend-shape {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
}

.legend-shape--project {
  border-radius: 4px;
}

@media (max-width: 560px) {
  .dl {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .dl dd {
    margin-bottom: 8px;
  }

  .list__item {
    align-items: flex-start;
    flex-direction: column;
  }

  .dialog__actions {
    flex-direction: column-reverse;
  }

  .dialog__actions .button {
    width: 100%;
  }

  .page-head {
    flex-direction: column;
  }

  .page-head__actions,
  .page-head__actions .button {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .note-card__date {
    margin-left: 0;
  }

  .editor-actions .button {
    flex: 1 1 auto;
  }

  .color-option {
    flex: 1 1 auto;
    justify-content: center;
  }

  .trash-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .trash-row .button {
    width: 100%;
  }

  .mini-note {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .mini-note__date {
    width: 100%;
  }

  .quick-add__row {
    grid-template-columns: 1fr;
  }

  .quick-add__submit {
    width: 100%;
  }

  .task-row {
    gap: 10px;
  }

  .task-row__meta {
    gap: 6px;
  }

  .link-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .link-row__remove {
    width: 100%;
  }

  .links-add .button {
    width: 100%;
  }

  .link-map__legend {
    gap: 10px;
  }

  .home-top {
    flex-direction: column;
    gap: 14px;
  }

  /* В колонке flex-basis задаёт высоту: без сброса блок hero
     растягивался на 380px пустоты. */
  .hero--home {
    flex: 0 0 auto;
  }

  .home-actions {
    width: 100%;
    justify-items: stretch;
  }

  .home-links {
    justify-content: flex-start;
  }

  .map-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .map-search {
    max-width: none;
  }

  .map-controls {
    width: 100%;
  }

  .map-controls__button--wide {
    flex: 1 1 auto;
  }

  .map-frame {
    max-width: none;
  }

  .link-map__count {
    margin-left: 0;
    width: 100%;
  }

  .toast {
    flex-wrap: wrap;
    justify-content: flex-start;
    border-radius: 16px;
    padding: 12px 14px;
    text-align: left;
  }

  .toast__text {
    flex: 1 1 auto;
  }
}
