:root {
  --bg: #eeeee7;
  --bg-soft: #f6f7f1;
  --panel: #fdfcf8;
  --panel-2: #e9eee4;
  --line: #dce1d6;
  --text: #23302b;
  --muted: #5d6a61;
  --accent: #355f48;
  --accent-soft: #e3ecdb;
  --accent-2: #527f63;
  --forest: #20372e;
  --lime: #d8eb9c;
  --danger: #a43737;
  --warn: #855b22;
  --ok: #2e6b45;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(34, 53, 43, 0.09);
  --title-font: Georgia, 'Times New Roman', serif;
  font-synthesis-weight: none;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, sans-serif;
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ── Шапка ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 72px;
  padding: 14px max(24px, calc((100vw - 1504px) / 2));
  background: var(--forest);
  color: #f7faef;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  min-width: 0;
}

.brand-mark {
  display: block;
  flex: none;
}

.brand strong {
  font-weight: 700;
}

.model-picker { position: relative; min-width: 0; margin-left: 10px; }

.model {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 12px;
  color: #eff5e9;
  padding: 6px 10px;
  border: 1px solid rgba(235, 247, 224, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  max-width: 220px;
}

#modelLabel {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pulse {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: #a9baaa;
  box-shadow: 0 0 0 0 rgba(88, 214, 141, 0.5);
  transition: background 0.3s;
}

.pulse[data-state='online'] {
  background: var(--lime);
  animation: breathe 2.6s ease-in-out infinite;
}

.pulse[data-state='busy'] {
  background: #ffd58c;
  animation: breathe 1.2s ease-in-out infinite;
}

.pulse[data-state='error'] {
  background: #ffa6a6;
}

@keyframes breathe {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(88, 214, 141, 0.45);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(88, 214, 141, 0);
  }
}

.metrics {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chip {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  white-space: nowrap;
}

.chip.warn {
  color: var(--warn);
  border-color: rgba(255, 184, 107, 0.35);
}

.chip.ok {
  color: var(--ok);
  border-color: rgba(88, 214, 141, 0.3);
}

.chip.bad {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.35);
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  cursor: pointer;
  transition: 0.16s;
}

.icon-btn:hover {
  border-color: var(--accent);
  background: var(--panel-2);
}

.icon-btn[aria-pressed='false'] {
  opacity: 0.68;
}

.topbar .chip,
.topbar .icon-btn {
  border-color: rgba(235, 247, 224, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: #f1f5ed;
}

.topbar .chip.ok {
  color: var(--lime);
}

.topbar .chip.warn { color: #ffdc9e; }
.topbar .chip.bad { color: #ffc0bd; }
.topbar .icon-btn:hover { background: rgba(255, 255, 255, 0.14); }
.topbar :focus-visible { outline-color: var(--lime); }

/* ── Раскладка ──────────────────────────────────────────────────────────── */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 152px minmax(0, 1fr) minmax(320px, 28%);
  gap: 18px;
  min-height: 0;
  width: min(100%, 1552px);
  margin-inline: auto;
  padding: 22px 24px 20px;
}

.chat,
.side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 2px 8px rgba(34, 53, 43, 0.04);
}

.chat-head,
.planner-head {
  display: flex;
  align-items: center;
  min-height: 62px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
}

.chat-head h1,
.planner-head h2 {
  margin: 0;
  font: 400 25px/1.2 var(--title-font);
}

.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding: 24px 24px 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.msg {
  max-width: min(760px, 88%);
  padding: 12px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  animation: rise 0.18s ease-out;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.msg.user {
  align-self: flex-end;
  background: var(--accent-soft);
  border-color: #d4e0cc;
  border-bottom-right-radius: 6px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--bg-soft);
  border-bottom-left-radius: 6px;
}

.msg.error {
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.08);
}

.msg .meta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.msg .activities {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--muted);
}

.activity {
  display: flex;
  gap: 7px;
  align-items: baseline;
}

.activity .tool-name {
  color: var(--accent-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.activity.done {
  opacity: 0.6;
}

.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s infinite;
}

.typing i:nth-child(2) {
  animation-delay: 0.18s;
}

.typing i:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.empty-state {
  margin: auto;
  text-align: left;
  color: var(--muted);
  width: min(100%, 560px);
  padding: 28px 0;
}

.empty-state h2 {
  font: 400 clamp(34px, 4.5vw, 64px)/1.04 var(--title-font);
  letter-spacing: -0.045em;
  color: var(--text);
  margin: 0 0 14px;
}

.empty-state p {
  margin: 6px 0;
  font-size: 14px;
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 26px;
}

.suggestions button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 55px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  padding: 9px 11px;
  border-radius: 11px;
  text-align: left;
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s;
}

.suggestions button:hover {
  border-color: var(--accent-2);
  background: var(--accent-soft);
}

.suggestion-symbol {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 17px;
}

.suggestion-arrow {
  color: var(--muted);
}

/* ── Ввод ───────────────────────────────────────────────────────────────── */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 8px 20px 6px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 3px 12px rgba(34, 53, 43, 0.05);
}

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

.composer textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 8px 4px;
  max-height: 180px;
  line-height: 1.5;
}

.composer textarea::placeholder {
  color: var(--muted);
}

.mic,
.send {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: 0.16s;
  flex: none;
}

#attachBtn { font-size: 21px; }

.mic-symbol {
  position: relative;
  width: 12px;
  height: 13px;
  margin-top: 4px;
  border: 1.5px solid currentColor;
  border-top: 0;
  border-radius: 0 0 7px 7px;
}

.mic-symbol::before,
.mic-symbol::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: currentColor;
}

.mic-symbol::before { width: 5px; height: 11px; top: -4px; border-radius: 4px; }
.mic-symbol::after { width: 1.5px; height: 4px; top: 12px; }

.mic:hover,
.send:hover {
  border-color: var(--accent);
}

.mic.listening {
  background: rgba(255, 107, 107, 0.14);
  border-color: rgba(255, 107, 107, 0.6);
  animation: pulse-mic 1.4s ease-in-out infinite;
}

@keyframes pulse-mic {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(255, 107, 107, 0);
  }
}

.send {
  background: var(--lime);
  border-color: transparent;
  color: var(--forest);
  font-size: 23px;
  line-height: 1;
}

.send:disabled {
  opacity: 0.5;
  cursor: default;
}

.hintline {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 1px 18px 12px;
}

.voice-hint {
  margin: 0 18px 8px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.08);
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  color: var(--danger);
}

.wave {
  display: inline-flex;
  gap: 3px;
  align-items: flex-end;
  height: 16px;
}

.wave i {
  width: 3px;
  height: 6px;
  border-radius: 2px;
  background: var(--danger);
  animation: wave 0.9s ease-in-out infinite;
}

.wave i:nth-child(2) {
  animation-delay: 0.1s;
}
.wave i:nth-child(3) {
  animation-delay: 0.2s;
}
.wave i:nth-child(4) {
  animation-delay: 0.3s;
}
.wave i:nth-child(5) {
  animation-delay: 0.4s;
}

@keyframes wave {
  0%,
  100% {
    height: 5px;
  }
  50% {
    height: 15px;
  }
}

/* ── Боковая панель ─────────────────────────────────────────────────────── */
.side {
  background: var(--bg-soft);
}

.tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 3px 0;
}

.tab {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 43px;
  white-space: nowrap;
  position: relative;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  padding: 7px 10px;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.tab:hover { background: var(--bg-soft); }

.tab.active {
  background: var(--accent-soft);
  border-color: #d5dece;
  color: var(--forest);
}

.nav-symbol {
  width: 20px;
  flex: none;
  text-align: center;
  font-size: 17px;
  line-height: 1;
}

.panel {
  display: none;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  padding: 16px 18px 18px;
}

.panel.active {
  display: flex;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 2px 10px;
}

.panel[data-panel='today'] .panel-head {
  align-items: flex-start;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 4px;
}

.day-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.day-actions .link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  font-weight: 600;
}

.day-actions .link:hover { border-color: var(--accent-2); }

.planner-empty {
  color: var(--muted);
  padding: 16px;
  margin: 4px 0;
  border: 1px dashed #cbd5c6;
  border-radius: 10px;
  font-size: 13px;
}

.link {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
}

.list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.task-item,
.note-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--panel);
  font-size: 13px;
}

.task-item .row1 {
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
}

.task-item .title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.status.done {
  color: var(--ok);
  border-color: rgba(88, 214, 141, 0.35);
}
.status.running {
  color: var(--accent);
  border-color: rgba(124, 140, 255, 0.4);
}
.status.queued {
  color: var(--warn);
  border-color: rgba(255, 184, 107, 0.35);
}
.status.failed {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.4);
}

.task-item .sub {
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 5px;
}

.task-item .actions {
  margin-top: 8px;
  display: flex;
  gap: 10px;
}

.task-item details {
  margin-top: 8px;
}

.task-item summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
}

.task-item .result {
  margin-top: 6px;
  white-space: pre-wrap;
  color: var(--text);
  font-size: 12.5px;
  max-height: 240px;
  overflow: auto;
}

.note-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.note-item .tag {
  font-size: 10.5px;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.mini-form {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.mini-form input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  padding: 8px 10px;
  outline: 0;
}

.mini-form input:focus {
  border-color: var(--accent);
}

.mini-form button {
  width: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  cursor: pointer;
}

.log {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  gap: 3px;
}

.log .entry {
  color: var(--muted);
  padding: 2px 0;
  border-bottom: 1px dashed var(--line);
  overflow-wrap: anywhere;
}

.log .entry.warn {
  color: var(--warn);
}
.log .entry.error {
  color: var(--danger);
}

/* ── Настройки ──────────────────────────────────────────────────────────── */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100dvh;
  width: min(400px, 92vw);
  background: var(--bg-soft);
  border-left: 1px solid var(--line);
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: slide 0.2s ease-out;
}

@keyframes slide {
  from {
    transform: translateX(20px);
    opacity: 0;
  }
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.drawer-body {
  padding: 16px 18px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.row select,
.row input[type='range'] {
  max-width: 160px;
}

.row select {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 5px 8px;
}

.kv {
  display: grid;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 14px;
  overflow-wrap: anywhere;
}

.kv b {
  color: var(--text);
  font-weight: 500;
}

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

.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
}

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

.btn.danger {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.35);
}

.fine {
  font-size: 11.5px;
  color: var(--muted);
  margin: 0;
}

/* ── Тост ───────────────────────────────────────────────────────────────── */
.toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
}

.toast {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 16px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: rise 0.2s ease-out;
}

.toast.error {
  border-color: rgba(255, 107, 107, 0.5);
  color: var(--danger);
}

.hidden,
[hidden] {
  display: none !important;
}

/* ── Мобильный вид ──────────────────────────────────────────────────────── */
@media (min-width: 861px) and (max-width: 1100px) {
  .layout {
    grid-template-columns: 112px minmax(0, 1fr) 290px;
    gap: 12px;
    padding-inline: 16px;
  }

  .tab { padding-inline: 6px; gap: 5px; font-size: 13px; }
  .suggestions button { gap: 7px; grid-template-columns: auto minmax(0, 1fr); }
  .suggestion-arrow { display: none; }
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 8px 10px;
  }

  .topbar {
    min-height: 58px;
    padding: 8px 14px;
  }

  .model {
    max-width: 130px;
  }

  .metrics {
    margin-left: auto;
  }

  .chip {
    font-size: 11px;
    padding: 3px 8px;
  }

  .side, .tabs { display: none; }
  .chat, .side { border-radius: 14px; }
  .chat-head, .planner-head { min-height: 46px; padding: 8px 14px; }
  .chat-head h1, .planner-head h2 { font-size: 21px; }

  body[data-view='side']:is([data-panel='memory'], [data-panel='system']) .layout {
    grid-template-rows: auto minmax(0, 1fr);
  }

  body[data-view='side']:is([data-panel='memory'], [data-panel='system']) .tabs {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 4px;
    padding: 1px 2px;
  }

  .tab { width: auto; flex: 1 0 auto; min-height: 34px; font-size: 12px; padding: 5px 8px; }
  .tabs .tab:not(:is([data-tab='memory'], [data-tab='system'])) { display: none; }
  .tab .nav-symbol { display: none; }

  body[data-view='side'] .chat {
    display: none;
  }

  body[data-view='side'] .side {
    display: flex;
  }

  .messages {
    padding: 15px 14px 4px;
  }

  .msg {
    max-width: 92%;
  }

  #hintline {
    display: none;
  }

  .composer {
    margin: 6px 9px 9px;
  }

  .empty-state {
    padding: 16px 0;
  }
}

@media (max-width: 480px) {
  #tgChip, #queueChip, .model-picker { display: none; }
  .metrics { gap: 5px; }
  .topbar :is(.chip.warn, .chip.bad) { max-width: 76px; overflow: hidden; text-overflow: ellipsis; }
  .brand { gap: 7px; }
  .brand-mark { width: 31px; height: 31px; }
  .suggestions { gap: 7px; margin-top: 17px; }
  .suggestions button { min-height: 48px; padding: 7px; gap: 6px; font-size: 12px; grid-template-columns: auto minmax(0, 1fr); }
  .suggestion-symbol { width: 24px; height: 24px; font-size: 15px; }
  .suggestion-arrow { display: none; }
  .composer { gap: 5px; padding: 5px; }
  .composer textarea { font-size: 16px; }
  .mic, .send { width: 36px; height: 36px; }

  .icon-btn {
    width: 34px;
    height: 34px;
  }
}

@media (display-mode: standalone) {
  .topbar {
    padding-top: calc(10px + env(safe-area-inset-top));
  }
}

/* ── Переключатель модели ───────────────────────────────────────────────── */
.topbar {
  position: relative;
}

.caret {
  font-size: 10px;
  opacity: 0.7;
}

.popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 45;
  min-width: 260px;
  max-width: calc(100vw - 32px);
  max-height: 70vh;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.menu-head {
  padding: 8px 10px 4px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
}

.menu-item:hover {
  background: var(--panel-2);
}

.menu-item.selected {
  color: var(--accent);
}

.menu-note {
  padding: 10px;
  font-size: 13px;
  color: var(--muted);
}

/* ── Вложения ───────────────────────────────────────────────────────────── */
.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 18px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-chip button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.msg code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 5px;
}

.msg code.block {
  display: block;
  padding: 10px 12px;
  margin: 6px 0;
  overflow-x: auto;
  white-space: pre;
}

.msg a {
  color: var(--accent-2);
}

.msg .h {
  display: inline-block;
  margin-top: 4px;
}

/* ── Панели: Сегодня, Дела, Списки ──────────────────────────────────────── */
.badge {
  display: inline-block;
  min-width: 16px;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  line-height: 16px;
}

.day-title {
  color: var(--text);
  font: 400 21px/1.25 var(--title-font);
}

.section-title {
  margin: 8px 2px 0;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.section-title.bad {
  color: var(--danger);
}

.row-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-size: 13px;
}

.row-item .time {
  flex: none;
  min-width: 46px;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}

.row-item small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
}

.row-item.past {
  opacity: 0.5;
}

.row-item.current {
  border-color: rgba(86, 208, 192, 0.6);
}

.grow {
  flex: 1;
  min-width: 0;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.filter {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.filter.active {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.filter-input {
  border: 1px solid var(--accent);
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  width: 120px;
  outline: 0;
}

.todo {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-size: 13.5px;
}

.todo input[type='checkbox'] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex: none;
}

.todo.p1 {
  border-left: 3px solid var(--danger);
}

.todo.p3 .todo-title {
  color: var(--muted);
}

.todo.overdue {
  background: rgba(255, 107, 107, 0.06);
}

.todo.done .todo-title {
  text-decoration: line-through;
  color: var(--muted);
}

.todo .clickable {
  cursor: pointer;
}

.todo-title {
  overflow-wrap: anywhere;
}

.todo-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
}

.tag {
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.tag.bad {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.4);
}

.tag.who {
  color: var(--warn);
  border-color: rgba(255, 184, 107, 0.35);
}

.tag.sphere {
  color: var(--accent-2);
}

.notes {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.todo-edit {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.todo-edit input,
.todo-edit select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
  padding: 6px 8px;
  font-size: 13px;
  color-scheme: dark;
}

.todo-edit .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.todo-edit label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
}

.edit-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn.small {
  padding: 6px 12px;
}

.link.danger {
  color: var(--danger);
}

.list-item {
  cursor: pointer;
}

.panel-foot {
  padding-top: 8px;
  text-align: right;
}

.block-link {
  text-align: left;
  padding: 6px 2px;
}

.tag-label {
  font-size: 10.5px;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.log-box {
  margin-top: 12px;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.log-box summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 2px;
}

.log-box .log {
  max-height: 300px;
}

.panel[data-panel='system'] .list:first-of-type {
  flex: 1;
}

.fine.bad {
  color: var(--danger);
}

/* ── Настройки: ИИ-сервисы ──────────────────────────────────────────────── */
.drawer section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.providers {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.provider {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.provider.active {
  border-color: var(--accent-2);
}

.provider.off {
  opacity: 0.55;
}

.provider-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
}

.provider-head input {
  margin-top: 4px;
  accent-color: var(--accent);
}

.provider-head small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
}

.provider select {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12.5px;
}

.provider-state {
  color: var(--muted);
  font-size: 11.5px;
}

.provider-state.bad {
  color: var(--danger);
}

/* ── Нижняя навигация (телефон) ─────────────────────────────────────────── */
.bottom-nav {
  display: none;
  justify-content: space-around;
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
}

.bottom-nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  padding: 4px 0;
  cursor: pointer;
}

.bottom-nav button span {
  display: grid;
  place-items: center;
  width: 35px;
  height: 25px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
}

.bottom-nav button.active {
  color: var(--forest);
  font-weight: 650;
}

.bottom-nav button.active span { background: var(--accent-soft); }

@media (max-width: 860px) {
  .bottom-nav {
    display: flex;
  }

  .side .panel {
    padding: 12px 12px 14px;
  }

}

/* ── Потянуть-обновить ──────────────────────────────────────────────────── */
.pull-indicator {
  position: fixed;
  top: 6px;
  left: 50%;
  z-index: 70;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 18px;
  opacity: 0;
  transform: translate(-50%, 0);
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}

.pull-indicator.visible {
  opacity: 1;
}

.pull-indicator.ready {
  color: var(--accent-2);
  border-color: rgba(86, 208, 192, 0.6);
}

.pull-indicator.loading {
  opacity: 1;
  color: var(--accent);
  transform: translate(-50%, 16px);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: translate(-50%, 16px) rotate(360deg);
  }
}

/* ── Смена пароля ───────────────────────────────────────────────────────── */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
}

.auth-form input {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 7px 10px;
  font-size: 14px;
  outline: 0;
}

.auth-form input:focus {
  border-color: var(--accent);
}

.auth-form .btn {
  align-self: flex-start;
}

/* ── Страница входа ─────────────────────────────────────────────────────── */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  overflow: auto;
}

.login-card {
  width: min(420px, 100%);
  padding: 32px 26px 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-brand img {
  border-radius: 12px;
}

.login-brand h1 {
  margin: 0;
  font: 400 29px/1.2 var(--title-font);
}

.login-brand p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.login-message {
  margin: 0 0 14px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 13px;
  color: var(--muted);
}

.login-message.bad {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.08);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  color: var(--muted);
}

.login-form input:not([type='checkbox']) {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  padding: 11px 13px;
  font-size: 16px;
  outline: 0;
}

.login-form input:not([type='checkbox']):focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-form .login-remember {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.login-remember input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.login-submit {
  margin-top: 4px;
  padding: 12px;
  border: 0;
  border-radius: 12px;
  background: var(--forest);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}

.login-submit:hover {
  filter: brightness(1.08);
}

.login-foot {
  margin: 18px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
}

.login-foot code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-reduced-motion: reduce) {
  .pulse, .mic.listening, .msg, .toast, .drawer, .typing i, .wave i { animation: none; }
  .messages { scroll-behavior: auto; }
}
