:root {
  color: #172033;
  background: #eef2f8;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
}

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

.topbar {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #d8e0ee;
  background: #ffffff;
  box-shadow: 0 8px 28px rgb(31 48 76 / 8%);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.7rem);
}

.app {
  display: grid;
  grid-template-columns: 250px minmax(520px, 1fr) 410px;
  gap: 18px;
  min-height: calc(100vh - 79px);
  padding: 24px;
}

.editor-sidebar {
  align-self: start;
}

.tool-panel {
  padding: 18px;
}

.panel {
  border: 1px solid #d9e1ef;
  border-radius: 20px;
  background: #ffffff;
  align-self: start;
  padding: 20px;
  box-shadow: 0 18px 48px rgb(30 45 70 / 10%);
}

.project-panel {
  padding: 0 0 18px;
  overflow: hidden;
}

.project-title {
  padding: 14px 18px;
  background: #5b636d;
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
}

.eyebrow {
  margin: 0 0 5px;
  color: #3b63d9;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h2 {
  margin: 0 0 12px;
  font-size: 0.92rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.section-title {
  margin: 14px 14px 12px;
  padding: 12px;
  border-radius: 8px;
  background: #e8eef8;
  color: #101722;
  font-size: 1.25rem;
  letter-spacing: 0;
  text-transform: none;
}

.panel > h2:not(.section-title) {
  margin: 0 20px 12px;
}

.panel h2:not(:first-child):not(.section-title) {
  margin-top: 24px;
}

.button-grid,
.field-stack {
  display: grid;
  gap: 10px;
}

.project-panel .field-stack {
  padding: 0 20px;
}

.inline-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(92px, 0.45fr);
  gap: 12px;
}

button,
.upload-button,
.download {
  display: inline-flex;
  justify-content: center;
  padding: 11px 14px;
  border: 0;
  border-radius: 12px;
  background: #214be8;
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.upload-button {
  position: relative;
}

.upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.secondary {
  background: #eef1f7;
  color: #172033;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.field-stack label {
  display: grid;
  gap: 6px;
  color: #354157;
  font-size: 0.88rem;
  font-weight: 700;
}

.field-inline {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: #354157;
  font-size: 0.88rem;
  font-weight: 700;
}

.field-inline input,
.field-inline select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #cfd8e8;
  border-radius: 10px;
}

.page-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.page-actions button:first-child {
  grid-column: 1 / -1;
}

.page-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 22px;
}

.page-item {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  align-items: center;
  justify-content: start;
  padding: 9px;
  border: 1px solid #d7dfeb;
  background: #ffffff;
  color: #172033;
  text-align: left;
}

.page-item span {
  display: grid;
  width: 28px;
  height: 36px;
  place-items: center;
  border: 1px solid #c8d2e0;
  border-radius: 4px;
  background: #f8fafc;
  font-weight: 800;
}

.page-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-item.active {
  border-color: #008f86;
  background: #e9fffb;
}

.field-stack input,
.field-stack select,
.field-stack textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #cfd8e8;
  border-radius: 10px;
  background: #ffffff;
  color: #172033;
}

.field-stack select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #172033 50%),
    linear-gradient(135deg, #172033 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 10px) 50%;
  background-size:
    8px 8px,
    8px 8px;
  background-repeat: no-repeat;
}

.field-stack input[type="color"] {
  height: 42px;
  padding: 4px;
}

.field-stack textarea {
  resize: vertical;
}

.field-stack span {
  color: #6c7890;
  font-size: 0.9rem;
}

.check-row {
  display: flex !important;
  flex-direction: row;
  gap: 10px !important;
  align-items: center;
}

.check-row input {
  width: auto;
}

.muted {
  color: #b8bec8 !important;
}

.option-group {
  display: grid;
  grid-template-columns: 1fr 94px 94px;
  gap: 8px;
  align-items: center;
}

.option-group span {
  color: #172033;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toggle {
  padding: 9px 10px;
  border: 1px solid #b8c3d3;
  background: #f6f8fb;
  color: #566274;
}

.toggle.active {
  border-color: #008f86;
  background: #e7fffb;
  color: #00756f;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto;
  align-self: start;
  min-width: 0;
  resize: horizontal;
  overflow: visible;
}

.canvas-shell {
  display: grid;
  overflow: visible;
  align-items: start;
  justify-items: center;
  min-width: 520px;
  min-height: calc(100vh - 156px);
  padding: 24px;
  border: 1px solid #d9e1ef;
  border-radius: 22px;
  background:
    linear-gradient(45deg, #dfe5f0 25%, transparent 25%),
    linear-gradient(-45deg, #dfe5f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dfe5f0 75%),
    linear-gradient(-45deg, transparent 75%, #dfe5f0 75%);
  background-color: #f7f9fc;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
}

.design-canvas {
  position: relative;
  flex: none;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 18px 70px rgb(20 31 55 / 26%);
}

.design-canvas::before,
.design-canvas::after {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  content: "";
}

.design-canvas::before {
  inset: 0;
  border: 2px dashed #e54848;
}

.design-canvas::after {
  left: var(--bleed-x);
  top: var(--bleed-y);
  width: var(--trim-width);
  height: var(--trim-height);
  border: 2px solid #2f6df6;
}

.margin-guide {
  position: absolute;
  z-index: 4;
  border: 1px dashed #13b981;
  pointer-events: none;
}

.design-element {
  position: absolute;
  z-index: 2;
  overflow: hidden;
  padding: 0;
  cursor: grab;
  user-select: none;
  white-space: pre-wrap;
}

.design-element.heading,
.design-element.text {
  display: block;
  line-height: 1.15;
}

.design-element.brand,
.design-element.smart {
  display: flex;
  align-items: flex-start;
  line-height: 1.15;
}

.design-element.text {
  font-weight: inherit;
}

.design-element.rect {
  border-radius: 0;
}

.design-element.brand {
  align-items: center;
  justify-content: center;
  border: 3px solid currentcolor;
  letter-spacing: 0.08em;
  text-align: center;
}

.design-element.table {
  background: #ffffff;
  user-select: auto;
}

.design-element.table td {
  user-select: text;
  cursor: text;
}

.design-element table {
  width: 100%;
  height: 100%;
  border-collapse: collapse;
  color: #172033;
  font-size: 12px;
}

.design-element td {
  padding: 6px;
  border: 1px solid #b8c3d3;
}

.design-element tr:first-child td {
  font-weight: inherit;
}

.design-element img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.design-element.selected {
  outline: 3px solid #13b981;
  outline-offset: 2px;
}

.context-menu {
  position: fixed;
  z-index: 1000;
  display: grid;
  min-width: 150px;
  overflow: hidden;
  padding: 6px;
  border: 1px solid #cfd8e8;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 18px 45px rgb(20 31 55 / 22%);
}

.context-menu.hidden {
  display: none;
}

.context-menu button {
  justify-content: flex-start;
  padding: 9px 12px;
  border-radius: 8px;
  background: transparent;
  color: #172033;
  font-weight: 700;
}

.context-menu button:hover:not(:disabled) {
  background: #eef3ff;
  color: #214be8;
}

.context-menu button:disabled {
  color: #9aa7ba;
}

.canvas-note {
  margin: 12px 0 0;
  color: #5d6b82;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: center;
}

.download {
  width: 100%;
  margin-top: 12px;
  background: #172033;
}

.hidden {
  display: none;
}

.status {
  min-height: 1.5em;
  margin: 18px 0 0;
  color: #526174;
  font-weight: 700;
}

.status.error {
  color: #b42318;
}

.preview-card {
  display: grid;
  grid-template-rows: auto 280px;
  overflow: hidden;
  margin-top: 22px;
  border: 1px solid #e1e7f0;
  border-radius: 16px;
}

.preview-header {
  display: flex;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #e4e9f2;
}

.preview-header h2 {
  margin: 0;
}

.preview-header span {
  overflow: hidden;
  max-width: 65%;
  color: #647086;
  font-size: 0.95rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #737b8a;
}

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

  .canvas-shell {
    min-height: 520px;
  }
}

/* Modern portal UI */
:root {
  color: #111827;
  background: #f5f7fb;
}

body {
  background: #f5f7fb;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: 230px 1fr auto;
  gap: 16px;
  height: 58px;
  padding: 0 18px;
  border-bottom: 1px solid #e5e9f2;
  background: rgb(255 255 255 / 96%);
  box-shadow: 0 1px 8px rgb(15 23 42 / 5%);
  backdrop-filter: blur(12px);
}

.brand-lockup,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 8px;
  background: #0f56d9;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 900;
}

.project-name {
  display: flex;
  align-items: center;
  padding-left: 18px;
  border-left: 1px solid #e5e9f2;
  color: #1f2937;
  font-weight: 800;
}

.topbar-actions {
  justify-content: end;
}

.saved-state {
  color: #64748b;
  font-size: 0.85rem;
  font-weight: 700;
}

.app {
  grid-template-columns: 58px 250px minmax(560px, 1fr) 360px;
  gap: 14px;
  padding: 14px;
}

.side-nav {
  position: sticky;
  top: 72px;
  display: grid;
  align-self: start;
  overflow: hidden;
  border: 1px solid #e5e9f2;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgb(15 23 42 / 7%);
}

.side-nav a {
  display: grid;
  gap: 4px;
  min-height: 64px;
  place-items: center;
  padding: 8px 4px;
  color: #334155;
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.side-nav a.active,
.side-nav a:hover {
  background: #eef5ff;
  color: #0f56d9;
}

.side-nav span {
  font-size: 1.1rem;
}

.nav-spacer {
  margin-top: 120px;
}

.panel {
  border-color: #e5e9f2;
  border-radius: 18px;
  box-shadow: 0 12px 32px rgb(15 23 42 / 7%);
}

.tool-panel {
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-heading h2,
.project-panel h2 {
  margin: 0;
  color: #0f172a;
  font-size: 0.92rem;
  letter-spacing: 0;
  text-transform: none;
}

.page-actions {
  grid-template-columns: 1fr auto auto;
}

.page-actions button:first-child {
  grid-column: auto;
}

button,
.upload-button,
.download {
  border: 1px solid transparent;
  border-radius: 10px;
  background: #0f56d9;
  box-shadow: 0 1px 2px rgb(15 23 42 / 8%);
  font-size: 0.86rem;
}

.secondary {
  border-color: #dbe3ef;
  background: #ffffff;
  color: #334155;
}

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

.button-grid button,
.upload-button {
  display: grid;
  min-height: 64px;
  place-items: center;
  padding: 10px;
  background: #ffffff;
  color: #0f172a;
  border-color: #e2e8f0;
}

.button-grid span,
.upload-button span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  color: #0f172a;
}

.button-grid button:hover,
.upload-button:hover {
  border-color: #9fc2ff;
  background: #f8fbff;
  color: #0f56d9;
}

.page-item {
  min-height: 84px;
  border-radius: 12px;
  border-color: #dbe3ef;
  background: #ffffff;
}

.page-item.active {
  border-color: #0f56d9;
  background: #f8fbff;
  box-shadow: 0 0 0 2px rgb(15 86 217 / 10%);
}

.page-item span {
  width: 42px;
  height: 56px;
  border-color: #dbe3ef;
  background: #fff7ed;
  color: #0f56d9;
}

.tips-card {
  margin: 16px 0 20px;
  padding: 14px;
  border-radius: 12px;
  background: #eff6ff;
  color: #334155;
  font-size: 0.83rem;
  line-height: 1.45;
}

.tips-card strong {
  display: block;
  margin-bottom: 5px;
  color: #0f172a;
}

.workspace {
  gap: 10px;
  resize: none;
}

.canvas-toolbar {
  display: flex;
  gap: 16px;
  align-items: center;
  overflow-x: auto;
  padding: 10px 12px;
  border: 1px solid #e5e9f2;
  border-radius: 16px;
  background: #ffffff;
  color: #334155;
  box-shadow: 0 10px 30px rgb(15 23 42 / 7%);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.canvas-toolbar label,
.canvas-toolbar span,
.zoom-tools {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.guide {
  display: inline-block;
  width: 34px;
  border-top: 2px dashed #c76a6a;
}

.guide.trim {
  border-top-style: solid;
  border-top-color: #2f9e87;
}

.guide.safe {
  border-top-color: #8aa5c9;
}

.zoom-tools {
  margin-left: auto;
}

.zoom-tools button {
  width: 30px;
  height: 30px;
  padding: 0;
}

.canvas-shell {
  min-height: calc(100vh - 154px);
  padding: 28px;
  border-color: #e5e9f2;
  border-radius: 18px;
  background:
    linear-gradient(45deg, #edf1f7 25%, transparent 25%),
    linear-gradient(-45deg, #edf1f7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf1f7 75%),
    linear-gradient(-45deg, transparent 75%, #edf1f7 75%);
  background-color: #f9fbff;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
  box-shadow: inset 0 1px 0 #ffffff;
}

.design-canvas {
  border-radius: 2px;
  box-shadow: 0 18px 60px rgb(15 23 42 / 18%);
}

.canvas-note {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid #e5e9f2;
  border-radius: 14px;
  background: #ffffff;
  color: #64748b;
  font-size: 0.78rem;
  text-align: left;
}

.project-panel {
  padding: 0 0 16px;
}

.project-title {
  padding: 18px 20px;
  background: #ffffff;
  color: #0f172a;
  text-align: left;
  border-bottom: 1px solid #e5e9f2;
}

.section-title {
  margin: 18px 20px 12px;
  padding: 0;
  background: transparent;
  color: #0f172a;
  font-size: 0.9rem;
}

.project-panel .field-stack {
  padding: 0 20px 16px;
  border-bottom: 1px solid #eef2f7;
}

.project-panel .field-stack:last-of-type {
  border-bottom: 0;
}

.field-stack label,
.field-inline {
  color: #334155;
  font-size: 0.76rem;
  text-transform: none;
}

.field-stack input,
.field-stack select,
.field-stack textarea,
.field-inline input,
.field-inline select {
  min-height: 36px;
  border-color: #e2e8f0;
  border-radius: 8px;
  font-size: 0.86rem;
}

.option-group {
  grid-template-columns: 1fr 82px 88px;
}

.option-group span {
  font-size: 0.76rem;
  letter-spacing: 0;
  text-transform: none;
}

.toggle {
  border-color: #dbe3ef;
  background: #ffffff;
}

.toggle.active {
  border-color: #9fc2ff;
  background: #edf5ff;
  color: #0f56d9;
}

.status {
  margin: 14px 20px 0;
  color: #64748b;
  font-size: 0.85rem;
}

.download {
  width: calc(100% - 40px);
  margin: 10px 20px 0;
}

.preview-card {
  margin: 16px 20px 0;
  border-color: #e5e9f2;
}

@media (max-width: 1280px) {
  .app {
    grid-template-columns: 58px 240px minmax(480px, 1fr);
  }

  .project-panel {
    grid-column: 2 / -1;
  }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    height: auto;
    padding: 12px;
  }

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

  .side-nav {
    position: static;
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Reference-matched polish */
.topbar {
  grid-template-columns: 34px 210px 1fr auto;
  height: 52px;
  padding: 0 12px;
}

.topbar-menu,
.undo-action {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  box-shadow: none;
}

.brand-lockup strong,
.project-name {
  font-size: 0.86rem;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
}

.topbar-actions button {
  height: 34px;
  padding: 0 14px;
}

#export-button {
  min-width: 118px;
  background: #006dff;
}

.app {
  grid-template-columns: 52px 206px minmax(620px, 1fr) 318px;
  gap: 10px;
  padding: 10px;
}

.side-nav {
  top: 62px;
  border-radius: 8px;
  box-shadow: none;
}

.side-nav a {
  min-height: 56px;
  font-size: 0.68rem;
}

.side-nav span {
  font-size: 1rem;
}

.nav-spacer {
  margin-top: 132px;
}

.panel {
  border-radius: 10px;
  box-shadow: 0 8px 22px rgb(15 23 42 / 6%);
}

.tool-panel {
  padding: 14px;
}

.panel-heading {
  margin-bottom: 10px;
}

.panel-heading h2 {
  font-size: 0.86rem;
}

.page-actions {
  grid-template-columns: 1fr 0 0;
  gap: 0;
}

.page-actions button:first-child {
  height: 36px;
  border-radius: 8px;
}

#duplicate-page,
#delete-page {
  width: 0;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border: 0;
}

.page-list {
  margin: 12px 0 28px;
}

.page-item {
  position: relative;
  display: grid;
  grid-template-columns: 24px 1fr 18px;
  min-height: 108px;
  padding: 10px;
  border-radius: 8px;
}

.page-number {
  width: 22px !important;
  height: 22px !important;
  border: 0 !important;
  border-radius: 6px !important;
  background: #0f56d9 !important;
  color: #ffffff !important;
  font-size: 0.78rem;
}

.page-thumb {
  display: grid;
  align-content: center;
  justify-items: center;
  width: 92px;
  height: 74px;
  margin: 0 auto;
  border-radius: 4px;
  background: #fbf3e8;
  color: #102b5c;
  font-size: 0.45rem;
  text-align: center;
}

.page-thumb em {
  display: block;
  width: 38px;
  height: 16px;
  margin-top: 8px;
  background: #0f56d9;
}

.page-name {
  grid-column: 1 / -1;
  color: #0f172a;
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.page-menu {
  color: #0f172a;
  font-size: 1rem;
}

.button-grid {
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.button-grid button,
.upload-button {
  min-height: 58px;
  border-radius: 8px;
  font-size: 0.74rem;
}

.button-grid span,
.upload-button span {
  width: 22px;
  height: 22px;
  border: 0;
  font-size: 1rem;
}

.field-inline {
  margin-top: 10px;
}

.tips-card {
  margin-top: 18px;
  background: #eef7ff;
  font-size: 0.74rem;
}

.workspace {
  gap: 8px;
}

.canvas-toolbar {
  min-height: 42px;
  padding: 7px 10px;
  border-radius: 8px;
  box-shadow: none;
  font-size: 0.72rem;
}

.canvas-toolbar input {
  width: 14px;
  height: 14px;
  accent-color: #0f56d9;
}

.guide {
  width: 30px;
}

.canvas-shell {
  min-height: calc(100vh - 116px);
  padding: 38px 44px 28px;
  border-radius: 8px;
  box-shadow: none;
}

.design-canvas {
  box-shadow: 0 20px 50px rgb(15 23 42 / 16%);
}

.crop-guide {
  position: absolute;
  z-index: 6;
  background: #111827;
  pointer-events: none;
}

.crop-guide.h {
  height: 1px;
}

.crop-guide.v {
  width: 1px;
}

.canvas-note {
  border-radius: 8px;
  font-size: 0.72rem;
}

.project-panel {
  border-radius: 10px;
}

.project-title {
  display: flex;
  justify-content: space-between;
  padding: 14px 16px;
  font-size: 0.92rem;
}

.project-title::after {
  content: "⌄";
}

.section-title {
  margin: 16px 16px 10px;
  font-size: 0.82rem;
}

.project-panel .field-stack {
  padding: 0 16px 14px;
  gap: 9px;
}

.inline-fields {
  grid-template-columns: 1fr 82px;
  gap: 10px;
}

.field-stack label,
.field-inline {
  gap: 5px;
  font-size: 0.68rem;
  font-weight: 800;
}

.field-stack input,
.field-stack select,
.field-stack textarea,
.field-inline input {
  min-height: 32px;
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 0.76rem;
}

.option-group {
  grid-template-columns: 1fr 74px 78px;
  gap: 7px;
}

.option-group span {
  font-size: 0.68rem;
  font-weight: 800;
}

.toggle {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 0.72rem;
}

.check-row {
  min-height: 22px;
  font-size: 0.72rem !important;
}

.check-row input {
  width: 14px;
  height: 14px;
  accent-color: #0f56d9;
}

.status {
  margin: 12px 16px 0;
  font-size: 0.76rem;
}

.download {
  width: calc(100% - 32px);
  margin: 8px 16px 0;
  min-height: 34px;
}

.preview-card {
  display: none;
}

/* Final fit-and-finish pass for the screenshot proportions */
body {
  color: #111827;
  font-size: 14px;
}

.topbar {
  grid-template-columns: 34px 230px minmax(170px, 1fr) auto;
  gap: 10px;
  min-width: 0;
}

.brand-lockup,
.project-name,
.topbar-actions {
  min-width: 0;
}

.brand-lockup strong,
.project-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  gap: 8px;
}

.topbar-actions button {
  font-size: 0.82rem;
  white-space: nowrap;
}

.app {
  grid-template-columns: 64px 230px minmax(0, 1fr) 360px;
  align-items: start;
  gap: 12px;
  padding: 12px;
  overflow-x: hidden;
}

.side-nav {
  width: 64px;
  border-radius: 12px;
}

.side-nav a {
  min-height: 58px;
  padding: 7px 4px;
  font-size: 0.72rem;
  line-height: 1.15;
  white-space: normal;
}

.side-nav span {
  display: block;
  font-size: 1.08rem;
  line-height: 1;
}

.editor-sidebar,
.project-panel,
.workspace {
  min-width: 0;
}

.tool-panel,
.project-panel {
  border-radius: 14px;
}

.tool-panel {
  padding: 16px;
}

.panel-heading h2,
.project-panel h2 {
  font-size: 0.95rem;
}

.page-actions button:first-child {
  height: 38px;
  font-size: 0.86rem;
}

.page-item {
  min-height: 116px;
  grid-template-columns: 26px minmax(0, 1fr) 18px;
}

.page-thumb {
  width: 112px;
  height: 82px;
  font-size: 0.5rem;
}

.page-name {
  font-size: 0.76rem;
}

.button-grid {
  gap: 9px;
}

.button-grid button,
.upload-button {
  min-height: 62px;
  font-size: 0.78rem;
  line-height: 1.2;
}

.field-inline,
.field-stack label {
  font-size: 0.78rem;
}

.field-inline input,
.field-stack input,
.field-stack select,
.field-stack textarea {
  font-size: 0.84rem;
}

.tips-card {
  font-size: 0.78rem;
}

.canvas-toolbar {
  gap: 12px;
  padding: 8px 10px;
  font-size: 0.76rem;
}

.canvas-toolbar .zoom-tools {
  flex: 0 0 auto;
}

.canvas-shell {
  min-width: 0;
  padding: 40px 42px 32px;
  overflow: visible;
}

.design-canvas::before {
  border-color: #d77272;
}

.design-canvas::after {
  border-color: #2fb383;
}

.margin-guide {
  border-color: #4ea3d8;
}

.crop-guide {
  background: #1f2937;
}

.project-title {
  padding: 16px 18px;
  font-size: 1rem;
}

.section-title {
  margin: 16px 18px 10px;
  font-size: 0.9rem;
}

.project-panel .field-stack {
  padding: 0 18px 15px;
  gap: 10px;
}

.inline-fields {
  grid-template-columns: minmax(0, 1fr) minmax(104px, 0.72fr);
}

.option-group {
  grid-template-columns: minmax(88px, 1fr) 86px 92px;
}

.option-group span,
.field-stack label,
.check-row {
  color: #1f2937;
}

.field-stack input,
.field-stack select,
.field-stack textarea,
.field-inline input {
  min-width: 0;
  min-height: 34px;
}

.check-row {
  font-size: 0.78rem !important;
}

.status {
  font-size: 0.82rem;
}

@media (max-width: 1180px) {
  .app {
    grid-template-columns: 60px 220px minmax(0, 1fr) 330px;
    gap: 10px;
  }

  .topbar-actions .undo-action {
    display: none;
  }

  .project-panel .field-stack {
    padding-inline: 14px;
  }

  .section-title {
    margin-inline: 14px;
  }

  .inline-fields,
  .option-group {
    grid-template-columns: 1fr 1fr;
  }

  .option-group span {
    grid-column: 1 / -1;
  }
}

/* Requested spacing alignment tweaks */
.side-nav {
  align-self: stretch;
  min-height: calc(100vh - 76px);
  padding: 8px 7px;
  border-radius: 0;
  border-block: 0;
  border-left: 0;
}

.side-nav a {
  min-height: 56px;
  padding: 8px 6px;
  border-radius: 8px;
}

.side-nav a + a {
  margin-top: 2px;
}

.nav-spacer {
  margin-top: auto;
}

.canvas-toolbar {
  width: 100%;
  justify-content: flex-start;
  align-self: stretch;
  border-radius: 10px;
}

.workspace {
  align-items: stretch;
}

.project-title,
.section-title {
  padding-left: 8px;
}

.section-title {
  margin-left: 22px;
}

.project-panel .field-stack {
  padding-left: 26px;
}

@media (max-width: 1180px) {
  .section-title {
    margin-left: 18px;
  }

  .project-panel .field-stack {
    padding-left: 22px;
  }
}

/* ── Layout fix v3: match reference screenshot ── */

.editor-topbar,
.topbar {
  display: flex;
  align-items: center;
  gap: 0;
  height: 56px;
  padding: 0 20px 0 24px;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: none;
}

.topbar-start {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  margin-right: 32px;
}

.topbar-back-btn {
  min-width: 0;
  padding: 0 14px;
}

.editor-topbar .brand-lockup,
.topbar .brand-lockup {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
  margin-right: auto;
}

.templates-topbar {
  padding-left: 24px;
}

.templates-topbar .brand-lockup {
  margin-right: auto;
}

.brand-lockup strong {
  font-size: 0.9rem;
  font-weight: 700;
}

.project-name {
  padding-left: 16px;
  border-left: 1px solid #e5e7eb;
  font-size: 0.88rem;
  font-weight: 600;
  color: #374151;
}

.topbar-actions {
  display: flex;
  flex-shrink: 0;
  gap: 12px;
  align-items: center;
}

.topbar-btn {
  display: inline-flex;
  flex-shrink: 0;
  gap: 8px;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 18px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: none;
  color: #111827;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
}

.topbar-btn .btn-icon {
  font-size: 1rem;
  line-height: 1;
}

.topbar-btn.primary,
#export-button.topbar-btn {
  min-width: 0;
  padding: 0 22px;
  border-color: #0066ff;
  background: #0066ff;
  color: #ffffff;
}

.topbar-btn.primary:hover,
#export-button.topbar-btn:hover {
  background: #0058d6;
}

.app {
  display: grid;
  grid-template-columns: 72px 248px minmax(0, 1fr) 348px;
  gap: 0;
  align-items: stretch;
  min-height: calc(100vh - 56px);
  padding: 0;
  overflow: hidden;
}

/* Left rail: fixed-height items, full-height white column */
.side-nav {
  position: sticky;
  top: 56px;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  width: 72px;
  min-height: calc(100vh - 56px);
  padding: 10px 0;
  border: 0;
  border-right: 1px solid #e5e7eb;
  border-radius: 0;
  background: #ffffff;
  box-shadow: none;
}

.side-nav a {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  justify-content: center;
  min-height: 0;
  height: auto;
  padding: 11px 10px;
  border-radius: 0;
  color: #4b5563;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.side-nav a + a {
  margin-top: 0;
}

.side-nav a.active {
  background: #eff6ff;
  color: #0066ff;
}

.side-nav a:hover:not(.active) {
  background: #f9fafb;
  color: #111827;
}

.side-nav span {
  display: block;
  font-size: 1.15rem;
  line-height: 1;
}

.side-nav .nav-bottom {
  margin-top: auto;
}

.editor-sidebar {
  padding: 14px 12px 14px 14px;
  border-right: 1px solid #eef2f7;
  background: #f8fafc;
}

.tool-panel {
  padding: 16px;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgb(15 23 42 / 6%);
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 14px 16px;
  background: #f3f4f6;
  overflow: visible;
}

.canvas-toolbar {
  display: flex;
  width: 100%;
  flex-wrap: wrap;
  gap: 14px 20px;
  align-items: center;
  min-height: 44px;
  margin-bottom: 12px;
  padding: 10px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: none;
  font-size: 0.78rem;
  font-weight: 600;
}

.canvas-shell {
  flex: 1;
  min-height: calc(100vh - 180px);
  padding: 36px 40px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background-color: #eef1f5;
}

.canvas-note {
  margin-top: 10px;
  padding: 10px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  font-size: 0.76rem;
}

/* Right settings panel */
.project-panel {
  align-self: stretch;
  padding: 0 0 24px;
  border: 0;
  border-left: 1px solid #e5e7eb;
  border-radius: 0;
  background: #ffffff;
  box-shadow: none;
  overflow-y: auto;
}

.project-title {
  padding: 18px 22px;
  border-bottom: 1px solid #eef2f7;
  background: #ffffff;
  color: #111827;
  font-size: 0.95rem;
  font-weight: 700;
}

.project-title::after {
  color: #9ca3af;
  font-size: 0.85rem;
}

.section-title {
  margin: 22px 0 14px;
  padding: 0 22px;
  background: transparent;
  color: #111827;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0;
}

.project-panel .field-stack {
  padding: 0 22px 22px;
  gap: 14px;
  border-bottom: 1px solid #f1f5f9;
}

.project-panel .field-stack:last-of-type {
  border-bottom: 0;
}

.field-stack label,
.field-inline {
  gap: 7px;
  color: #374151;
  font-size: 0.76rem;
  font-weight: 600;
}

.field-stack input,
.field-stack select,
.field-stack textarea,
.field-inline input {
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #ffffff;
  font-size: 0.84rem;
}

.inline-fields {
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 12px;
}

.option-group {
  grid-template-columns: minmax(0, 1fr) 88px 92px;
  gap: 10px;
  align-items: center;
}

.option-group span {
  color: #6b7280;
  font-size: 0.72rem;
  font-weight: 600;
}

.toggle {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #ffffff;
  font-size: 0.76rem;
  font-weight: 600;
}

.toggle.active {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #0066ff;
}

.check-row {
  min-height: 28px;
  font-size: 0.8rem !important;
  font-weight: 500 !important;
}

.check-row input {
  width: 16px;
  height: 16px;
}

.status {
  margin: 16px 22px 0;
  font-size: 0.8rem;
}

.download {
  width: calc(100% - 44px);
  margin: 12px 22px 0;
  height: 38px;
}

@media (max-width: 1180px) {
  .app {
    grid-template-columns: 72px 220px minmax(0, 1fr);
  }

  .project-panel {
    grid-column: 2 / -1;
    border-left: 0;
    border-top: 1px solid #e5e7eb;
  }
}

/* Pages panel – match reference thumbnail grid */
.page-action-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.page-actions {
  display: block;
  margin-bottom: 14px;
}

.add-page-btn {
  display: flex;
  width: 100%;
  align-items: stretch;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: #0066ff;
  box-shadow: none;
  color: #ffffff;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  overflow: hidden;
}

.add-page-label {
  display: flex;
  flex: 1;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.add-page-plus {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
}

.add-page-divider {
  width: 1px;
  align-self: center;
  height: 22px;
  background: rgb(255 255 255 / 35%);
}

.add-page-chevron {
  display: grid;
  width: 42px;
  place-items: center;
  font-size: 1rem;
  line-height: 1;
}

.page-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  margin: 0 0 26px;
}

.page-card-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.page-card {
  position: relative;
  width: 100%;
  max-width: 168px;
  padding: 0;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.page-card:hover {
  border-color: #93c5fd;
}

.page-card.active {
  border-color: #0066ff;
  box-shadow: 0 0 0 1px #0066ff;
}

.page-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 6px;
  background: #0066ff;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.page-kebab {
  position: absolute;
  top: 6px;
  right: 4px;
  z-index: 3;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  box-shadow: none;
  color: #374151;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.page-kebab:hover {
  background: rgb(255 255 255 / 70%);
}

.page-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  aspect-ratio: 8.5 / 11;
  padding: 34px 10px 12px;
}

.page-preview-title {
  max-width: 100%;
  overflow: hidden;
  color: #102b5c;
  font-size: 0.52rem;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-preview-block {
  width: 46%;
  height: 12px;
  margin-top: auto;
  margin-bottom: 6px;
  border-radius: 2px;
  background: #0066ff;
}

.page-label {
  color: #6b7280;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
}

/* Inline canvas text editing */
.design-element.editing {
  cursor: text;
  user-select: text;
  overflow: visible;
}

.design-element .inline-editor {
  width: 100%;
  height: 100%;
  min-height: 100%;
  outline: none;
  line-height: 1.15;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
  user-select: text;
}

.design-element.editing.selected {
  outline: 2px solid #0066ff;
  outline-offset: 2px;
}

.design-element td.cell-editing {
  outline: 2px solid #0066ff;
  outline-offset: -2px;
  background: rgba(0, 102, 255, 0.06);
  cursor: text;
  user-select: text;
}

.design-element table td {
  cursor: text;
}

.sidebar-hint {
  margin: 0 0 12px;
  color: #64748b;
  font-size: 0.82rem;
  line-height: 1.45;
}

.sidebar-panel.hidden {
  display: none;
}

.project-panel.hidden {
  display: none;
}

.sidebar-text-size-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.sidebar-style-buttons,
.sidebar-align-buttons {
  display: flex;
  gap: 6px;
}

.sidebar-align-buttons .align-btn {
  width: 36px;
  height: 36px;
  border: 1px solid #d1d5db;
  background: #ffffff;
}

.sidebar-align-buttons .align-btn.active {
  border-color: #0066ff;
  background: #eff6ff;
  color: #0066ff;
}

.sidebar-align-row {
  display: grid;
  gap: 8px;
  color: #475569;
  font-size: 0.78rem;
  font-weight: 700;
}

.image-upload-area {
  position: relative;
  display: grid;
  gap: 6px;
  place-items: center;
  padding: 28px 16px;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  cursor: pointer;
  text-align: center;
}

.image-upload-area input[type='file'] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.image-upload-icon {
  font-size: 2rem;
  color: #64748b;
}

.image-upload-hint {
  color: #94a3b8;
  font-size: 0.78rem;
}

.resize-handle {
  position: absolute;
  z-index: 5;
  width: 10px;
  height: 10px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #0066ff;
  box-shadow: 0 0 0 1px rgb(0 102 255 / 35%);
}

.resize-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.resize-n { top: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.resize-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.resize-e { top: calc(50% - 5px); right: -5px; cursor: ew-resize; }
.resize-se { right: -5px; bottom: -5px; cursor: nwse-resize; }
.resize-s { bottom: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.resize-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.resize-w { top: calc(50% - 5px); left: -5px; cursor: ew-resize; }

.design-element.selected.text,
.design-element.selected.heading,
.design-element.selected.image {
  overflow: visible;
}

.text-toolbar {
  position: relative;
  z-index: 50;
  gap: 10px 12px;
  overflow: visible;
}

.canvas-toolbar.text-toolbar {
  overflow: visible;
}

.toolbar-floating-tooltip {
  position: fixed;
  z-index: 10000;
  padding: 6px 10px;
  border-radius: 6px;
  background: #111827;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -100%);
  box-shadow: 0 8px 20px rgb(15 23 42 / 18%);
}

.toolbar-floating-tooltip.hidden {
  display: none;
}

.text-toolbar .toolbar-select {
  min-width: 118px;
  height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
  color: #111827;
  font-size: 0.78rem;
  font-weight: 600;
}

.text-toolbar .toolbar-select-sm {
  min-width: 92px;
}

.font-size-tools {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.toolbar-size-input {
  width: 44px;
  height: 32px;
  padding: 0 6px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
  color: #111827;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.toolbar-unit {
  color: #6b7280;
  font-size: 0.76rem;
  font-weight: 600;
}

.toolbar-icon-btn {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #374151;
  font-size: 0.86rem;
  font-weight: 700;
}

.toolbar-icon-btn:hover {
  background: #f3f4f6;
}

.toolbar-icon-btn.active {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.toolbar-divider {
  display: inline-block;
  width: 1px;
  height: 24px;
  background: #e5e7eb;
}

.toolbar-color {
  position: relative;
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
}

.toolbar-color input[type='color'] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.toolbar-color-label {
  color: #111827;
  font-size: 0.92rem;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.toolbar-line-height {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: #4b5563;
  font-size: 0.76rem;
  font-weight: 600;
}

.toolbar-line-height input {
  width: 52px;
  height: 32px;
  padding: 0 6px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
}

.text-toolbar .align-btn .align-glyph,
.align-btn .align-glyph {
  display: inline-grid;
  gap: 2px;
  width: 14px;
}

.text-toolbar .align-btn .align-glyph i,
.align-btn .align-glyph i {
  display: block;
  height: 2px;
  border-radius: 999px;
  background: currentcolor;
}

.text-toolbar .align-left i:nth-child(1),
.align-left i:nth-child(1) { width: 14px; }
.text-toolbar .align-left i:nth-child(2),
.align-left i:nth-child(2) { width: 10px; }
.text-toolbar .align-left i:nth-child(3),
.align-left i:nth-child(3) { width: 12px; }

.text-toolbar .align-center i:nth-child(1),
.align-center i:nth-child(1) { width: 14px; margin-inline: auto; }
.text-toolbar .align-center i:nth-child(2),
.align-center i:nth-child(2) { width: 10px; margin-inline: auto; }
.text-toolbar .align-center i:nth-child(3),
.align-center i:nth-child(3) { width: 12px; margin-inline: auto; }

.text-toolbar .align-right i:nth-child(1),
.align-right i:nth-child(1) { width: 14px; margin-left: auto; }
.text-toolbar .align-right i:nth-child(2),
.align-right i:nth-child(2) { width: 10px; margin-left: auto; }
.text-toolbar .align-right i:nth-child(3),
.align-right i:nth-child(3) { width: 12px; margin-left: auto; }

.text-toolbar .align-justify i,
.align-justify i {
  width: 14px;
}

.design-element.text-placeholder::before {
  content: attr(data-placeholder);
  color: #94a3b8;
  font-weight: 500;
  pointer-events: none;
}

.table-insert-panel {
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid #dbe3f0;
  border-radius: 12px;
  background: #ffffff;
}

.table-size-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.table-size-fields label {
  display: grid;
  gap: 6px;
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.table-size-fields input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  color: #111827;
  font-size: 0.92rem;
  font-weight: 700;
}

.table-insert-btn {
  width: 100%;
  margin-bottom: 12px;
}

.table-grid-picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
}

.table-grid-cell {
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid #d1d5db;
  border-radius: 3px;
  background: #f8fafc;
  cursor: pointer;
}

.table-grid-cell.active {
  border-color: #0066ff;
  background: #dbeafe;
}

.table-options-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.table-options-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.table-tab {
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #f3f4f6;
  color: #374151;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
}

.table-tab.active {
  border-color: #0066ff;
  background: #ffffff;
  color: #0066ff;
}

.table-tab-panel {
  display: grid;
  gap: 12px;
}

.table-option-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.table-option-row label,
.table-option-field {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 0.78rem;
  font-weight: 700;
}

.table-option-group {
  display: grid;
  gap: 8px;
}

.table-option-label {
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.table-icon-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.table-icon-btn {
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #ffffff;
  color: #374151;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.table-icon-btn:hover {
  background: #f8fafc;
}

.table-option-check {
  display: flex;
  gap: 8px;
  align-items: center;
  color: #374151;
  font-size: 0.82rem;
  font-weight: 600;
}

/* Element inspector (Table / Text / Layout tabs) */
.element-inspector {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.property-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin-bottom: 12px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
}

.property-tab {
  padding: 10px 8px;
  border: none;
  background: #64748b;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.property-tab:hover {
  background: #475569;
}

.property-tab.active {
  background: #ffffff;
  color: #0f172a;
}

.property-tab-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.property-tab-panel.hidden {
  display: none;
}

.property-section {
  border: 1px solid #cbd5e1;
  border-radius: 0;
  margin-bottom: -1px;
  overflow: hidden;
}

.property-section:first-of-type {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.property-section:last-of-type {
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  margin-bottom: 0;
}

.property-section > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(180deg, #b8c9d9 0%, #a8bacb 100%);
  color: #1e293b;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.property-section > summary::-webkit-details-marker {
  display: none;
}

.property-section > summary::before {
  content: '▼';
  font-size: 0.55rem;
  opacity: 0.7;
}

.property-section:not([open]) > summary::before {
  content: '▶';
}

.property-section-body {
  padding: 12px;
  background: #e8edf2;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.property-row-label {
  flex: 0 0 100%;
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: -4px;
}

.property-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.property-inline label {
  color: #475569;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.property-inline input[type='number'],
.property-inline select {
  flex: 1;
  min-width: 48px;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  font-size: 0.82rem;
}

.property-icon-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.property-icon-btn {
  min-width: 36px;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #374151;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}

.property-icon-btn:hover {
  background: #f1f5f9;
}

.property-icon-btn.active {
  background: #0d9488;
  border-color: #0d9488;
  color: #ffffff;
}

.border-grid-picker {
  display: grid;
  grid-template-columns: repeat(3, 36px);
  gap: 4px;
}

.border-grid-picker button {
  width: 36px;
  height: 36px;
  padding: 4px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
  font-size: 0.65rem;
}

.border-grid-picker button.active {
  background: #0d9488;
  border-color: #0d9488;
  color: #ffffff;
}

.table-grid-picker {
  display: grid;
  gap: 2px;
  padding: 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
}

.table-grid-picker-cell {
  width: 18px;
  height: 18px;
  border: 1px solid #94a3b8;
  border-radius: 2px;
  background: #f8fafc;
  cursor: pointer;
}

.table-grid-picker-cell.highlight {
  background: #0d9488;
  border-color: #0f766e;
}

/* Image drop zone + project library */
.image-drop-zone {
  display: grid;
  gap: 6px;
  place-items: center;
  min-height: 140px;
  padding: 28px 16px;
  margin-bottom: 12px;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.image-drop-zone.dragover,
.image-drop-zone.drag-over {
  border-color: #0d9488;
  background: #ecfdf5;
}

.image-drop-zone .image-upload-icon {
  font-size: 2rem;
  color: #64748b;
}

.image-drop-zone strong {
  color: #475569;
  font-size: 0.85rem;
}

.image-drop-zone .image-upload-hint {
  color: #94a3b8;
  font-size: 0.78rem;
}

.project-images-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-images-title {
  margin: 0;
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.project-image-library {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.inspector-size-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.inspector-fill-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #475569;
  font-size: 0.78rem;
  font-weight: 700;
}

.inspector-tool-group {
  display: grid;
  gap: 6px;
}

.inspector-icon-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inspector-icon-btn {
  min-width: 36px;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #374151;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}

.inspector-icon-btn:hover {
  background: #f1f5f9;
}

.inspector-icon-btn.active {
  background: #0d9488;
  border-color: #0d9488;
  color: #ffffff;
}

.border-style-row label {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 0.78rem;
  font-weight: 700;
}

.project-image-card {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
}

.project-image-card:hover {
  border-color: #0d9488;
}

.project-image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.project-image-card span {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 6px;
  background: rgba(15, 23, 42, 0.72);
  color: #ffffff;
  font-size: 0.6rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-filename {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 4px;
}

.topbar-filename-label {
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.topbar-filename input {
  width: min(220px, 28vw);
  height: 38px;
  padding: 0 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #ffffff;
  color: #111827;
  font-size: 0.84rem;
}

.topbar-filename input:focus {
  outline: 2px solid rgb(0 102 255 / 18%);
  border-color: #0066ff;
}

.settings-section {
  border-bottom: 1px solid #e5e7eb;
}

.settings-section:last-of-type {
  border-bottom: none;
}

.settings-section > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.settings-section > summary::-webkit-details-marker {
  display: none;
}

.settings-section > summary.section-title {
  margin: 14px 14px 12px;
}

.settings-section > summary.section-title::before {
  content: '▼';
  flex-shrink: 0;
  font-size: 0.62rem;
  opacity: 0.65;
}

.settings-section:not([open]) > summary.section-title::before {
  content: '▶';
}

.settings-section:not([open]) > summary.section-title {
  margin-bottom: 14px;
}

.settings-section[open] .field-stack {
  padding-bottom: 4px;
}

.canvas-toolbar span:has(.guide) {
  gap: 10px;
}

.canvas-toolbar .guide {
  display: inline-block;
  flex-shrink: 0;
  width: 56px;
  height: 28px;
  border: 3px dashed #d77272;
  border-radius: 4px;
  background: rgb(215 114 114 / 10%);
  vertical-align: middle;
}

.canvas-toolbar .guide.bleed {
  border-color: #d77272;
}

.canvas-toolbar .guide.trim {
  border-style: solid;
  border-color: #2fb383;
  background: rgb(47 179 131 / 10%);
}

.canvas-toolbar .guide.safe {
  border-style: dashed;
  border-color: #4ea3d8;
  background: rgb(78 163 216 / 10%);
  box-shadow: inset 0 0 0 5px rgb(255 255 255 / 85%);
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #eef2f8 0%, #f8fafc 100%);
}

.login-card {
  width: min(100%, 420px);
  padding: 32px 28px;
  border: 1px solid #d9e1ef;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 18px 48px rgb(30 45 70 / 10%);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.login-brand strong {
  font-size: 1rem;
  font-weight: 700;
}

.login-title {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.login-subtitle {
  margin: 0 0 24px;
  color: #64748b;
  font-size: 0.92rem;
  line-height: 1.5;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 0.82rem;
  font-weight: 700;
}

.login-form input {
  height: 42px;
  padding: 0 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  font-size: 0.95rem;
}

.login-form input:focus {
  outline: 2px solid rgb(0 102 255 / 18%);
  border-color: #0066ff;
}

.login-submit {
  width: 100%;
  height: 42px;
  margin-top: 4px;
}

.login-message {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.45;
}

.login-error {
  color: #b91c1c;
}

.login-config-error {
  color: #475569;
}

.login-config-error code {
  font-size: 0.8rem;
}

.app-loading {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: rgb(238 242 248 / 92%);
}

.app-loading-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border: 1px solid #d9e1ef;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 18px 48px rgb(30 45 70 / 10%);
}

.login-screen.hidden,
#app-shell.hidden,
#home-shell.hidden,
#templates-shell.hidden,
.app-loading.hidden {
  display: none !important;
}

.home-shell {
  min-height: 100vh;
  background: #eef2f8;
}

.home-page {
  max-width: 920px;
  margin: 0 auto;
  padding: 48px 24px 56px;
  text-align: center;
}

.home-greeting {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  color: #111827;
}

.home-subtitle {
  margin: 10px 0 36px;
  color: #64748b;
  font-size: 1rem;
}

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

.home-action-card {
  display: grid;
  gap: 18px;
  justify-items: center;
  padding: 24px 20px 28px;
  border: 1px solid #d9e1ef;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 14px 40px rgb(30 45 70 / 8%);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.home-action-card:hover {
  border-color: #0066ff;
  transform: translateY(-2px);
  box-shadow: 0 18px 48px rgb(0 102 255 / 12%);
}

.home-action-image {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 4 / 3;
  border-radius: 16px;
  overflow: hidden;
}

.home-action-image-templates {
  background: linear-gradient(145deg, #eff6ff 0%, #dbeafe 100%);
}

.home-action-image-create {
  background: linear-gradient(145deg, #f8fafc 0%, #e2e8f0 100%);
}

.home-thumb {
  position: absolute;
  width: 58%;
  aspect-ratio: 3 / 4;
  border: 1px solid rgb(255 255 255 / 80%);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgb(15 23 42 / 12%);
}

.home-thumb-a {
  top: 18%;
  left: 14%;
  transform: rotate(-8deg);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.home-thumb-b {
  top: 24%;
  left: 34%;
  transform: rotate(4deg);
  background: linear-gradient(180deg, #ffffff 0%, #eff6ff 100%);
}

.home-thumb-c {
  top: 16%;
  right: 12%;
  transform: rotate(10deg);
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
}

.home-blank-page {
  width: 62%;
  aspect-ratio: 3 / 4;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
}

.home-plus {
  position: absolute;
  right: 22%;
  bottom: 18%;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #0066ff;
  color: #ffffff;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 8px 20px rgb(0 102 255 / 35%);
}

.home-action-label {
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
}

@media (max-width: 720px) {
  .home-actions {
    grid-template-columns: 1fr;
  }
}

.templates-shell {
  min-height: 100vh;
  background: #eef2f8;
}

.templates-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}

.templates-title {
  margin: 0 0 24px;
  font-size: 1.8rem;
}

.templates-status {
  margin: -12px 0 20px;
  color: #64748b;
  font-size: 0.92rem;
}

.templates-status.hidden {
  display: none;
}

.templates-status.error {
  color: #b91c1c;
}

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

.template-card {
  display: grid;
  gap: 10px;
  justify-items: start;
  min-height: 150px;
  padding: 18px;
  border: 1px solid #d9e1ef;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgb(30 45 70 / 8%);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, transform 0.15s;
}

.template-card:hover {
  border-color: #0066ff;
  transform: translateY(-1px);
}

.template-card-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #eff6ff;
  color: #0066ff;
  font-size: 1.2rem;
}

.template-card strong {
  font-size: 1rem;
  color: #111827;
}

.template-card-meta {
  color: #64748b;
  font-size: 0.82rem;
}

.templates-empty {
  grid-column: 1 / -1;
  padding: 48px 24px;
  border: 1px dashed #cbd5e1;
  border-radius: 16px;
  background: #ffffff;
  text-align: center;
}

.templates-empty h2 {
  margin: 0 0 8px;
}

.templates-empty p {
  margin: 0;
  color: #64748b;
}
