/* Shared design tokens for every screen; responsive files contain layout only. */
:root {
  color-scheme: light;
  --page: #FAF6EF;
  --page-fill: var(--page);
  --shell: #FAF6EF;
  --shell-fill: var(--shell);
  --surface: #F0ECE3;
  --panel-fill: #FFFCF7;
  --field: #FFFCF7;
  --editor-field: var(--field);
  --ink: #4B2F1C;
  --muted: #78624E;
  --accent: #6A7758;
  --button-fill: #EEEADF;
  --button-hover: #E4E4D5;
  --primary-fill: #C5D0B3;
  --primary-hover: #B6C4A2;
  --primary-text: #35432C;
  --nav-active: var(--primary-fill);
  --nav-active-hover: var(--primary-hover);
  --active: #E5E8D8;
  --focus: #6A7758;
  --success: #50613B;
  --warning: #71502F;
  --warning-bg: #F2E7D3;
  --error: #A2342B;
  --error-bg: #F8E6DE;
  --stop-fill: #F29A86;
  --stop-text: #4D251C;
  --shadow: 0 12px 32px #4B2F1C18;
  /* Geometry is shared by both themes. Values are project choices, not norms. */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --page-gutter-mobile: 16px;
  --page-gutter-tablet: 24px;
  --page-gutter-desktop: 24px;
  --content-max-width: 1130px;
  --reading-max-width: 760px;
  --editor-column-width: 720px;
  --font-body: 1rem;
  --font-label: 1rem;
  --font-help: .875rem;
  --font-section: 1.125rem;
  --font-page: 1.5rem;
  --font-display: 1.0625rem;
  --font-editor: 1.125rem;
  --line-body: 1.5;
  --line-heading: 1.25;
  --line-control: 1.25;
  --control-min-height: 44px;
  --control-padding-x: 12px;
  --control-radius: 14px;
  --card-padding: 20px;
  --card-radius: 22px;
  --popover-padding: 8px;
  --popover-radius: 18px;
  --icon-button-hit-area: 44px;
  --focus-width: 2px;
  --focus-offset: 2px;
  --disabled-opacity: .6;
  --radius: var(--card-radius);
  --app-height: 100vh;
  --gutter: var(--page-gutter-mobile);
  --waveform-edge: #879570;
  --waveform-peach: #D98969;
  --waveform-coral: #C45442;
  /* V30: «Обработать» is greener than «Дозаписать» and lighter than «Копировать». */
  --process-text: #4E5C3E;
  --process-fill: #F3F5EA;
  --process-edge: #B9C6A3;
  --process-hover: #E9EEDC;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--page-fill); font: var(--font-body)/var(--line-body) "Segoe UI", Arial, sans-serif; }
button, input, textarea { font: inherit; }
button, input, .select-trigger { min-height: var(--control-min-height); }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  max-width: 100%; padding: var(--space-sm) var(--control-padding-x); color: var(--ink); background: var(--button-fill);
  border: 0; border-radius: var(--control-radius); cursor: pointer;
  line-height: var(--line-control); text-align: center; overflow-wrap: anywhere;
}
button:hover:enabled { background: var(--button-hover); }
button:disabled { opacity: var(--disabled-opacity); cursor: default; }
button.primary { background: var(--primary-fill); color: var(--primary-text); font-weight: 600; }
button.primary:hover:enabled { background: var(--primary-hover); }
button.quiet-button { background: transparent; }
button.quiet-button:hover:enabled { background: var(--button-hover); }
button svg {
  width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.icon-button { width: var(--icon-button-hit-area); min-width: var(--icon-button-hit-area); padding: 0; flex: none; }
input, textarea {
  display: block; width: 100%; min-width: 0; max-width: 100%; padding: 10px var(--control-padding-x);
  color: var(--ink); background: var(--field); border: 0; border-radius: var(--control-radius);
}
textarea { resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea[readonly] { background: var(--field); }
label { display: block; margin: var(--space-md) 0 var(--space-xs); font-size: var(--font-label); font-weight: 600; line-height: var(--line-body); }
label.check { display: flex; align-items: center; gap: var(--space-sm); min-height: var(--control-min-height); margin: var(--space-sm) 0 0; font-weight: 400; cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; margin: 0; flex: none; accent-color: var(--accent); }
:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
input:focus, textarea:focus { outline: none; box-shadow: none; }
/* V29: a field shows the focus line only after moving to it with Tab (ui.js).
   A tap, a click and typing, including an on-screen keyboard, leave just the caret. */
:root[data-input="keyboard"] :is(input, textarea):focus {
  box-shadow: inset 0 -2px var(--focus);
}
:is(input, textarea)[aria-invalid="true"] { box-shadow: inset 0 -2px var(--error); }
:is(input, textarea):disabled { color: var(--muted); opacity: var(--disabled-opacity); }
.mobile-only { display: none; }
.field-help { margin-top: var(--space-xs); }
button[aria-pressed="true"] { background: var(--active); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
h1, h2, h3, p { margin: 0; overflow-wrap: anywhere; }
h1 { font-size: var(--font-display); line-height: var(--line-heading); letter-spacing: -.02em; }
h2 { font-size: var(--font-page); line-height: var(--line-heading); letter-spacing: -.02em; }
h3 { font-size: var(--font-section); line-height: var(--line-heading); }
.muted { color: var(--muted); font-size: var(--font-help); }
.eyebrow { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
.footnote { margin-top: var(--space-lg); }
summary { cursor: pointer; min-height: var(--control-min-height); padding-block: 11px; }

.app-shell {
  display: flex; flex-direction: column; min-width: 0; min-height: 100vh;
  margin: 0; border: 0; border-radius: 0; background: var(--shell-fill);
}
.brand-bar {
  position: relative; z-index: 10; display: flex; align-items: center;
  gap: var(--space-xs); flex: 0 0 auto; min-height: 64px;
  padding: var(--space-xs) var(--page-gutter-desktop);
}
.brand-title { min-width: 0; margin-right: auto; }
.brand-home {
  display: inline-flex; align-items: center; justify-content: flex-start;
  gap: var(--space-sm); padding: 0; min-width: 0; min-height: var(--control-min-height);
  color: var(--ink); background: transparent; font: inherit;
  text-align: left; text-decoration: none; line-height: var(--line-heading);
}
.brand-home:hover:enabled { background: transparent; color: var(--accent); }
.brand-mark { display: inline-flex; width: 30px; flex: 0 0 30px; color: var(--accent); }
.brand-mark svg { display: block; width: 100%; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; }
.back-button { margin: 0 auto 0 -8px; padding-inline: 8px 12px; font-weight: 600; }
.workspace-bar { display: none; position: relative; flex: none; }
.workspace-active .workspace-bar { display: block; }
#menu-toggle { display: inline-flex; background: transparent; }
#workspace-nav {
  position: absolute; top: calc(100% + var(--space-xs)); right: 0;
  width: min(224px, calc(100vw - 2 * var(--gutter)));
  max-height: calc(var(--app-height) - 76px); overflow: auto; overscroll-behavior: contain;
  display: grid; gap: var(--space-xs); padding: var(--popover-padding);
  border: 0; border-radius: var(--popover-radius); background: var(--field); box-shadow: var(--shadow);
}
#workspace-nav > button {
  width: 100%; justify-content: flex-start; text-align: left; background: transparent;
  font-size: var(--font-body); padding-inline: var(--control-padding-x);
}
#workspace-nav button:hover:enabled { background: var(--button-hover); }
#workspace-nav > button[aria-current="page"] { background: var(--active); }
.menu-account { padding: var(--space-xs) var(--control-padding-x); }
.disclosure { position: relative; min-width: 0; }
.popover {
  position: absolute; z-index: 4; top: calc(100% + 6px); left: 0;
  display: grid; gap: var(--space-xs); width: 290px; max-width: calc(100vw - 24px); max-height: min(420px, 60vh);
  padding: var(--popover-padding); overflow: auto; overscroll-behavior: contain; color: var(--ink);
  background: var(--field); border: 0; border-radius: var(--popover-radius); box-shadow: var(--shadow);
}
.popover p { padding: 3px 0; }
#workspace { display: flex; flex: 1 1 auto; flex-direction: column; min-width: 0; min-height: 0; }
.session-note { margin: 0; padding: 3px 12px; text-align: center; border: 0; background: var(--surface); font-size: 12px; }
.session-note:empty, #status:empty { display: none; }
#status { padding: 7px 11px; border: 0; border-radius: 8px; background: var(--surface); }
.app-shell > #status { margin: 12px auto 0; width: min(680px, calc(100% - 24px)); }
#status.error { color: var(--error); background: var(--error-bg); }
/* Exit notice, centred over the editor's style row. */
#back-notice {
  position: fixed; z-index: 40; left: 50%; top: 50%;
  width: max-content; max-width: calc(100% - 24px); transform: translate(-50%, -50%);
  box-sizing: border-box; margin: 0; padding: 5px 12px; border-radius: 24px;
  font-family: inherit; font-size: 17px; font-weight: 500; line-height: 20px;
  color: #FFFFFF; background: rgba(58, 42, 32, 0.68); backdrop-filter: blur(6px);
  text-align: center; pointer-events: none; animation: back-notice-fade 1.5s linear forwards;
}
@keyframes back-notice-fade {
  0%, 86.667% { opacity: 1; }
  100% { opacity: 0; }
}

/* One state-driven editor for voice and text; operations remain in app.js. */
.editor-open { --ink: #542B10; --muted: #77543B; --active: #E4E4D3; }
.editor-open .app-shell { min-height: var(--app-height); background: transparent; position: relative; z-index: 1; }
#editor-view { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; min-width: 0; }
.editor-open #theme-toggle { background: #E1E2D0B3; border-radius: 16px; }
.voice-workspace { display: flex; flex-direction: column; width: 100%; flex: 1 1 auto; min-height: 0; }
.voice-stage { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1 1 auto; width: 100%; min-height: 220px; padding: 20px 24px; gap: 16px; text-align: center; }
#stage-tap { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; background: transparent; box-shadow: none; cursor: pointer; }
#mobile-stage > :not(#stage-tap) { position: relative; z-index: 1; }
#stage-tap:not([hidden]) ~ :not(button) { pointer-events: none; }
#mobile-stage :is(button, a, summary) { pointer-events: auto; }
.recording-heading { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 26px; }
.stage-title { font-size: 1.0625rem; font-weight: 500; }
.recording-dot { display: none; width: 13px; height: 13px; border-radius: 50%; background: #EF7158; box-shadow: 0 3px 12px #E7795352, inset 0 1px #FFD7C3; }
[data-editor-state="recording"] .recording-dot { display: inline-block; }
#voice-timer-slot { min-height: 78px; }
#timer { font-size: 64px; line-height: 1.15; letter-spacing: -.04em; font-weight: 400; font-variant-numeric: tabular-nums; color: var(--ink); }
#timer-separator { position: relative; }
#timer-baseline { display: inline-block; width: 0; height: 0; vertical-align: baseline; }
#mobile-record-visual { position: relative; display: grid; place-items: center; width: min(100%, 760px); height: 192px; }
.stage-icon { display: grid; place-items: center; color: var(--accent); width: 64px; height: 64px; }
.stage-icon svg { width: 54px; height: 54px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
#record-wave-window { --record-wave-fade: 15%; position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: hidden; pointer-events: none;
  mask-image: linear-gradient(to right, transparent 0, #000 var(--record-wave-fade), #000 calc(100% - var(--record-wave-fade)), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--record-wave-fade), #000 calc(100% - var(--record-wave-fade)), transparent 100%); }
#record-wave { --record-wave-idle-opacity: .4; --record-wave-active-opacity: 1; position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; will-change: transform; }
#record-wave-window:has(> #record-wave:not([hidden])) + .stage-icon { display: none; }
.stage-note { max-width: 38rem; font-size: 1rem; color: var(--muted); }
#mobile-stage-status { max-width: 560px; width: 100%; text-align: left; }
#mobile-stage-status:empty { display: none; }
#mobile-stage > .operation-strip { max-width: 560px; width: 100%; padding: 0; }
.voice-actions { flex: none; display: grid; grid-template-rows: minmax(64px, auto) 52px minmax(48px,auto); gap: 10px; width: min(440px, calc(100% - 40px)); margin: 0 auto; padding: 12px 0 max(24px, env(safe-area-inset-bottom)); }
#voice-record-slot { display: grid; gap: 10px; }
#voice-record-slot .recorder-panel { display: block; }
#voice-record-slot #record, #voice-record-slot .recovery-actions button, #voice-record-slot #send-audio { width: 100%; min-height: max(64px, calc(2.5em + 16px)); border-radius: 26px; font-size: 1.125rem; font-weight: 600; background: var(--primary-fill); color: var(--primary-text); box-shadow: 0 12px 28px #6D684322, inset 0 1px #FFFFFFB0; }
#voice-record-slot #record:hover:enabled, #voice-record-slot .recovery-actions button:hover:enabled, #voice-record-slot #send-audio:hover:enabled { background: var(--primary-hover); }
#voice-record-slot .recorder-panel[data-recording="true"] #record {
  background: linear-gradient(165deg,#BF513F,#B84E3E); color: #FFF;
  box-shadow: 0 14px 26px #BD69494A, inset 0 1px #FFFFFFC7, inset 0 -1px #FFFFFF70;
}
#voice-record-slot .record-stop { padding: 10px; border-radius: 50%; background: #FFFFFF30; }
#voice-record-slot #record .record-stop { width: 40px; height: 40px; }
#voice-record-slot .record-stop rect { fill: currentColor; stroke: none; }
#voice-record-slot #record svg { width: 25px; height: 25px; color: inherit; }
/* An interrupted recording: «Обработать запись» is the main action, a new recording stays at hand. */
.editor-open #voice-record-slot[data-secondary-record="true"] #record { min-height: 52px; font-size: 1rem; background: var(--field); color: var(--ink); box-shadow: none; }
.editor-open #voice-record-slot[data-secondary-record="true"] #record:hover:enabled { background: var(--button-hover); }
.editor-open #voice-record-slot[data-secondary-record="true"] #record::before, .editor-open #voice-record-slot[data-secondary-record="true"] #record::after { display: none; }
#voice-paste { font-size: 1rem; color: var(--muted); }
/* V29: «Последний текст» is quieter than the two main actions in colour and weight, not in size. */
#last-text { font-size: 1rem; font-weight: 400; color: var(--muted); }
.voice-actions[data-last-text="true"] { grid-template-rows: minmax(64px, auto) 52px 52px minmax(48px,auto); }
#voice-privacy-slot, .editor-privacy-slot { display: flex; justify-content: center; align-items: center; }
.privacy-details { position: relative; width: 100%; text-align: center; color: var(--muted); font-size: 1rem; }
/* V42: a quiet footnote; the explanation in the popover keeps the normal size. */
.privacy-details summary { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0; list-style: none; font-size: .6875rem; line-height: 1.3; }
.privacy-details summary::-webkit-details-marker { display: none; }
.footer-popover { top: auto; bottom: calc(100% + 8px); left: 50%; right: auto; transform: translateX(-50%); width: min(340px, calc(100vw - 24px)); color: var(--ink); text-align: left; }
[data-voice-scene="true"]:not([data-editor-state="start"]) :is(#voice-paste, #last-text) { visibility: hidden; pointer-events: none; }
[data-editor-state="start"] .recording-heading { visibility: hidden; }
[data-editor-state="microphone"] .stage-icon, [data-editor-state="preparing"] .stage-icon, [data-editor-state="transcribing"] .stage-icon, [data-editor-state="processing"] .stage-icon { border: 2px solid var(--active); border-top-color: var(--accent); border-radius: 50%; animation: editor-wait 1.6s linear infinite; }
[data-editor-state="microphone"] .stage-icon svg, [data-editor-state="preparing"] .stage-icon svg, [data-editor-state="transcribing"] .stage-icon svg, [data-editor-state="processing"] .stage-icon svg { display: none; }

/* V27: the text and result screens are one centred column at every width. */
.editor-column {
  --column-gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  display: flex; flex-direction: column; flex: 1 1 auto; gap: 12px; min-height: 0;
  width: min(var(--editor-column-width), calc(100% - 2 * var(--column-gutter))); margin: 0 auto;
  padding: 4px 0 max(12px, env(safe-area-inset-bottom));
}
.editor-tabs { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); flex: none; padding: 3px; background: var(--surface); border-radius: 16px; }
.editor-tabs button { background: transparent; font-size: 1rem; }
.editor-tabs button[aria-selected="true"] { background: var(--field); font-weight: 600; }
.text-panel { display: flex; flex-direction: column; flex: 1 1 auto; gap: 8px; min-width: 0; min-height: 0; }
.variant-nav { display: flex; align-items: center; justify-content: center; gap: 4px; flex: none; font-size: 1rem; font-variant-numeric: tabular-nums; }
.variant-nav button { width: 44px; height: 44px; }
.variant-nav button svg { width: 24px; height: 24px; }
#variant-position { min-width: 6.5em; text-align: center; font-weight: 600; }
.panel-body { position: relative; display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; min-width: 0; border-radius: 20px; overflow: hidden; background: var(--field); }
.panel-body textarea { flex: 1 1 auto; min-height: 168px; height: auto; padding: 16px 56px 16px 18px; border-radius: 0; resize: none; font-size: var(--font-editor); background: var(--editor-field); }
.field-trash { position: absolute; top: 4px; right: 4px; color: var(--muted); }
.field-trash svg { width: 22px; height: 22px; }
.panel-meta { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 18px 12px; color: var(--muted); font-size: 1rem; }
.panel-meta:empty, .panel-meta:has(> [hidden]:only-child) { display: none; }
#source-count { margin-left: auto; font-variant-numeric: tabular-nums; }
#source-count[data-limit="reached"] { color: var(--error); }
#result-meta { margin: 0; overflow-wrap: anywhere; }
.operation-strip { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; flex: none; font-size: 1rem; }
#editor-status-slot { flex: 1 1 220px; min-width: 0; }
.budget-warning { padding: 8px 12px; color: var(--warning); background: var(--warning-bg); border-radius: 12px; }
.editor-actions { display: grid; gap: 10px; flex: none; }
.editor-main-slot, .recovery-actions { display: grid; gap: 10px; }
.editor-main-slot > button, .editor-main-slot .recovery-actions button { width: 100%; min-height: 60px; border-radius: 24px; font-size: 1.125rem; box-shadow: 0 12px 28px #6D684322, inset 0 1px #FFFFFFB0; }
.editor-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: start; }
.editor-record-slot .recorder-panel { display: block; }
.editor-row #record, #process { width: 100%; min-height: 52px; padding-inline: 8px; gap: 6px; border-radius: 18px; font-size: 1rem; font-weight: 600; color: var(--ink); background: var(--field); }
.editor-row #record:hover:enabled { background: var(--button-hover); }
.editor-row #record svg, #process svg { width: 20px; height: 20px; }
#process { color: var(--process-text); background: var(--process-fill); box-shadow: inset 0 0 0 1.5px var(--process-edge); }
#process:hover:enabled { background: var(--process-hover); }
/* V30: the style line sits under the whole row, on one line; a long name ends with «…». */
.style-picker { position: relative; min-width: 0; }
.style-line { display: flex; align-items: center; justify-content: center; gap: .3em; width: 100%; min-height: 44px; padding: 10px 8px; font-size: 1rem; line-height: 1.5; color: var(--ink); white-space: nowrap; overflow-wrap: normal; }
.style-line-caption { flex: none; color: var(--muted); }
#selected-prompt-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.style-line svg { flex: none; width: 18px; height: 18px; }
/* V32: the open list is a layer over the dimmed screen with a fixed heading;
   the options scroll under it. Wider than 700 px it stands in the middle,
   narrower it rises from the bottom edge (forma.js places it). */
.style-list {
  --style-hover: #F3F2E8; --style-divider: #E9E1D6; --style-scroll: #CDBFAE;
  position: fixed; z-index: 30; top: 0; left: 0; display: flex; flex-direction: column; gap: 0;
  max-width: none; max-height: 70vh; padding: 0 0 var(--popover-padding); overflow: hidden;
  opacity: 0; transform: translateY(8px); transition: opacity .18s ease, transform .18s ease;
}
.style-list[data-shown] { opacity: 1; transform: none; }
.style-backdrop {
  position: fixed; inset: 0; z-index: 29; background: #211B1866;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  opacity: 0; transition: opacity .18s ease; overscroll-behavior: contain; touch-action: none;
}
.style-backdrop[data-shown] { opacity: 1; }
:is(.style-list, .style-backdrop)[data-closing] { pointer-events: none; }
.style-list .style-list-title { flex: none; padding: 16px 20px 12px; border-bottom: 1px solid var(--style-divider); color: var(--ink); font-size: var(--font-section); font-weight: 700; line-height: var(--line-heading); }
.style-options {
  flex: 1 1 auto; min-height: 0; padding: 0 var(--popover-padding); overflow: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--style-scroll) transparent;
}
.style-list button {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; row-gap: 3px;
  width: 100%; min-height: 44px; padding-block: 12px; justify-items: start; text-align: left; background: transparent; font-size: 1rem;
}
.style-list button + button::before { content: ""; position: absolute; top: 0; left: 12px; right: 12px; height: 1px; background: var(--style-divider); }
.style-list button:is(:hover, [aria-selected="true"])::before, .style-list button:is(:hover, [aria-selected="true"]) + button::before { visibility: hidden; }
.style-list button:hover { background: var(--style-hover); }
.style-list button[aria-selected="true"] { background: var(--active); }
.style-option-name { grid-column: 1; color: var(--ink); font-weight: 600; }
.style-option-note { grid-column: 1; color: var(--muted); font-size: 1rem; font-weight: 400; }
.style-list button[aria-selected="true"]::after { content: "✓"; grid-column: 2; grid-row: 1; color: var(--accent); font-weight: 700; }
.style-list .style-group { padding: 8px 12px 6px; color: var(--muted); font-size: 13px; font-weight: 600; line-height: 1.4; letter-spacing: .06em; text-transform: uppercase; }
.style-list .style-group:not(:first-child) { margin-top: 16px; }
@media (max-width: 700px) {
  .style-list { border-radius: var(--popover-radius) var(--popover-radius) 0 0; padding-bottom: max(var(--popover-padding), env(safe-area-inset-bottom)); transform: translateY(100%); transition: opacity .2s ease, transform .2s ease; opacity: 1; }
}
/* V32: a short glow on the style line after a choice from the list. */
.style-line[data-chosen] { animation: style-chosen .8s ease-in-out; }
@keyframes style-chosen { 30% { background-color: var(--active); } }
@media (prefers-reduced-motion: reduce) {
  .style-list, .style-list[data-shown] { transform: none; }
  .style-list { opacity: 0; }
  .style-list[data-shown] { opacity: 1; }
  .style-line[data-chosen] { animation: none; background: var(--active); }
}
@media (min-width: 701px) {
  .editor-column, .text-panel, .panel-body { flex: none; }
  .panel-body textarea { flex: none; height: var(--desktop-field-height, 33vh); }
}
/* V41: the live background is its own component (app/static/ambient/: settings.js, scenes, engine.js).
   Under the canvas the base colour of the scene of the current theme (dark themes set it in dark.css). */
:root { --ambient-base: #FAEBDF; }
#editor-ambient {
  display: none; position: fixed; inset: 0; overflow: hidden; pointer-events: none;
  contain: strict; z-index: 0; background: var(--ambient-base);
}
.editor-open #editor-ambient { display: block; }
/* The canvas covers the container; it shows only once its first frame is drawn (and not while the GPU is away). */
.ambient-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; visibility: hidden; }
#editor-ambient[data-renderer="webgl"][data-scene-ready="true"] > .ambient-canvas { visibility: visible; }
/* Without WebGL: a picture of the theme's scene, tall or wide (wider than 1.15 of the height); the base colour shows while it loads. */
#editor-ambient[data-renderer="image"] { background: var(--ambient-base) url(ambient/fallback/light-phone.webp?v=V41) center / cover no-repeat; }
:root[data-theme="dark"][data-dark="dusk"] #editor-ambient[data-renderer="image"] { background-image: url(ambient/fallback/dusk-phone.webp?v=V41); }
:root[data-theme="dark"][data-dark="rose"] #editor-ambient[data-renderer="image"] { background-image: url(ambient/fallback/rose-phone.webp?v=V41); }
@media (min-aspect-ratio: 1151/1000) {
  #editor-ambient[data-renderer="image"] { background-image: url(ambient/fallback/light-wide.webp?v=V41); }
  :root[data-theme="dark"][data-dark="dusk"] #editor-ambient[data-renderer="image"] { background-image: url(ambient/fallback/dusk-wide.webp?v=V41); }
  :root[data-theme="dark"][data-dark="rose"] #editor-ambient[data-renderer="image"] { background-image: url(ambient/fallback/rose-wide.webp?v=V41); }
}
@keyframes editor-wait { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .stage-icon { animation: none !important; } }

.access-panel, .secondary-view { width: calc(100% - 2 * var(--page-gutter-desktop)); margin: 0 auto; padding: var(--space-lg) 0 var(--space-xl); min-width: 0; }
.access-panel { width: min(440px, calc(100% - 2 * var(--gutter))); margin-top: var(--space-xl); padding: var(--card-padding); background: var(--panel-fill); border: 0; border-radius: var(--card-radius); }
.access-panel h2, .access-panel h2 + p { margin-bottom: var(--space-md); }
.secondary-view { max-width: var(--content-max-width); }
@media (min-width: 701px) {
  :is(#prompts-view, #settings-view, #account-view) {
    max-width: var(--reading-max-width);
    margin-left: max(var(--page-gutter-desktop), calc((100vw - var(--reading-max-width)) / 2));
  }
}
.section-heading { margin-bottom: var(--space-lg); }
.section-heading p { margin-top: var(--space-sm); }
.form-panel, .card, .admin-log { min-width: 0; border: 0; border-radius: var(--card-radius); background: var(--panel-fill); padding: var(--card-padding); }
.form-panel > h3 { margin-bottom: var(--space-md); }
.form-panel > label:first-of-type { margin-top: 0; }
.form-panel > textarea { min-height: 96px; }
:is(.form-panel, .access-panel) :is(input:not([type="checkbox"]), textarea) { background: var(--surface); }
.form-actions, .admin-log-controls { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-sm); margin-top: var(--space-md); }
.reading-panel { max-width: var(--reading-max-width); margin-bottom: var(--space-lg); }
.reading-panel > p:not(.footnote) { margin-bottom: var(--space-md); }
.reading-panel > button { margin: var(--space-md) 0 0; }
#reasoning-effort { min-inline-size: 0; margin: 0; padding: 0; border: 0; }
#reasoning-effort legend { padding: 0; font-size: var(--font-section); font-weight: 700; line-height: var(--line-heading); }
.reasoning-effort-options { display: flex; flex-wrap: wrap; column-gap: var(--space-lg); margin-block: var(--space-xs); }
#reasoning-effort .check { margin: 0; }
#reasoning-effort input { padding: 0; }
#reasoning-effort .check:focus-within:has(input:focus-visible) {
  outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset);
}
#reasoning-effort-status:not(:empty) { margin-top: var(--space-sm); color: var(--error); }

#auto-process-help, #reasoning-effort-help, #reasoning-effort-status { font-size: var(--font-body); }
#auto-process-help { margin: var(--space-xs) 0 0; }
#ambient-help { margin: var(--space-xs) 0 0; }
/* V30: one column at every width; the form opens in place of the list. */
.prompt-library, #prompt-form { max-width: var(--reading-max-width); }
.prompt-library-tools { display: grid; justify-items: start; gap: var(--space-md); margin: 0 0 var(--space-lg); }
.prompt-library-tools label { margin: 0; min-width: 0; }
.prompt-search-field { width: 100%; min-width: 0; }
.admin-forms { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; gap: var(--space-md); }
/* V35: both forms are as tall as their row; their buttons sit on one line at the bottom. */
.admin-forms > .form-panel { display: flex; flex-direction: column; }
.admin-forms > .form-panel > .form-actions { margin-top: auto; padding-top: var(--space-md); }
#prompt-list, #user-list { display: grid; align-items: start; gap: var(--space-sm); min-width: 0; }
.prompt-group { margin: var(--space-md) 0 var(--space-xs); color: var(--muted); font-size: var(--font-body); font-weight: 600; }
.prompt-group:first-child { margin-top: 0; }
.prompt-card { padding: var(--space-md); overflow-wrap: anywhere; }
.prompt-card[data-selected] { box-shadow: inset 0 0 0 2px var(--accent); }
.prompt-card-text { margin-top: 4px; }
.prompt-card-text[data-own] { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; color: var(--muted); }
.prompt-card .form-actions { margin-top: var(--space-sm); }
#prompt-empty { padding: var(--space-sm) 0; color: var(--muted); }
#prompt-instruction { min-height: calc(12em + 20px); resize: none; overflow: hidden; }
/* V35: the owner's accounts are one list of rows; a row's buttons sit on the right, or under the row when narrow. */
#user-list { grid-template-columns: minmax(0, 1fr); }
.member-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-sm) var(--space-md); }
.member-row-info { flex: 1 1 240px; min-width: 0; }
.member-row-name { font-weight: 600; }
.member-row-info .muted { margin-top: 2px; }
.member-row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-xs); }
/* V35 fix: a row's text starts at the left edge of «Участники»; the vertical spacing between rows stays. */
#user-list > .member-row { padding-inline: 0; }
/* V35: «По почте» and «По логину и паролю» as one row of checks. */
.member-mode { display: flex; flex-wrap: wrap; column-gap: var(--space-lg); margin-top: var(--space-sm); }
#temporary-password:not(:empty) { margin-top: 10px; padding: 9px; border-radius: 7px; background: var(--warning-bg); }
.admin-log { margin-top: 10px; }
/* V35 fix: one 10px gap between all blocks of «Управление». */
#admin-view > .form-panel { margin-top: 10px; }
.admin-log summary { font-weight: 600; }
.admin-log p { margin: 5px 0; }
.admin-log-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.admin-log-filters label { margin: 8px 0 2px; }
.admin-log-filters input { margin-top: var(--space-xs); }
.admin-log-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; }
.admin-log-table th, .admin-log-table td { padding: 10px 5px; border: 0; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.admin-log-table td > span { display: block; }
.admin-log-table tbody > tr:nth-child(odd) { background: var(--surface); }
.admin-log-detail { background: var(--surface); }
.admin-log-table button { font-size: var(--font-body); }
.admin-log-table button[aria-expanded] { border: 1px solid var(--muted); }
.usage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 8px; margin: 0 0 8px; }
.usage-grid > div { padding: 8px 10px; border: 0; border-radius: 8px; background: var(--surface); }
.usage-grid dt { color: var(--muted); font-size: 13px; }
/* V35: the owner's short labels stay on one line, so the amounts line up across the cards. */
.usage-grid-short dt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usage-grid dd { margin: 4px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.probe-panel pre { max-width: 100%; overflow: auto; background: var(--surface); padding: 8px; border-radius: 7px; }
.probe-panel audio { display: block; margin-top: 8px; }
.probe-panel #status { margin-top: 8px; }

@media (max-width: 780px) {
  .admin-log-filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .admin-log-table .admin-log-extra { display: none; }
}
/* V35: on a narrow screen each operation is a card: date, stage and status, amounts, «Детали». No sideways scrolling. */
@media (max-width: 700px) {
  .admin-log-table thead { display: none; }
  .admin-log-table, .admin-log-table tbody, .admin-log-table tr, .admin-log-table td { display: block; width: 100%; }
  .admin-log-table tbody > tr { margin-bottom: 8px; padding: 10px 12px; border-radius: var(--card-radius); background: var(--surface); }
  .admin-log-table td { padding: 2px 0; }
  /* V35 fix: a button on the card stands out from it as ordinary buttons do from their panel. */
  .admin-log-table td > button { margin-top: var(--space-xs); background: var(--admin-card-button, var(--panel-fill)); }
  .member-row-info { flex-basis: 100%; }
  .member-row-actions { flex: 1 1 100%; flex-direction: column; align-items: stretch; }
  .member-row-actions > button { width: 100%; }
}
@media (max-width: 700px), (max-width: 1000px) and (max-height: 540px) and (pointer: coarse) {
  :root { --card-padding: 16px; }
  .brand-bar { min-height: 64px; padding: max(8px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) 8px max(16px,env(safe-area-inset-left)); }
  .brand-title { font-size: 1rem; }
  .brand-mark { width: 22px; flex-basis: 22px; }
  .brand-home { gap: 6px; }
  .secondary-view { width: calc(100% - 32px); }
  .access-panel { margin-top: 16px; }
  .admin-forms { grid-template-columns: minmax(0,1fr); }
}
/* Select-only combobox: one component for library, editor and owner filters. */
.select-field { min-width: 0; }
ui-select { display: block; position: relative; min-width: 0; max-width: 100%; }
.select-trigger { width: 100%; justify-content: space-between; text-align: left; background: var(--surface); font-weight: 400; }
.select-trigger::after { content: ""; flex: 0 0 7px; height: 7px; margin: 0 3px 3px 8px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); }
.select-list { position: fixed; z-index: 30; padding: var(--popover-padding); overflow: auto; overscroll-behavior: contain; background: var(--field); color: var(--ink); border-radius: var(--popover-radius); box-shadow: var(--shadow); }
.select-list [role="option"] { display: flex; align-items: center; min-height: var(--control-min-height); padding: var(--space-sm) var(--control-padding-x); border-radius: var(--control-radius); overflow-wrap: anywhere; cursor: pointer; }
.select-list [role="option"][aria-selected="true"] { background: var(--active); font-weight: 600; }
.select-list [role="option"][data-active] { box-shadow: inset 0 -2px var(--focus); }
.select-group { padding: var(--space-xs) var(--control-padding-x); font-size: var(--font-help); color: var(--muted); }
.admin-log-filters ui-select { margin-top: var(--space-xs); }
/* V35: the period field matches the select fields beside it: height, fill and gap from the label. */
.admin-log-filters .select-field input { margin-top: var(--space-xs); padding: var(--space-sm) var(--control-padding-x); line-height: var(--line-control); background: var(--surface); }
@media (max-width: 355px) {
  .brand-title { font-size: .9375rem; }
  .brand-mark { width: 20px; flex-basis: 20px; }
  #process { padding-inline: 4px; gap: 4px; }
}

#app-dialog {
  width: min(440px, calc(100% - 32px)); max-height: calc(100% - 32px);
  max-height: min(calc(100% - 32px), calc(var(--app-height) - 32px));
  padding: var(--card-padding); border: 0; border-radius: var(--card-radius);
  color: var(--ink); background: var(--panel-fill); box-shadow: var(--shadow);
  overflow: auto; overflow-wrap: anywhere;
}
#app-dialog::backdrop { background: #211B1866; }
#app-dialog-title { margin: 0; font-size: var(--font-section); }
#app-dialog-value { margin-top: var(--space-lg); background: var(--surface); }
.app-dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--space-sm); margin-top: var(--space-lg); }

/* V36: the sign-in screen (Google, a code from a letter, the password). Colours come from the theme variables. */
.login-panel .login-lead { color: var(--ink); }
.login-google { margin-top: var(--space-lg); }
.google-button { display: flex; align-items: center; justify-content: center; min-height: var(--control-min-height); min-width: 0; }
#google-native { width: 100%; height: 48px; min-height: 48px; justify-content: flex-start; gap: 12px; padding: 0 12px; border: 1px solid #747775; background: #FFFFFF; color: #1F1F1F; font-weight: 500; }
#google-native svg { width: 20px; height: 20px; stroke: none; }
#google-native span { flex: 1; }
.login-divider { display: flex; align-items: center; gap: var(--space-md); margin-top: var(--space-md); color: var(--muted); font-size: var(--font-help); }
.login-divider::before, .login-divider::after { content: ""; flex: 1 1 0; height: 1px; background: currentColor; opacity: .35; }
.login-step > label:first-child { margin-top: var(--space-md); }
.login-step .form-actions > button { flex: 1 1 auto; }
.code-info { margin-top: var(--space-md); }
.code-info p + p { margin-top: var(--space-xs); }
.code-resend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs) var(--space-md); margin-top: var(--space-md); }
.code-resend p { flex: 1 1 12em; min-width: 0; }
.confirm-question { margin-top: var(--space-md); font-weight: 600; }
/* Headings with tabindex="-1", the card of a just saved style and the question take the focus from the script only; they are not in the Tab order. */
:is(h2, h3)[tabindex="-1"]:focus, .prompt-card[tabindex="-1"]:focus, .confirm-question:focus { outline: none; }
.login-switch {
  display: flex; justify-content: flex-start; width: 100%; margin-top: var(--space-lg); padding-inline: 0;
  color: var(--ink); background: transparent; font-size: var(--font-body); text-align: left;
  text-decoration: underline; text-underline-offset: 3px;
}
.login-switch:hover:enabled { color: var(--accent); background: transparent; }
#login-form { margin-top: var(--space-xs); }
#login-form > label:first-child { margin-top: 0; }
.login-status { margin-top: var(--space-md); padding: 7px 11px; border-radius: 8px; background: var(--surface); }
.login-status:empty { display: none; }
.login-status.error { color: var(--error); background: var(--error-bg); }
/* V36 fix 2.6: until the button carries the nonce of the current pair, the Google block keeps its place unseen. */
.login-google.google-wait { visibility: hidden; }
/* V36 fix 2.8: the sign-in fields keep a visible edge, at least 3:1 to the card in both themes. */
#login-view :is(input:not([type="checkbox"]), textarea) { border: 1px solid var(--muted); }
.login-consent { margin-top: var(--space-lg); }
.login-consent a, .legal-text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* V36: /privacy and /terms, plain reading pages without the application. */
.legal-bar, .legal-text { width: 100%; max-width: var(--reading-max-width); margin: 0 auto; padding-inline: var(--page-gutter-mobile); }
.legal-bar { padding-top: var(--space-sm); }
.legal-home { display: inline-flex; align-items: center; min-height: var(--control-min-height); color: var(--ink); font-size: var(--font-display); font-weight: 600; text-decoration: none; }
.legal-home:hover { color: var(--accent); }
.legal-text { padding-bottom: var(--space-xl); overflow-wrap: anywhere; }
.legal-text h1 { margin: var(--space-md) 0 var(--space-sm); font-size: var(--font-page); }
.legal-text h2 { margin: var(--space-xl) 0 var(--space-sm); font-size: var(--font-section); }
.legal-text p, .legal-text li { margin: 0 0 var(--space-sm); }
.legal-text ul, .legal-text ol { margin: 0 0 var(--space-md); padding-left: 1.5em; }
.legal-date { color: var(--muted); }
.legal-links { margin-top: var(--space-xl); }
@media (min-width: 701px) {
  .legal-bar, .legal-text { padding-inline: var(--page-gutter-desktop); }
}

/* V37: account panels use the existing reading column and theme tokens. */
#account-view { overflow-wrap: anywhere; }
#account-view .form-actions > button { min-height: 44px; }
#account-delete-panel input { border: 1px solid var(--muted); }
#account-delete-status:not(:empty) { margin-top: var(--space-md); }
.account-links a, #account-delete-panel a { color: inherit; }
#app-dialog-title { white-space: pre-line; }

/* V42: the share action occupies only the space beside its visible copy button. */
#editor-main-slot:has(> .share-button:not([hidden])) { grid-template-columns: minmax(0, 1fr) 60px; }
#editor-main-slot > .share-button { width: 60px; padding: 0; border-radius: 32px; background: var(--button-fill); color: var(--ink); box-shadow: none; }
#editor-main-slot > .share-button:hover:enabled { background: var(--button-hover); }
#editor-main-slot > .share-button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#editor-main-slot:has(> .share-button:not([hidden])) > :is(.recovery-actions, #send-audio) { grid-column: 1 / -1; }
