:root {
  --chrome: #f5f1e8;
  --chrome-2: #ebe4d6;
  --surface: #fffdf8;
  --surface-2: #f8f4ec;
  --ink: #24211e;
  --muted: #71695f;
  --hairline: #ddd3c3;
  --accent: #1687d9;
  --danger: #b64646;
  --shadow: 0 18px 50px rgba(53, 45, 33, 0.16);
  --radius: 12px;
  font-family:
    "PingFang SC", "Hiragino Sans GB", "Heiti SC", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 215, 202, 0.28), transparent 34%),
    radial-gradient(circle at 82% 16%, rgba(196, 238, 230, 0.32), transparent 34%),
    linear-gradient(135deg, #f8f3e9 0%, #eee6d8 100%);
}

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

button {
  border: 1px solid #d6ccbd;
  background: #fffdf8;
  color: var(--ink);
  border-radius: 8px;
  height: 34px;
  padding: 0 12px;
  cursor: pointer;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

button:hover {
  border-color: #a99780;
  background: #fff8eb;
}

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

button.primary {
  border-color: #1279c3;
  background: #1687d9;
  color: white;
}

button.danger {
  border-color: rgba(182, 70, 70, 0.35);
  color: var(--danger);
}

#app {
  display: grid;
  grid-template-columns: 286px minmax(520px, 1fr) 328px;
  overflow: hidden;
}

.sidebar,
.inspector {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  min-width: 0;
  overflow: auto;
  background: rgba(250, 247, 240, 0.84);
  backdrop-filter: blur(16px);
  border-right: 1px solid rgba(182, 170, 152, 0.42);
}

.inspector {
  border-right: 0;
  border-left: 1px solid rgba(182, 170, 152, 0.42);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 2px 10px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #1687d9;
  background: #ffd8d3;
  border: 1px solid #ffc5c0;
  border-radius: 10px;
  font-family: "Xingkai SC", "STKaiti", serif;
  font-size: 26px;
  box-shadow: 0 8px 22px rgba(105, 81, 72, 0.12);
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 650;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel {
  background: rgba(255, 253, 248, 0.8);
  border: 1px solid rgba(215, 204, 188, 0.82);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 8px 22px rgba(62, 52, 38, 0.06);
}

.panel-title {
  margin-bottom: 10px;
  color: #5b5147;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.page-list {
  display: grid;
  gap: 8px;
}

.page-card {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  height: auto;
  padding: 9px;
  text-align: left;
  background: #fffdf8;
}

.page-card.active {
  border-color: #1687d9;
  box-shadow: 0 0 0 3px rgba(22, 135, 217, 0.13);
}

.page-thumb {
  width: 34px;
  height: 48px;
  border: 1px solid #d3c8b7;
  border-radius: 4px;
  background:
    linear-gradient(#fffdf8, #fffaf1),
    repeating-linear-gradient(0deg, transparent 0 10px, rgba(43, 38, 32, 0.1) 10px 11px);
}

.page-card strong {
  display: block;
  font-size: 13px;
  font-weight: 650;
}

.page-card span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.preset-list,
.tool-grid,
.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.preset-button {
  height: 44px;
  text-align: left;
  line-height: 1.15;
}

.preset-button.active {
  border-color: #1687d9;
}

.tool-button {
  height: 38px;
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-rows: 56px minmax(0, 1fr);
  min-width: 0;
}

.topbar {
  display: grid;
  grid-template-columns: 210px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(182, 170, 152, 0.5);
  background: rgba(252, 249, 242, 0.86);
  backdrop-filter: blur(14px);
}

.topbar-left,
.topbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.topbar-right button {
  font-size: 12px;
}

.icon-button {
  width: 34px;
  padding: 0;
  font-size: 16px;
}

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

.topbar-center {
  display: flex;
  gap: 12px;
  align-items: baseline;
  justify-content: center;
  min-width: 0;
}

#currentPageName {
  font-size: 14px;
  font-weight: 650;
}

#saveState {
  color: var(--muted);
  font-size: 12px;
}

.canvas-shell {
  position: relative;
  overflow: auto;
  padding: 44px;
}

.artboard-wrap {
  display: grid;
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  place-items: center;
}

.artboard {
  width: calc(1280px * var(--zoom, 0.62));
  height: calc(1810px * var(--zoom, 0.62));
  filter: drop-shadow(var(--shadow));
  transform-origin: top center;
}

.artboard svg {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 5px;
  background: white;
}

.block {
  cursor: grab;
}

.block:active {
  cursor: grabbing;
}

.selection-outline {
  pointer-events: none;
}

.resize-handle {
  cursor: nwse-resize;
}

.table-guide {
  pointer-events: all;
}

.table-guide[data-guide-kind="col"] {
  cursor: ew-resize;
}

.table-guide[data-guide-kind="row"] {
  cursor: ns-resize;
}

.image-layer {
  cursor: move;
}

.image-layer:active {
  cursor: grabbing;
}

.image-selection-outline {
  pointer-events: none;
}

.image-resize-handle {
  cursor: nwse-resize;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.field input,
.field select,
.field textarea,
.number-grid input {
  width: 100%;
  border: 1px solid #d8cdbc;
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  outline: none;
}

.field input,
.field select {
  height: 34px;
  padding: 0 9px;
}

.field textarea {
  min-height: 132px;
  padding: 9px;
  resize: vertical;
  line-height: 1.55;
}

.number-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.number-grid input {
  height: 32px;
  margin-top: 4px;
  padding: 0 7px;
}

.color-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.color-row input {
  display: block;
  width: 100%;
  height: 30px;
  margin-top: 5px;
  padding: 2px;
  border: 1px solid #d8cdbc;
  border-radius: 8px;
  background: #fffdf8;
}

.actions-row,
.actions-grid {
  display: grid;
  gap: 8px;
}

.table-line-controls,
.image-layer-controls {
  margin: 10px 0 12px;
  padding: 10px;
  border: 1px dashed #d8cdbc;
  border-radius: 10px;
  background: rgba(255, 248, 235, 0.58);
}

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

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

.actions-row button,
.actions-grid button,
.image-actions button {
  font-size: 12px;
}

.empty-state {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.hidden {
  display: none;
}

@media (max-width: 1180px) {
  #app {
    grid-template-columns: 250px minmax(420px, 1fr);
  }

  .inspector {
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 10;
    width: min(328px, calc(100vw - 24px));
    max-height: 72vh;
    border: 1px solid rgba(182, 170, 152, 0.62);
    border-radius: 16px;
    box-shadow: var(--shadow);
  }
}

@media print {
  body {
    background: white;
  }

  .sidebar,
  .inspector,
  .topbar {
    display: none;
  }

  #app,
  .workspace,
  .canvas-shell,
  .artboard-wrap {
    display: block;
    width: auto;
    height: auto;
    overflow: visible;
    padding: 0;
  }

  .artboard {
    width: 100vw;
    height: auto;
    filter: none;
  }
}
