/* Окна приложения, общее меню выделения, расшифровки, модели и обучение. */
dialog.modal { width: min(440px, calc(100vw - 24px)); max-height: min(92dvh, 720px); overflow-y: auto; padding: 14px 16px 16px; border-radius: 20px; box-shadow: 0 18px 60px #0006; animation: fade .16s ease-out; }
dialog.modal::backdrop { background: #0008; backdrop-filter: blur(2px); }
@keyframes fade { from { opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.modal-head h3 { flex: 1; margin: 0; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.modal-badge { display: grid; place-content: center; width: 38px; height: 38px; flex: none; border-radius: 12px; color: var(--accent); background: #1e96eb1f; }
.modal-form { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.modal-field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.modal-field .input { width: 100%; color: var(--text); font-size: 16px; padding: 10px 12px; border-radius: 12px; }
.modal-text, .modal-form .hint { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.modal-error:empty { display: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.modal-actions button { min-height: 42px; padding: 8px 20px; border-radius: 22px; justify-content: center; }
.modal-actions .btn-primary.destructive { background: var(--danger); border-color: var(--danger); }
#new-kind { margin: 0; }
#pick-list { max-height: 46dvh; overflow-y: auto; }
#pick-list .model-text { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 760px) {
  dialog.modal { margin-top: max(8vh, env(safe-area-inset-top)); }
  .modal-actions button { flex: 1; }
}

/* Одно меню: сверху буфер обмена, ниже действия. */
.clip-row, .tool-row { display: flex; gap: 2px; justify-content: center; }
.popover .clip-row { border-bottom: 1px solid var(--line); padding-bottom: 5px; margin-bottom: 4px; }
.popover .clip-row:last-child { border: 0; margin: 0; padding: 0; }
.popover .clip-button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 62px; padding: 8px 4px; background: none; border: 0; border-radius: 10px; font-size: 12px; }
.popover .clip-button:hover { background: var(--hover); }
#selection-bar { flex-direction: column; max-width: calc(100vw - 12px); border-radius: 18px; }
#selection-bar .clip-row + .tool-row { border-top: 1px solid var(--line); padding-top: 2px; }
#selection-bar button { padding: 6px 10px; }
@media (max-width: 420px) { #selection-bar button { flex-direction: column; gap: 2px; padding: 5px 7px; font-size: 11px; } }
/* Долгое нажатие по холсту открывает только наше меню, без выделения под пальцем. */
#board { -webkit-user-select: none; -webkit-touch-callout: none; }
#board textarea { user-select: text; -webkit-user-select: text; }

/* Расшифровка */
.player-transcript .transcript-tabs { margin-top: 6px; }
.player-transcript .transcript-tabs button { width: auto; height: 28px; padding: 0 10px; font-size: 12px; }
.player-words { white-space: pre-wrap; }
#transcript-modal { width: min(620px, calc(100vw - 24px)); }
#transcript-tabs { margin: 0; }
#transcript-text, #transcript-original { width: 100%; min-height: 200px; max-height: 40dvh; font-size: 15px; line-height: 1.6; }
#transcript-text { resize: vertical; }
#transcript-original { overflow-y: auto; border: 1px dashed var(--line); border-radius: 8px; padding: 7px 10px; white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
#transcript-modal .row { margin: 0; }

/* Модели на устройстве */
.local-model { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.local-model.selected { border-color: var(--accent); }
.local-model-head { display: flex; align-items: center; gap: 8px; }
.local-model-head strong { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.local-model-badge { font-size: 11px; color: var(--accent); border: 1px solid currentColor; border-radius: 10px; padding: 0 7px; }
.local-model progress { margin-top: 6px; }
.local-model .row { margin: 8px 0 0; }

/* Режим хранения */
.mode-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 8px 0; }
.mode-tile { position: relative; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left; padding: 14px; background: var(--card); border: 2px solid var(--line); border-radius: 16px; }
.mode-tile:hover { border-color: var(--accent); }
.mode-tile.active { border-color: var(--accent); background: #1e96eb12; }
.mode-mark { display: grid; place-content: center; width: 40px; height: 40px; border-radius: 12px; color: var(--accent); background: #1e96eb1f; }
.mode-text { font-size: 13px; color: var(--muted); line-height: 1.45; }
.mode-now { position: absolute; top: 10px; right: 12px; font-size: 11px; color: var(--accent); border: 1px solid currentColor; border-radius: 10px; padding: 0 7px; }
#first-mode { width: min(620px, calc(100vw - 24px)); }
