 /* =========================================================================
   Propal — A4 Proposal Maker
   ========================================================================= */

:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --toolbar-h: 56px;
  --panel-w: 240px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 16px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

/* Respect the HTML hidden attribute even when a class sets display. */
[hidden] {
  display: none !important;
}

/* Busy / progress overlay (shown during long-running actions). */
.busy-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}
.busy-card {
  background: #fff;
  border-radius: 14px;
  padding: 28px 34px;
  min-width: 300px;
  max-width: 430px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
.busy-spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto 14px;
  border: 4px solid #e5e7eb;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: busy-spin 0.8s linear infinite;
}
@keyframes busy-spin { to { transform: rotate(360deg); } }
.busy-title { font-weight: 600; font-size: 15px; color: #111827; }
.busy-status { font-size: 13px; color: #6b7280; margin-top: 4px; min-height: 18px; }
.busy-bar { margin-top: 14px; height: 6px; background: #eef2ff; border-radius: 999px; overflow: hidden; }
.busy-bar-fill {
  height: 100%;
  width: 40%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
  animation: busy-slide 1.2s ease-in-out infinite;
}
@keyframes busy-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

/* API / integration status rows (Settings) */
.api-status-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 14px; }
.api-status-summary { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 10px 12px; background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 10px; margin-bottom: 12px; }
.api-status-label { font-size: 12px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: .04em; }
.pill { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: #eef2ff; color: #4f46e5; white-space: nowrap; }

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

h1,
h2,
h3 {
  margin: 0 0 8px;
  line-height: 1.2;
}

p {
  margin: 0 0 8px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.center {
  text-align: center;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-ghost:hover {
  background: #f9fafb;
}

.btn-danger {
  color: var(--danger);
}

.btn-danger:hover {
  background: #fef2f2;
  border-color: #fca5a5;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.active {
  background: #eef2ff;
  border-color: var(--primary);
  color: var(--primary);
}

/* ---------- Topbar ---------- */
.topbar {
  min-height: 60px;
  height: auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.brand-sm {
  font-size: 15px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-icon { padding: 6px 10px; }
.nav-badge {
  position: absolute;
  top: -2px;
  right: -6px;
  background: #dc2626;
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  padding: 1px 5px;
}
.nav-menu form { margin: 0; }
.nav-logout {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: none;
  background: none;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}
.nav-logout:hover { background: #f3f4f6; }

.topbar-user {
  font-size: 14px;
  color: var(--muted);
}

.logout-form {
  display: inline-flex;
  margin: 0;
}

/* Accessibility: visible focus + skip link */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--primary, #4f46e5);
  outline-offset: 2px;
}
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 3001;
  background: var(--primary, #4f46e5);
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
}
.skip-link:focus { left: 8px; top: 8px; }

.impersonation-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  color: #92400e;
  padding: 8px 16px;
  font-size: 13px;
}

/* Grouped navigation dropdowns */
.nav-group { position: relative; }
.nav-toggle { cursor: pointer; }
.nav-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 190px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
  padding: 6px;
  z-index: 200;
}
.nav-group:hover .nav-menu,
.nav-group:focus-within .nav-menu { display: block; }
.nav-menu a {
  display: block;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.nav-menu a:hover { background: #f3f4f6; }

/* AI prompt character meter */
.ai-meter { font-size: 12px; color: var(--muted); text-align: right; margin: 4px 0 12px; font-variant-numeric: tabular-nums; }
.ai-meter.warn { color: #b45309; font-weight: 600; }
.ai-meter.over { color: var(--danger); font-weight: 700; }

/* ---------- Activity log viewer ---------- */
.act-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}

.act-filters .field {
  margin: 0;
}

.act-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
}

.act-table th,
.act-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-strong);
  font-size: 14px;
  vertical-align: top;
}

.act-table th {
  background: #f9fafb;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.act-table tbody tr:last-child td {
  border-bottom: none;
}

.act-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #eef2ff;
  color: #4338ca;
  white-space: nowrap;
}

.act-note {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.act-pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

/* ---------- Page shell (top-level pages layout wrapper) ---------- */
.page-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.auth-card h1 {
  font-size: 22px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span {
  font-size: 13px;
  font-weight: 600;
}

.input,
input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
}

.input:focus,
input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.alert {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 14px;
}

.alert-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* ---------- Dashboard ---------- */
.dash-head {
  margin-bottom: 20px;
}

.dash-head h1 {
  font-size: 26px;
}

.create-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 24px;
}

.create-card h2 {
  font-size: 17px;
  margin-bottom: 12px;
}

.create-form {
  display: flex;
  gap: 10px;
}

.create-form .input {
  flex: 1;
}

.proposal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 0;
}

.proposal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.proposal-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e5e7eb;
  height: 200px;
  padding: 10px;
  overflow: hidden;
}

/* Real first-page thumbnail (scaled read-only render) */
.thumb-scale {
  position: relative;
  flex-shrink: 0;
  width: 142px;
  height: 200px;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.page-mini {
  position: absolute;
  top: 0;
  left: 0;
  width: 794px;
  height: 1123px;
  transform: scale(0.1788);
  transform-origin: top left;
  box-shadow: none;
}

.thumb-scale .el {
  position: absolute;
}

.thumb-scale .el-text .text-content {
  width: 100%;
  height: 100%;
  white-space: pre-wrap;
  overflow: hidden;
  word-break: break-word;
}

.thumb-scale .el-image img {
  display: block;
}

.rename-target {
  cursor: text;
  border-bottom: 1px dashed transparent;
}

.rename-target:hover {
  border-bottom-color: var(--border-strong);
}

.rename-input {
  width: 100%;
  font-size: 15px;
  font-weight: 600;
}

.dash-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.dash-search {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 220px;
  max-width: 420px;
}

.dash-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dash-sort {
  width: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.proposal-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.proposal-title {
  font-size: 15px;
  margin: 0;
}

.proposal-title a {
  color: var(--text);
}

.proposal-title a:hover {
  color: var(--primary);
}

.proposal-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
}

.proposal-actions form {
  margin: 0;
}

/* =========================================================================
   Editor
   ========================================================================= */

.editor-body {
  height: 100vh;
  overflow: hidden;
  background: #e5e7eb;
}

.editor-app {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr 300px;
  grid-template-rows: var(--toolbar-h) 1fr auto;
  grid-template-areas:
    "toolbar toolbar toolbar"
    "palette canvas inspector"
    "pages pages pages";
  height: 100vh;
}

/* Toolbar */
.toolbar {
  grid-area: toolbar;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  z-index: 30;
}

.doc-title-input {
  flex: 1;
  max-width: 420px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 16px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--text);
}

.doc-title-input:hover {
  background: #f3f4f6;
}

.doc-title-input:focus {
  border-color: var(--primary);
  background: #fff;
  outline: none;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-strong);
  margin: 0 4px;
}

.save-status {
  font-size: 12px;
  color: var(--muted);
  min-width: 90px;
  text-align: right;
}

.grid-size {
  padding: 5px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.save-status.saving {
  color: #b45309;
}

.save-status.saved {
  color: #15803d;
}

.save-status.error {
  color: var(--danger);
}

/* Palette */
.palette {
  grid-area: palette;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  scrollbar-width: thin;
}

.palette-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: background 0.12s, border-color 0.12s;
}

.palette-btn:hover {
  background: #f3f4f6;
  border-color: var(--border-strong);
}

.palette-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  font-weight: 700;
  font-family: Georgia, serif;
  flex-shrink: 0;
}

.rect-icon {
  width: 18px;
  height: 14px;
  border: 2px solid currentColor;
  margin-left: 4px;
}

.ellipse-icon {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 50%;
  margin-left: 4px;
}

.line-icon {
  width: 20px;
  height: 2px;
  background: currentColor;
  margin-left: 3px;
}

/* Palette tabs (Elements / Libraries) */
.palette-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 3px;
  border-radius: 9px;
  flex-shrink: 0;
}

.palette-tab {
  flex: 1;
  padding: 7px 6px;
  border: none;
  border-radius: 7px;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
}

.palette-tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.palette-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  min-width: 0;
  scrollbar-width: thin;
}

/* Libraries */
.lib-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  flex-shrink: 0;
}

.lib-tab {
  padding: 7px 6px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
  text-align: center;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: anywhere;
  min-width: 0;
}

.lib-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* When the last tab is odd (e.g. the 7th of 7), let it span the full row. */
.lib-tab:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.lib-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  padding-bottom: 20px;
  scrollbar-width: thin;
}

.lib-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s, background 0.12s;
  min-width: 0;
  overflow: hidden;
}

.lib-item:hover {
  border-color: var(--primary);
  background: #f8fafc;
}

.lib-item svg {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.lib-item .lib-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  object-fit: cover;
  background: #f1f5f9;
  overflow: hidden;
}

.lib-item .lib-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lib-item .lib-label {
  font-size: 10.5px;
  line-height: 1.15;
  color: var(--muted);
  font-weight: 600;
  word-break: break-word;
}

/* Image frame shape previews (Frames library) */
.lib-item .frame-preview {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  box-sizing: border-box;
  background: #f1f5f9;
  border-radius: 6px;
}
.lib-item .frame-preview i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #6366f1, #a855f7);
}

/* Empty image frame placeholder shown until an image is dropped in */
.frame-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  box-sizing: border-box;
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(241, 245, 249, 0.65);
  pointer-events: none;
}

/* Library item spans multiple columns (layouts/thumbnails) */
.lib-item-wide {
  grid-column: span 3;
  flex-direction: row;
  justify-content: flex-start;
  gap: 10px;
  text-align: left;
  padding: 10px;
}

.lib-item-wide .lib-thumb {
  width: 74px;
  aspect-ratio: 4 / 3;
}

.lib-item-wide .lib-label {
  font-size: 12px;
  color: var(--text);
}

.lib-item-wide .lib-sub {
  font-size: 10px;
  color: var(--muted);
}

.brand-panel {
  grid-column: span 3;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 4px;
}

.brand-colors {
  display: flex;
  gap: 8px;
}

.brand-colors input[type="color"] {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: none;
  cursor: pointer;
}

/* Brand templates & AI draft */
.brand-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.brand-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  align-items: flex-start;
}

.brand-card:hover {
  border-color: var(--primary);
  background: #f8fafc;
}

.brand-card-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.5px;
}

.brand-card-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.brand-card-swatches {
  display: flex;
  gap: 3px;
}

.brand-card-swatches i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: block;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.brand-hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

.brand-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.brand-field input[type="text"],
.brand-field select {
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
}

.brand-field input[type="color"] {
  align-self: flex-start;
  width: 44px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: none;
  cursor: pointer;
}

.brand-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* AI draft dialog */
.ai-card {
  width: min(560px, calc(100vw - 40px));
}

.ai-card textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 110px;
}

.ai-field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin: 12px 0 5px;
}

.ai-card select {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  box-sizing: border-box;
}

.ai-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  margin-top: 12px;
  cursor: pointer;
}

/* ---------- Settings page ---------- */
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.settings-card h2 {
  font-size: 17px;
  margin: 0 0 10px;
}

.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}

.field em.muted {
  font-style: normal;
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
}

.settings-actions {
  display: flex;
  gap: 10px;
}

.alert-success {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.test-result {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  color: var(--muted);
}

.test-result.test-ok {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}

.test-result.test-error {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

/* ---------- Rotate / flip inspector actions ---------- */
.inspector-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.inspector-actions .btn {
  flex: 1 1 40px;
  padding: 6px 8px;
  font-size: 14px;
}

/* ---------- Image drag-and-drop overlay ---------- */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 6000;
  pointer-events: none;
  background: rgba(37, 99, 235, 0.08);
  border: 3px dashed var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
}

.drop-overlay.active {
  opacity: 1;
  visibility: visible;
}

.drop-overlay > div {
  background: #0f172a;
  color: #fff;
  padding: 14px 22px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
}

/* ---------- Instant hover tooltips for header buttons ---------- */
.toolbar [data-tooltip] {
  position: relative;
}

.toolbar [data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease;
  z-index: 5000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.toolbar [data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
}

/* ---------- Collapsible side panels ---------- */
.editor-app.palette-collapsed {
  grid-template-columns: 0 1fr 300px;
}

.editor-app.palette-collapsed .palette {
  padding: 0;
  border-right: none;
  overflow: hidden;
}

.editor-app.inspector-collapsed {
  grid-template-columns: var(--panel-w) 1fr 0;
}

.editor-app.inspector-collapsed .inspector {
  padding: 0;
  border-left: none;
  overflow: hidden;
}

.editor-app.palette-collapsed.inspector-collapsed {
  grid-template-columns: 0 1fr 0;
}

/* ---------- Image gallery: larger thumbnails + visible names ---------- */
.lib-grid.lib-grid-images {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.lib-grid-images .lib-item {
  padding: 8px;
  justify-content: flex-start;
}

/* Show each image at its natural (proportionate) aspect ratio — boxes in a
   row are allowed to differ in height. */
.lib-grid-images .lib-thumb {
  aspect-ratio: auto;
}

.lib-grid-images .lib-thumb img {
  height: auto;
}

.lib-grid-images .lib-label {
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Document type cards (dashboard) ---------- */
.doc-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.doc-type-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}

.doc-type-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.15);
  transform: translateY(-1px);
}

.doc-type-icon {
  font-size: 26px;
  line-height: 1;
}

.doc-type-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.doc-type-size {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.doc-type-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* ---------- Format label in the editor toolbar ---------- */
.format-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 3px 8px;
  white-space: nowrap;
}

/* ---------- Document formats list (settings) ---------- */
.formats-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* Settings page: full-width responsive grid */
.settings-head {
  margin-bottom: 20px;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 16px;
  align-items: start;
  margin-bottom: 24px;
}

.formats-card h2 {
  font-size: 17px;
  margin: 0 0 4px;
}

.format-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.format-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.format-row-icon {
  font-size: 20px;
}

.format-row-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  flex: 1;
}

.format-row-size {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- Master templates ---------- */
.masters-group-title {
  font-size: 15px;
  margin: 24px 0 10px;
}

.masters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 12px;
}

.master-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.master-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.master-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 224px;
  margin-bottom: 12px;
  background: #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

.master-thumb .thumb-scale {
  flex-shrink: 0;
}

.master-card-head h3 {
  margin: 0;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.master-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
  border-radius: 20px;
  padding: 2px 10px;
  white-space: nowrap;
}

.master-badge-toolbar {
  background: rgba(5, 150, 105, 0.12);
  color: #047857;
}

.master-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.master-actions form {
  margin: 0;
  display: inline-flex;
}

.master-history {
  border-top: 1px solid var(--border);
  margin-top: 14px;
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.master-version {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}

.master-version-num {
  font-weight: 700;
  color: var(--text);
  min-width: 28px;
}

.master-version-note {
  color: var(--muted);
  flex: 1;
  min-width: 100px;
}

.master-version-date {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

/* ---------- Proposal version history (editor modal) ---------- */
.version-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  max-height: 320px;
  overflow-y: auto;
}

.version-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}

.version-row-num {
  font-weight: 700;
  color: var(--text);
  min-width: 28px;
}

.version-row-note {
  color: var(--muted);
  flex: 1;
  min-width: 100px;
}

.version-row-date {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

/* Icon element on canvas */
.icon-content {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* Smart alignment guides (element-to-element) */
.smart-guide-v {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #ec4899;
  z-index: 2001;
  pointer-events: none;
}

.smart-guide-h {
  position: fixed;
  left: 0;
  right: 0;
  height: 1px;
  background: #ec4899;
  z-index: 2001;
  pointer-events: none;
}

/* Marquee selection rectangle */
.marquee {
  position: fixed;
  border: 1px solid var(--primary);
  background: rgba(37, 99, 235, 0.08);
  z-index: 1999;
  pointer-events: none;
}

/* Align / distribute toolbar */
.align-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.align-btn {
  padding: 5px 7px;
  min-width: 28px;
  font-size: 14px;
  line-height: 1;
}

.align-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.align-sep {
  width: 1px;
  height: 18px;
  background: var(--border-strong);
  margin: 0 4px;
}

/* Zoom controls */
.zoom-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.zoom-label {
  min-width: 48px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  user-select: none;
}

/* Generic modal (toasts/dialogs) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.modal-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: min(480px, calc(100vw - 40px));
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  max-height: calc(100vh - 80px);
  overflow: auto;
}

.modal-card h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.shortcut-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
}

.shortcut-key {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 3px 8px;
  color: #0f172a;
  white-space: nowrap;
}

/* Toast notifications */
#toastWrap {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 4000;
  align-items: center;
}

.toast {
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(8px);
  animation: toast-in 0.18s ease forwards;
}

.toast-error {
  background: #dc2626;
}

.toast-success {
  background: #16a34a;
}

.toast.out {
  transition: opacity 0.3s ease, transform 0.3s ease;
  opacity: 0;
  transform: translateY(8px);
}

@keyframes toast-in {
  to { opacity: 1; transform: translateY(0); }
}

/* Canvas area */
.canvas-area {
  grid-area: canvas;
  overflow: auto;
  padding: 32px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.pages-container {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.page {
  position: relative;
  width: 794px;
  height: 1123px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12), 0 10px 30px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.page.selected {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Page management strip ---------- */
.page-strip {
  grid-area: pages;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  overflow-x: auto;
}

.page-strip-list {
  display: flex;
  gap: 10px;
  flex: 1;
  overflow-x: auto;
  padding: 2px;
}

.page-thumb {
  position: relative;
  flex-shrink: 0;
  width: 64px;
  height: 90px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.page-thumb:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.page-thumb.active {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.page-thumb.dragging {
  opacity: 0.5;
}

.page-thumb-inner {
  position: absolute;
  top: 0;
  left: 0;
  width: 794px;
  height: 1123px;
  transform: scale(0.0806);
  transform-origin: top left;
  pointer-events: none;
}

.page-thumb-num {
  position: absolute;
  bottom: 2px;
  left: 4px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  background: rgba(15, 23, 42, 0.65);
  border-radius: 3px;
  padding: 0 4px;
  line-height: 1.4;
  pointer-events: none;
}

.page-thumb-actions {
  position: absolute;
  top: 2px;
  right: 2px;
  display: none;
  gap: 2px;
}

.page-thumb:hover .page-thumb-actions {
  display: flex;
}

.page-thumb-btn {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.7);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-thumb-btn:hover {
  background: var(--primary);
}

.page-thumb-btn.danger:hover {
  background: var(--danger, #dc2626);
}

.page-strip-add {
  flex-shrink: 0;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.page-strip-add:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* ---------- Layout guides (magazine grid / golden ratio) ---------- */
.page-guides {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 999;
}

/* Dotted baseline grid */
.guide-grid {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, #cbd5e1 1px, transparent 1px);
  opacity: 0.7;
}

/* Safety margin frame */
.guide-margin {
  position: absolute;
  border: 1px dashed #94a3b8;
  pointer-events: none;
}

/* Header / footer content zones */
.guide-zone {
  position: absolute;
  left: 0;
  right: 0;
  border-bottom: 1px dashed #f59e0b;
  color: #f59e0b;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 6px 8px;
  font-size: 10px;
  letter-spacing: 0.08em;
  font-weight: 700;
  text-transform: uppercase;
}

.guide-zone.guide-footer {
  border-bottom: none;
  border-top: 1px dashed #f59e0b;
  align-items: flex-end;
}

.guide-zone span {
  background: rgba(255, 255, 255, 0.85);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Golden-ratio lines */
.guide-golden-v {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #ec4899;
  opacity: 0.55;
}

.guide-golden-h {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: #ec4899;
  opacity: 0.55;
}

/* Magazine column guides */
.guide-column {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #38bdf8;
  border-left: 1px dashed #38bdf8;
}

/* Hidden when guides are toggled off */
body:not(.show-guides) .page-guides {
  display: none;
}

/* Automatic page numbers (every page except the first) */
.page-number {
  position: absolute;
  bottom: 30px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: Georgia, serif;
  font-size: 12px;
  color: #6b7280;
  pointer-events: none;
  z-index: 998;
}

/* Elements */
.element {
  position: absolute;
  cursor: move;
  user-select: none;
  transform-origin: center center;
}

.element.editing {
  cursor: text;
}

.element.selected .selection-outline {
  display: block;
  position: absolute;
  inset: 0;
  border: 1.5px solid var(--primary);
  pointer-events: none;
}

.element .selection-outline {
  display: none;
}

.element .text-content {
  width: 100%;
  height: 100%;
  white-space: pre-wrap;
  overflow: hidden;
  outline: none;
  word-break: break-word;
}

.element .resize-handle {
  display: none;
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  border: 1.5px solid var(--primary);
  border-radius: 2px;
  z-index: 50;
}

.element.selected .resize-handle {
  display: block;
}

.resize-handle.se {
  right: -7px;
  bottom: -7px;
  cursor: nwse-resize;
}

.resize-handle.ne {
  right: -7px;
  top: -7px;
  cursor: nesw-resize;
}

.resize-handle.nw {
  left: -7px;
  top: -7px;
  cursor: nwse-resize;
}

.resize-handle.sw {
  left: -7px;
  bottom: -7px;
  cursor: nesw-resize;
}

.element .rotate-handle {
  display: none;
  position: absolute;
  top: -34px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  background: #fff;
  border: 1.5px solid var(--primary);
  border-radius: 50%;
  cursor: grab;
  z-index: 50;
}

.element.selected .rotate-handle {
  display: block;
}

.rotate-handle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 9px;
  width: 1.5px;
  height: 16px;
  background: var(--primary);
  transform: translateX(-50%);
}

/* Inspector */
.inspector {
  grid-area: inspector;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

.inspector-empty {
  padding-top: 24px;
}

.inspector-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.inspector-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inspector-group label,
.inspector-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.inspector-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inspector-row input[type="number"] {
  flex: 1;
  min-width: 0;
}

.segmented {
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  overflow: hidden;
}

.segmented button {
  flex: 1;
  padding: 7px;
  background: #fff;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.segmented button.active {
  background: var(--primary);
  color: #fff;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

input[type="color"] {
  width: 36px;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 2px;
  background: #fff;
  cursor: pointer;
}

input[type="range"] {
  width: 100%;
}

input[type="number"],
select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 13px;
  font-family: inherit;
}

textarea {
  width: 100%;
  min-height: 90px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}

/* Share link dialog */
.share-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(17, 24, 39, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.share-dialog-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  padding: 22px;
  width: 100%;
  max-width: 520px;
}

.share-dialog-card h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.share-dialog-row {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

.share-dialog-row input {
  flex: 1;
}

.share-dialog-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 4px 0 10px;
}

.share-settings {
  border-top: 1px solid var(--border);
  margin-top: 14px;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.share-settings h4 {
  margin: 0 0 4px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.share-settings label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.share-settings .btn {
  margin-top: 10px;
}

/* Context menu */
.context-menu {
  position: fixed;
  z-index: 1000;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  min-width: 160px;
  padding: 6px;
}

.context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}

.context-menu button:hover {
  background: #f3f4f6;
}

.context-menu button.danger {
  color: var(--danger);
}

.context-menu button.danger:hover {
  background: #fef2f2;
}

.context-menu hr {
  margin: 6px 0;
  border: none;
  border-top: 1px solid var(--border);
}

/* =========================================================================
   Print preview
   ========================================================================= */

@media print {
  body {
    background: #fff !important;
  }

  .editor-app {
    display: block;
    height: auto;
  }

  .toolbar,
  .palette,
  .inspector,
  .save-status,
  .context-menu,
  .page-strip {
    display: none !important;
  }

  .canvas-area {
    display: block !important;
    overflow: visible !important;
    padding: 0 !important;
  }

  .pages-container {
    display: block !important;
    gap: 0 !important;
  }

  .page {
    width: 210mm !important;
    height: 297mm !important;
    box-shadow: none !important;
    outline: none !important;
    margin: 0 !important;
    overflow: hidden !important;
    page-break-after: always;
    break-after: page;
  }

  .page:last-child {
    page-break-after: auto;
    break-after: auto;
  }

  .page-guides,
  .element .selection-outline,
  .element .resize-handle,
  .element .rotate-handle {
    display: none !important;
  }
}

/* =========================================================================
   Proposals page (redesigned)
   ========================================================================= */

/* Hero header */
.proposals-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.proposals-hero h1 {
  font-size: 28px;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.proposals-sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}
.proposals-hero-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Create modal */
.create-modal {
  width: min(720px, calc(100vw - 40px));
}
.create-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}
.create-modal-head h3 {
  margin: 0;
  font-size: 20px;
}
.modal-x {
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 6px;
  border-radius: 6px;
}
.modal-x:hover {
  color: var(--text);
  background: #f3f4f6;
}
.create-modal-hint {
  margin: 0 0 18px;
  font-size: 13px;
}
.create-modal .field {
  margin-bottom: 16px;
}
.create-modal-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 10px;
}

/* Toolbar */
.proposals-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.proposals-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 240px;
  max-width: 440px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.proposals-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.proposals-search .input {
  border: none;
  box-shadow: none;
  flex: 1;
  padding: 10px 0;
  background: transparent;
}
.proposals-search .input:focus {
  outline: none;
}
.proposals-search input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}
.search-icon {
  color: var(--muted);
  flex-shrink: 0;
}
.search-clear {
  color: var(--muted);
  text-decoration: none;
  font-size: 18px;
  line-height: 1;
  padding: 4px;
}
.search-clear:hover {
  color: var(--text);
}
.proposals-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Segmented control */
.segmented {
  display: inline-flex;
  background: #e5e7eb;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.seg {
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.seg:hover {
  color: var(--text);
}
.seg.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.proposals-sort {
  width: auto;
}

/* Grid + cards */
.proposal-grid {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 22px;
}
.proposal-card {
  border-radius: 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.proposal-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  border-color: var(--border-strong);
}
.proposal-thumb {
  background: linear-gradient(180deg, #f9fafb 0%, #e5e7eb 100%);
  height: 210px;
  padding: 14px;
}
.proposal-thumb .thumb-scale {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.proposal-body {
  padding: 14px 16px 16px;
  gap: 8px;
}
.proposal-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.proposal-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: #f3f4f6;
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.proposal-shared-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.proposal-title {
  font-size: 15px;
  line-height: 1.3;
}
.proposal-meta {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}
.proposal-actions {
  margin-top: auto;
  padding-top: 4px;
  flex-wrap: wrap;
}

/* Empty state */
.empty-state h3 {
  font-size: 17px;
  margin: 8px 0 4px;
}
.empty-icon {
  font-size: 34px;
}
.empty-state .btn {
  margin-top: 14px;
}
