/* Shared presentation layer. No changes to controls, actions, or saved state. */
:root {
  --ui-border: #dce1d7;
  --ui-hover: #f0f3eb;
  --ui-shadow: 0 14px 42px #263b2b14, 0 2px 8px #263b2b08;
  --ui-focus: 0 0 0 3px #637e6826;
}

/* Consistent control rhythm, including compact toolbars. */
.btn {
  border-radius: 10px;
  line-height: 1.5;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.btn:hover { transform: none; }
.btn:not(.primary):not(.dark):not(.text):not(:disabled):hover {
  background: var(--ui-hover);
  border-color: #c5d0bf;
}
.btn.small { min-height: 36px; padding: 7px 12px; }
.btn:disabled { transform: none; box-shadow: none; }
.btn:focus-visible, .icon-btn:focus-visible, summary:focus-visible,
.chat-context-menu button:focus-visible, .candidate-select:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}
input:not([type=checkbox]):not([type=radio]), textarea, select {
  border-radius: 10px;
  transition: border-color .16s ease, box-shadow .16s ease;
}
input:not([type=checkbox]):not([type=radio]):focus, textarea:focus, select:focus {
  border-color: #78917a;
  box-shadow: var(--ui-focus);
}
input[type=checkbox], input[type=radio] { accent-color: var(--green); }
.composer textarea:focus { box-shadow: none; }
.composer:focus-within { border-color: #a2b19a; box-shadow: var(--ui-focus); }

/* Menus read as grouped actions rather than miniature forms. */
.admin-switcher > summary {
  border-radius: 10px;
  transition: background .16s ease, border-color .16s ease;
}
.admin-switcher[open] > summary { background: var(--green-soft); color: var(--green); }
.admin-switcher .workspace-picker {
  padding: 18px;
  gap: 8px;
  border: 1px solid var(--ui-border);
  border-radius: 16px;
  box-shadow: var(--ui-shadow);
}
.admin-switcher .workspace-picker label {
  display: block;
  margin-bottom: 2px;
  font-size: 11px;
  letter-spacing: .04em;
}
.admin-switcher .workspace-picker select {
  min-height: 42px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #f6f7f2;
}
.admin-switcher .workspace-picker .btn {
  justify-content: flex-start;
  min-height: 40px;
  padding: 10px 12px;
  border-color: transparent;
  background: transparent;
  font-size: 13px;
  text-align: left;
}
.admin-switcher .workspace-picker [data-action=client-view] {
  color: var(--green);
  background: var(--green-soft);
}
.admin-switcher .workspace-picker [data-action=new-client] {
  border-top: 1px solid var(--line);
  border-radius: 0 0 10px 10px;
  margin-top: 3px;
  padding-top: 13px;
}
.chat-context-menu {
  min-width: 184px;
  padding: 7px;
  border-color: var(--ui-border);
  border-radius: 14px;
  box-shadow: var(--ui-shadow);
}
.chat-context-menu button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  min-height: 42px;
  border-radius: 8px;
  font: 13px/1.5 var(--sans);
}
.chat-context-menu button::before {
  content: '';
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 3h6v5l3 4v2H6v-2l3-4V3ZM12 14v7' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;
}
.chat-context-menu [data-cmd=delete] {
  color: #a74732;
  border-top: 1px solid #eee5df;
  border-radius: 0 0 8px 8px;
  margin-top: 4px;
}
.chat-context-menu [data-cmd=delete]::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 6h16M9 6V3h6v3M6 6l1 15h10l1-15M10 10v7M14 10v7' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.chat-context-menu [data-cmd=delete]:hover { background: #fbefe9; }
.settings-popover, .history-menu[open], #selection-edit,
#title-options.title-picker {
  border-color: var(--ui-border);
  border-radius: 16px;
  box-shadow: var(--ui-shadow);
}
.settings-popover { padding: 20px; }
.settings-popover > label { font-size: 13px; font-weight: 500; color: var(--ink); }
.settings-popover > p { line-height: 1.85; font-size: 12px; }
.settings-popover .ai-file-details {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 12px;
}
.settings-popover > .btn { margin-top: 12px; }
.title-picker-heading { gap: 10px; }
.title-picker-heading > strong { flex: 1; }
.title-close { display: grid; place-items: center; min-width: 32px; min-height: 32px; border-radius: 8px; }
.title-close:hover { background: var(--green-soft); }
#selection-edit { padding: 12px; }
#selection-edit form { max-width: 100%; }
.compact-tools { row-gap: 6px; }
.compact-tools > .btn, .compact-tools select, .ai-settings > summary {
  min-height: 32px;
  font-size: 12px;
}
.draft-panel > header { row-gap: 10px; padding-bottom: 8px; }
.draft-panel > header .btn, .draft-panel > header #draft-versions {
  min-height: 32px;
  border-radius: 8px;
}
.draft-actions { align-items: center; gap: 8px; padding-top: 14px; }

/* Stable dialog headings; form content scrolls independently. */
.modal-backdrop, .kb-overlay { background: #23332966; backdrop-filter: blur(4px); }
.modal, .kb-dialog, .polish-dialog, .publication-date-dialog {
  border: 1px solid #e0e5da;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 24px 80px #17291e29, 0 4px 16px #17291e12;
}
.modal { display: flex; flex-direction: column; overflow: hidden; max-height: calc(100dvh - 48px); }
.modal-header { flex: 0 0 auto; padding: 22px 28px; gap: 16px; background: #f6f7f1; }
.modal-header h2 { font-family: var(--sans); font-size: 20px; font-weight: 600; }
.modal-header .icon-btn { width: 36px; height: 36px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.modal-body { overflow: auto; min-height: 0; padding: 24px 28px; overscroll-behavior: contain; }
.modal-body .field { margin-bottom: 20px; }
.modal-body textarea { height: clamp(130px, 28dvh, 280px); }
.modal-body .label, .kb-dialog .label { color: #697464; font-size: 12px; }
.modal-actions { padding-top: 18px; border-top: 1px solid var(--line); }
.kb-dialog { display: flex; flex-direction: column; overflow: auto; padding: 24px; max-height: calc(100dvh - 48px); }
.kb-dialog:has(#kb-form) { overflow: hidden; }
.kb-dialog-head { flex-shrink: 0; margin: -24px -24px 0; padding: 18px 24px; background: #f6f7f1; border-bottom: 1px solid var(--line); }
.kb-dialog-head h2 { font-size: 20px; font-weight: 600; }
.kb-dialog #kb-form { overflow: auto; min-height: 0; padding: 2px 3px 0; overscroll-behavior: contain; }
.kb-dialog textarea { height: 28dvh; min-height: 130px; }
.kb-options { gap: 10px 20px; padding: 12px 0; }
.kb-options label { min-height: 30px; }
.kb-dialog #kb-form > .actions {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 16px 0 2px;
  margin-top: 18px;
  justify-content: flex-end;
}
.publication-date-dialog h3 { font-size: 20px; font-weight: 600; margin-bottom: 14px; }
.publication-date-dialog p { font-size: 14px; line-height: 1.85; color: #687563; margin: 12px 0; }
.publication-date-dialog .actions { border-top: 1px solid var(--line); padding-top: 18px; justify-content: flex-end; }
.publication-date-dialog::backdrop, .polish-dialog::backdrop { background: #23332966; backdrop-filter: blur(4px); }

/* Space between adjacent panels; related actions stay in one visual group. */
.content > .admin-panel + .admin-panel { margin-top: 16px; }
.page-intro > .actions, .production-heading > .actions { margin-top: 0; align-items: center; gap: 10px; }
.knowledge-page .filters { gap: 6px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.knowledge-page .filter { padding: 9px 13px; border-radius: 8px; border-bottom: 0; }
.knowledge-page .filter.on { color: var(--green); background: #e6edde; }
.knowledge-page .filter:hover { background: var(--green-soft); }
.drive-panel .actions { align-items: center; gap: 8px; }
[data-kb=drive-disconnect], [data-trash-material], [data-trash-selected] { color: #a74732; }
.production-detail-head { gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.production-detail-head > small { color: var(--muted); font-variant-numeric: tabular-nums; }
.production-title { margin-bottom: 20px; }
.production-main > .actions { gap: 8px; padding: 12px 0; margin-top: 6px; align-items: center; }
.production-main > .actions [data-video-approve] { margin-left: auto; }
.review-video-head select { min-height: 40px; }
.production-tabs { gap: 6px; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: #eef0e8; }
.production-tabs button { min-height: 38px; padding: 8px 14px; }
.production-tabs button.on { background: var(--surface); box-shadow: 0 1px 4px #27382c10; }
.production-comments { align-self: start; border: 1px solid var(--line); padding: 18px; border-radius: 16px; background: var(--surface); }
.vr-list-heading { gap: 12px; margin-bottom: 6px; }
.vr-version-hint { margin-bottom: 12px; }
.vr-note { padding: 16px 0; }
.vr-compose-actions { gap: 8px; }
.vr-composer .btn, .vr-composer select { min-height: 36px; }
.recording-script-actions { align-items: center; gap: 8px; }
.recording-script-actions > [role=status] { flex: 1 1 220px; font-size: 12px; line-height: 1.7; }
.material-bulk { gap: 8px; flex-wrap: wrap; padding: 10px 0; }
.material-bulk > label { margin-right: auto; }

@media (max-width: 700px) {
  .btn.small { min-height: 40px; }
  .admin-switcher .workspace-picker { padding: 16px; border-radius: 16px; }
  .admin-switcher .workspace-picker .btn { min-height: 44px; }
  .admin-switcher .workspace-picker select { font-size: 16px; }
  .modal, .kb-dialog { max-height: calc(100dvh - 24px); border-radius: 16px; }
  .modal-header { padding: 16px 18px; }
  .modal-body { padding: 20px 18px; }
  .modal-header h2, .kb-dialog-head h2 { font-size: 18px; }
  .kb-dialog { padding: 18px; }
  .kb-dialog-head { margin: -18px -18px 0; padding: 14px 18px; }
  .kb-dialog input:not([type=checkbox]), .kb-dialog select, .kb-dialog textarea,
  .modal input:not([type=checkbox]), .modal select, .modal textarea { font-size: 16px; }
  .kb-options { display: grid; gap: 6px; }
  .modal-actions > .btn { flex: 1; }
  .settings-popover { padding: 16px; }
  .draft-panel > header { gap: 10px; }
  .draft-panel > header .btn { min-height: 36px; }
  .compact-tools > .btn, .compact-tools select, .ai-settings > summary { min-height: 36px; }
  .production-comments { padding: 16px; margin-top: 20px; }
  .production-main > .actions [data-video-approve] { margin-left: 0; }
  .production-main > .actions { gap: 8px; }
  .production-main > .actions > .btn { flex: 1 1 auto; }
  .material-bulk > label { flex-basis: 100%; }
  .material-bulk > .btn { flex: 1; }
  .page-intro > .actions, .production-heading > .actions { flex-wrap: wrap; }
  .publication-date-dialog { padding: 20px; }
  .publication-date-dialog .actions > .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .btn, input:not([type=checkbox]):not([type=radio]), textarea, select,
  .admin-switcher > summary { transition: none; }
}
