:root {
  --ink: #172033;
  --muted: #6b7588;
  --line: #dde2eb;
  --soft: #f5f7fa;
  --accent: #3559a6;
  --accent-dark: #243f7b;
  --danger: #b33b43;
  --app-bg: #eef1f5;
  background: var(--app-bg);
  color: var(--ink);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0.01em;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a,
summary,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: var(--accent);
}

[hidden] {
  display: none !important;
}

.demo-only {
  display: none;
}

body.demo-mode .demo-only {
  display: inline-flex;
}

body.demo-mode .owner-only {
  display: none !important;
}

.app-bar {
  height: 68px;
  padding: 0 22px;
  display: grid;
  grid-template-columns: 236px 1fr auto;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  position: relative;
  z-index: 20;
}

.app-brand {
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  font: 700 11px/1 Georgia, serif;
  letter-spacing: -0.08em;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  font-size: 11px;
  letter-spacing: 0.14em;
}

.brand-copy small {
  color: var(--muted);
  font-size: 11px;
}

.document-identity {
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

.demo-identity {
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.demo-identity-avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  object-fit: cover;
  object-position: center 25%;
  border: 1px solid #c9d4e2;
  border-radius: 50%;
}

.demo-identity-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.demo-identity strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.demo-identity-copy span {
  color: var(--muted);
  font-size: 10px;
}

.demo-pill {
  padding: 4px 7px;
  color: #365a96;
  background: #edf3ff;
  border: 1px solid #cedcf3;
  border-radius: 999px;
  font: 700 9px/1 Arial, sans-serif;
  letter-spacing: 0.12em;
}

body.demo-mode {
  --accent: #3559a6;
}

body.demo-mode .app-bar {
  border-bottom-color: #d8e2f0;
  background: rgba(249, 251, 255, 0.98);
}

body.demo-mode .local-note .local-dot {
  background: #3559a6;
}

.demo-session-actions {
  padding: 3px;
  display: none;
  align-items: center;
  gap: 3px;
  background: #eef2f8;
  border: 1px solid #d6deea;
  border-radius: 10px;
}

body.demo-mode .demo-session-actions {
  display: inline-flex;
}

.demo-session-button {
  min-width: 92px;
  height: 36px;
  padding: 0 13px;
  border: 0;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 680;
  cursor: pointer;
}

.demo-session-button.reset {
  color: #43516a;
  background: transparent;
}

.demo-session-button.reset:hover {
  background: #fff;
}

.demo-session-button.exit {
  color: #fff;
  background: #1d293c;
}

.demo-session-button.exit:hover {
  background: #2a3a54;
}

body.demo-mode .local-note {
  display: block;
  padding: 14px;
  background: #f6f8fc;
  border: 1px solid #dfe5ef;
  border-radius: 10px;
}

body.demo-mode .local-note .demo-note-kicker {
  display: block;
  margin-bottom: 7px;
  color: #3559a6;
  font: 750 8px/1 Arial, sans-serif;
  letter-spacing: 0.14em;
}

body.demo-mode .local-note strong {
  display: block;
  font-size: 12px;
  letter-spacing: 0;
}

body.demo-mode .local-note p {
  margin-top: 5px;
  color: #768297;
  font-size: 10px;
  line-height: 1.55;
}

.resume-switcher {
  min-width: 0;
  max-width: min(520px, 42vw);
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  font-weight: 650;
}

.resume-switcher-prefix {
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--accent);
  background: #edf2ff;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.resume-switcher:hover,
.resume-switcher[aria-expanded="true"] {
  border-color: var(--line);
  background: var(--soft);
}

.resume-switcher #document-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resume-switcher-icon {
  color: #8b95a6;
  font-size: 13px;
}

.resume-popover {
  width: min(430px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 96px));
  padding: 18px;
  overflow: auto;
  position: absolute;
  z-index: 80;
  left: 0;
  top: calc(100% + 10px);
  border: 1px solid #d7dee9;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(20, 31, 49, 0.2);
}

.resume-popover-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.resume-popover-head h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.025em;
}

.resume-popover-help {
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.resume-list {
  display: grid;
  gap: 7px;
}

.resume-list-item {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  color: var(--ink);
  background: #fff;
}

.resume-list-item:hover {
  border-color: #b9c8df;
  background: #f8faff;
}

.resume-list-item.current {
  border-color: #aebfe0;
  background: #f1f5ff;
}

.resume-open {
  min-width: 0;
  padding: 0;
  border: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.resume-open strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.resume-open small {
  grid-column: 1;
  color: var(--muted);
  font-size: 10px;
}

.resume-open .resume-state {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--accent);
  font-size: 10px;
}

.resume-row-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.resume-action {
  padding: 5px 7px;
  border: 1px solid #d7dfe9;
  border-radius: 6px;
  color: #5f6b7e;
  background: #fff;
  cursor: pointer;
  font-size: 10px;
  white-space: nowrap;
}

.resume-action:hover {
  color: var(--accent);
  border-color: #afc0dc;
}

.save-state {
  flex: none;
  padding: 4px 8px;
  border-radius: 99px;
  color: var(--muted);
  background: var(--soft);
  font-size: 11px;
}

.save-state.dirty {
  color: #8a5b12;
  background: #fff7e4;
}

.save-state.saving {
  color: var(--accent);
  background: #eef3ff;
}

.save-state.error {
  color: var(--danger);
  background: #fff0f1;
}

.app-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button:active {
  transform: translateY(1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.55;
}

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

.button.primary:hover {
  background: #29344a;
}

.button.secondary {
  border-color: var(--line);
  background: #fff;
}

.button.secondary:hover,
.button.ghost:hover {
  border-color: #c4ccda;
  background: var(--soft);
}

.button.ghost {
  border-color: transparent;
  background: transparent;
}

.utility-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.utility-button.active {
  color: var(--accent);
  border-color: #c3d0e6;
  background: #f1f5ff;
}

.utility-button.layout-locked {
  color: #805a19;
  border-color: #e5d0a5;
  background: #fffaf0;
}

.utility-button.layout-locked.active {
  color: #805a19;
  border-color: #d7ba80;
  background: #fff6e4;
}

.utility-icon {
  color: currentColor;
  font: 700 13px/1 Georgia, serif;
}

.utility-label {
  font-size: 12px;
}

.button.wide {
  width: 100%;
}

.studio-shell {
  height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: 236px minmax(430px, 0.92fr) minmax(520px, 1.18fr);
}

.modules-panel {
  min-height: 0;
  padding: 24px 16px 18px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
}

.panel-heading {
  padding: 0 8px 18px;
}

.panel-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-toggle {
  min-height: 27px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #687487;
  background: #fff;
  cursor: pointer;
  font-size: 10px;
}

.sidebar-toggle:hover {
  color: var(--accent);
  border-color: #bac7dc;
}

.eyebrow {
  margin: 0 0 7px;
  color: #8690a2;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.16em;
}

.panel-heading h1 {
  margin: 0 0 8px;
  font-size: 21px;
  letter-spacing: -0.02em;
}

.panel-heading > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.module-nav {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 5px;
  padding-right: 3px;
}

.module-button {
  width: 100%;
  min-height: 44px;
  padding: 7px 9px 7px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #49556a;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.module-button:hover {
  background: #f1f4f8;
}

.module-button.active {
  color: var(--ink);
  border-color: #d8dfeb;
  background: #fff;
  box-shadow: 0 2px 8px rgba(31, 44, 66, 0.05);
}

.module-glyph {
  width: 27px;
  height: 27px;
  display: grid;
  flex: none;
  place-items: center;
  border-radius: 7px;
  color: var(--accent);
  background: #edf2ff;
  font-size: 10px;
  font-weight: 750;
}

.module-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.module-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 650;
}

.module-copy small {
  color: #9098a7;
  font-size: 10px;
}

.module-button.hidden-section {
  opacity: 0.56;
}

.module-button.locked-section {
  border-color: #eadfca;
  background: #fffdf8;
}

.module-button.locked-section .module-glyph {
  color: #8a6122;
  background: #fff2d7;
}

.module-lock {
  margin-left: auto;
  padding: 2px 5px;
  border-radius: 4px;
  color: #8a6122;
  background: #fff2d7;
  font-size: 9px;
  font-weight: 700;
}

.add-module {
  margin-top: 14px;
  border-top: 1px solid var(--line);
}

.add-module summary {
  padding: 14px 8px 8px;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  list-style: none;
}

.add-module summary::-webkit-details-marker {
  display: none;
}

.add-module-grid {
  padding: 5px 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.add-module-grid button {
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #526076;
  background: #fff;
  cursor: pointer;
  font-size: 11px;
  text-align: left;
}

.add-module-grid button:hover {
  color: var(--accent);
  border-color: #bbc8e1;
}

.local-note {
  margin-top: auto;
  padding: 14px 8px 0;
  display: flex;
  gap: 9px;
  border-top: 1px solid var(--line);
}

.local-dot {
  width: 7px;
  height: 7px;
  margin-top: 5px;
  flex: none;
  border-radius: 50%;
  background: #4c9a6b;
  box-shadow: 0 0 0 4px rgba(76, 154, 107, 0.1);
}

.local-note strong {
  font-size: 11px;
  font-weight: 650;
}

.local-note p {
  margin: 4px 0 0;
  color: #8a93a4;
  font-size: 10px;
  line-height: 1.5;
}

.editor-panel {
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: #fff;
}

.editor-scroll {
  height: 100%;
  overflow: auto;
  padding: 28px clamp(22px, 2.6vw, 38px) 70px;
}

#editor-root {
  max-width: 720px;
  margin: 0 auto;
}

.editor-header {
  margin-bottom: 22px;
}

.editor-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.editor-header h2 {
  margin: 0 0 5px;
  font-size: clamp(21px, 2vw, 26px);
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.editor-header p:last-child {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.editor-toolbar,
.item-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.editor-toolbar {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid #e8ecf2;
}

.toolbar-group {
  height: 32px;
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.toolbar-group .mini-button {
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.toolbar-group .mini-button + .mini-button {
  border-left: 1px solid var(--line);
}

.compact-tool {
  width: 32px;
  padding: 0;
  font-size: 14px;
}

.editor-toolbar .lock-button {
  min-height: 32px;
}

.mini-button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
}

.mini-button {
  min-height: 30px;
  padding: 0 9px;
  color: #5c687c;
  font-size: 11px;
}

.mini-button:hover {
  border-color: #b9c5d8;
  color: var(--accent);
}

.mini-button.danger:hover {
  color: var(--danger);
  border-color: #e5b3b7;
}

.mini-button.active {
  color: var(--accent);
  border-color: #aabce0;
  background: #f3f6ff;
}

.lock-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-color: #d8bc80;
  color: #765318;
  background: #fffaf0;
  font-weight: 700;
  white-space: nowrap;
}

.lock-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.lock-button.is-locked {
  color: #fff;
  border-color: #9a6c1f;
  background: #9a6c1f;
}

.mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.icon-button {
  width: 32px;
  height: 32px;
  font-size: 20px;
  line-height: 1;
}

.form-section {
  margin-bottom: 24px;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
}

.form-section > h3 {
  margin: 0 0 3px;
  font-size: 15px;
}

.form-section > p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.locked-banner {
  margin: -10px 0 18px;
  padding: 11px 13px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid #ead8b4;
  border-radius: 9px;
  color: #73521d;
  background: #fffaef;
}

.locked-banner-icon {
  width: 26px;
  height: 26px;
  display: grid;
  flex: none;
  place-items: center;
  border-radius: 7px;
  color: #fff;
  background: #a97929;
  font-size: 10px;
  font-weight: 750;
}

.locked-banner > div {
  display: grid;
  gap: 2px;
}

.locked-banner strong {
  font-size: 12px;
}

.locked-banner span {
  color: #8a734d;
  font-size: 10px;
}

.fields-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.fields-grid > .wide,
.fields-grid > .asset-field,
.fields-grid > .repeat-stack,
.fields-grid > .add-repeat {
  grid-column: 1 / -1;
}

.field {
  min-width: 0;
  display: grid;
  gap: 7px;
  color: #526076;
  font-size: 11px;
  font-weight: 650;
}

.field-heading {
  min-height: 16px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.field-help {
  position: relative;
  min-width: 28px;
  height: 16px;
  display: inline-grid;
  flex: none;
  place-items: center;
  padding: 0 5px;
  border: 1px solid #c9d1df;
  border-radius: 999px;
  color: #7c8799;
  background: #fff;
  font-size: 9px;
  font-weight: 650;
  line-height: 1;
  cursor: help;
}

.field-help::after {
  position: absolute;
  z-index: 40;
  left: 50%;
  bottom: calc(100% + 8px);
  width: max-content;
  max-width: min(260px, 70vw);
  padding: 7px 9px;
  border-radius: 7px;
  content: attr(data-tooltip);
  color: #fff;
  background: #263246;
  box-shadow: 0 8px 24px rgba(21, 31, 48, 0.18);
  font-size: 10px;
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 3px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
  pointer-events: none;
}

.field-help:hover::after,
.field-help:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.field.wide {
  grid-column: 1 / -1;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-width: 0;
  border: 1px solid #d9dfea;
  border-radius: 8px;
  color: var(--ink);
  background: #fbfcfe;
  outline: none;
  font-size: 13px;
  font-weight: 450;
}

.field input,
.field select {
  height: 39px;
  padding: 0 11px;
}

.field textarea {
  min-height: 94px;
  padding: 10px 11px;
  resize: vertical;
  line-height: 1.6;
}

.rich-toolbar {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.format-button {
  width: 30px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #d9dfea;
  border-radius: 7px;
  color: #4c5a70;
  background: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.format-button:hover {
  border-color: #aebbd0;
  color: var(--accent);
}

.format-bold {
  font-family: Georgia, serif;
  font-size: 15px;
}

.format-swatch {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--swatch-color);
  box-shadow: 0 0 0 1px #cbd3df;
  cursor: pointer;
}

.format-swatch:hover,
.format-swatch:focus-visible {
  box-shadow: 0 0 0 2px #8fa8d8;
  outline: none;
}

.format-reset {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid #d9dfea;
  border-radius: 7px;
  color: #68758a;
  background: #fff;
  font-size: 10px;
  cursor: pointer;
}

.format-reset:hover {
  border-color: #aebbd0;
  color: var(--accent);
}

.rich-text-editor {
  width: 100%;
  min-height: 94px;
  padding: 10px 11px;
  border: 1px solid #d9dfea;
  border-radius: 8px;
  color: var(--ink);
  background: #fbfcfe;
  outline: none;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 13px;
  font-weight: 450;
  line-height: 1.6;
}

.rich-text-editor:empty::before {
  color: #a3acba;
  content: attr(data-placeholder);
  pointer-events: none;
}

.rich-text-editor:focus {
  border-color: #91a8d5;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(53, 89, 166, 0.1);
}

.rich-text-editor[contenteditable="false"] {
  cursor: not-allowed;
  color: #8992a1;
  border-color: #e1e5eb;
  background: #f5f6f8;
}

.rich-text-editor .rich-text {
  display: inline;
  margin: 0;
}

.rich-text-editor .rich-strong {
  font-weight: 700;
}

.rich-text-editor .inline-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.theme-color-field {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}

.theme-color-controls {
  display: flex;
  align-items: center;
  gap: 9px;
}

.theme-color-preview {
  width: 34px;
  height: 34px;
  flex: none;
  border: 2px solid #fff;
  border-radius: 9px;
  box-shadow: 0 0 0 1px #cbd3df, 0 3px 10px rgba(30, 47, 72, 0.1);
}

.theme-color-sample {
  min-width: 70px;
  font-size: 14px;
  font-weight: 750;
}

.theme-color-controls input[type="color"] {
  width: 34px;
  height: 32px;
  padding: 2px;
  border: 1px solid #d9dfea;
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
}

.theme-color-hex {
  width: 108px;
  height: 32px;
  padding: 0 9px;
  border: 1px solid #d9dfea;
  border-radius: 7px;
  color: var(--ink);
  background: #fbfcfe;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.theme-color-hex:focus {
  border-color: #91a8d5;
  outline: none;
  box-shadow: 0 0 0 3px rgba(53, 89, 166, 0.1);
}

.theme-presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.theme-preset {
  min-width: 0;
  min-height: 48px;
  padding: 7px 9px;
  border: 1px solid #d9dfea;
  border-radius: 9px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #39465a;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.theme-preset:hover {
  border-color: #b8c5d9;
  background: #fbfcff;
}

.theme-preset.active {
  border-color: var(--accent);
  background: #f3f6ff;
  box-shadow: 0 0 0 2px rgba(53, 89, 166, 0.1);
}

.theme-preset-swatch {
  width: 20px;
  height: 20px;
  flex: none;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #cbd3df;
}

.theme-preset > span:last-child {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.theme-preset strong {
  overflow: hidden;
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-preset small {
  color: #8490a3;
  font-size: 8px;
  font-variant-numeric: tabular-nums;
}

.theme-color-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #8a93a4;
  font-size: 9px;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: #91a8d5;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(53, 89, 166, 0.1);
}

.field input:disabled,
.field textarea:disabled,
.field select:disabled,
.form-section button:disabled {
  cursor: not-allowed;
  color: #8992a1;
  border-color: #e1e5eb;
  background: #f5f6f8;
}

.field small {
  color: #929bab;
  font-size: 10px;
  font-weight: 450;
  line-height: 1.5;
}

.bullets-field {
  min-width: 0;
  display: grid;
  gap: 7px;
  color: #526076;
  font-size: 11px;
  font-weight: 650;
}

.bullets-field.wide {
  grid-column: 1 / -1;
}

.bullets-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.list-tools {
  display: flex;
  align-items: center;
  gap: 5px;
}

.rich-bullet-editor {
  width: 100%;
  min-height: 132px;
  padding: 10px 11px 10px 14px;
  border: 1px solid #d9dfea;
  border-radius: 8px;
  color: var(--ink);
  background: #fbfcfe;
  outline: none;
  font-size: 12px;
  font-weight: 450;
  line-height: 1.58;
}

.rich-bullet-editor:focus {
  border-color: #91a8d5;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(53, 89, 166, 0.1);
}

.rich-bullet-editor[contenteditable="false"] {
  cursor: not-allowed;
  color: #8992a1;
  border-color: #e1e5eb;
  background: #f5f6f8;
}

.rich-bullet-editor ul,
.rich-bullet-editor ol {
  margin: 0;
  padding-left: 18px;
}

.rich-bullet-editor ul {
  list-style: disc;
}

.rich-bullet-editor ol {
  list-style: decimal;
}

.rich-bullet-editor li {
  margin: 2px 0;
}

.rich-bullet-editor li::marker {
  color: var(--accent);
  font-weight: 700;
}

.rich-bullet-editor a {
  color: var(--accent);
}

.toggle-field {
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid #d9dfea;
  border-radius: 8px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #526076;
  background: #fbfcfe;
  cursor: pointer;
}

.toggle-field input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.toggle-field > span {
  display: grid;
  gap: 2px;
}

.toggle-field strong {
  font-size: 12px;
  font-weight: 650;
}

.toggle-field small {
  color: #8a93a4;
  font-size: 10px;
  font-weight: 450;
  line-height: 1.45;
}

.repeat-stack {
  display: grid;
  grid-column: 1 / -1;
  gap: 10px;
}

.repeat-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfdff;
}

.repeat-item[open] {
  background: #fff;
}

.repeat-item summary {
  min-height: 44px;
  padding: 10px 13px;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  list-style: none;
}

.repeat-item summary::-webkit-details-marker {
  display: none;
}

.repeat-index {
  width: 24px;
  height: 24px;
  display: grid;
  flex: none;
  place-items: center;
  border-radius: 6px;
  color: var(--accent);
  background: #edf2ff;
  font-size: 9px;
  font-weight: 750;
}

.repeat-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 650;
}

.repeat-toggle {
  margin-left: auto;
  color: #9aa3b2;
  font-size: 11px;
  font-weight: 500;
}

.repeat-item[open] .repeat-toggle {
  color: var(--accent);
}

.repeat-content {
  padding: 4px 13px 16px;
}

.fixed-contact-card .repeat-content {
  height: 100%;
  padding-top: 13px;
  display: flex;
  flex-direction: column;
}

.fixed-contact-slot {
  margin-bottom: 13px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.fixed-contact-number {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--accent);
  background: #edf2ff;
  font-size: 9px;
  font-weight: 750;
}

.fixed-contact-slot strong {
  font-size: 13px;
}

.fields-grid.fixed-contact-grid {
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 12px;
}

.fixed-contact-grid .fixed-contact-card {
  min-width: 0;
}

.fixed-contact-card .fields-grid {
  flex: 1;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.45fr);
  align-content: start;
  gap: 10px;
}

.repeat-content .item-actions {
  margin-bottom: 13px;
}

.add-repeat {
  width: 100%;
  grid-column: 1 / -1;
  min-height: 40px;
  margin-top: 11px;
  border: 1px dashed #c7d0df;
  border-radius: 9px;
  color: var(--accent);
  background: #f8faff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.add-repeat:hover {
  border-color: #9eb1d5;
  background: #f2f6ff;
}

.asset-field {
  display: grid;
  grid-template-columns: 144px minmax(0, 1fr);
  gap: 14px;
  grid-column: 1 / -1;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
}

.asset-preview {
  width: 100%;
  height: 144px;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px dashed #c6cfdd;
  border-radius: 8px;
  color: #9aa4b4;
  background: #fff;
  font-size: 10px;
}

.asset-preview.photo {
  aspect-ratio: 23 / 31;
  height: auto;
}

.asset-preview.logo {
  aspect-ratio: 1;
  height: auto;
}

.asset-preview img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
}

.asset-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.asset-actions label.button {
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  white-space: nowrap;
}

.asset-actions input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.asset-actions p {
  width: 100%;
  margin: 0;
  color: #8a93a4;
  font-size: 10px;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr 72px;
  align-items: center;
  gap: 12px;
}

.range-field {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  color: #526076;
  font-size: 11px;
  font-weight: 650;
}

.range-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.range-field input[type="range"] {
  width: 100%;
  height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  accent-color: var(--accent);
  background: transparent;
  cursor: ew-resize;
}

.range-field small {
  color: #929bab;
  font-size: 10px;
  font-weight: 450;
  line-height: 1.5;
}

.range-value {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.color-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-field input[type="color"] {
  width: 46px;
  padding: 3px;
}

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

.version-card {
  padding: 14px 0;
  display: flex;
  justify-content: space-between;
  gap: 15px;
  border-bottom: 1px solid var(--line);
}

.version-card:last-child {
  border-bottom: 0;
}

.version-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.version-card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.version-card time {
  display: block;
  margin-top: 4px;
  color: #9aa3b2;
  font-size: 10px;
}

.preview-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.72), transparent 34%),
    #e9edf3;
}

.preview-toolbar {
  height: 52px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid #d6dce6;
  background: rgba(245, 247, 250, 0.84);
  backdrop-filter: blur(10px);
}

.preview-toolbar-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.preview-toolbar-title strong {
  font-size: 12px;
}

.preview-toolbar-title span {
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.preview-tools {
  display: flex;
  align-items: center;
  gap: 12px;
}

.demo-lock-tools {
  align-items: center;
  gap: 4px;
  padding: 3px;
  background: #eef2f8;
  border: 1px solid #d8e0eb;
  border-radius: 9px;
}

.demo-lock-button {
  height: 29px;
  padding: 0 9px 0 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #536179;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 680;
  cursor: pointer;
}

.demo-lock-button:hover {
  background: #fff;
}

.demo-lock-button[aria-pressed="true"] {
  color: #8a6418;
  background: #fff8e8;
  box-shadow: inset 0 0 0 1px #ead7a5;
}

.demo-lock-icon {
  padding: 3px 4px;
  color: #3559a6;
  background: #fff;
  border-radius: 4px;
  font: 700 8px/1 Arial, sans-serif;
  letter-spacing: 0.03em;
}

.demo-lock-button[aria-pressed="true"] .demo-lock-icon {
  color: #8a6418;
}

.preview-tools label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
}

.preview-tools select {
  height: 30px;
  border: 1px solid #cfd6e1;
  border-radius: 6px;
  background: #fff;
  font-size: 11px;
}

.open-print {
  font-size: 11px;
  font-weight: 650;
  text-decoration: none;
}

.preview-stage {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 28px 30px 90px;
}

.preview-pages {
  --preview-zoom: 0.78;
  width: fit-content;
  min-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  zoom: var(--preview-zoom);
}

.preview-pages .resume-page {
  box-shadow:
    0 2px 4px rgba(26, 37, 54, 0.08),
    0 14px 38px rgba(26, 37, 54, 0.13);
}

.preview-pages .resume-page.page-overflow {
  outline-color: rgba(179, 59, 67, 0.3);
}

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  padding: 20px;
  display: grid;
  place-items: center;
  background: rgba(17, 25, 39, 0.38);
  backdrop-filter: blur(4px);
}

.modal {
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  padding: 24px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(12, 20, 34, 0.24);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.modal h2 {
  margin: 0;
  font-size: 21px;
}

.modal-help {
  margin: 12px 0 20px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.version-storage-summary {
  margin: -8px 0 18px;
  padding: 9px 11px;
  border-radius: 8px;
  color: #58657a;
  background: #f4f7fb;
  font-size: 11px;
}

#version-form {
  display: grid;
  gap: 13px;
}

.version-list {
  margin-top: 24px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  z-index: 120;
  left: 50%;
  bottom: 26px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 11px 16px;
  border-radius: 9px;
  color: #fff;
  background: #1b2537;
  box-shadow: 0 12px 40px rgba(15, 24, 39, 0.22);
  font-size: 12px;
  transform: translateX(-50%);
}

.toast.error {
  background: var(--danger);
}

@media (max-width: 1180px) {
  .app-bar {
    grid-template-columns: 220px 1fr auto;
  }

  .studio-shell {
    grid-template-columns: 230px minmax(360px, 0.9fr) minmax(430px, 1.1fr);
  }

  .utility-label {
    display: none;
  }

  .utility-button {
    width: 36px;
    padding: 0;
    justify-content: center;
  }
}

@media (max-width: 920px) {
  body {
    overflow: auto;
  }

  .app-bar {
    height: auto;
    min-height: 68px;
    padding: 12px 16px;
    grid-template-columns: 1fr auto;
  }

  .document-identity {
    display: none;
  }

  .studio-shell {
    height: auto;
    display: block;
  }

  .modules-panel {
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .panel-heading {
    display: none;
  }

  .module-nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 6px;
  }

  .module-button {
    width: auto;
    min-width: max-content;
  }

  .add-module,
  .local-note {
    display: none;
  }

  .editor-panel {
    border-right: 0;
  }

  .editor-scroll {
    height: auto;
    padding: 22px 16px 34px;
  }

  .preview-panel {
    min-height: 70vh;
  }

  .preview-stage {
    padding: 22px 20px 70px;
  }
}

body.sidebar-collapsed .app-bar {
  grid-template-columns: 64px 1fr auto;
}

body.sidebar-collapsed .app-brand {
  justify-content: flex-start;
}

body.sidebar-collapsed .brand-copy {
  display: none;
}

body.sidebar-collapsed .studio-shell {
  grid-template-columns: 64px minmax(430px, 1fr) minmax(520px, 1.18fr);
}

body.sidebar-collapsed .modules-panel {
  padding-inline: 8px;
}

body.sidebar-collapsed .panel-heading {
  padding: 0 0 12px;
}

body.sidebar-collapsed .panel-heading-row {
  justify-content: center;
}

body.sidebar-collapsed .panel-heading .eyebrow,
body.sidebar-collapsed .panel-heading h1,
body.sidebar-collapsed .panel-heading > p:last-child,
body.sidebar-collapsed .module-copy,
body.sidebar-collapsed .add-module,
body.sidebar-collapsed .local-note,
body.sidebar-collapsed .sidebar-toggle-label {
  display: none;
}

body.sidebar-collapsed .sidebar-toggle {
  width: 32px;
  padding: 0;
  justify-content: center;
}

body.sidebar-collapsed .module-button {
  min-height: 42px;
  padding: 6px;
  justify-content: center;
}

body.sidebar-collapsed .module-glyph {
  width: 30px;
  height: 30px;
}

body.sidebar-collapsed .module-lock {
  display: none;
}

@media (max-width: 920px) {
  body.sidebar-collapsed .app-bar {
    grid-template-columns: 1fr auto;
  }

  body.sidebar-collapsed .studio-shell {
    display: block;
  }

  body.sidebar-collapsed .sidebar-toggle {
    display: none;
  }

  body.sidebar-collapsed .module-copy {
    display: grid;
  }
}

@media (max-width: 640px) {
  .app-bar {
    grid-template-columns: 1fr;
  }

  .app-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .app-actions .button.ghost {
    display: none;
  }

  body.demo-mode .app-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  body.demo-mode .demo-session-actions {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  body.demo-mode .demo-session-button {
    min-width: 0;
    padding-inline: 7px;
    font-size: 11px;
  }

  .preview-toolbar {
    height: auto;
    min-height: 52px;
    padding-block: 8px;
    flex-wrap: wrap;
  }

  .demo-lock-tools {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .demo-lock-button {
    flex: 1;
    justify-content: center;
  }

  .fields-grid {
    grid-template-columns: 1fr;
  }

  .field.wide {
    grid-column: auto;
  }

  .fixed-contact-card .fields-grid {
    grid-template-columns: 1fr;
  }

  .theme-presets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .theme-color-controls {
    flex-wrap: wrap;
  }

  .form-section {
    padding: 16px;
  }

  .editor-header-row {
    display: block;
  }

  .editor-toolbar {
    margin-top: 14px;
  }

  .asset-field {
    grid-template-columns: 1fr;
  }
}
