/* Мысли (этап 10б, thoughts.js и recorder.js) — по макету reference/maket/Thoughts.dc.html.
   Слева стеклянная лента, справа открытая мысль: белые карточки «Запись» и «Разбор», стеклянный блок «Связано и советы».
   Внизу по центру — капсула записи. Вверху ленты — «Надиктовать», «Написать» (карточка справа) и поиск;
   отдельной кнопки микрофона в меню нет (19.10). */

/* ---------- капсула записи ---------- */
.rec-capsule { position: fixed; left: 50%; bottom: 28px; z-index: 35; height: 64px; max-width: calc(100% - 40px); padding: 0 8px 0 22px;
  border-radius: 32px; border: 1px solid var(--glass-border); background: var(--glass-strong); box-shadow: var(--pill-shadow);
  -webkit-backdrop-filter: blur(24px) saturate(150%); backdrop-filter: blur(24px) saturate(150%); color: var(--text);
  display: flex; align-items: center; gap: 14px; opacity: 0; transform: translate(-50%, 16px);
  transition: opacity .2s var(--ease-out), transform .3s var(--ease-out); }
.rec-capsule.open { opacity: 1; transform: translate(-50%, 0); }
/* на экране с плавающим переключателем внизу (канбан, календарь) — над ним; всплывающее сообщение — над капсулой */
body:has(.float-switch) .rec-capsule { bottom: 96px; }
body:has(.rec-capsule.open) .toast { bottom: 108px; }
body:has(.float-switch):has(.rec-capsule.open) .toast { bottom: 172px; }
.rec-capsule.closing { pointer-events: none; }
.rec-dot { flex: none; width: 10px; height: 10px; border-radius: 5px; background: var(--accent); animation: rec-blink 1.6s ease-in-out infinite; }
.rec-capsule[data-mode="saving"] .rec-dot { background: var(--text3); animation: none; }
.rec-capsule[data-mode="failed"] .rec-dot { background: var(--danger); animation: none; }
@keyframes rec-blink { 50% { opacity: .35; } }
.rec-time { flex: none; min-width: 2.6em; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rec-wave { flex: none; height: 28px; display: flex; align-items: center; gap: 3px; }
.rec-wave i { width: 3px; height: 4px; border-radius: 2px; background: var(--text2); transition: height .1s linear; }
.rec-capsule:not([data-mode="rec"]) .rec-wave i { opacity: .4; }
.rec-label { flex: 0 1 auto; min-width: 0; font-size: 13px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-capsule[data-mode="failed"] .rec-label { color: var(--danger); font-weight: 600; }
.rec-capsule .btn { flex: none; height: 48px; border-radius: 24px; padding: 0 18px; }
.rec-capsule .btn.primary { padding: 0 22px; }

/* ---------- лента слева ---------- */
.th-list { flex: 0 0 340px; min-width: 0; padding: 20px 16px 16px; display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
.th-list-head { display: flex; align-items: flex-start; gap: 8px; padding: 0 4px; }
.th-list-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.th-list-title h1 { margin: 0; font-size: 26px; line-height: 32px; font-weight: 600; letter-spacing: -.3px; }
.th-private { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; line-height: 16px; color: var(--text3); }
.th-private .ico { width: 12px; height: 12px; }
/* две кнопки: записать голосом (главная) и написать текстом; поиск — под ними, всегда на виду */
.th-make { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.th-make .btn { min-width: 0; height: 44px; padding: 0 12px; border-radius: 22px; gap: 8px; }
.th-make .btn .ico { width: 18px; height: 18px; }
.th-make .btn span { overflow: hidden; text-overflow: ellipsis; }
.th-rec[aria-pressed="true"] { background: var(--accent-hover); }
.th-write[aria-pressed="true"] { background: var(--sel-bg); border-color: rgba(204, 75, 12, .7); }
.th-search { flex: none; }
.th-seg { flex: none; display: flex; width: 100%; }
.th-seg button { flex: 1; justify-content: center; height: 34px; border-radius: 17px; }
.th-items { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin: 0 -6px; padding: 0 6px 6px; }
.th-row { flex: none; padding: 12px 14px; border-radius: 18px; border: 1.5px solid transparent; color: var(--text); text-decoration: none;
  display: flex; flex-direction: column; gap: 5px; transition: background-color .2s var(--ease-out), border-color .2s var(--ease-out); }
@media (hover: hover) { .th-row:hover { background: var(--sub); } }
.th-row:active { background: var(--sub-hover); transition-duration: .06s; }
.th-row.on { background: var(--sel-bg); border-color: rgba(204, 75, 12, .7); }
.th-row-top { display: flex; align-items: center; gap: 8px; }
.th-when { flex: 1; min-width: 0; font-size: 12px; line-height: 16px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.th-title { font-size: 15px; line-height: 20px; font-weight: 600; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.th-sub { font-size: 13px; line-height: 18px; color: var(--text3); overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* статус мысли */
.th-tag { flex: none; height: 20px; padding: 0 8px; border-radius: 10px; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center;
  white-space: nowrap; background: var(--sub); color: var(--text3); }
.th-tag.wait { background: var(--tint); color: var(--accent-text); }
.th-tag.done { background: var(--ev-bg); color: var(--ev-text); }
.th-tag.bad { background: var(--danger-bg); color: var(--danger); }
.th-meta .th-tag { height: 22px; padding: 0 9px; border-radius: 11px; font-size: 12px; }

/* ---------- открытая мысль ---------- */
.panel.main.th-main { padding: 24px 24px 0; gap: 18px; }
.th-head { flex: none; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 16px; }
.th-back { display: none; }
.th-head-text { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.th-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--text3); }
.th-head h2 { margin: 0; font-size: 26px; line-height: 32px; font-weight: 600; letter-spacing: -.3px; overflow-wrap: anywhere; }
.th-head-actions { display: flex; align-items: center; gap: 10px; }
.th-progress { height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--sub-border); background: var(--sub); font-size: 13px;
  font-weight: 600; display: inline-flex; align-items: center; white-space: nowrap; }
.th-more { width: 44px; height: 44px; border-radius: 22px; }
.th-more .ico { width: 20px; height: 20px; }
.th-body { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -24px; padding: 0 24px 24px; }
.th-grid { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; }
.th-col { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.th-grid.single .th-col { max-width: 760px; }

/* белые карточки — одинаковые в обеих темах */
.th-card { padding: 18px 20px; border-radius: 22px; background: #fff; color: var(--card-text); box-shadow: var(--card-shadow);
  display: flex; flex-direction: column; gap: 12px; }
.th-text { margin: 0; font-size: 14px; line-height: 21px; white-space: pre-wrap; overflow-wrap: anywhere; }
.th-hint { color: var(--card-text2); }
.th-hint.bad { color: #C62828; }
.th-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.cbtn { height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid #D5DAE0; background: #fff; color: #16181D; font-size: 13px;
  font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  transition: transform .2s var(--ease-out), background-color .2s var(--ease-out), border-color .2s var(--ease-out); }
.cbtn .ico { width: 14px; height: 14px; }
.cbtn.primary { padding: 0 14px; border-color: transparent; background: var(--accent); color: #fff; }
@media (hover: hover) {
  .cbtn:hover:not(:disabled) { background: #F1F3F5; }
  .cbtn.primary:hover:not(:disabled) { background: var(--accent-hover); }
}
.cbtn:active:not(:disabled) { transform: scale(.97); transition-duration: .06s; }
.cbtn:disabled { opacity: .5; cursor: default; }
.th-editing { display: flex; flex-direction: column; gap: 10px; }
.th-edit { width: 100%; min-height: 120px; padding: 12px 14px; border-radius: 16px; border: 1px solid #D5DAE0; background: #fff; color: #16181D;
  font-size: 14px; line-height: 21px; resize: vertical; outline: none; }
.th-edit:focus { border-color: var(--accent); }
.th-edit::placeholder { color: #8A909A; }

/* новая мысль текстом — большое поле справа */
.th-writer .th-new { min-height: 220px; max-height: 60vh; font-size: 15px; line-height: 22px; resize: none; }
.th-writer .th-new:disabled { opacity: .6; }
.th-keys { margin-left: auto; align-self: center; font-size: 12px; color: var(--card-text2); }

/* плеер: кнопка, волна (нажать — перемотать), время */
.th-player { display: flex; align-items: center; gap: 12px; }
.th-play { flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 22px; background: var(--accent); color: #fff;
  display: grid; place-items: center; transition: transform .2s var(--ease-out), background-color .2s var(--ease-out); }
.th-play .ico { width: 16px; height: 16px; }
@media (hover: hover) { .th-play:hover { background: var(--accent-hover); } }
.th-play:active { transform: scale(.92); transition-duration: .06s; }
.th-wave { flex: 1; min-width: 0; height: 34px; display: flex; align-items: center; gap: 2px; overflow: hidden; cursor: pointer; border-radius: 4px; }
.th-wave i { flex: 1 1 0; min-width: 2px; border-radius: 2px; background: #C9CED6; transition: background-color .15s linear; }
.th-wave i.on { background: var(--accent); }
.th-ptime { flex: none; font-size: 12px; color: var(--card-text2); font-variant-numeric: tabular-nums; }

/* разбор */
.th-parse { flex: 1.3 1 420px; min-width: 0; padding: 18px 20px 20px; gap: 16px; }
.th-parse-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.th-parse-head h3 { margin: 0; font-size: 16px; line-height: 22px; font-weight: 600; }
.th-parse-head span { font-size: 12px; line-height: 16px; color: var(--card-text2); }
.th-group { display: flex; flex-direction: column; gap: 8px; }
.th-group-head { display: flex; align-items: center; gap: 8px; }
.th-group-head h4 { margin: 0; font-size: 14px; line-height: 19px; font-weight: 600; }
.th-gcount { font-size: 13px; color: var(--card-text2); }
.th-gico { flex: none; width: 26px; height: 26px; border-radius: 13px; display: grid; place-items: center; }
.th-gico .ico { width: 15px; height: 15px; }
.th-gico.task { background: #F9EBE3; color: #BC450B; }
.th-gico.idea { background: #F3EBC4; color: #6B5200; }
.th-gico.decision { background: #E6F2EA; color: #1E7D3A; }
.th-gico.unclear { background: #E6EEF8; color: #1F5FAF; }
.th-item { padding: 12px 14px; border-radius: 16px; border: 1px solid #E6E9ED; background: #fff; display: flex; flex-wrap: wrap;
  align-items: center; gap: 10px 12px; transition: background-color .2s var(--ease-out); }
.th-item.closed { background: #F7F8FA; }
.th-item-main { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.th-item-title { font-size: 14px; line-height: 19px; font-weight: 600; overflow-wrap: anywhere; }
.th-item.off .th-item-title { color: var(--card-text2); text-decoration: line-through; }
.th-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.th-chips span { height: 22px; padding: 0 8px; border-radius: 11px; background: #F1F3F5; color: #4B515C; font-size: 12px; display: inline-flex; align-items: center; }
.th-note { font-size: 12px; line-height: 16px; color: var(--card-text2); }
.th-acts { flex: none; display: flex; flex-wrap: wrap; gap: 6px; max-width: 100%; }
.th-res { flex: none; display: flex; align-items: center; gap: 4px; max-width: 100%; }
.th-res-text { min-width: 0; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; line-height: 18px; font-weight: 600; color: #1E7D3A; }
.th-res-text .ico { width: 14px; height: 14px; }
.th-res-text a { color: inherit; }
.th-res.off .th-res-text { color: var(--card-text2); }
.th-undo { height: 34px; padding: 0 8px; border: 0; background: transparent; color: #4B515C; font-size: 13px; text-decoration: underline; }
@media (hover: hover) { .th-undo:hover { color: #16181D; } }

/* связано и советы — стекло */
.th-side { padding: 16px; border-radius: 24px; border: 1px solid var(--sub-border); background: var(--sub); display: flex; flex-direction: column; gap: 10px; }
.th-side h3 { margin: 0; padding: 0 4px; font-size: 16px; line-height: 22px; font-weight: 600; }
.th-side h3 + .th-rels + h3 { margin-top: 4px; }
.th-rels { display: flex; flex-direction: column; }
.th-rel { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 0 4px; border-radius: 12px; color: var(--text); text-decoration: none; }
.th-rel.sep { border-top: 1px solid var(--sep); }
@media (hover: hover) { .th-rel.link:hover { background: var(--sub); } }
.th-rel-ico { flex: none; width: 30px; height: 30px; border-radius: 15px; background: var(--sub); color: var(--text2); display: grid; place-items: center; }
.th-rel-ico .ico { width: 15px; height: 15px; }
.th-rel-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.th-rel-title { font-size: 14px; line-height: 19px; font-weight: 500; overflow-wrap: anywhere; }
.th-rel-sub { font-size: 12px; line-height: 16px; color: var(--text3); }
.th-rel-go { width: 16px; height: 16px; color: var(--text3); }
.th-adv { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; border-radius: 16px; border: 1px solid var(--sub-border); background: var(--sub); }
.th-adv > span { flex: 1; min-width: 0; font-size: 13px; line-height: 18px; }
.th-adv button { flex: none; height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid var(--glass-border); background: transparent;
  color: var(--text); font-size: 13px; font-weight: 600; transition: transform .2s var(--ease-out), background-color .2s var(--ease-out); }
.th-adv button[aria-pressed="true"] { background: var(--tab-on); color: var(--tab-on-text); }
@media (hover: hover) { .th-adv button:hover:not(:disabled) { background: var(--sub-hover); } }
.th-adv button:active:not(:disabled) { transform: scale(.97); transition-duration: .06s; }

/* ---------- ширина экрана ---------- */
@media (max-width: 1499px) { #app.has-detail[data-section="thoughts"] .th-list { display: none; } }
@media (max-width: 1099px) { .th-list { flex-basis: 300px; } }

/* Телефон: лента — один экран, открытая мысль — следующий */
@media (max-width: 899px) {
  .th-list { flex: 1; min-height: 0; padding: 16px 12px 12px; }
  .th-list.has-open, .th-main:not(.has-open) { display: none; }
  .panel.main.th-main { flex: 1; min-height: 0; padding: 14px 16px 0; gap: 14px; }
  .th-back { display: inline-grid; }
  .th-head { gap: 10px; }
  .th-head-text { order: 3; flex-basis: 100%; }
  .th-head-actions { margin-left: auto; }
  .th-head h2 { font-size: 22px; line-height: 28px; }
  .th-body { margin: 0 -16px; padding: 0 16px 24px; }
  .th-card { padding: 16px; }
  .th-col, .th-parse { flex-basis: 100%; }
  .rec-capsule { bottom: 88px; height: 60px; max-width: calc(100% - 20px); padding: 0 6px 0 18px; gap: 10px; }
  body:has(.float-switch) .rec-capsule { bottom: 158px; }
  body:has(.rec-capsule.open) .toast { bottom: 160px; }
  body:has(.float-switch):has(.rec-capsule.open) .toast { bottom: 228px; }
  .rec-label { display: none; }
  .rec-capsule .btn { height: 46px; padding: 0 14px; }
  .rec-wave { gap: 2px; }
}
@media (max-width: 380px) { .rec-wave { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .rec-capsule { transform: translate(-50%, 0); }
  .rec-dot { animation: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .rec-capsule { -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* ---------- вкладка «Мысли» в «Базе знаний» (23.10, thoughts.js): слева список всех мыслей, справа открытая ---------- */
.tl-filter .tl-seg { display: flex; width: 100%; }
.tl-filter .tl-seg button { flex: 1; justify-content: center; padding: 0 8px; font-size: 13px; white-space: nowrap; }
.kb-chat-ico.tl-text { background: var(--sub); color: var(--text2); }
.tl-body { display: flex; flex-direction: column; gap: 14px; padding-top: 4px; }
.tl-card { flex: none; padding: 16px 18px; border-radius: 22px; background: #fff; color: var(--card-text); box-shadow: var(--card-shadow);
  display: flex; flex-direction: column; gap: 12px; }
.tl-card h3 { margin: 0; font-size: 15px; line-height: 20px; font-weight: 600; }
.tl-card .kb-ai-head h3 { margin-right: 4px; }
.tl-card .kb-player { max-width: 520px; }
.tl-wait { color: #B54708; }
.th-res-text a { color: inherit; }
.tl-main .kb-chat-kind { display: block; flex-basis: 100%; }
.tl-go.bottom { display: none; }
@media (max-width: 899px) {
  .tl-main .kb-chat-kind { display: block; }
  .tl-go.top { display: none; }
  .tl-go.bottom { display: inline-flex; flex: none; align-self: stretch; justify-content: center; }
}
