* { box-sizing: border-box; }
html, body, #app { margin: 0; padding: 0; height: 100%; }

/* --- Login page --- */
.login-page { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--bg) center/cover no-repeat; background-color: #1a1a2e; }
.login-page[style*="background-image"]::before { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,0.45); }
.login-page { position: relative; }
.login-loading { color: var(--muted); font-size: 14px; position: relative; z-index: 1; }
.login-card { display: flex; flex-direction: column; gap: 12px; width: 320px; padding: 32px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); position: relative; z-index: 1; box-shadow: 0 8px 32px rgba(0,0,0,0.3); }
.login-title { font-size: 22px; font-weight: 700; text-align: center; letter-spacing: 0.05em; margin-bottom: 8px; color: var(--text); }
.login-btn { width: 100%; justify-content: center; font-weight: 600; background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.login-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.login-btn:disabled { opacity: 0.5; }

/* --- Header user --- */
.header-user { font-size: 12px; color: var(--muted); white-space: nowrap; padding: 0 4px; }

/* --- Admin page --- */
.admin-page { padding: 0 16px 24px; }
.admin-projects-cell { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.admin-project-tag { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; background: var(--pill); padding: 2px 6px; border-radius: 4px; }
.admin-tag-remove { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 12px; padding: 0 2px; line-height: 1; }
.admin-tag-remove:hover { color: var(--error); }
.admin-all-projects { font-size: 11px; color: var(--success); font-weight: 600; }
.admin-add-project select { font-size: 11px; padding: 1px 4px; border: 1px dashed var(--panel-border); background: transparent; color: var(--text); cursor: pointer; border-radius: 4px; }
.admin-new-user { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.admin-new-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.admin-new-fields { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.admin-new-fields .field-control { min-width: 120px; flex: 1; }
.admin-new-fields select.field-control { min-width: 80px; flex: 0; }

:root {
  --bg: #ffffff;
  --bg-alt: #f4f4f6;
  --panel: #ffffff;
  --panel-border: #A5A8BE80;
  --panel-shadow: 0 2px 30px rgba(33, 49, 73, 0.08);
  --text: #130F33;
  --muted: #7D7882;
  --line: #A5A8BE80;
  --accent: #130F33;
  --accent-hover: #162668;
  --accent-contrast: #ffffff;
  --accent-secondary: #AAC8C8;
  --pill: #f4f4f6;
  --pill-border: #A5A8BE80;
  --input-bg: transparent;
  --input-border: #7D7882;
  --card: #ffffff;
  --code-bg: #f4f4f6;
  --code-border: #A5A8BE80;
  --drag: rgba(19, 15, 51, 0.08);
  --success: #10b981;
  --error: #D92D20;
  --radius: 0px;
}

body.theme-dark {
  --bg: #130F33;
  --bg-alt: #1a1545;
  --panel: #1a1545;
  --panel-border: rgba(255, 255, 255, 0.1);
  --panel-shadow: 0 2px 30px rgba(0, 0, 0, 0.3);
  --text: #e4e7ec;
  --muted: #ADB2BD;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #AAC8C8;
  --accent-hover: #c0d8d8;
  --accent-contrast: #130F33;
  --accent-secondary: #AAC8C8;
  --pill: #221c52;
  --pill-border: rgba(255, 255, 255, 0.1);
  --input-bg: transparent;
  --input-border: rgba(255, 255, 255, 0.2);
  --card: #1a1545;
  --code-bg: #0f0b2a;
  --code-border: rgba(255, 255, 255, 0.08);
  --drag: rgba(170, 200, 200, 0.12);
  --success: #10b981;
  --error: #D92D20;
  --radius: 0px;
}

/* Reaspekt dark theme: mint subtitles */
body.theme-dark .panel-subtitle,
body.theme-dark .code-panel-subtitle { color: var(--accent-secondary); }
body.theme-dark .settings-section-title { color: var(--accent-secondary); }

body {
  font-family: "Onest", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.page {
  min-height: 100vh;
  background: var(--bg);
  display: grid;
  grid-template-columns: auto 1fr;
}

.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 20px 32px;
  gap: 20px;
  min-height: 100vh;
  overflow-x: hidden;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 20px 12px;
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  z-index: 10;
  width: calc(100% + 40px);
  margin-left: -20px;
}
.workspace-header::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 120px;
  height: 100%;
  pointer-events: none;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 4px,
    color-mix(in srgb, var(--accent-secondary) 8%, transparent) 4px,
    color-mix(in srgb, var(--accent-secondary) 8%, transparent) 5px
  );
  mask-image: linear-gradient(to left, rgba(0,0,0,0.5), transparent);
  -webkit-mask-image: linear-gradient(to left, rgba(0,0,0,0.5), transparent);
}
.workspace-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  flex-wrap: wrap;
}
.letter-title {
  font-size: 14px;
  color: var(--muted);
  margin-left: 8px;
  white-space: nowrap;
  cursor: text;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.letter-title-input {
  font-size: 14px;
  color: var(--text);
  margin-left: 8px;
  white-space: nowrap;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0;
  border-radius: 0;
  appearance: none;
  -webkit-appearance: none;
  line-height: 1.2;
}
.letter-date {
  cursor: text;
}
.letter-name {
  cursor: text;
}
.letter-gap {
  display: inline-block;
  width: 4px;
}
.letter-date-input {
  font-size: 14px;
  color: var(--text);
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0;
  border-radius: 0;
  appearance: none;
  -webkit-appearance: none;
  line-height: 1.2;
}
.preset-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.preset-inline .field-control {
  min-width: 220px;
}
.product-options-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  flex-wrap: wrap;
}
.product-options-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 8px;
}
.product-options-settings {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.product-option-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg-alt);
  border-radius: var(--radius);
}
.product-option-row .field-control { min-width: 0; }
.parts-editor-fields { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.parts-editor-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-items: center; }
.parts-editor-row.single { grid-template-columns: 1fr; }
.parts-editor-group-title {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); margin: 10px 0 4px; padding-bottom: 4px; border-bottom: 1px solid var(--line);
}
.parts-editor-group-title:first-child { margin-top: 0; }
.parts-editor-type { font-size: 13px; text-align: center; color: var(--muted); }
.product-option-default {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.preset-links {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.preset-page-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px;
}
.letters-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
}
.preset-quick-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 10px;
}
.preset-pill-btn {
  background: var(--pill);
  border: 1px solid var(--pill-border);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  min-height: 28px;
  border-radius: var(--radius);
  box-shadow: none;
}
.preset-pill-btn:hover {
  background: var(--bg-alt);
  border-color: var(--muted);
  box-shadow: none;
}
.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.panel-subsection {
  margin-bottom: 12px;
}
.letter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  border: none;
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--panel);
  box-shadow: var(--panel-shadow);
  gap: 0;
}
.letter-row-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.letter-row-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60vw;
}
.letter-row-date {
  color: var(--muted);
  white-space: nowrap;
  font-size: 12px;
}
.letter-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.15s;
}
.letter-row:hover .letter-row-actions,
.letter-row.history-open .letter-row-actions {
  opacity: 1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
body.theme-dark .modal-backdrop {
  background: rgba(0, 0, 0, 0.5);
}
.modal-card {
  background: var(--panel);
  border: none;
  border-radius: 14px;
  padding: 24px;
  width: 420px;
  max-width: calc(100% - 32px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
}
.modal-title {
  font-size: 16px;
  font-weight: 600;
}
.modal-step {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.modal-preview {
  font-size: 12px;
  color: var(--muted);
}
.modal-error {
  font-size: 12px;
  color: var(--danger);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.preset-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
}
.preset-toolbar .field-control {
  min-width: 220px;
}
.preset-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--panel-shadow);
}
.preset-card-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.preset-name {
  font-size: 16px;
  font-weight: 600;
}
.preset-date {
  font-size: 12px;
  color: var(--muted);
}
.preset-links .text-link {
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 4px;
  border-radius: var(--radius);
}
.preset-links .text-link:hover {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.04);
}
.preset-links .text-link:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}
.preset-links-sidebar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin: 2px 0 6px;
}

.workspace-meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.workspace-breadcrumb {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.workspace-breadcrumb .sep { opacity: 0.6; }

.ghost-link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 1px;
}
.ghost-link:hover {
  color: var(--text);
  border-color: var(--text);
}

.btn-textual {
  width: auto;
  min-width: unset;
  padding: 6px 12px;
  font-weight: 600;
}
.btn-textual span {
  font-size: 12px;
  letter-spacing: 0.03em;
}
.btn-textual.danger {
  border-color: #ba473a;
  color: #ba473a;
  background: transparent;
}

.workspace-header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex: 0 0 auto;
  justify-content: flex-end;
}
.header-status {
  font-size: 12px;
  color: var(--success);
  white-space: nowrap;
}
.workspace-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  padding-left: 14px;
}
.workspace-header-actions::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 1px;
  height: 24px;
  background: var(--line);
  transform: translateY(-50%);
}
.image-base-field {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}
.image-base-input {
  width: 100%;
  min-width: 260px;
  max-width: none;
  height: auto;
  padding: 4px 2px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 13px;
}
.image-base-input:focus {
  outline: none;
  border: none;
  box-shadow: none;
}
.workspace-header .pug-actions {
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  gap: 3px;
}

/* Reaspekt header buttons: dark fill, white text; hover: mint fill, dark text */
.workspace-header .workspace-meta-row .btn,
.workspace-header .workspace-header-actions .btn:not(.theme-switch *) {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}
.workspace-header .workspace-meta-row .btn .icon-img,
.workspace-header .workspace-header-actions .btn:not(.theme-switch *) .icon-img {
  filter: invert(1);
  opacity: 1;
}
.workspace-header .workspace-meta-row .btn:hover,
.workspace-header .workspace-header-actions .btn:not(.theme-switch *):hover {
  background: var(--accent-secondary);
  color: #130F33;
  border-color: var(--accent-secondary);
}
.workspace-header .workspace-meta-row .btn:hover .icon-img,
.workspace-header .workspace-header-actions .btn:not(.theme-switch *):hover .icon-img {
  filter: none;
  opacity: 0.8;
}
/* Keep toggled state distinct */
.workspace-header-actions .btn[aria-pressed="true"],
.workspace-header-actions .btn.toggled {
  background: var(--accent-secondary);
  border-color: var(--accent-secondary);
  color: #130F33;
  box-shadow: none;
}
.workspace-header-actions .btn.toggled .icon-img {
  filter: none;
  opacity: 0.8;
}
.workspace-header-actions .btn[aria-pressed="true"]:hover,
.workspace-header-actions .btn.toggled:hover {
  background: var(--accent-secondary);
  border-color: var(--accent-secondary);
  color: #130F33;
  box-shadow: none;
}

.workspace-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.workspace-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.workspace-subtitle {
  font-size: 14px;
  color: var(--muted);
}

.workspace-grid {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(560px, 1fr) minmax(360px, 1fr);
  gap: 10px;
  align-items: start;
}
.builder-grid {
  height: calc(100vh - 160px);
  grid-template-columns: minmax(400px, 1fr) minmax(380px, 620px);
}
.builder-grid.preview-focus {
  grid-template-columns: minmax(400px, 1fr) minmax(380px, 620px);
}
.builder-grid .panel.panel-left {
  min-width: 0;
  height: 100%;
  overflow: hidden;
  max-width: none;
}
.builder-grid .panel.panel-right {
  min-width: 0;
  max-width: none;
  width: 100%;
}
.builder-grid .blocks-container {
  max-height: 100%;
  padding-bottom: 50vh;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.panel-title { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; padding-left: 12px; border-left: 3px solid var(--accent-secondary); }
.panel-subtitle { font-size: 12px; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; }

.settings-section {
  padding: 0 0 20px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-section:last-child { border-bottom: none; padding-bottom: 0; }
.panel > .settings-section:first-child { padding-top: 4px; }
.panel .settings-section + .settings-section { padding-top: 20px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.settings-section > label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 500; color: var(--muted); }
.settings-section > label .field-control { font-size: 13px; }
.settings-section .inline label:not(.btn) { display: flex; flex-direction: column; gap: 3px; font-size: 11px; font-weight: 500; color: var(--muted); min-width: 0; flex-shrink: 0; }
.settings-section .inline label:not(.btn) .field-control { min-width: 0; }
.settings-section .inline label input[type="checkbox"] { margin: 0; }
.settings-section .inline label input[type="file"] { display: none; }
.settings-section-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: -6px;
  letter-spacing: -0.01em;
  padding-left: 10px;
  border-left: 3px solid var(--accent-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.settings-section-title::before {
  content: '↘';
  color: var(--accent-secondary);
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
}
.settings-section-desc {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
  line-height: 1.5;
}

/* Settings page — card layout */
.settings-grid {
  display: block;
}
.settings-grid .panel-left {
  max-width: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-grid .settings-section {
  background: var(--panel);
  padding: 18px 22px 22px;
  border-radius: var(--radius);
  border: none;
  box-shadow: var(--panel-shadow);
}
.settings-grid .settings-section:last-child {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--panel-border);
}
.settings-grid .panel > .settings-section:first-child {
  padding-top: 16px;
}
.settings-grid .panel .settings-section + .settings-section {
  padding-top: 16px;
}
.settings-grid .settings-section > label > .field-control,
.settings-grid .settings-section > label > select.field-control {
  width: 100%;
  min-width: 0;
}
.settings-grid .settings-section .inline .field-control {
  min-width: 0;
  flex: 1;
}
.settings-grid .settings-section .inline .field-control.inline-col {
  flex: 0 0 48px;
  width: 48px;
  min-width: 48px;
}
/* Two-column layout for "Project" tab */
.settings-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}
.settings-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.theme-toggle-inner { display: flex; align-items: center; gap: 6px; }
.theme-icon { display: none; }
.theme-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.theme-switch input { opacity: 0; width: 0; height: 0; }
.theme-slider {
  position: absolute; inset: 0;
  cursor: pointer;
  background: var(--pill);
  border-radius: 999px;
  transition: 0.2s;
  border: none;
}
.theme-slider::before {
  content: "";
  position: absolute;
  height: 14px;
  width: 14px;
  left: 5px;
  top: 5px;
  background: #fefefe;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: none;
}
.theme-slider::after {
  content: none;
}
.theme-switch input:checked + .theme-slider { background: #3e444c; border-color: #3e444c; }
.theme-switch input:checked + .theme-slider::before { transform: translateX(20px); background: #fefefe; }
.theme-switch input:checked + .theme-slider::after {
  right: 26px;
  background: var(--accent-contrast);
}

.theme-slider::after {
  content: none;
}

.panel-left { max-width: 780px; width: 100%; padding: 20px; gap: 0; }
.panel-right { width: 100%; max-width: 460px; padding: 20px; gap: 0; }

.id-manager-panel {
  width: 100%;
  margin-bottom: 14px;
  padding: 10px 8px;
  border: none;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--panel-shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.id-manager-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.id-manager-title { font-weight: 700; font-size: 14px; letter-spacing: 0.02em; }
.id-manager-count { font-size: 12px; color: var(--muted); }

.id-manager-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-start;
}

.id-manager-input {
  width: 100%;
  min-height: 60px;
  padding: 6px 6px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 13px;
  color: var(--text);
  resize: vertical;
}

.id-manager-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px;
  border-radius: var(--radius);
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  max-height: 110px;
  overflow-y: auto;
}

.id-manager-preview .id-chip {
  padding: 2px 6px;
  border-radius: var(--radius);
  background: var(--pill);
  border: 1px solid var(--pill-border);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--text);
  outline: none;
  min-width: 0;
  max-width: none;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  width: fit-content;
  flex: 0 0 auto;
  white-space: nowrap;
}
.id-manager-preview .id-chip:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.id-manager-preview .id-chip.free {
  background: color-mix(in srgb, var(--success) 8%, transparent);
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
  color: var(--text);
}
.id-manager-preview .id-chip.used {
  text-decoration: line-through;
  color: var(--muted);
  opacity: 0.6;
  background: transparent;
}

.id-manager-hint {
  font-size: 12px;
  color: var(--muted);
}

.tabs { display: inline-flex; gap: 8px; margin-bottom: 0; }
.tabs button {
  padding: 4px 8px;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 140ms ease;
  font-weight: 600;
  min-height: 26px;
}
.tabs button:hover { background: var(--bg-alt); color: var(--text); }
.tabs button.tab-active { background: var(--text); color: var(--panel); border-color: var(--text); font-weight: 700; }
.tabs-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sidebar-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.tabs-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-alt);
  border-radius: var(--radius);
  padding: 3px;
}
.tabs-actions .btn {
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 16px;
  background: transparent;
  color: var(--muted);
  transition: all 0.15s;
}
.tabs-actions .btn:hover { color: var(--text); background: transparent; border-color: transparent; box-shadow: none; }
.tabs-actions .btn.toggled {
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  outline: none;
}
.price-toggle {
  min-width: 32px;
  min-height: 30px;
  padding: 0;
  justify-content: center;
  font-weight: 700;
  border-radius: var(--radius);
}
.price-toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

.panel {
  background: var(--panel);
  border: none;
  padding: 12px;
  display: flex;
  flex-direction: column;
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
}

.control-panel {
  width: 300px;
  padding: 16px 20px 20px;
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--line);
  background: var(--panel);
  box-shadow: none;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  gap: 16px;
}

.control-panel-title {
  font-size: 28px;
  font-weight: 100;
  letter-spacing: 0.02em;
  color: var(--text);
  margin-bottom: 10px;
}

.meta-panel {
  display: grid;
  gap: 8px;
  margin-bottom: 1px;
}
.meta-panel label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.meta-panel input {
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 13px;
}

.quick-preset-panel label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.preset-preview {
  padding: 10px;
  border-radius: var(--radius);
  border: 1px dashed var(--input-border);
  background: var(--input-bg);
}
.preset-preview-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}
.preset-preview-desc {
  font-size: 12px;
  color: var(--muted);
}

.note-templates {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.change-log {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--panel);
  box-shadow: var(--panel-shadow);
  gap: 6px;
}
.change-log ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.change-log li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text);
}
.change-log li time {
  font-size: 11px;
  color: var(--muted);
}
.change-log-empty {
  font-size: 12px;
  color: var(--muted);
  opacity: 0.7;
}

.id-manager-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-start;
}
.id-manager-panel .btn {
  padding: 5px 10px;
  min-height: 28px;
}
.id-manager-panel .btn.icon-square {
  width: 28px;
  min-width: 28px;
  height: 28px;
}

.dot-loader {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ba473a;
  display: inline-block;
  animation: dotPulse 0.8s infinite alternate;
  margin-right: 4px;
}

@keyframes dotPulse {
  to {
    transform: scale(0.6);
    opacity: 0.4;
  }
}
.panel.panel-left,
.panel.panel-right {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  border-radius: 0;
}
.panel-full {
  grid-column: 1 / -1;
}
.panel.panel-left .blocks-container {
  padding: 10px 8px 14px;
}
.builder-grid .panel.panel-left .blocks-container {
  padding-bottom: 50vh;
}
.panel-sidebar {
  align-self: stretch;
  gap: 8px;
}
.panel-sidebar .sidebar-group { display: flex; flex-direction: column; gap: 6px; }
.panel-sidebar .sidebar-title { margin-top: 16px; }
.sidebar-divider {
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 16px 0;
}
.sidebar-separator {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
}
.sidebar-divider .sidebar-title {
  margin-top: 0;
}
.panel-sidebar .sidebar-title { font-size: 12px; color: var(--muted); font-weight: 700; }
.panel-sidebar .sidebar-title.sidebar-title-accent {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-left: 8px;
  border-left: 2px solid var(--accent-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
}
.panel-sidebar .sidebar-title.sidebar-title-accent::before {
  content: '↘';
  color: var(--accent-secondary);
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
}
.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}
.sidebar-title-row .sidebar-title {
  margin-top: 0;
}
.sidebar-collapse-btn { background: none; border: none; cursor: pointer; padding: 0; font: inherit; text-align: left; }
.sidebar-collapse-btn:hover { opacity: 0.8; }
.collapse-arrow { font-size: 10px; opacity: 0.5; transition: transform 0.2s; display: inline-block; }
.collapse-arrow.collapsed { transform: rotate(-90deg); }
.sidebar-title-btn {
  padding: 0 6px;
  font-size: 16px;
  line-height: 1;
  color: var(--muted);
  opacity: 0.6;
}
.sidebar-title-btn:hover {
  opacity: 1;
}
.sidebar-note {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-note-textarea {
  resize: none;
  min-height: 84px;
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 0;
  outline: none;
}
.acard {
  background: var(--panel);
  border: none;
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--panel-shadow);
}
.acard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.acard-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #130F33;
  background: var(--accent-secondary);
  padding: 2px 8px;
  border-radius: 4px;
  line-height: 1.6;
}
.acard-actions { display: flex; gap: 6px; margin-top: 8px; }
.acard-actions .btn { flex: 1; font-size: 12px; justify-content: center; text-align: center; padding: 6px 10px; font-weight: 600; box-sizing: border-box; }
.acard-close {
  all: unset;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  padding: 0 2px;
  opacity: 0.5;
  transition: opacity .15s;
}
.acard-close:hover { opacity: 1; }
.acard-subject {
  font-weight: 700;
  font-size: 13px;
  line-height: 1.35;
  color: var(--text);
}
.acard-preheader {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  font-style: italic;
}
.acard-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.acard-tag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--panel);
  border: 1px solid var(--pill-border);
  color: var(--text);
  white-space: nowrap;
  line-height: 1.5;
}
.acard-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid var(--pill-border);
  padding-top: 8px;
}
.acard-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.4;
  transition: opacity .15s;
}
.acard-link:hover { opacity: 0.7; }
.acard-link svg { flex-shrink: 0; }
.acard-mailing-btn {
  background: var(--text);
  color: var(--panel);
  border-color: var(--text);
}
.acard-mailing-btn:hover {
  background: var(--muted);
  border-color: var(--muted);
  color: var(--panel);
  box-shadow: none;
}
.acard-plan { margin-top: 10px; border-top: 1px solid var(--pill-border); padding-top: 8px; }
.acard-plan-title { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; cursor: pointer; }
.acard-plan-title:hover { color: var(--text); }
.acard-cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.acard-cal-month { font-size: 11px; font-weight: 600; color: var(--text); text-transform: capitalize; }
.acard-cal-arrow { all: unset; cursor: pointer; font-size: 16px; color: var(--muted); padding: 0 4px; line-height: 1; }
.acard-cal-arrow:hover { color: var(--text); }
.acard-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; text-align: center; }
.acard-cal-dow { font-size: 9px; color: var(--muted); padding: 2px 0; }
.acard-cal-empty { padding: 2px; }
.acard-cal-day {
  position: relative; font-size: 10px; padding: 3px 0; border-radius: 3px;
  color: var(--muted); line-height: 1.3; display: flex; flex-direction: column; align-items: center;
}
.acard-cal-day.acard-cal-today { font-weight: 700; color: var(--text); background: var(--drag); }
.acard-cal-day.acard-cal-has { color: var(--text); }
.acard-cal-day.acard-cal-clickable { cursor: pointer; }
.acard-cal-day.acard-cal-clickable:hover { background: var(--drag); }
.acard-cal-dots { display: flex; gap: 2px; justify-content: center; margin-top: 2px; }
.acard-cal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.acard-cal-dot.plan-dot-done { background: var(--success); }
.acard-cal-dot.acard-cal-dot-past { background: var(--success); opacity: 0.35; }
.acard-cal-dot.plan-dot-wip { background: #e09020; }
.acard-cal-dot.plan-dot-queue { background: var(--accent); }
.acard-plan-row {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 4px;
  cursor: pointer; font-size: 11px; transition: background .15s;
}
.acard-plan-row:hover { background: var(--drag); }
.acard-plan-date { color: var(--muted); font-size: 10px; white-space: nowrap; min-width: 42px; }
.acard-plan-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; background: var(--accent); }
.acard-plan-dot.plan-dot-done { background: var(--success); }
.acard-plan-dot.plan-dot-wip { background: #e09020; }
.acard-plan-dot.plan-dot-queue { background: var(--accent); }
.acard-plan-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.acard-plan-overdue .acard-plan-date { color: var(--error, #e74c3c); font-weight: 600; }
.acard-plan-overdue .acard-plan-subject { color: var(--error, #e74c3c); }

/* --- FTP Gallery Modal --- */
.ftp-modal { max-width: 1100px; width: 92vw; }
.ftp-modal-path { font-size: 11px; color: var(--muted); margin-bottom: 8px; font-family: monospace; }
.ftp-upload-form {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 12px;
}
.ftp-upload-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ftp-file-btn {
  font-size: 11px; cursor: pointer; gap: 6px;
}
.ftp-file-btn.uploading { opacity: 0.7; animation: ftp-pulse 0.8s ease-in-out infinite alternate; cursor: default; }
.ftp-progress { color: var(--muted); font-size: 10px; }
.ftp-progressbar { height: 3px; background: var(--bg-alt); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.ftp-progressbar-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s ease; min-width: 4px; }
.ftp-upload-preview-url {
  font-size: 10px; color: var(--muted); font-family: monospace; word-break: break-all;
}
.ftp-upload-status {
  font-size: 11px; color: var(--accent); margin-top: 4px;
}
@keyframes ftp-pulse { from { opacity: 0.5; } to { opacity: 1; } }
.ftp-gallery-state { font-size: 12px; color: var(--muted); padding: 20px 0; text-align: center; }
.ftp-gallery-error { color: var(--error); }
.ftp-gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px; max-height: 55vh; overflow-y: auto; padding: 2px;
}
.ftp-gallery-item {
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: border-color .15s;
}
.ftp-gallery-item:hover { border-color: var(--accent); }
.ftp-gallery-item-img { cursor: pointer; }
.ftp-gallery-item img {
  width: 100%; height: 100px; object-fit: contain; background: var(--bg-alt); display: block;
}
.ftp-gallery-item-footer {
  display: flex; align-items: center; gap: 2px; padding: 0 4px 0 6px;
}
.ftp-gallery-item-name {
  font-size: 10px; color: var(--muted); flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ftp-gallery-delete-btn {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 14px; line-height: 1; padding: 2px 4px;
  border-radius: var(--radius); opacity: 0;
  transition: opacity .15s, color .15s;
}
.ftp-gallery-item:hover .ftp-gallery-delete-btn { opacity: 1; }
.ftp-gallery-delete-btn:hover { color: var(--danger, #e53e3e); }
.ftp-gallery-item.delete-pending { border-color: var(--danger, #e53e3e); }
.ftp-gallery-item.delete-pending .ftp-gallery-item-img { opacity: 0.5; }
.ftp-gallery-confirm-btn {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  font-size: 12px; line-height: 1; padding: 2px 4px; border-radius: var(--radius);
  transition: color .15s;
}
.ftp-gallery-confirm-btn.yes { color: var(--danger, #e53e3e); }
.ftp-gallery-confirm-btn.yes:hover { color: #c53030; }
.ftp-gallery-confirm-btn.no { color: var(--muted); }
.ftp-gallery-confirm-btn.no:hover { color: var(--text); }

details.sidebar-group > summary.sidebar-title {
  cursor: pointer;
  user-select: none;
}
.sidebar-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
.control-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: flex-start;
}
.notes-area {
  width: 100%;
  min-height: 110px;
  padding: 6px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  resize: vertical;
  font-size: 12px;
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
}

.panel h1, .panel h2 { margin: 0 0 6px; font-weight: 700; color: var(--text); letter-spacing: 0.01em; }
.panel h1 { font-size: 16px; }
.panel h2 { font-size: 14px; }

.toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px 10px;
  align-items: end;
  margin-bottom: 8px;
  position: sticky;
  top: 10px;
  z-index: 5;
  background: var(--panel);
  padding: 4px 0 4px;
}
.toolbar-field { display: flex; flex-direction: column; gap: 6px; }
.folder-field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.folder-field .folder-btn { align-self: flex-start; width: 32px; }
.folder-field .field-control { width: 100%; min-width: 360px; }
.folder-actions { display: flex; align-items: center; gap: 4px; }
.btn.icon-square {
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 0;
  justify-content: center;
  font-size: 13px;
  border-radius: var(--radius);
  aspect-ratio: 1 / 1;
  line-height: 1;
}
.btn:not(.icon-square) {
  min-width: 32px;
}
.btn.icon-square.btn-textual {
  width: auto;
  min-width: 0;
  height: 32px;
  padding: 6px 8px;
  justify-content: flex-start;
  border-width: 1px;
  aspect-ratio: unset;
}
.btn.icon-square.btn-textual.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  color: var(--accent);
}
.btn.icon-square.btn-textual.partial {
  border-style: dashed;
  color: var(--text);
}
.product-options-bar .btn[data-state="on"] {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
  box-shadow: 0 0 0 1px var(--accent) !important;
}
.product-options-bar .btn[data-state="partial"] {
  border-color: var(--accent) !important;
  border-style: dashed !important;
  color: var(--accent) !important;
}
.btn.icon-square.triangle { font-size: 13px; }
.btn.icon-square.danger {
  border-color: #ba473a;
  color: #ba473a;
}
.btn.icon-square.danger:hover { background: rgba(186, 71, 58, 0.14); border-color: #ba473a; }
.small-actions { display: flex; align-items: center; gap: 6px; }

.sidebar-row .folder-actions { flex: 0 0 auto; justify-content: flex-start; flex-wrap: nowrap; }
.folder-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  min-height: 40px;
  flex: 0 0 auto;
}

.field-label { font-size: 12px; color: var(--muted); letter-spacing: 0.01em; }
.field-control {
  padding: 7px 10px;
  font-size: 13px;
  min-width: 240px;
  height: 34px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.field-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent); }
.color-input {
  width: 44px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  border-radius: var(--radius);
  overflow: hidden;
}

.hint { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.settings-section .hint { margin-bottom: 0; margin-top: -4px; }
.status-badge, .plan-status-badge {
  display: inline-flex; align-items: center; font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: var(--radius); border: 1px solid var(--panel-border);
  background: transparent; color: var(--muted);
}
.status-badge.ok, .plan-status-badge.ok { color: var(--success); border-color: var(--success); background: color-mix(in srgb, var(--success) 8%, transparent); }
.status-badge.warn, .plan-status-badge.warn { color: #e09020; border-color: #e09020; background: color-mix(in srgb, #e09020 8%, transparent); }
.status-badge.error, .plan-status-badge.error { color: var(--error); border-color: var(--error); background: color-mix(in srgb, var(--error) 8%, transparent); }

.quick-blocks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.quick-blocks .btn.icon-square.btn-textual {
  height: 26px;
  padding: 3px 8px;
  font-size: 11px;
}
.quick-blocks-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.quick-block-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--bg-alt);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  transition: border-color 0.12s;
}
.quick-block-pill:hover { border-color: var(--muted); }
.quick-block-pill[draggable], .quick-blocks .btn[draggable] { cursor: grab; }
.quick-block-pill[draggable]:active, .quick-blocks .btn[draggable]:active { cursor: grabbing; }
.qb-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 14px;
  border-top: 1px dashed var(--panel-border);
  margin-top: 4px;
}
.qb-inline-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  letter-spacing: -0.5px;
}
.qb-inline-btn svg {
  width: 20px;
  height: 20px;
  display: block;
  flex-shrink: 0;
}
.qb-inline-btn[draggable] { cursor: grab; }
.qb-inline-btn[draggable]:active { cursor: grabbing; }
.qb-add-btn {
  height: 32px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 18px;
}
.qb-dragging { opacity: 0.4; }
.qb-drag-over { border-color: var(--accent) !important; box-shadow: 0 0 0 2px var(--accent-muted, #b2dfdb); }
.qb-drag-handle { color: var(--muted); font-size: 14px; cursor: grab; user-select: none; }
.qb-color-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--panel-border); background: var(--bg); cursor: pointer; flex-shrink: 0; padding: 0; transition: border-color 0.12s, transform 0.1s; }
.qb-color-dot:hover { transform: scale(1.2); }
.qb-color-dot.active { border-color: var(--accent) !important; box-shadow: 0 0 0 2px var(--accent); }
.quick-block-pill .btn.icon-square {
  width: 22px;
  min-width: 22px;
  height: 22px;
  font-size: 12px;
  padding: 0;
}
.field-error {
  font-size: 12px;
  color: var(--error);
}
.field-success {
  font-size: 12px;
  color: var(--success);
}

.btn {
  padding: 7px 14px;
  font-size: 13px;
  border: 1px solid var(--accent);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius);
  transition: all 150ms ease;
  font-weight: 500;
  min-height: 32px;
  box-shadow: none;
}
.btn:hover {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  box-shadow: none;
}
.btn:active {
  transform: scale(0.98);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.btn.reset-btn {
  border-color: #ba473a;
  color: #ba473a;
  background: transparent;
  font-weight: 600;
}
.btn.reset-btn:hover {
  box-shadow: 0 0 0 1px #ba473a;
  border-color: #ba473a;
  color: #ba473a;
}
.btn.reset-btn:disabled {
  opacity: 0.35;
  color: rgba(186, 71, 58, 0.55);
  border-color: rgba(186, 71, 58, 0.4);
  background: transparent;
}
.btn.ghost { background: transparent; border-style: dashed; border-color: var(--muted); color: var(--muted); box-shadow: none; }
.btn.ghost:hover {
  border-color: var(--accent);
  background: transparent;
  box-shadow: none;
  color: var(--accent);
}
.folder-btn { font-weight: 600; }
.folder-field .folder-btn { min-width: 38px; min-height: 32px; padding: 0; justify-content: center; }
#copy-btn.btn-primary, #copy-btn-top.btn-primary, #export-btn.btn-primary, #export-btn-top.btn-primary {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}
#copy-btn.btn-primary:hover, #copy-btn-top.btn-primary:hover, #export-btn.btn-primary:hover, #export-btn-top.btn-primary:hover {
  box-shadow: 0 0 0 1px var(--accent);
}
.pug-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 0;
}
.pug-actions .btn {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.pug-actions .btn:hover {
  border-color: var(--accent);
  background: transparent;
  box-shadow: 0 0 0 1px var(--accent);
}
.pug-actions .btn.danger {
  color: #ba473a;
  border: none;
  background: transparent;
}
.pug-actions .btn.danger:hover {
  border-color: #ba473a;
  box-shadow: 0 0 0 1px #ba473a;
  background: transparent;
}

.blocks-toolbar {
  display: flex;
  gap: 6px;
  padding: 6px 0 0;
}

.blocks-container {
  margin-top: 6px;
  border-top: none;
  padding-top: 0;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.block-card.flash {
  box-shadow: 0 0 0 2px var(--accent);
}

.segment-divider {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 2px 0;
}
.segment-divider::before,
.segment-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
  opacity: 0.4;
}
.segment-divider span {
  font-weight: 600;
  color: var(--muted);
}

.block-card {
  border: 1px solid color-mix(in srgb, var(--text) 18%, transparent);
  padding: 9px 10px 10px 14px;
  background: var(--panel);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: none;
  transition: background 140ms ease, box-shadow 200ms ease, border-color 140ms ease, transform 140ms ease;
  position: relative;
  flex: 0 0 auto;
}
.block-card:hover {
  border-color: color-mix(in srgb, var(--text) 30%, transparent);
}
.block-card.dragging {
  background: var(--pill);
  transform: scale(0.98);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  cursor: grabbing;
}
.block-card.dragging * { cursor: grabbing; }
.block-card.block-dragging {
  opacity: 0.4;
}
.block-card.block-drag-over {
  border-top: 3px solid var(--accent, #6b7280);
  margin-top: -3px;
}
.drag-handle {
  cursor: grab;
  opacity: 0.35;
  margin-right: 4px;
  user-select: none;
  font-size: 12px;
}
.drag-handle:hover { opacity: 0.7; }
.block-card.collapsed {
  padding: 8px 12px 8px 16px;
  min-height: 40px;
  overflow: hidden;
}
.block-card.collapsed .block-title { opacity: 0.92; }
.block-card.collapsed .block-header { margin-bottom: 0; }
.block-card::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 999px;
  background: transparent;
  opacity: 0.85;
}
.block-card.marker-female::before { background: #ba473a; }
.block-card.marker-male::before { background: #2a6cc6; }
.block-card.marker-common::before { background: #6b7b70; opacity: 0.4; }
.block-card.marker-center::before { background: #9ca3af; opacity: 0.6; }

.block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: -2px -4px 6px;
  gap: 6px;
  padding: 4px 8px;
  background: transparent;
  border-bottom: none;
  border-radius: 0;
}
.block-card.collapsed .block-header { margin: 0; }
.block-card.collapsed .block-header { border-bottom: none; }
.block-title { font-weight: 600; font-size: 12px; color: var(--text); display: flex; align-items: center; gap: 6px; letter-spacing: 0.01em; }
.block-num { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; border: 1px solid var(--panel-border); font-size: 10px; font-weight: 700; padding: 0 4px; color: var(--muted); flex-shrink: 0; }
.block-title.clickable { cursor: pointer; }
.template-override-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.template-custom-badge { font-size: 10px; font-weight: 600; color: #130F33; background: color-mix(in srgb, var(--accent-secondary) 40%, transparent); padding: 1px 5px; border-radius: 4px; flex-shrink: 0; }
.block-actions { display: inline-flex; align-items: center; gap: 3px; margin-left: auto; }

.collapse-btn {
  border: 1px solid var(--panel-border);
  background: var(--pill);
  color: var(--text);
  border-radius: var(--radius);
  width: 26px;
  height: 24px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 12px;
  transition: background 120ms ease, border-color 120ms ease;
}
.collapse-btn:hover { background: var(--bg-alt); border-color: var(--muted); }

.segment-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 0 3px;
  margin-right: 2px;
  border-radius: var(--radius);
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 700;
  font-size: 10px;
  line-height: 1.1;
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
}

.segment-switch { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; }
.segment-toggle {
  display: inline-flex;
  border: none;
  border-radius: var(--radius);
  overflow: visible;
  background: transparent;
  gap: 2px;
}
.segment-toggle button {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0 5px;
  height: 24px;
  min-width: 22px;
  font-size: 11px;
  cursor: pointer;
  line-height: 1.2;
  border-radius: var(--radius);
  transition: all 120ms ease;
}
.segment-toggle button:focus,
.segment-toggle button:focus-visible {
  outline: none;
  box-shadow: none;
  border-radius: var(--radius);
}
.segment-toggle button + button { border-left: none; }
.segment-toggle button.active {
  font-weight: 700;
  border-radius: var(--radius);
}
.segment-toggle button:nth-child(1).active { color: #4b4c46; border-color: #4b4c46; }
.segment-toggle button:nth-child(2).active { color: #ba473a; border-color: #ba473a; }
.segment-toggle button:nth-child(3).active { color: #2a6cc6; border-color: #2a6cc6; }
.segment-toggle.compact { transform: none; }

.block-actions button {
  margin-left: 2px;
  padding: 0 5px;
  height: 22px;
  min-height: 22px;
  font-size: 11px;
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 120ms ease;
}
.block-actions button:hover { background: rgba(107, 114, 128, 0.1); color: var(--text); border-color: var(--accent); }
.block-actions .segment-toggle button {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0 6px;
  height: 24px;
  min-width: 22px;
  font-size: 11px;
  border-radius: var(--radius);
}
.block-actions .segment-toggle button:hover { background: transparent; color: var(--text); }
.block-actions .segment-toggle button:focus,
.block-actions .segment-toggle button:focus-visible {
  outline: none;
  box-shadow: none;
  border-radius: var(--radius);
}
.block-actions .segment-toggle button:nth-child(1).active { background: transparent; color: #4b4c46; border-color: #4b4c46; border-radius: var(--radius); }
.block-actions .segment-toggle button:nth-child(2).active { background: transparent; color: #ba473a; border-color: #ba473a; border-radius: var(--radius); }
.block-actions .segment-toggle button:nth-child(3).active { background: transparent; color: #2a6cc6; border-color: #2a6cc6; border-radius: var(--radius); }
.block-actions .icon-btn {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  justify-content: center;
  align-items: center;
  padding: 0;
  border: none;
  background: transparent;
}
.block-actions .icon-btn svg { display: block; }
.block-actions .icon-btn.danger { color: #ba473a; }
.block-actions .icon-btn.danger:hover { background: rgba(186,71,58,0.18); color: #ba473a; }

.block-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 4px;
}
.block-summary {
  flex: 0 1 220px;
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 10px;
  color: var(--muted);
  opacity: 0.9;
}
.block-issues {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: auto;
}
.issue-badge {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid rgba(186, 71, 58, 0.35);
  color: #ba473a;
}

.drag-placeholder { height: 8px; margin: 8px 0; background: var(--drag); border-radius: 999px; }
.block-drag-handle { display: inline-flex; align-items: center; justify-content: center; width: 18px; cursor: grab; color: #9b9b97; user-select: none; }
.block-drag-handle:active { cursor: grabbing; }

.block-section-divider { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 4px 0 2px; border-top: 1px solid var(--border); margin-top: 4px; }
.block-section-divider:first-child { border-top: none; margin-top: 0; }
.section-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-actions-inline { display: inline-flex; gap: 4px; margin-left: auto; opacity: 0; transition: opacity 120ms ease; }
.block-card:hover .section-actions-inline { opacity: 0.35; }
.section-actions-inline:hover { opacity: 1; }

.block-body { font-size: 13px; display: grid; gap: 6px; }
.block-body label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.block-body input[type="checkbox"],
.block-body input[type="radio"],
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

.block-body input[type="text"],
.block-body input[type="number"],
.block-body textarea,
select.field-control {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  margin-top: 2px;
  border: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  background: var(--input-bg);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.block-body input[type="text"]:focus,
.block-body input[type="number"]:focus,
.block-body textarea:focus,
select.field-control:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--text) 25%, transparent);
  box-shadow: none;
}

.block-body textarea { min-height: 70px; resize: vertical; }
.block-body .singleline-textarea { min-height: 36px; height: 36px; resize: none; }
.block-body .inline { display: flex; align-items: center; gap: 10px; margin: 2px 0; }
.block-body .inline label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  font-size: 12px;
}
.spacing-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius);
  width: fit-content;
  background: transparent;
  margin-top: 0;
  line-height: 1;
  height: 32px;
}
.spacing-toggle {
  margin: 0;
  line-height: 1;
  height: 32px;
  width: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  padding: 0;
  cursor: pointer;
}
.spacing-control.active {
  border-color: var(--accent);
  box-shadow: none;
}
.spacing-control.active .spacing-toggle {
  color: var(--muted);
}
.spacing-value {
  width: 3ch;
  min-width: 3ch;
  max-width: 3ch;
  text-align: right;
  line-height: 1;
  height: 32px;
  display: inline-flex;
  align-items: center;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  color: var(--text);
  font-size: 12px;
  padding: 0;
  border-radius: 0;
}
.spacing-value:focus { outline: none; }
.spacing-value:disabled { opacity: 0.5; }
.block-body .inline .inline-number {
  width: 64px;
  min-width: 0;
  padding: 6px 8px;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(43,47,52,0.35);
  outline-offset: 2px;
}

.code-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 8px;
}
.code-panel-header > div:first-child { border-left: 3px solid var(--accent-secondary); padding-left: 10px; }
.code-panel-title { font-size: 18px; font-weight: 600; letter-spacing: 0.01em; }
.code-panel-subtitle { font-size: 12px; color: var(--muted); }
.code-panel-actions {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  align-items: center;
}
.actions-divider {
  width: 1px;
  height: 20px;
  background: var(--panel-border);
  margin: 0 4px;
  flex-shrink: 0;
}
.code-panel-actions .btn {
  font-size: 12px;
  padding: 5px 10px;
  min-height: 28px;
  border-style: solid;
  border-color: var(--panel-border);
  background: var(--pill);
}
.code-panel-actions .btn:hover {
  background: var(--pill);
  color: var(--accent);
  border-color: var(--accent);
}
.code-panel-actions .btn.toggled {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

textarea#pug-output,
textarea#html-output {
  width: 100%;
  margin-top: 6px;
  padding: 14px;
  font-family: "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  border: 1px solid var(--code-border);
  background: var(--code-bg);
  color: var(--text);
  resize: none;
  white-space: pre;
  min-height: 0;
  max-height: none;
  height: auto;
  overflow: auto;
  border-radius: var(--radius);
  box-shadow: none;
}

.preview-panel {
  width: min(100%, 600px);
  margin: 0 auto;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.preview-zoom-overlay {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  border-radius: 20px;
  padding: 4px 10px 4px 8px;
  z-index: 10;
  opacity: 0.35;
  transition: opacity 0.2s;
}
.preview-zoom-overlay:hover {
  opacity: 1;
}
.preview-zoom-overlay input[type="range"] {
  width: 80px;
  height: 3px;
  accent-color: #fff;
  cursor: pointer;
}
.preview-zoom-overlay span {
  font-size: 11px;
  color: #fff;
  min-width: 28px;
  font-variant-numeric: tabular-nums;
}
.preview-meta {
  font-size: 12px;
  color: var(--muted);
}
/* ── Нет в наличии ── */
.preview-warning {
  border: 1px solid #fca5a5;
  background: #fff5f5;
  border-radius: 0;
  margin-top: 6px;
  overflow: hidden;
}
.unavailable-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #b91c1c;
  gap: 6px;
}
.unavailable-header:hover {
  background: #fee2e2;
}
.unavailable-toggle {
  font-size: 11px;
  color: #b91c1c;
  opacity: 0.7;
  flex-shrink: 0;
}
.unavailable-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-top: 1px solid #fecaca;
  font-size: 12px;
  background: #ffffff;
}
.unavailable-item:hover {
  background: #fafafa;
}
.unavailable-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #111;
  font-weight: 500;
}
.unavailable-meta {
  color: #888;
  font-weight: 400;
}
.btn-xs {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 0;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Панель замен ── */
.suggest-panel {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 0;
  margin-top: 6px;
  max-height: 340px;
  overflow-y: auto;
}
.suggest-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 700;
  color: #111;
  border-bottom: 1px solid #e5e5e5;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.suggest-header .btn-xs {
  color: #888;
  border-color: #ddd;
  background: #f5f5f5;
  font-size: 14px;
  width: 26px;
  height: 26px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.suggest-search {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid #e5e5e5;
  background: #fafafa;
  position: sticky;
  top: 35px;
  z-index: 1;
}
.suggest-search input {
  flex: 1;
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid #ddd;
  border-radius: 0;
  background: #fff;
  color: #111;
  outline: none;
}
.suggest-search input:focus { border-color: #aaa; }
.suggest-loading, .suggest-empty {
  padding: 20px 12px;
  font-size: 12px;
  color: #aaa;
  text-align: center;
}
.suggest-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.1s;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover { background: #f7f7f7; }
.suggest-img {
  width: 48px;
  height: 58px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 0;
  background: #f5f5f5;
}
.suggest-info {
  flex: 1;
  min-width: 0;
}
.suggest-name {
  font-size: 12px;
  font-weight: 500;
  color: #111;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.suggest-price {
  font-size: 13px;
  font-weight: 700;
  color: #111;
  margin-top: 4px;
}
.suggest-id {
  font-size: 11px;
  color: #aaa;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Hover-попап ── */
.suggest-hover-popup {
  position: fixed; z-index: 9999; pointer-events: none;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.22); padding: 14px; display: flex; gap: 16px;
  max-width: 420px;
}
.suggest-hover-img { width: 220px; height: 280px; object-fit: contain; border-radius: 4px; flex-shrink: 0; background: var(--pill); }
.suggest-hover-info { display: flex; flex-direction: column; gap: 5px; min-width: 0; padding-top: 4px; }
.suggest-hover-name { font-size: 14px; font-weight: 600; line-height: 1.35; }
.suggest-hover-row { font-size: 12px; color: var(--muted); }
.suggest-hover-price { font-size: 18px; font-weight: 700; margin-top: 8px; }

.preview-empty {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
}

.email-preview-viewport {
  width: min(100%, 600px);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 8px;
  flex: 1;
  min-height: 200px;
  transition: border-color 0.6s ease;
}
.email-preview-viewport.preview-flash {
  border-color: var(--success);
  transition: border-color 0.1s ease;
}

.email-preview-scale-shell {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  max-width: 100%;
}

.email-preview-frame {
  display: block;
  border: 0;
  border-radius: 0;
  background: #fff;
  transform-origin: top left;
}

.copy-status { margin-top: 4px; font-size: 12px; color: var(--success); }
.code-collapsed-hint {
  border: 1px dashed var(--panel-border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel);
}

.footer-note { margin: 8px 0 16px; text-align: left; font-size: 11px; color: var(--muted); opacity: 0.85; }
.footer-link { color: var(--text); text-decoration: none; border-bottom: 1px dashed var(--muted); }
.footer-link:hover { color: var(--accent); }

@media (max-width: 1200px) {
  .workspace { padding: 0 20px 24px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .panel-right { max-width: 100%; }
}
@media (max-width: 900px) {
  .settings-two-col { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .notion-layout { flex-direction: column; }
  .control-panel {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--panel-border);
    border-radius: 0 0 12px 12px;
  }
  .workspace { padding-top: 20px; }
  .workspace-header { position: relative; }
  .field-control { min-width: 240px; }
}

.preset-list { display: grid; gap: 10px; }
.preset-card {
  border: 1px solid var(--line);
  background: var(--card);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-radius: var(--radius);
  box-shadow: none;
}
.preset-title { font-weight: 700; color: var(--text); letter-spacing: 0.01em; }
.preset-desc { font-size: 13px; color: var(--muted); }
.preset-fields { display: grid; gap: 10px; margin: 4px 0; }
.html-pug-fields {
  margin: 8px 0 10px;
}
.html-pug-fields .html-pug-label {
  display: block;
  font-weight: 100;
  font-size: 11px;
  color: var(--muted);
}
.html-pug-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.html-pug-path {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#html-pug-path {
  margin-top: 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding-left: 0;
  padding-right: 0;
}
#html-pug-path:focus {
  border-bottom-color: var(--accent);
  box-shadow: none;
}
#html-pug-preheader {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding-left: 0;
  padding-right: 0;
}
#html-pug-preheader:focus {
  border-bottom-color: var(--accent);
  box-shadow: none;
}
.html-pug-grow {
  flex: 1 1 auto;
}
.html-pug-actions {
  align-items: center;
  gap: 8px;
  padding: 0 4px;
}
.save-status {
  margin-top: 4px;
  font-size: 12px;
  color: var(--success);
}
.html-pug-actions .btn-inline-row {
  margin-top: 10;
}
.html-pug-actions .btn-inline {
  height: 26px;
  min-height: 26px;
  line-height: 1;
}
.html-pug-gender .btn-inline:hover {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}
.html-pug-copy.btn.icon-square.btn-textual {
  margin-left: auto;
  height: 26px;
  min-height: 26px;
  padding: 4px 8px;
  line-height: 1;
}
.html-pug-gender .btn-inline.female.active,
.html-pug-gender .btn-inline.female.active:hover {
  color: #ba473a;
  border-color: #ba473a;
}
.html-pug-gender .btn-inline.male.active,
.html-pug-gender .btn-inline.male.active:hover {
  color: #2a6cc6;
  border-color: #2a6cc6;
}
.autosave-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  margin-left: 6px;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.4s ease, background 0.4s ease, border-color 0.4s ease, transform 0.4s ease, box-shadow 0.4s ease;
}
.autosave-dot.active {
  opacity: 1;
  background: var(--success);
  border-color: var(--success);
  transform: scale(1);
  box-shadow: 0 0 6px rgba(107, 114, 128, 0.3);
}
.autosave-dot.error {
  opacity: 1;
  background: var(--error);
  border-color: var(--error);
  transform: scale(1);
  box-shadow: 0 0 6px rgba(224, 82, 82, 0.6);
}
.save-error-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--error);
  border: 1px solid var(--error);
  border-radius: 4px;
  padding: 0 6px;
  height: 22px;
  margin-left: 2px;
  white-space: nowrap;
}
.save-error-dismiss {
  background: none;
  border: none;
  color: var(--error);
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  opacity: 0.7;
}
.save-error-dismiss:hover {
  opacity: 1;
}
.preset-fields textarea {
  min-height: 70px;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  min-width: 320px;
  width: 100%;
  border-radius: 1px;
}
.note-textarea {
  width: 100%;
  min-width: 0;
  resize: none;
  overflow: hidden;
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 0;
  outline: none;
}
.preset-fields textarea.note-textarea {
  border: none;
  background: transparent;
  box-shadow: none;
  outline: none;
}
.preset-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.preset-row label { width: 100%; }
.preset-advanced { margin-top: 6px; }

.custom-presets { display: grid; gap: 8px; }
.custom-preset-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.custom-preset-name { font-weight: 600; color: var(--text); }
.custom-preset-actions button { margin-left: 6px; }

.btn-inline {
  margin-top: 2px;
  padding: 4px 8px;
  font-size: 11px;
  border: 1px solid var(--line);
  background: var(--pill);
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  width: auto;
  align-self: flex-start;
  justify-self: flex-start;
  grid-column: auto;
  max-width: 80px;
}
.btn-inline:hover {
  background: #2f8f55;
  border-color: #2f8f55;
  color: var(--accent-contrast);
}
.btn-inline.active {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.btn-inline.active:hover {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.btn-inline.push-right { margin-left: auto; }
.btn-inline-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.btn-inline.vk-btn {
  box-sizing: border-box;
  height: 34px;
  padding: 0 4px;
  min-width: 24px;
  background: transparent;
  border: none;
  line-height: 1;
}
.btn-inline.vk-btn:hover {
  background: transparent;
  border: none;
  color: var(--text);
}
.btn-inline.vk-btn.active,
.btn-inline.vk-btn.active:hover {
  background: transparent;
  border: none;
  color: var(--accent);
}

.advanced-wrapper { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
.btn-advanced-toggle {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 11px;
  padding: 0;
  cursor: pointer;
  text-decoration: underline dotted;
  margin-bottom: 4px;
}
.btn-advanced-toggle.is-open { color: var(--text); }
.advanced-panel label { margin-bottom: 6px; font-size: 11px; }

.block-preview {
  margin: 6px auto 10px;
  padding: 10px;
  border: 1px dashed var(--line);
  background: var(--card);
  color: var(--text);
  min-height: 40px;
  width: 540px;
  max-width: 100%;
  text-align: center;
}
.paragraph-textarea {
  font-size: 18px;
  line-height: 27px;
  font-family: Helvetica, Arial, sans-serif;
}
.paragraph-preview {
  font-size: 18px;
  line-height: 27px;
  font-family: Helvetica, Arial, sans-serif;
}

.theme-light textarea#pug-output,
.theme-light textarea#html-output,
.theme-light .field-control,
.theme-light .preset-fields textarea,
.theme-light .block-body input[type="text"],
.theme-light .block-body input[type="number"],
.theme-light .block-body textarea { background: var(--input-bg); color: var(--text); }
.block-card:focus-within { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 0.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.icon-img {
  width: 16px;
  height: 16px;
  display: block;
  opacity: 0.7;
}
body.theme-dark .icon-img {
  filter: invert(1);
}
.btn:hover .icon-img {
  filter: invert(1);
}
body.theme-dark .btn:hover .icon-img {
  filter: invert(0);
}
.icon-svg {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-svg svg {
  width: 16px;
  height: 16px;
  display: block;
}
.icon-svg.accent {
  color: var(--accent);
}

/* Brand tweaks */
.brand { display: flex; flex-direction: column; gap: 6px; position: relative; }
.brand-button {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.brand-button:focus-visible {
  outline: 2px solid rgba(43,47,52,0.35);
  outline-offset: 2px;
  border-radius: var(--radius);
}
.brand-mark { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: 0.02em; color: var(--project-accent, var(--text)); }
.brand-sub { margin: 0; font-size: 18px; font-weight: 500; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.brand-sub::before { content: '✦'; color: var(--accent-secondary); font-size: 14px; }
.brand-logo {
  width: 128px;
  height: auto;
  max-height: 56px;
  object-fit: contain;
  filter: drop-shadow(0 0 0 transparent);
}
.brand-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  display: grid;
  gap: 4px;
  min-width: 180px;
  padding: 6px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 12px 28px rgba(0,0,0,0.12);
  z-index: 30;
}
.brand-menu-item {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.brand-menu-item:hover {
  background: var(--pill);
}
.brand-menu-item.selected {
  border-color: var(--accent);
  color: var(--accent);
}

.preset-create,
.add-block {
  display: grid;
  gap: 6px;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  width: 100%;
}

.link-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.link-input {
  min-width: 160px;
}

.text-preview {
  margin-top: 6px;
}

.text-preview-frame {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  padding: 10px;
  color: var(--text);
  max-width: 600px;
}

textarea.code {
  width: 100%;
  min-height: 300px;
  resize: vertical;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px;
  font-family: "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.block-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
  align-items: center;
  width: 100%;
}

.btn.icon-square.active {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-eye {
  width: 16px;
  height: 16px;
  display: block;
}

.add-inline {
  min-width: 220px;
}

/* Weight + spacing tweaks */
.block-footer { gap: 8px; }
.block-footer .product-options-inline {
  margin: 0;
  margin-right: auto;
  align-items: center;
}
.btn { font-weight: 500; }
.panel-title,
.workspace-title,
.block-title,
.sidebar-title,
label,
.brand-mark,
.workspace-label {
  font-weight: 500;
}

.panel.panel-right {
  position: sticky;
  top: 80px;
  height: calc(100vh - 100px);
  align-self: start;
  display: flex;
  flex-direction: column;
}

#pug-output,
#html-output {
  width: 100%;
  flex: 1 1 auto;
  height: 100%;
}

.quick-edit-popup {
  position: fixed;
  z-index: 1200;
  width: 340px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.28);
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quick-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.quick-edit-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quick-edit-close {
  flex: 0 0 auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
}
.quick-edit-close:hover { color: var(--text); }
.quick-edit-textarea {
  width: 100%;
  resize: vertical;
  min-height: 64px;
  padding: 8px 10px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.5;
}

.linebreak-preview {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.linebreak-label {
  display: block;
  margin-bottom: 4px;
}

.linebreak-content {
  background: var(--code-bg);
  border: 1px dashed var(--code-border);
  border-radius: var(--radius);
  padding: 6px 8px;
  color: var(--text);
  font-family: "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}

.linebreak-content .newline {
  display: inline-block;
  padding: 0 4px;
  margin: 0 2px;
  border-radius: 4px;
  background: rgba(226, 75, 91, 0.2);
  color: #e24b5b;
}

/* Search in letters list */
.search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  border: none;
  border-bottom: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  outline: none;
  margin-bottom: 8px;
}
.search-input::placeholder {
  color: var(--muted);
}

/* History dropdown */
.history-dropdown {
  width: 100%;
  margin-top: 8px;
  border-top: 1px solid var(--panel-border);
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.history-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 5px 8px;
  background: none;
  border: none;
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.history-item:hover {
  background: var(--hover);
}
.history-item.muted {
  color: var(--muted);
  cursor: default;
}
.history-item.muted:hover {
  background: none;
}

/* Startup modal */
.startup-letters-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
  max-height: 280px;
  overflow-y: auto;
}
.startup-letter-btn {
  text-align: left;
  justify-content: flex-start;
}
.startup-last-letter-btn {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  font-weight: 600;
}
.startup-plan-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}
.startup-plan-btn {
  text-align: left;
  justify-content: flex-start;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.startup-plan-date { font-size: 12px; color: var(--muted); white-space: nowrap; min-width: 70px; }
.startup-plan-subject { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.startup-plan-status { font-size: 10px; padding: 1px 6px; border: 1px solid var(--panel-border); white-space: nowrap; }
.startup-plan-overdue { color: var(--error); }
.startup-plan-overdue .startup-plan-date { color: var(--error); font-weight: 600; }
.modal-divider {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 8px 0;
}

/* === Plan page === */
.plan-page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: start;
  width: 100%;
  min-width: 0;
}
.plan-list-panel { padding: 0; background: transparent; border: none; box-shadow: none; min-width: 0; }
.plan-cal-panel {
  position: sticky; top: 16px;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: var(--radius); overflow: hidden; padding: 16px;
}

.plan-cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.plan-cal-title { font-size: 13px; font-weight: 600; color: var(--text); text-align: center; flex: 1; }

.plan-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.plan-cal-dow {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); text-align: center; padding: 4px 0 6px;
}
.plan-cal-day {
  display: flex; flex-direction: column; align-items: center;
  padding: 5px 2px 4px; border-radius: 7px; cursor: default;
  transition: background 0.12s; min-height: 36px;
}
.plan-cal-has { cursor: pointer; }
.plan-cal-has:hover { background: var(--bg-alt); }
.plan-cal-num { font-size: 12px; font-weight: 500; color: var(--text); line-height: 1; }
.plan-cal-other .plan-cal-num { color: var(--muted); opacity: 0.4; }
.plan-cal-today .plan-cal-num {
  background: var(--accent); color: var(--accent-contrast);
  border-radius: 50%; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.plan-cal-selected { background: var(--bg-alt); outline: 1.5px solid var(--accent); outline-offset: -1px; }
.plan-cal-dots { display: flex; gap: 2px; margin-top: 3px; flex-wrap: wrap; justify-content: center; }
.plan-cal-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--muted); flex-shrink: 0;
}
.plan-cal-dot.plan-dot-done { background: var(--success); }
.plan-cal-dot.plan-dot-queue { background: var(--accent); }
.plan-cal-dot.plan-dot-wip { background: #e09020; }

.plan-state { padding: 32px 0; color: var(--muted); font-size: 14px; }
.plan-state-error { color: var(--error); }
.plan-loaded-at { font-size: 12px; color: var(--muted); }
.plan-warnings { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.plan-warning { font-size: 12px; color: #e09020; background: color-mix(in srgb, #e09020 8%, transparent); border: 1px solid color-mix(in srgb, #e09020 25%, transparent); border-radius: var(--radius); padding: 6px 10px; }

.plan-periods { display: flex; flex-direction: column; gap: 24px; padding: 4px 0 12px; }

.plan-period { display: flex; flex-direction: column; gap: 0; }
.plan-period-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); padding: 0 4px 8px;
}
.plan-period-urgent .plan-period-label { color: var(--error); }
.plan-period-warn .plan-period-label { color: #e09020; }
.plan-period-error .plan-period-label { color: var(--error); opacity: 0.7; }

.plan-period .plan-groups { gap: 8px; padding: 0; }

.plan-group { border: 1px solid var(--panel-border); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.plan-period-urgent .plan-group { border-left: 3px solid var(--error); }
.plan-period-warn .plan-group { border-left: 3px solid #e09020; }
.plan-period-error .plan-group { opacity: 0.55; }
.plan-group-selected { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 1px; }

.plan-day-header {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px 9px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--bg-alt);
}
.plan-day-num { font-size: 22px; font-weight: 700; line-height: 1; color: var(--text); width: 28px; flex-shrink: 0; }
.plan-day-label { display: flex; flex-direction: column; flex: 1; }
.plan-day-month { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.2; }
.plan-day-dow { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-top: 1px; }
.plan-group-count {
  font-size: 11px; font-weight: 700; color: var(--accent-contrast);
  background: var(--accent); border-radius: 20px; padding: 1px 7px; line-height: 1.6; flex-shrink: 0;
}

.plan-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px;
  border-bottom: 1px solid var(--panel-border);
  transition: background 0.12s;
}
.plan-item:last-child { border-bottom: none; }
.plan-item:hover { background: var(--bg-alt); }
.plan-item:hover .plan-item-btn { opacity: 1; }
.plan-item-selected { background: color-mix(in srgb, var(--accent) 8%, transparent) !important; }

.plan-proj-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); background: var(--bg-alt); border: 1px solid var(--panel-border);
  border-radius: 5px; padding: 2px 6px; white-space: nowrap; flex-shrink: 0;
}

.plan-item-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: var(--panel-border);
}
.plan-item-dot.plan-dot-done { background: var(--success); }
.plan-item-dot.plan-dot-queue { background: var(--accent); }
.plan-item-dot.plan-dot-wip { background: #e09020; }

.plan-item-content { flex: 1; min-width: 0; }
.plan-item-subject { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); line-height: 1.3; }
.plan-item-meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; min-width: 0; }
.plan-item-status { font-size: 11px; font-weight: 500; white-space: nowrap; flex-shrink: 0; color: var(--muted); }
.plan-item-status.plan-dot-done { color: var(--success); }
.plan-item-status.plan-dot-queue { color: var(--accent); }
.plan-item-status.plan-dot-wip { color: #e09020; }
.plan-status-editable { cursor: pointer; border-bottom: 1px dashed currentColor; transition: opacity 0.12s; }
.plan-status-editable:hover { opacity: 0.7; }
.plan-status-empty { font-size: 11px; color: var(--muted); cursor: pointer; opacity: 0.45; border-bottom: 1px dashed var(--muted); flex-shrink: 0; }
.plan-status-empty:hover { opacity: 0.8; }
.plan-status-select {
  font-size: 11px; font-weight: 500; color: var(--text);
  background: var(--input-bg); border: 1px solid var(--accent);
  border-radius: 5px; padding: 1px 4px; outline: none; cursor: pointer;
  max-width: 200px; flex-shrink: 0;
}
.plan-item-sep { color: var(--panel-border); font-size: 12px; flex-shrink: 0; }
.plan-item-preheader { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.plan-item-btn {
  flex-shrink: 0; padding: 6px 12px; font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--panel-border); border-radius: var(--radius);
  background: transparent; color: var(--muted); cursor: pointer;
  transition: border-color 0.15s, color 0.15s; white-space: nowrap;
  opacity: 0;
}
.plan-item-btn:hover { border-color: var(--accent); color: var(--accent); }

.plan-extra-link { font-size: 11px; color: var(--accent); text-decoration: none; white-space: nowrap; opacity: 0.7; flex-shrink: 0; }
.plan-extra-link:hover { opacity: 1; text-decoration: underline; }
.plan-item-extra { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.plan-extra-tag { font-size: 10px; background: var(--pill); padding: 1px 5px; border-radius: 4px; color: var(--muted); white-space: nowrap; }
.plan-extra-tag.plan-extra-highlight { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--text); font-weight: 600; }

/* --- Stats page --- */
.stats-page { padding: 0 16px 24px; }
.stats-month { margin-bottom: 24px; }
.stats-month-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.stats-month-label { font-size: 15px; font-weight: 600; text-transform: capitalize; }
.stats-month-total { font-size: 12px; color: var(--muted); }
.stats-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stats-table th { text-align: left; font-weight: 600; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.stats-table td { padding: 6px 8px; border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent); }
.stats-project { font-weight: 500; white-space: nowrap; }
.stats-letter { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-tag { font-size: 11px; color: var(--muted); }
.stats-time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.stats-status { font-size: 11px; color: var(--muted); }

.field-control.inline-col { width: 48px; min-width: 48px; text-align: center; text-transform: uppercase; }

/* --- Image upload field --- */
.ids-input { max-width: 260px; }
.image-upload-row { display: flex; align-items: center; gap: 6px; }
.image-upload-row input[type="text"] { flex: 1; min-width: 0; }
.image-upload-btn { cursor: pointer; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.image-upload-btn svg { display: block; }
.image-upload-status { font-size: 11px; color: var(--accent); white-space: nowrap; flex-shrink: 0; }
.image-upload-row.image-drag-over { outline: 2px dashed var(--accent); outline-offset: 2px; background: color-mix(in srgb, var(--accent) 6%, transparent); border-radius: var(--radius); }
.image-preview-thumb { margin-top: 4px; max-width: 200px; max-height: 120px; border: 1px solid var(--panel-border); border-radius: var(--radius); object-fit: contain; display: block; }

/* Link check panel */
.feed-diff-list { font-size: 12px; }
.feed-diff-item { display: flex; gap: 8px; padding: 2px 0; }
.feed-diff-id { color: var(--accent); font-weight: 600; min-width: 60px; }
.feed-diff-name { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-check-panel { max-height: 200px; overflow-y: auto; font-size: 11px; border-bottom: 1px solid var(--line); padding: 6px 8px; background: var(--panel); }
.link-check-item { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.link-check-item.link-ok .link-status { color: var(--success); }
.link-check-item.link-error .link-status { color: var(--error); font-weight: 600; }
.link-status { min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; }
.link-url { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.link-url:hover { text-decoration: underline; }
.link-redirect { color: var(--muted); font-style: italic; flex-shrink: 0; }
.link-error-msg { color: var(--error); flex-shrink: 0; }

/* Block dropdown */
.block-dropdown { position: relative; }
.block-dropdown-trigger { cursor: pointer; text-align: left; color: var(--muted); width: 100%; }
.block-dropdown-menu {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15); max-height: 400px; overflow: hidden;
  display: flex; flex-direction: column; margin-top: 4px;
}
.block-dropdown-search { border: none; border-bottom: 1px solid var(--line); border-radius: 0; margin: 0; }
.block-dropdown-list { overflow-y: auto; flex: 1; }
.block-dropdown-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line); transition: background 0.1s; }
.block-dropdown-item:last-child { border-bottom: none; }
.block-dropdown-item:hover { background: var(--bg-alt); }
.block-dropdown-item-header { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.block-dropdown-item-name { font-weight: 600; font-size: 12px; }
.block-type-tag { font-size: 9px; padding: 1px 5px; border-radius: 3px; background: var(--pill); color: var(--muted); border: 1px solid var(--pill-border); white-space: nowrap; }
.block-type-tag.custom { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 20%, transparent); }
.block-dropdown-preview { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 10px; color: var(--muted); margin: 0; white-space: pre; overflow: hidden; max-height: 42px; line-height: 14px; }

/* Toast notifications */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 10000; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; background: var(--accent); color: var(--accent-contrast); border: 1px solid var(--accent); font-size: 13px; line-height: 1.4; white-space: pre-line; box-shadow: 0 4px 20px rgba(0,0,0,0.2); animation: toast-in 0.3s ease; }
.toast-plan { background: var(--accent); border-color: var(--accent-secondary); border-left: 3px solid var(--accent-secondary); }
.toast-text { flex: 1; }
.toast-close { flex-shrink: 0; background: none; border: none; color: inherit; opacity: 0.6; cursor: pointer; font-size: 18px; line-height: 1; padding: 0; margin: -2px 0 0 0; }
.toast-close:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }

/* === Gender segments === */
.block-card.segment-female { border-left: 3px solid #d63031; }
.block-card.segment-male { border-left: 3px solid #0984e3; }
.block-card.segment-common { border-left: 3px solid color-mix(in srgb, var(--text) 15%, transparent); }

.segment-toggle { display: flex; gap: 1px; margin-right: 6px; }
.seg-btn { padding: 1px 5px; font-size: 10px; font-weight: 700; border: 1px solid var(--line); border-radius: 3px; background: transparent; color: var(--text-muted); cursor: pointer; line-height: 1.4; min-width: 20px; text-align: center; }
.seg-btn:hover { background: var(--hover); }
.seg-btn.active { background: var(--bg-secondary); color: var(--text); border-color: var(--text-muted); }
.seg-btn.seg-f.active { background: #d63031; color: #fff; border-color: #d63031; }
.seg-btn.seg-m.active { background: #0984e3; color: #fff; border-color: #0984e3; }
.seg-btn.seg-axis.active { background: #6c5ce7; color: #fff; border-color: #6c5ce7; }
.seg-btn.seg-cert.active { background: #AAC8C8; color: #130F33; border-color: #AAC8C8; }
.block-card.segment-certificate { border-left: 3px solid #AAC8C8; }

.gender-controls { display: flex; align-items: center; gap: 4px; }
.sidebar-gender-controls { padding: 2px 0 6px; }
.gender-btn { padding: 3px 10px; font-size: 12px; font-weight: 700; border-radius: 0; }
.gender-btn.active { opacity: 1; }
.gender-btn:not(.active) { opacity: 0.4; }
.gender-flip-btn { padding: 3px 8px; font-size: 14px; }

/* === ID Pool === */
.id-pool-panel { padding: 8px; border-bottom: 1px solid var(--line); }
.id-pool-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.id-pool-title { font-weight: 600; font-size: 12px; }
.id-pool-count { font-size: 11px; color: var(--text-muted); }
.id-pool-actions { display: flex; gap: 4px; }
.id-pool-textarea { width: 100%; min-height: 50px; font-size: 11px; resize: vertical; }
.id-pool-chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.id-chip { display: inline-block; padding: 2px 6px; font-size: 10px; border-radius: 3px; background: var(--bg-secondary); border: 1px solid var(--line); font-family: monospace; }
.id-chip.used { background: var(--accent); color: #fff; border-color: var(--accent); opacity: 0.7; }

/* === Image auto-numbering === */
.image-auto-num { font-size: 10px; color: var(--accent); font-weight: 600; margin-left: 4px; }


/* === Сертификат === */
.cert-toggle { padding: 4px 0 2px; }
.cert-toggle-label { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; cursor: pointer; }
.cert-settings-add { display: flex; gap: 6px; margin-bottom: 12px; }
.cert-block-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.cert-block-item { border: 1px solid var(--panel-border); border-radius: var(--radius); overflow: hidden; }
.cert-block-item.qb-drag-over { border-color: var(--accent); }
.cert-block-item.qb-dragging { opacity: 0.4; }
.cert-block-header { display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: var(--bg-alt); }
.cert-block-name { flex: 1; font-size: 12px; font-weight: 600; }
.cert-block-fields { padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.cert-field-label { font-size: 11px; color: var(--muted); margin-bottom: -2px; }

/* === Cert editor banner === */
.cert-editor-banner { background: #AAC8C8; color: #130F33; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-radius: var(--radius); margin: 0 0 12px 0; font-size: 13px; font-weight: 700; width: 100%; }
.cert-editor-actions { display: flex; gap: 6px; }
.cert-block-summary { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.cert-block-chip { background: var(--bg-alt); border: 1px solid var(--panel-border); border-radius: 4px; padding: 3px 8px; font-size: 12px; }
