/* Палитра «студийный пульт» — те же цвета, что в Android-версии (colors.xml) */
:root {
  --paper: #EEEAE1;      /* фон экрана */
  --panel: #E5E0D5;      /* фон панелей и нажатых кнопок */
  --ink: #1B1A17;        /* основной текст */
  --ink-muted: #716B60;  /* подписи и второстепенный текст */
  --hairline: #C8C0B1;   /* тонкие линии-разделители */
  --signal: #D63F18;     /* единственный акцент: красный «REC» */
  --signal-soft: rgba(214, 63, 24, 0.25);
  --wave-idle: #A29A8B;  /* волна, когда запись на паузе */

  --mono: ui-monospace, "SF Mono", "Roboto Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

/* Тёмная версия: графит вместо бумаги */
:root[data-theme="dark"] {
  --paper: #141312;
  --panel: #1E1D1B;
  --ink: #EAE5DA;
  --ink-muted: #8F887C;
  --hairline: #34312D;
  --signal: #FF5A2D;
  --signal-soft: rgba(255, 90, 45, 0.25);
  --wave-idle: #4B4740;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141312;
    --panel: #1E1D1B;
    --ink: #EAE5DA;
    --ink-muted: #8F887C;
    --hairline: #34312D;
    --signal: #FF5A2D;
    --signal-soft: rgba(255, 90, 45, 0.25);
    --wave-idle: #4B4740;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0;
  cursor: pointer;
}
button:disabled { cursor: default; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Колонка «как телефон» по центру: на ноутбуке выглядит так же, как на смартфоне */
#app {
  max-width: 560px;
  margin: 0 auto;
  height: 100%;
  border-left: 1px solid transparent;
  border-right: 1px solid transparent;
}
@media (min-width: 600px) {
  #app { border-color: var(--hairline); }
}
.screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ---------- Типографика (styles.xml) ---------- */
.label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-muted);
}
.body-text { font-size: 16px; color: var(--ink); }
.signal { color: var(--signal) !important; }

/* ---------- Верхняя панель ---------- */
.topbar {
  flex: none;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  border-bottom: 1px solid var(--hairline);
}
.topbar .title {
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  padding: 0 8px;
  white-space: nowrap;
}
.topbar .brand-code { color: var(--signal); }
.topbar .spacer { flex: 1; }
.topbar-action {
  height: 100%;
  padding: 0 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}
.topbar-action:active { background: var(--panel); }
.icon-btn {
  width: 48px; height: 48px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--ink);
}
.icon-btn:active { background: var(--panel); }
.icon-btn svg { width: 24px; height: 24px; }

/* ---------- Экран записи ---------- */
.rec-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 24px;
}
.status-row {
  display: flex;
  align-items: center;
  padding: 24px 0 0;
  gap: 8px;
}
.lamp {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--signal);
  opacity: 0.25;
  flex: none;
}
.status-row .state { flex: none; }
.status-row .format { flex: 1; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer-wrap {
  flex: 1 1 auto;
  min-height: 120px;
  max-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.timer-line { display: flex; align-items: baseline; }
.timer {
  font-family: var(--mono);
  font-size: 68px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.tenths {
  font-family: var(--mono);
  font-size: 28px;
  color: var(--ink-muted);
}
.file-name {
  margin-top: 12px;
  text-align: center;
  font-size: 13px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  margin-top: 8px;
}
.wave-box {
  flex: none;
  height: 120px;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  background: var(--panel);
  overflow: hidden;
}
.wave-box canvas { width: 100%; height: 100%; display: block; }
.tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink);
  border: 1px solid var(--ink-muted);
  border-radius: 2px;
  padding: 2px 6px;
}
.transcript-box {
  flex: 1 1 140px;
  min-height: 96px;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  background: var(--panel);
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  -webkit-overflow-scrolling: touch;
}
.transcript-box .partial,
.transcript-box .hint { color: var(--ink-muted); }
.transcript-box .hint.link { cursor: pointer; }

.controls {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  padding: 24px 16px 28px;
}
.control { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 120px; }
.control .label { color: var(--ink-muted); white-space: nowrap; }
.control.main .label { color: var(--ink); }
.control.side { padding-top: 18px; }

/* Круглые кнопки со значками (GlyphButton) */
.glyph {
  display: block;
  border-radius: 50%;
  flex: none;
}
.glyph svg { display: block; width: 100%; height: 100%; }
.glyph:active:not(:disabled) { background: var(--panel); }
.glyph:disabled { opacity: 0.3; }
.glyph.size-main { width: 96px; height: 96px; }
.glyph.size-side { width: 60px; height: 60px; }
.glyph.size-player { width: 44px; height: 44px; }

/* ---------- Список записей ---------- */
.search-row {
  flex: none;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 0 16px;
  border-bottom: 1px solid var(--hairline);
}
.search-row input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
  color: var(--ink);
  padding: 8px 0;
}
.search-row input::placeholder { color: var(--ink-muted); }
.text-btn {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  padding: 10px 8px;
  white-space: nowrap;
}
.text-btn:active { background: var(--panel); }
.text-btn.accent { color: var(--signal); }

.list-wrap { flex: 1; min-height: 0; overflow-y: auto; position: relative; -webkit-overflow-scrolling: touch; }
.list { list-style: none; margin: 0; padding: 0 0 16px; }
.empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  white-space: pre-line;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink-muted);
  padding: 24px;
}
.item {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 72px;
  padding: 14px 0;
  cursor: pointer;
}
.item:active { background: var(--panel); }
.item + .item::before {
  content: "";
  position: absolute;
  top: 0; left: 16px; right: 0;
  border-top: 1px solid var(--hairline);
}
.item .marker {
  position: absolute; left: 0; top: 12px; bottom: 12px;
  width: 4px;
  background: var(--signal);
  visibility: hidden;
}
.item.playing .marker { visibility: visible; }
.item .num {
  width: 48px;
  flex: none;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-muted);
}
.item.playing .num { color: var(--signal); }
.item .main { flex: 1; min-width: 0; }
.item .name {
  font-size: 17px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item .meta { margin-top: 4px; white-space: pre; }
.item .preview {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item .preview.title { color: var(--ink); }
.item .ai-status { margin-top: 6px; line-height: 1.5; }
.item .ai-status.error { color: var(--signal); cursor: pointer; }
.item .right {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  padding-left: 8px;
}
.item .duration { font-family: var(--mono); font-size: 15px; color: var(--ink); letter-spacing: 0.05em; }
.item .marks { color: var(--signal); }
.item .more {
  width: 44px; height: 44px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink);
  border-radius: 50%;
}
.item .more:active { background: var(--hairline); }
mark { background: var(--signal-soft); color: var(--ink); border-radius: 2px; }

/* ---------- Плеер ---------- */
.player {
  flex: none;
  max-height: 72%;
  overflow-y: auto;
  background: var(--panel);
  border-top: 1px solid var(--hairline);
  padding: 16px;
}
.player-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.player-head .label { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.speed-btn {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  border: 1px solid var(--ink-muted);
  border-radius: 3px;
  padding: 4px 8px;
  min-width: 64px;
}
.speed-btn:active { background: var(--paper); }
.player-row { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.player-row .glyph:active { background: var(--paper); }
.seek {
  flex: 1;
  position: relative;
  height: 32px;
  cursor: pointer;
  touch-action: none;
}
.seek .track { position: absolute; left: 0; right: 0; top: 15px; height: 2px; background: var(--hairline); }
.seek .fill { position: absolute; left: 0; top: 15px; height: 2px; background: var(--signal); }
.seek .thumb {
  position: absolute; top: 9px; width: 14px; height: 14px; margin-left: -7px;
  border-radius: 50%; background: var(--signal);
}
.seek .tick { position: absolute; top: 9px; width: 2px; height: 14px; margin-left: -1px; background: var(--ink); }
.player-time { font-family: var(--mono); font-size: 13px; color: var(--ink-muted); white-space: nowrap; }

.chips { display: flex; gap: 8px; overflow-x: auto; margin-top: 12px; padding-bottom: 2px; }
.chip {
  flex: none;
  max-width: 240px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  background: var(--paper);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip .t { color: var(--signal); margin-right: 8px; }

.panel-section { border-top: 1px solid var(--hairline); margin-top: 12px; }
.panel-section .head { display: flex; align-items: center; height: 40px; }
.panel-section .head .label { flex: 1; }
.summary-text {
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
  white-space: pre-line;
}
.summary-text.expanded { display: block; -webkit-line-clamp: unset; }
.summary-text.muted { color: var(--ink-muted); cursor: default; }
.summary-text b { font-weight: 600; }
.player-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-muted);
  max-height: calc(1.6em * 2);
  overflow-y: auto;
  position: relative;
  scroll-behavior: smooth;
}
.player-text.expanded { max-height: calc(1.6em * 8); }
.player-text.plain { color: var(--ink); }
.player-text .w { cursor: pointer; border-radius: 2px; }
.player-text .w.spoken { color: var(--ink); }
.player-text .w.current { background: var(--signal-soft); color: var(--ink); }

/* ---------- Настройки ---------- */
.settings-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.settings-section { border-bottom: 1px solid var(--hairline); padding: 16px 0; }
.settings-section > .label { padding: 12px 16px 8px; display: block; }
.sub-label { padding: 16px 16px 4px; display: block; }
.option {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 64px;
  padding: 8px 16px;
  text-align: left;
  gap: 16px;
}
.option:active:not(:disabled) { background: var(--panel); }
.option:disabled { opacity: 0.45; }
.indicator {
  width: 14px; height: 14px; flex: none;
  border: 1px solid var(--ink-muted);
  border-radius: 1px;
}
.option.selected .indicator { background: var(--signal); border-color: var(--signal); }
.option .texts { flex: 1; min-width: 0; }
.option .t1 { font-size: 17px; color: var(--ink); }
.option .t2 { margin-top: 3px; }
.option .t2.error { color: var(--signal); }
.option .action { flex: none; }
.note {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  color: var(--ink-muted);
  padding: 8px 16px;
  margin: 0;
}
.key-box {
  margin: 8px 16px 0;
  display: flex;
  align-items: center;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  background: var(--panel);
  padding: 0 4px 0 14px;
  min-height: 56px;
}
.key-box input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: transparent;
  font-family: var(--mono);
  font-size: 15px;
  padding: 12px 0;
}
.key-box input::placeholder { color: var(--ink-muted); }
.key-status { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 4px; gap: 8px; }
.key-status .meta { color: var(--ink); font-size: 13px; }
.key-status .meta.error { color: var(--signal); }

/* ---------- Меню, диалоги, тост ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; }
.overlay.dim { background: rgba(0, 0, 0, 0.35); display: flex; align-items: center; justify-content: center; padding: 24px; }
.menu {
  position: fixed;
  min-width: 220px;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  padding: 6px 0;
  z-index: 21;
}
.menu button { display: block; width: 100%; text-align: left; padding: 13px 18px; font-size: 16px; }
.menu button:active { background: var(--panel); }
.dialog {
  width: 100%;
  max-width: 400px;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 22px 22px 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
.dialog h2 { margin: 0 0 14px; font-size: 20px; font-weight: 500; }
.dialog p { margin: 0 0 8px; color: var(--ink-muted); line-height: 1.45; white-space: pre-line; word-break: break-word; }
.dialog input {
  width: 100%;
  border: 0;
  border-bottom: 2px solid var(--signal);
  background: transparent;
  outline: 0;
  font-size: 17px;
  padding: 8px 0;
}
.dialog .error { color: var(--signal); font-size: 13px; min-height: 20px; margin-top: 6px; }
.dialog .buttons { display: flex; justify-content: flex-end; gap: 4px; margin-top: 10px; }
.dialog .buttons .text-btn { padding: 12px; }
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(32px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 48px);
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  padding: 12px 18px;
  border-radius: 3px;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  text-align: center;
}
#toast.show { opacity: 1; }

/* Низкие экраны (альбомная ориентация, маленькие ноутбуки) */
@media (max-height: 700px) {
  .status-row { padding-top: 12px; }
  .timer { font-size: 52px; }
  .tenths { font-size: 22px; }
  .wave-box { height: 96px; }
  .controls { padding: 12px 16px 16px; }
  .glyph.size-main { width: 80px; height: 80px; }
  .glyph.size-side { width: 52px; height: 52px; }
  .control.side { padding-top: 14px; }
}
