:root {
  --bg: #f4f4f4;
  --panel: #ffffff;
  --text: #111111;
  --muted: #555555;
  --border: #d0d0d0;
  --accent: #111111;
  --accent-text: #ffffff;
  --flash-error-bg: #f5e8e8;
  --flash-success-bg: #e8f0e8;
  --flash-info-bg: #ececec;
  --sidebar: #111111;
  --sidebar-text: #f0f0f0;
  --sidebar-muted: #aaaaaa;
}

html[data-theme="dark"] {
  --bg: #0e0e0e;
  --panel: #1a1a1a;
  --text: #f2f2f2;
  --muted: #a0a0a0;
  --border: #333333;
  --accent: #f2f2f2;
  --accent-text: #111111;
  --flash-error-bg: #3a2020;
  --flash-success-bg: #1e2e1e;
  --flash-info-bg: #2a2a2a;
  --sidebar: #050505;
  --sidebar-text: #f0f0f0;
  --sidebar-muted: #888888;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "IBM Plex Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex-shrink: 0;
}
.brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--sidebar-muted);
}
.sidebar nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.sidebar nav a {
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 0.45rem 0.6rem;
  border: 1px solid transparent;
}
.sidebar nav a:hover,
.sidebar nav a.active {
  border-color: #444;
  background: #1c1c1c;
}
.sidebar-foot { display: flex; flex-direction: column; gap: 0.4rem; }
.main { flex: 1; padding: 1.5rem 2rem; max-width: 1100px; }

h1 { margin: 0 0 0.35rem; font-size: 1.5rem; font-weight: 600; }
.h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.muted { color: var(--muted); margin: 0; }
.page-head { margin-bottom: 1.25rem; }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 1.25rem;
}
.stack { display: flex; flex-direction: column; gap: 0.9rem; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }

/* Desktop sidebar defaults; mobile overrides below */
.mobile-topbar { display: none; }
.nav-backdrop { display: none; }
.sidebar-close { display: none; }
.topbar-close { display: none !important; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.btn-icon {
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0.35rem 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}


label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 0.5rem 0.6rem;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  font-size: 14px;
}
textarea { resize: vertical; }
fieldset {
  border: 1px solid var(--border);
  padding: 0.75rem 1rem 1rem;
  margin: 0;
}
legend {
  padding: 0 0.35rem;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.4rem 0.75rem;
}
.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  font-size: 14px;
  color: var(--text);
  text-transform: none;
}
.check input { width: auto; }

.btn {
  display: inline-block;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--text);
  padding: 0.45rem 0.9rem;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-ghost { border-color: var(--border); }
.btn-block { width: 100%; }
.btn:hover { opacity: 0.9; }

/* Sidebar + mobile topbar are always dark — keep controls readable in light mode */
.sidebar .btn,
.sidebar .btn-ghost,
.mobile-topbar .btn,
.mobile-topbar .btn-ghost {
  color: #f0f0f0;
  border-color: #666;
  background: #1c1c1c;
}
.sidebar .btn:hover,
.sidebar .btn-ghost:hover,
.mobile-topbar .btn:hover,
.mobile-topbar .btn-ghost:hover {
  opacity: 1;
  background: #2a2a2a;
  border-color: #888;
  color: #fff;
}
.sidebar-close {
  color: #fff !important;
  border: 1px solid #888 !important;
  background: #2a2a2a !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1 !important;
  min-width: auto;
  min-height: 2.5rem;
  padding: 0.45rem 0.85rem !important;
  z-index: 2;
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(255,255,255,0.2);
}
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }

.flash { padding: 0.65rem 0.85rem; border: 1px solid var(--border); margin-bottom: 1rem; }
.flash-error { background: var(--flash-error-bg); }
.flash-success { background: var(--flash-success-bg); }
.flash-info { background: var(--flash-info-bg); }

.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.65rem 0.85rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.row-actions { display: flex; gap: 0.75rem; align-items: center; }
.row-actions form { margin: 0; }
.link-danger {
  background: none; border: none; color: #a33; cursor: pointer; font: inherit; padding: 0; text-decoration: underline;
}
a { color: var(--text); }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}
.login-card { width: min(360px, 100%); }
.login-card h1 { margin-bottom: 0.25rem; }

.preview-frame {
  background: #fff;
  color: #111;
  border: 1px solid var(--border);
  padding: 2rem;
  max-width: 800px;
}
html[data-theme="dark"] .preview-frame { box-shadow: 0 0 0 1px #333; }

.cv-doc { font-size: 14px; line-height: 1.4; color: #111; }
.cv-header { text-align: center; border-bottom: 2px solid #111; padding-bottom: 0.75rem; margin-bottom: 1.25rem; }
.cv-logo { max-height: 48px; margin-bottom: 0.35rem; }
.cv-company { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: #333; }
.cv-name { font-size: 1.55rem; margin: 0.15rem 0; text-transform: uppercase; letter-spacing: 0.02em; }
.cv-headline { color: #333; font-size: 13px; margin-bottom: 0.25rem; }
.cv-meta { color: #444; font-size: 12px; }
.cv-meta span + span::before { content: " · "; }
.cv-section { margin-bottom: 0.85rem; }
.cv-section h2 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid #999; padding-bottom: 0.15rem; margin: 0 0 0.4rem;
}
.cv-section p { margin: 0 0 0.4rem; }
.cv-section ul { margin: 0.15rem 0 0; padding-left: 1.15rem; }
.cv-section li { margin-bottom: 0.2rem; }
.cv-skill-row { margin-bottom: 0.25rem; font-size: 13px; }
.cv-entry { margin-bottom: 0.55rem; }
.cv-entry-title { font-weight: 700; }
.cv-entry-sub { color: #555; font-size: 12px; font-style: italic; margin-bottom: 0.15rem; }
.pre-lines { white-space: pre-wrap; }
.cv-footer {
  margin-top: 1.25rem; padding-top: 0.75rem; border-top: 1px solid #ccc;
  text-align: center; font-size: 12px; color: #555;
}
.cv-footer span + span::before { content: " · "; }

.logo-preview { max-height: 40px; vertical-align: middle; }
.sep { border: none; border-top: 1px solid var(--border); margin: 0.5rem 0; }
.check-list { display: flex; flex-direction: column; gap: 0.45rem; }
.check-block { align-items: flex-start; }
.small { font-size: 12px; }
.sticky-actions {
  position: sticky; bottom: 0; background: var(--bg);
  padding: 0.75rem 0; border-top: 1px solid var(--border); margin-top: 0.5rem;
}
fieldset { margin-top: 0.5rem; }

@media print {
  .sidebar, .page-head, .flash { display: none !important; }
  .main { padding: 0; max-width: none; }
  .preview-frame { border: none; padding: 0; }
}

select[multiple] {
  min-height: 7rem;
  padding: 0.35rem;
}
.field-hint {
  font-size: 12px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: var(--muted);
  margin-top: 0.25rem;
}
.tall-scroll {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--border);
  padding: 0.5rem;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.tab {
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  color: var(--muted);
  padding: 0.55rem 1rem;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.04em;
}
.tab.active {
  color: var(--text);
  border-color: var(--border);
  background: var(--panel);
  position: relative;
  top: 1px;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Multi-add picker */
.field-block { display: flex; flex-direction: column; gap: 0.35rem; }
.field-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.multi-add-row { display: flex; gap: 0.5rem; align-items: stretch; }
.multi-add-row select { flex: 1; }
.multi-add-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; min-height: 0.25rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 0.25rem 0.45rem 0.25rem 0.6rem;
  font-size: 13px;
}
.chip-remove {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 0.15rem;
}
.chip-remove:hover { color: var(--text); }

/* Category accordion */
.category-list, .pack-skill-picker { border: 1px solid var(--border); background: var(--panel); }
.cat-block { border-bottom: 1px solid var(--border); }
.cat-block:last-child { border-bottom: none; }
.cat-block > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  font-weight: 600;
}
.cat-block > summary::-webkit-details-marker { display: none; }
.cat-block > summary::before {
  content: "▸";
  margin-right: 0.5rem;
  color: var(--muted);
  font-size: 12px;
}
.cat-block[open] > summary::before { content: "▾"; }
.cat-name { flex: 1; }
.skill-name-list {
  list-style: none;
  margin: 0;
  padding: 0 0 0.5rem;
  border-top: 1px solid var(--border);
}
.skill-name-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 400;
}
.skill-name-list li:last-child { border-bottom: none; }
.skill-name-list form { margin: 0; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-backdrop[hidden] { display: none !important; }
.modal {
  width: min(420px, 100%);
  max-height: 90vh;
  overflow: auto;
}

/* Generate page: equal-width controls */
#generate-form {
  max-width: 720px;
}
#generate-form label > select,
#generate-form label > input,
#generate-form label > textarea,
#generate-form .multi-add-row {
  width: 100%;
  box-sizing: border-box;
}
#generate-form .multi-add-row select {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}
#generate-form .multi-add-btn {
  flex: 0 0 4.5rem;
  width: 4.5rem;
}
#generate-form .field-block,
#generate-form .multi-add {
  width: 100%;
}

/* ========== Mobile ========== */
@media (max-width: 900px) {
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    position: sticky;
    top: 0;
    z-index: 900;
    background: var(--sidebar);
    color: var(--sidebar-text);
    padding: 0.55rem 0.75rem;
    padding-top: max(0.55rem, env(safe-area-inset-top));
    border-bottom: 1px solid #333;
  }
  .mobile-topbar-title {
    flex: 1;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
  }
  .nav-toggle {
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid #777;
    background: #1a1a1a;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
  }
  .nav-toggle-bars {
    display: block;
    width: 1.15rem;
    height: 2px;
    background: #fff;
    position: relative;
    box-shadow: 0 -6px 0 #fff, 0 6px 0 #fff;
  }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 950;
    pointer-events: auto;
  }
  .nav-backdrop[hidden] { display: none !important; pointer-events: none; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 86vw);
    z-index: 1000;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    box-shadow: 4px 0 24px rgba(0,0,0,0.35);
    pointer-events: auto;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open { overflow: hidden; }
  .sidebar-close {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 1001;
  }
  .topbar-close {
    display: none !important;
    color: #fff !important;
    border: 1px solid #888 !important;
    background: #2a2a2a !important;
    font-size: 12px !important;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    min-height: 2.5rem;
    padding: 0.4rem 0.75rem !important;
    cursor: pointer;
  }
  body.nav-open .topbar-close {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }
  body.nav-open .mobile-topbar {
    z-index: 1100; /* above drawer so top Close is always tappable */
  }
  .sidebar-top {
    position: relative;
    z-index: 1001;
    flex-shrink: 0;
  }
  .sidebar nav a {
    padding: 0.7rem 0.75rem;
    min-height: 2.75rem;
    display: flex;
    align-items: center;
  }

  .layout { flex-direction: column; min-height: 100dvh; }
  .main {
    padding: 1rem;
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
    max-width: none;
    width: 100%;
  }
  .row-2 { grid-template-columns: 1fr; }
  .page-head.row-between { flex-direction: column; align-items: stretch; }
  .page-head .btn { width: 100%; text-align: center; }

  h1 { font-size: 1.25rem; }
  .card { padding: 1rem; }
  .login-wrap { padding: 1rem; min-height: 100dvh; }
  .login-card { width: 100%; }

  input, select, textarea, .btn {
    min-height: 2.75rem;
    font-size: 16px; /* avoid iOS zoom */
  }
  textarea { min-height: 6rem; }
  .btn { padding: 0.65rem 0.9rem; }

  .actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .actions .btn,
  .actions a.btn { width: 100%; text-align: center; }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table { min-width: 520px; }
  th, td { padding: 0.7rem 0.65rem; }

  .row-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }
  .tab {
    flex: 0 0 auto;
    padding: 0.7rem 0.9rem;
    min-height: 2.75rem;
  }

  .multi-add-row {
    flex-direction: column;
  }
  #generate-form {
    max-width: none;
  }
  #generate-form .multi-add-btn {
    width: 100%;
    flex: none;
  }
  #generate-form .multi-add-row select {
    width: 100%;
  }
  .chip {
    max-width: 100%;
    padding: 0.45rem 0.55rem;
  }
  .chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 75vw;
  }
  .chip-remove {
    min-width: 1.75rem;
    min-height: 1.75rem;
    font-size: 1.25rem;
  }

  .preview-frame {
    padding: 1rem;
    overflow-x: auto;
  }
  .page-head .actions {
    width: 100%;
  }

  .modal {
    width: 100%;
    max-height: min(92dvh, 100%);
  }
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal-backdrop .modal {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  .check-grid {
    grid-template-columns: 1fr;
  }
  .cat-block > summary {
    min-height: 2.75rem;
    padding: 0.85rem 1rem;
  }
  .skill-name-list li {
    padding: 0.65rem 1rem;
    gap: 0.5rem;
  }

  .sticky-actions {
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }
}

@media (max-width: 420px) {
  .main { padding: 0.75rem; }
  table { min-width: 460px; }
}

@media print {
  .mobile-topbar, .nav-backdrop, .sidebar, .sidebar-close { display: none !important; }
}

/* Layout pattern picker */
.layout-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}
.layout-picker-inline {
  grid-template-columns: repeat(4, 1fr);
}
.layout-option {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 0.7rem 0.75rem;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  color: var(--text);
  margin: 0;
}
.layout-option input {
  margin-top: 0.2rem;
  width: auto;
  min-height: auto;
  accent-color: #111;
}
.layout-option-body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.layout-option-name { font-weight: 700; font-size: 13px; }
.layout-option-desc { font-size: 12px; color: var(--muted); line-height: 1.3; }
.layout-option:has(input:checked),
.layout-option.is-selected {
  border-color: var(--text);
  box-shadow: inset 0 0 0 1px var(--text);
}
.layout-switch {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border: 2px solid var(--border);
}
.layout-switch .h2 { margin-bottom: 0.25rem; }
.layout-switch .field-label { margin-bottom: 0.5rem; }
.layout-switch .layout-picker {
  margin-bottom: 0.25rem;
}

@media (max-width: 900px) {
  .layout-picker { grid-template-columns: 1fr; }
  .layout-picker-inline { grid-template-columns: 1fr 1fr; }
}

/* ---- CV layout patterns (preview) ---- */
.cv-layout-classic .cv-header {
  text-align: center;
  border-bottom: 2px solid #111;
  padding-bottom: 0.75rem;
  margin-bottom: 1.25rem;
}

.cv-modern-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 640px;
  border: 1px solid #ddd;
}
.cv-modern-side {
  background: #111;
  color: #f0f0f0;
  padding: 1.25rem 1rem;
}
.cv-modern-side .cv-name {
  color: #fff;
  font-size: 1.25rem;
  text-transform: none;
  letter-spacing: 0;
  margin: 0.35rem 0 0.2rem;
  text-align: left;
}
.cv-modern-side .cv-headline { color: #ccc; font-size: 0.9rem; }
.cv-side-years { font-size: 12px; color: #aaa; margin: 0.4rem 0 0.8rem; }
.cv-side-block { margin-top: 1.1rem; }
.cv-side-block h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #999;
  border-bottom: 1px solid #333;
  margin: 0 0 0.45rem;
  padding-bottom: 0.25rem;
}
.cv-side-list { list-style: none; margin: 0; padding: 0; font-size: 12px; color: #ddd; }
.cv-side-list li { margin-bottom: 0.35rem; word-break: break-word; }
.cv-side-skill { margin-bottom: 0.55rem; }
.cv-side-skill-cat { font-size: 12px; font-weight: 700; color: #fff; }
.cv-side-skill-items { font-size: 11px; color: #bbb; line-height: 1.35; }
.cv-modern-main { padding: 1.25rem 1.35rem; background: #fff; }
.cv-modern-main .cv-section h2 {
  border-bottom-color: #111;
}
.cv-entry-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}
.cv-entry-role { font-size: 13px; color: #333; margin-bottom: 0.15rem; }
.cv-entry-period { font-size: 12px; color: #555; white-space: nowrap; }

.cv-layout-executive .cv-header {
  text-align: left;
  border-bottom: 3px solid #111;
  padding-bottom: 0.75rem;
  margin-bottom: 1.15rem;
}
.cv-exec-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}
.cv-layout-executive .cv-name {
  font-size: 1.75rem;
  margin: 0.1rem 0;
  letter-spacing: 0.01em;
}
.cv-layout-executive .cv-section h2 {
  border-bottom: 2px solid #111;
  letter-spacing: 0.08em;
}
.cv-exec-entry-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}
.cv-entry-org { font-size: 13px; color: #333; margin-top: 0.1rem; }
.cv-exec-skills .cv-skill-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.cv-exec-skills .cv-skill-row strong {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #333;
}
.cv-exec-footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.cv-layout-compact { font-size: 13px; line-height: 1.35; }
.cv-compact-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  border-bottom: 1px solid #111;
  padding-bottom: 0.55rem;
  margin-bottom: 0.85rem;
  text-align: left;
}
.cv-layout-compact .cv-name {
  font-size: 1.35rem;
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
}
.cv-compact-meta { text-align: right; max-width: 45%; }
.cv-chip-wrap { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.cv-chip {
  border: 1px solid #666;
  padding: 0.15rem 0.45rem;
  font-size: 11px;
  background: #f7f7f7;
}
.cv-compact-entry { margin-bottom: 0.45rem; }
.cv-compact-entry-line {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}
.cv-compact-summary { margin: 0; }
.cv-compact-bottom { font-size: 12px; color: #333; }
.cv-compact-bottom div { margin-bottom: 0.25rem; }

@media (max-width: 720px) {
  .cv-modern-grid { grid-template-columns: 1fr; }
  .cv-compact-header { flex-direction: column; align-items: flex-start; }
  .cv-compact-meta { text-align: left; max-width: none; }
  .cv-exec-footer-grid { grid-template-columns: 1fr; }
  .cv-exec-skills .cv-skill-row { grid-template-columns: 1fr; }
}

/* Company branding toggle */
.toggle-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.75rem;
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 0.85rem 1rem;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  color: var(--text);
  margin: 0;
}
.toggle-row input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  min-height: auto;
  margin-top: 0.15rem;
  accent-color: #111;
  flex-shrink: 0;
}
.toggle-copy { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.toggle-title { font-weight: 700; font-size: 14px; }
.toggle-desc { font-size: 12px; color: var(--muted); line-height: 1.35; }
.toggle-row:has(input:checked) {
  border-color: var(--text);
  box-shadow: inset 0 0 0 1px var(--text);
}

/* ========== Generate form polish ========== */
.gen-form {
  max-width: 720px;
  gap: 1.25rem;
}
.gen-section {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
}
.gen-section:first-child {
  border-top: none;
  padding-top: 0;
}
.gen-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.gen-grid {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 0.85rem;
}
.gen-form .field-block select,
.gen-form .field-block input,
.gen-form .field-block textarea,
.gen-form .multi-add-row {
  width: 100%;
}
.gen-form .multi-add-row select {
  flex: 1 1 auto;
  min-width: 0;
}
.gen-form .multi-add-btn {
  flex: 0 0 4.5rem;
  width: 4.5rem;
}
.gen-form .field-hint { display: none; }
.gen-actions {
  justify-content: flex-start;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
}
.gen-actions .btn-primary {
  min-width: 160px;
}

/* Bloomberg-style switch */
.switch-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 0.9rem 1rem;
}
.switch-panel-text { min-width: 0; flex: 1; }
.switch-panel-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.15rem;
}
.switch-panel-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}
.switch {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
  flex-shrink: 0;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.switch-track {
  position: relative;
  width: 44px;
  height: 24px;
  border: 1px solid var(--border);
  background: #c8c8c8;
  display: inline-block;
  transition: background 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}
html[data-theme="dark"] .switch-track { background: #333; }
.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border: 1px solid #999;
  transition: left 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.switch input:checked + .switch-track {
  background: #111;
  border-color: #111;
}
html[data-theme="dark"] .switch input:checked + .switch-track {
  background: #f2f2f2;
  border-color: #f2f2f2;
}
.switch input:checked + .switch-track .switch-knob {
  left: 22px;
  border-color: #111;
}
html[data-theme="dark"] .switch input:checked + .switch-track .switch-knob {
  background: #111;
  border-color: #111;
}
.switch-state {
  min-width: 1.6rem;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.switch input:checked ~ .switch-state {
  color: var(--text);
}
.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* Preview segmented layout control */
.layout-switch {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  max-width: 920px;
}
.layout-switch-head { margin-bottom: 0.75rem; }
.layout-switch-head .muted { margin-top: 0.2rem; }
.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--border);
  background: var(--bg);
}
.segment {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0.7rem 0.5rem;
  cursor: pointer;
  border-right: 1px solid var(--border);
  background: transparent;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  color: var(--muted);
  min-height: 2.75rem;
}
.segment:last-child { border-right: none; }
.segment input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.segment-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
}
.segment.is-selected,
.segment:has(input:checked) {
  background: var(--text);
  color: var(--bg);
}
.layout-hint {
  margin: 0.65rem 0 0;
  font-size: 12px;
}

@media (max-width: 900px) {
  .gen-grid { grid-template-columns: 1fr; }
  .gen-form .multi-add-row { flex-direction: column; }
  .gen-form .multi-add-btn { width: 100%; flex: none; }
  .switch-panel {
    flex-direction: column;
    align-items: stretch;
  }
  .switch { justify-content: space-between; width: 100%; }
  .segmented { grid-template-columns: 1fr 1fr; }
  .segment:nth-child(2) { border-right: none; }
  .segment:nth-child(1),
  .segment:nth-child(2) { border-bottom: 1px solid var(--border); }
}
