/* ───── Новое для обоих стилей: порядок в заметках, медиа, меню и формы.
   Здесь — вид в стиле Claude; TheiaSora переопределяет цвета в sora.css. ───── */

/* Плавная смена темы (650–1000 мс; при «меньше анимации» — 200 мс) */
:root.theme-anim *, :root.theme-anim *::before, :root.theme-anim *::after {
  transition: background-color var(--theme-dur, .85s) ease, color var(--theme-dur, .85s) ease,
    border-color var(--theme-dur, .85s) ease, fill var(--theme-dur, .85s) ease, box-shadow var(--theme-dur, .85s) ease !important;
}
:root.reduce-motion *, :root.reduce-motion *::before, :root.reduce-motion *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }

/* ───── Боковая панель: вкладки, категории, фильтры ───── */
.side-tabs { display: flex; background: var(--hover); border-radius: 10px; padding: 2px; }
.side-tabs button { flex: 1; height: 28px; border-radius: 8px; font-size: 12.5px; color: var(--muted); }
.side-tabs button.on { background: var(--elev); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); font-weight: 500; }
:root[data-theme="dark"] .side-tabs button.on { background: #45443F; }

.cat-row { display: flex; align-items: center; gap: 2px; padding: 0 6px 4px 12px; }
#app.side-alt .cat-row, #app.side-alt .filter-pill { display: none; }
.cat-chips { flex: 1; min-width: 0; display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; mask-image: linear-gradient(90deg, #000 88%, transparent); }
.cat-chips::-webkit-scrollbar { display: none; }
.cat-chips button {
  flex: none; height: 26px; padding: 0 10px; border-radius: 13px;
  font-size: 12px; color: var(--text-2); background: var(--hover);
  transition: background .12s, color .12s;
}
.cat-chips button:hover { background: var(--active); }
.cat-chips button.on { background: var(--text); color: var(--bg); }
#btnFilters { width: 30px; height: 30px; }
#btnFilters.on { color: var(--accent); background: var(--accent-soft); }
.filter-pill {
  display: none; align-items: center; gap: 6px; align-self: flex-start;
  margin: 2px 12px 4px; padding: 4px 6px 4px 10px; max-width: calc(100% - 24px);
  border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-size: 12px;
}
.filter-pill.show { display: inline-flex; }
.filter-pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filter-pill svg { width: 13px; height: 13px; stroke-width: 2; }

.side-view { display: none; flex: 1; overflow-y: auto; padding: 4px 12px 16px; }
#app.side-alt .side-view { display: block; }
#app.side-alt #list { display: none; }

/* строки списка: превью фото, категория и теги */
.item.has-thumb { display: flex; gap: 10px; align-items: center; }
.it-main { flex: 1; min-width: 0; }
.item .thumb {
  flex: none; width: 46px; height: 46px; border-radius: 9px;
  background: var(--hover) center / cover no-repeat;
}
.item .fav { color: #d8a43a; font-size: 12px; align-self: center; }
.it-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.it-tags span { font-size: 11px; color: var(--muted); background: var(--hover); padding: 1px 7px; border-radius: 7px; }
.it-tags .it-cat { color: var(--accent); background: var(--accent-soft); }

/* «Обзор» */
.sv-sec { margin-bottom: 16px; }
.sv-head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--muted); margin: 10px 2px 8px; text-transform: none; }
.sv-head button { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 500; color: var(--accent); padding: 2px 6px; border-radius: 7px; }
.sv-head button:hover { background: var(--accent-soft); }
.sv-head svg { width: 14px; height: 14px; }
.sv-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sv-col { position: relative; display: flex; flex-direction: column; text-align: left; border-radius: 12px; overflow: hidden; background: var(--elev); border: 1px solid var(--border); transition: transform .15s, box-shadow .15s; }
.sv-col:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(40, 30, 20, .1); }
.sv-cover { height: 62px; background: center / cover no-repeat; }
.sv-col-t { font-size: 12.5px; font-weight: 600; padding: 6px 9px 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sv-col-n { font-size: 11px; color: var(--muted); padding: 0 9px 7px; }
.sv-row { width: 100%; display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: 9px; color: var(--text-2); font-size: 13px; }
.sv-row:hover { background: var(--hover); }
.sv-row svg { width: 16px; height: 16px; color: var(--muted); }
.sv-row span { flex: 1; text-align: left; }
.sv-row i { font-style: normal; font-size: 12px; color: var(--faint); }
.sv-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.sv-tags button { font-size: 12.5px; padding: 4px 10px; border-radius: 10px; background: var(--hover); color: var(--text-2); }
.sv-tags button:hover { background: var(--active); }
.sv-tags i { font-style: normal; color: var(--faint); margin-left: 2px; }
.sv-empty { font-size: 12.5px; color: var(--faint); padding: 4px 2px 8px; line-height: 1.45; }
.sv-note { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 10px; }
.sv-note:hover { background: var(--hover); }
.sv-note b { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sv-note span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-view .btn.wide { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 10px; }
.side-view .btn.wide svg { width: 15px; height: 15px; }

/* Календарь */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 8px; }
.cal-head b { font: 500 16px/1 var(--serif); text-transform: capitalize; }
.cal-head button { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.cal-head button:hover { background: var(--hover); color: var(--text); }
.cal-head svg { width: 16px; height: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-wd { font-size: 10.5px; color: var(--faint); text-align: center; padding: 2px 0 4px; text-transform: uppercase; }
.cal-d { position: relative; aspect-ratio: 1; border-radius: 9px; font-size: 12.5px; color: var(--text-2); display: grid; place-items: center; }
.cal-d:hover { background: var(--hover); }
.cal-d.out { color: var(--faint); opacity: .55; }
.cal-d.today { color: var(--accent); font-weight: 700; }
.cal-d.sel { background: var(--text); color: var(--bg); }
.cal-d i { position: absolute; bottom: 3px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); }
.cal-d i.sch { background: transparent; border: 1px solid var(--accent); }

/* ───── Редактор: кнопка «вставить» и чипы заметки ───── */
.insert-btn { margin-left: 6px; color: var(--accent); }
.insert-btn:hover { background: var(--accent-soft); color: var(--accent); }
.note-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 16px; user-select: none; }
.note-meta:empty { display: none; }
.mchip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 10px; border-radius: 13px;
  font: 12px var(--sans); color: var(--text-2);
  background: var(--hover); border: 1px solid transparent;
  transition: background .12s, border-color .12s, color .12s;
}
button.mchip:hover:not(:disabled) { background: var(--active); }
.mchip svg { width: 13px; height: 13px; }
.mchip-empty, .mchip-add { color: var(--faint); background: transparent; border: 1px dashed var(--border-strong); }
.mchip-tag { color: var(--accent); background: var(--accent-soft); }
.mchip-icon { width: 26px; padding: 0; justify-content: center; }
.mchip-icon.on { color: #d8a43a; }
.mchip-icon.on svg { fill: currentColor; }
.mchip:disabled { cursor: default; }

/* ───── Блоки внутри заметки: фото, голос, файл ───── */
.body figure.nb-img {
  position: relative; margin: .7em 0; max-width: 100%;
  border-radius: 14px; overflow: hidden;
  background: var(--hover);
  user-select: none;
}
.body figure.nb-img img {
  display: block; width: 100%; height: auto; aspect-ratio: var(--ratio, 4 / 3); object-fit: cover;
  cursor: zoom-in; transition: opacity .3s;
}
.body figure.nb-img.loading img { opacity: 0; }
.body figure.nb-img.missing img { opacity: 0; }
.body figure.nb-img.missing::after { content: '⧗'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); font-size: 28px; }
.body .nb-cap {
  display: block; padding: 8px 12px 9px; font: italic .82em/1.4 var(--serif); color: var(--muted);
  outline: none; user-select: text; background: var(--elev);
}
.body .nb-cap:empty { display: none; }
.body .nb-cap:empty:focus { display: block; }
.body .nb-cap.editing { display: block; }
.body .nb-cap:empty:focus::before { content: attr(data-ph); color: var(--faint); }
.nb-img-tools {
  position: absolute; top: 8px; right: 8px; display: flex; gap: 4px;
  opacity: 0; transform: translateY(-4px); transition: opacity .15s, transform .15s;
}
.body figure.nb-img:hover .nb-img-tools, .body figure.nb-img.sel .nb-img-tools { opacity: 1; transform: none; }
.body[contenteditable="false"] .nb-img-tools, .body[contenteditable="false"] .nb-x { display: none !important; }
.nb-img-tools button {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: rgba(20, 20, 19, .62); color: #fff; backdrop-filter: blur(6px);
}
.nb-img-tools button:hover { background: rgba(20, 20, 19, .85); }
.nb-img-tools svg { width: 16px; height: 16px; }

.body .nb-voice, .body .nb-file { margin: .6em 0; user-select: none; }
.nb-voice-ui, .nb-file-ui {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 8px; border-radius: 14px;
  background: var(--elev); border: 1px solid var(--border);
  font: 13px var(--sans); color: var(--text-2);
  max-width: 420px;
}
.nb-play {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: #fff;
}
.nb-play svg { width: 15px; height: 15px; }
.nb-wave {
  flex: 1; height: 22px; position: relative; border-radius: 6px; overflow: hidden;
  background: repeating-linear-gradient(90deg, var(--border-strong) 0 2px, transparent 2px 5px);
  mask-image: linear-gradient(0deg, transparent 0 20%, #000 20% 80%, transparent 80%);
}
.nb-prog { position: absolute; inset: 0 auto 0 0; width: 0; background: repeating-linear-gradient(90deg, var(--accent) 0 2px, transparent 2px 5px); }
.nb-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; min-width: 34px; }
.nb-x { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: var(--faint); }
.nb-x:hover { background: var(--hover); color: var(--text); }
.nb-x svg { width: 14px; height: 14px; }
.nb-options { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 8px; color: var(--muted); }
.nb-options:hover { background: var(--hover); }
.nb-options svg { width: 18px; height: 18px; }
.body[contenteditable="false"] .nb-options { display: none; }
.nb-file-ic { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.nb-file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.nb-file-meta b { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-file-meta small { font-size: 11.5px; color: var(--muted); }
.nb-file-ui button[data-act="open"] { font-size: 12.5px; color: var(--accent); padding: 4px 8px; border-radius: 8px; }
.nb-file-ui button[data-act="open"]:hover { background: var(--accent-soft); }

/* ───── Всплывающее меню ───── */
.pop-menu {
  position: fixed; z-index: 60; min-width: 190px; max-width: 300px; max-height: 70vh; overflow-y: auto;
  padding: 5px; border-radius: 13px;
  background: var(--elev); border: 1px solid var(--border); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(-4px) scale(.98); transform-origin: top left;
  transition: opacity .12s, transform .12s;
  font: 13px var(--sans); color: var(--text);
}
.pop-menu.show { opacity: 1; transform: none; }
.pop-menu button { width: 100%; display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 8px; text-align: left; }
.pop-menu button:hover { background: var(--hover); }
.pop-menu button:disabled { opacity: .4; cursor: default; background: transparent; }
.pop-menu button > svg { width: 16px; height: 16px; color: var(--muted); }
.pop-menu button span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pop-menu .pm-check { width: 16px; height: 16px; color: var(--accent); }
.pop-menu .pm-check svg { width: 16px; height: 16px; stroke-width: 2.2; }
.pop-menu .pm-sep { height: 1px; background: var(--border); margin: 4px 6px; }

/* ───── Форма ───── */
#formBox { z-index: 45; }
.form-card { width: min(400px, calc(100vw - 32px)); }
.form-title { font: 500 19px/1.3 var(--serif); margin-bottom: 14px; }
.form-fields { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.ff { display: flex; flex-direction: column; gap: 5px; }
.ff > span { font-size: 12.5px; color: var(--muted); }
.ff input, .ff textarea {
  width: 100%; padding: 9px 12px; border-radius: 10px;
  border: 1.5px solid var(--border-strong); background: var(--bg); color: var(--text);
  font: 14px var(--sans); outline: none; resize: vertical;
}
.ff input:focus, .ff textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cover-pick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.cover-pick button { aspect-ratio: 4 / 3; border-radius: 9px; background: center / cover no-repeat; outline: 2px solid transparent; outline-offset: 1px; transition: outline-color .12s; }
.cover-pick button.on { outline-color: var(--accent); }
.form-extra { margin-right: auto; }

/* ───── Просмотр фото ───── */
.viewer {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(10, 10, 12, .9);
  display: flex; align-items: center; justify-content: center; gap: 12px; padding: 24px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.viewer.show { opacity: 1; pointer-events: auto; }
.viewer-fig { margin: 0; max-width: calc(100% - 100px); max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.viewer-fig img { max-width: 100%; max-height: calc(100vh - 110px); border-radius: 10px; object-fit: contain; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.viewer-fig figcaption { color: rgba(255, 255, 255, .8); font: italic 15px/1.4 var(--serif); text-align: center; }
.viewer .icon-btn { color: rgba(255, 255, 255, .8); }
.viewer .icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.viewer-close { position: absolute; top: 12px; right: 12px; }
.viewer-nav { flex: none; }

/* ───── Запись голоса ───── */
.rec-bar {
  position: fixed; left: 50%; bottom: 52px; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 16px; border-radius: 16px;
  background: var(--elev); border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: 13.5px; color: var(--text-2);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.rec-bar.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.rec-bar b { font-variant-numeric: tabular-nums; min-width: 40px; color: var(--text); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #e0483a; animation: pulse 1s infinite; }

/* ───── Установка на телефон ───── */
.install-bar {
  position: fixed; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 56;
  max-width: 480px; margin: 0 auto;
  display: none; align-items: center; gap: 10px;
  padding: 10px 8px 10px 10px; border-radius: 18px;
  background: var(--elev); border: 1px solid var(--border); box-shadow: var(--shadow);
  animation: pop .3s both;
}
.install-bar.show { display: flex; }
:root[data-skin="sora"] .install-bar { bottom: calc(var(--nav-h) + 12px); }
body.s-editing .install-bar { display: none !important; }
.ib-icon { width: 42px; height: 42px; border-radius: 11px; flex: none; }
.ib-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ib-text b { font-size: 14px; font-weight: 600; color: var(--text); }
.ib-text span { font-size: 12px; color: var(--muted); line-height: 1.35; }
.ib-close { width: 28px; height: 28px; border-radius: 8px; color: var(--muted); font-size: 18px; line-height: 1; flex: none; }
.ib-close:hover { background: var(--hover); color: var(--text); }
.ios-card { width: min(380px, calc(100vw - 32px)); }
.ios-steps { margin: 0 0 18px; padding-left: 22px; color: var(--text-2); font-size: 15px; line-height: 1.5; }
.ios-steps li { margin-bottom: 8px; }
.ios-help { margin: -6px 0 18px; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
#iosInstall { z-index: 60; }
.auth.show ~ .install-bar, body:has(.auth.show) .install-bar { bottom: calc(14px + env(safe-area-inset-bottom)); }

/* ───── Настройки: стиль, язык, данные ───── */
.style-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
body[data-edition="theiasora"] .style-pick { display: none; }
.style-pick button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 8px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); text-align: left;
  transition: border-color .12s;
}
.style-pick button:hover { border-color: var(--border-strong); }
.style-pick button.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.style-pick b { font-size: 12.5px; font-weight: 600; margin-top: 6px; }
.style-pick small { font-size: 11px; color: var(--muted); }
.sp-prev { width: 100%; height: 46px; border-radius: 8px; display: flex; gap: 4px; padding: 6px; overflow: hidden; }
.sp-prev i { display: block; border-radius: 4px; }
.sp-claude { background: #F3F1EA; }
.sp-claude i:nth-child(1) { width: 30%; background: #E8E5DB; }
.sp-claude i:nth-child(2) { flex: 1; background: #FAF9F5; border: 1px solid #E5E2D8; }
.sp-claude i:nth-child(3) { position: absolute; display: none; }
.sp-sora { position: relative; background: linear-gradient(160deg, #FFE9D6, #F7D3D8 45%, #C9D7EE); }
.sp-sora i:nth-child(1) { flex: 1; background: rgba(255, 249, 242, .85); }
.sp-sora i:nth-child(2) { width: 34%; background: linear-gradient(180deg, #0D1D2E, #071525); }
.sp-sora i:nth-child(3) { position: absolute; right: 12px; top: 10px; width: 10px; height: 10px; border-radius: 50%; background: #F3E3B5; box-shadow: 0 0 8px #F3E3B5; }
.select {
  height: 30px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--bg); color: var(--text); font: 12.5px var(--sans); outline: none; max-width: 150px;
}
.data-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 2px 12px; }
.popover .seg button { padding: 5px 7px; }

@media (max-width: 760px) {
  .cat-row { padding-left: 8px; }
  .item .thumb { width: 40px; height: 40px; }
}
