:root {
  color-scheme: light;
  --canvas: #efede8;
  --panel: #fdfcf9;
  --sheet: #fffdfa;
  --ink: #302721;
  --muted: #746961;
  --line: #e9e1d8;
  --line-strong: #d9cdc0;
  --accent: #8e2432;
  --accent-hover: #751a28;
  --accent-soft: #f7e9e8;
  --green: #547160;
  --focus: #a33246;
  --ui-font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  font-family: var(--ui-font);
  font-size: 16px;
  color: var(--ink);
  background: var(--panel);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; height: 100vh; height: 100dvh; display: grid; grid-template-rows: 70px 47px minmax(0, 1fr); overflow: hidden; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .42; }
button, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.icon-library { display: none; }
.icon { width: 19px; height: 19px; flex: 0 0 auto; display: block; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.app-header { padding: 0 24px; display: grid; grid-template-columns: 1fr minmax(150px, 300px) 1fr; gap: 20px; align-items: center; border-bottom: 1px solid var(--line); background: var(--sheet); z-index: 4; }
.app-brand, .header-actions, .history-actions, .save-feedback { display: flex; align-items: center; }
.app-brand { gap: 12px; min-width: 0; }
.brand-mark { width: 39px; height: 39px; display: grid; place-items: center; color: #ffebbb; background: var(--accent); border-radius: 10px; box-shadow: inset 0 1px 0 #ffffff24, 0 2px 4px #64273319; flex-shrink: 0; }
.brand-mark .icon { width: 22px; height: 22px; }
.brand-name { font-size: 17px; font-weight: 750; letter-spacing: .035em; white-space: nowrap; }
.project-identity { display: grid; justify-items: center; gap: 1px; min-width: 0; }
#project-title { color: var(--ink); margin: 0; min-width: 0; width: 100%; height: 31px; text-align: center; font-weight: 690; font-size: 15px; padding: 3px 8px; border: 1px solid transparent; background: transparent; border-radius: 6px; text-overflow: ellipsis; }
#project-title:hover, #project-title:focus { background: #f8f3eb; border-color: var(--line); }
.save-feedback { gap: 5px; color: var(--green); font-size: 12px; white-space: nowrap; }
.save-feedback .icon { width: 13px; height: 13px; }
.header-actions { justify-content: flex-end; gap: 9px; white-space: nowrap; }
.history-actions { gap: 2px; padding-right: 8px; border-right: 1px solid var(--line); }
.icon-button { border: 1px solid transparent; border-radius: 7px; background: transparent; color: #665952; display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; flex: 0 0 auto; list-style: none; }
.icon-button::-webkit-details-marker { display: none; }
.icon-button:hover:not(:disabled), .file-menu[open] summary, .icon-button[aria-expanded="true"] { background: #f2ece4; color: var(--accent); }
.icon-button.small { width: 31px; height: 31px; }
.icon-button.small .icon { width: 16px; height: 16px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 0 13px; border: 1px solid transparent; border-radius: 7px; font-weight: 650; font-size: 14px; white-space: nowrap; }
.button .icon { width: 17px; height: 17px; }
.button.primary { color: #fff9f3; background: var(--accent); box-shadow: 0 1px 2px #60122226; }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); }
.button.secondary { color: #54443b; background: var(--sheet); border-color: var(--line-strong); }
.button.secondary:hover:not(:disabled) { background: #f7f1ea; }
.button.compact { min-height: 34px; }
.button.grow { width: 100%; }
.file-menu { position: relative; }
.file-menu-popover { position: absolute; right: 0; top: calc(100% + 8px); z-index: 6; min-width: 165px; padding: 5px; background: var(--sheet); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 8px 24px #4231231f; }
.file-menu-popover button { display: flex; gap: 8px; align-items: center; width: 100%; border: 0; border-radius: 5px; background: transparent; color: var(--ink); padding: 9px; text-align: left; font-size: 14px; }
.file-menu-popover button:hover { background: var(--accent-soft); }
.file-menu-popover .icon { width: 16px; height: 16px; color: var(--accent); }

.template-bar { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 0 24px; background: #f6efe8; border-bottom: 1px solid var(--line); }
.template-label { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; color: #59453c; font-size: 14px; font-weight: 680; }
.template-label .icon { color: var(--accent); width: 17px; height: 17px; }
#template-picker { appearance: none; width: min(280px, 100%); min-width: 0; min-height: 34px; padding: 5px 30px 5px 10px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--sheet) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23746961' stroke-width='1.5' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E") right 8px center / 16px no-repeat; color: var(--ink); font-size: 14px; font-weight: 650; text-overflow: ellipsis; }
.collab-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; margin-left: auto; }
.collab-status { border: 0; background: none; color: #59453c; text-align: right; font-size: 13px; font-weight: 650; }
.collab-status[data-state="synced"] { color: #52705b; }
.collab-status[data-state="offline"], .collab-status[data-state="error"], .collab-status[data-state="conflict"] { color: var(--accent); }

.app-workspace { display: grid; min-width: 0; min-height: 0; grid-template-columns: 192px minmax(0, 1fr) 288px; position: relative; }
.sidebar { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); }
.pages-panel { border-right: 1px solid var(--line); }
.inspector-panel { border-left: 1px solid var(--line); }
.panel-heading { height: 48px; flex: 0 0 48px; padding: 0 15px; display: flex; align-items: center; justify-content: space-between; gap: 7px; border-bottom: 1px solid var(--line); font-size: 14px; font-weight: 700; }
.panel-heading > span { display: inline-flex; align-items: center; gap: 8px; }
.panel-heading > span > .icon { color: var(--accent); width: 17px; height: 17px; }
.pages-scroller, .inspector-content { min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: #d8c9bd transparent; }
.pages-scroller { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 13px; }
.page-entry { display: grid; justify-items: center; flex: 0 0 auto; width: 100%; gap: 8px; border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 9px 5px 7px; color: var(--muted); text-align: center; }
.page-entry:hover { background: #f5eee6; color: var(--ink); }
.page-entry.is-active, .page-entry[aria-current="true"], .page-entry[aria-selected="true"] { background: var(--accent-soft); border-color: #dbafae; color: var(--accent); }
.page-thumb { position: relative; display: block; width: 112px; max-width: 100%; overflow: hidden; border-radius: 3px; background: white; box-shadow: 0 1px 4px #3a241828, 0 0 0 1px #63473b17; isolation: isolate; }
.page-thumb-paper { position: absolute; top: 0; left: 0; transform-origin: top left; pointer-events: none; overflow: hidden; }
.page-label { display: inline-flex; align-items: center; justify-content: center; gap: 6px; max-width: 100%; line-height: 1.4; font-size: 13px; }
.page-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-number { font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 750; opacity: .8; }
.pages-actions { margin-top: auto; padding: 11px 13px; border-top: 1px solid var(--line); }

.studio { display: grid; grid-template-rows: 48px minmax(0, 1fr) 45px; min-width: 0; min-height: 0; }
.studio-tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 0 14px; background: var(--sheet); border-bottom: 1px solid var(--line); z-index: 2; }
.studio-insert, .stage-page-actions, .mobile-tools { display: flex; align-items: center; gap: 5px; }
.toolbar-button { background: transparent; color: #58453d; min-height: 33px; padding: 0 9px; }
.toolbar-button .icon { color: var(--accent); }
.toolbar-button:hover { background: var(--accent-soft); color: var(--accent); }
.mobile-tools { display: none; }
#stage { min-width: 0; min-height: 0; overflow: auto; padding: 23px 28px; background-color: var(--canvas); background-image: radial-gradient(circle, #a28d7f4a 0.8px, transparent 0.9px); background-size: 17px 17px; scrollbar-width: thin; scrollbar-color: #d8c9bd transparent; overscroll-behavior: contain; }
#paper-wrap { position: relative; margin: 0 auto; flex-shrink: 0; background: white; box-shadow: 0 1px 4px #3a241823, 0 12px 30px #3a241820, 0 0 0 1px #63473b18; }
#paper { position: absolute; top: 0; left: 0; transform-origin: top left; isolation: isolate; overflow: hidden; }
.paper-item { position: absolute; touch-action: none; }
#paper .paper-item { cursor: move; }
#paper .paper-item.is-selected { z-index: auto; outline: 2px solid #d57562; outline-offset: 0; }
#paper .paper-item:not(.is-selected):hover { outline: 1px dashed #b94c5d; }
.paper-text { width: 100%; height: 100%; white-space: pre-wrap; overflow-wrap: anywhere; overflow: hidden; font-family: var(--ui-font); }
.paper-text[contenteditable] { color: inherit; cursor: text; touch-action: auto; outline: none; user-select: text; }
.paper-image { display: block; width: 100%; height: 100%; pointer-events: none; user-select: none; }
.paper-placeholder { width: 100%; height: 100%; display: grid; align-content: center; justify-items: center; gap: 7px; color: #8c6d62; background: #f4ebe4; border: 1px dashed #c6a899; font-size: 14px; line-height: 1.35; text-align: center; padding: 8px; }
.paper-placeholder::before { content: ""; display: block; width: 24px; height: 18px; padding: 2px; border: 1.5px solid currentColor; border-radius: 3px; background: linear-gradient(143deg, transparent 54%, currentColor 55% 60%, transparent 61%) right 4px bottom 3px / 13px 10px no-repeat, radial-gradient(circle, currentColor 0 1.2px, transparent 1.5px) left 4px top 3px / 5px 5px no-repeat; }
.resize-handle { position: absolute; z-index: 1; display: block; width: 16px; height: 16px; padding: 0; right: -7px; bottom: -7px; border: 2px solid #fff4e2; background: #b74355; border-radius: 3px; cursor: nwse-resize; box-shadow: 0 0 0 1px #ac3d56; touch-action: none; }
.studio-footer { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; gap: 7px; align-items: center; padding: 0 12px; background: var(--sheet); border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.zoom-controls { display: flex; align-items: center; gap: 4px; }
#zoom-value { min-width: 43px; text-align: center; font-weight: 650; }
.zoom-fit { margin-left: 3px; }
.help-button { justify-self: end; }
.inspector-content { padding: 14px; }
.inspector-content:empty::before { display: block; content: "正在载入页面属性…"; color: var(--muted); font-size: 14px; }
.inspector-section { display: grid; gap: 9px; padding: 0 0 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.inspector-section:last-child { margin-bottom: 0; border-bottom: 0; }
.inspector-section h2, .inspector-section h3, .inspector-section h4 { margin: 0 0 2px; font-size: 14px; font-weight: 700; }
.inspector-label { display: grid; gap: 5px; min-width: 0; font-size: 13px; font-weight: 650; color: #5d4d44; }
.inspector-content input:not([type="checkbox"]), .inspector-content select, .inspector-content textarea { width: 100%; min-width: 0; min-height: 35px; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background-color: var(--sheet); color: var(--ink); font-size: 14px; }
.inspector-content select { appearance: none; padding-right: 26px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23746961' stroke-width='1.5' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-position: right 6px center; background-repeat: no-repeat; }
.inspector-content input[type="color"] { padding: 3px 5px; cursor: pointer; }
.inspector-content textarea { min-height: 92px; resize: vertical; }
.inspector-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inspector-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.inspector-content button { min-height: 32px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--accent); background: var(--sheet); padding: 4px 8px; font-size: 13px; }
.inspector-content button:hover:not(:disabled) { background: var(--accent-soft); }
.inspector-empty { color: var(--muted); font-size: 13px; line-height: 1.7; background: #f6f0e9; border: 1px solid var(--line); padding: 10px 11px; border-radius: 7px; margin: 5px 0; }
.pane-backdrop { display: none; }
#toast { pointer-events: none; position: fixed; left: 50%; bottom: 60px; z-index: 8; width: max-content; max-width: calc(100% - 26px); transform: translateX(-50%); padding: 9px 14px; text-align: center; border-radius: 7px; color: white; background: #362926; font-size: 14px; box-shadow: 0 4px 15px #32231a35; }
#toast:empty { display: none; }

dialog { width: min(485px, calc(100vw - 30px)); max-height: calc(100dvh - 32px); padding: 23px; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 12px 55px #32221e39; background: var(--sheet); color: var(--ink); }
dialog::backdrop { background: #32221e63; }
dialog form { position: relative; }
dialog h2 { margin: 0 34px 12px 0; font-size: 21px; }
dialog p { margin: 8px 0 14px; line-height: 1.6; }
.dialog-close { position: absolute; right: -8px; top: -8px; }
.help-steps { display: grid; gap: 13px; padding-left: 24px; line-height: 1.6; }
.help-steps strong, .help-steps span { display: block; }
.help-steps span, .dialog-note { color: var(--muted); font-size: 14px; }
.dialog-note { margin: 15px 0; }
.share-link-row { display: flex; gap: 7px; }
.share-link-row input { min-width: 0; flex: 1; padding: 7px 9px; background: #f7f1ea; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); font-size: 14px; }

@media (max-width: 1100px) {
  .app-header { padding: 0 16px; gap: 12px; grid-template-columns: 1fr minmax(145px, 220px) 1fr; }
  .app-workspace { grid-template-columns: 156px minmax(0, 1fr) 240px; }
}
@media (max-width: 850px) {
  body { grid-template-rows: 61px 45px minmax(0, 1fr); }
  .template-bar { gap: 9px; padding: 0 10px; }
  #template-picker { flex: 0 1 280px; }
  .collab-tools { flex: 0 0 auto; gap: 4px; }
  .collab-status { max-width: 115px; padding-inline: 0; font-size: 12px; }
  .collab-tools .button { padding-inline: 6px; font-size: 12px; }
  .app-header { grid-template-columns: auto minmax(70px, 1fr) auto; gap: 6px; padding: 0 10px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 8px; }
  .brand-name { display: none; }
  .header-actions { gap: 4px; }
  .history-actions { padding-right: 2px; }
  .app-workspace { display: block; }
  .studio { height: 100%; }
  .sidebar { position: absolute; top: 48px; bottom: 45px; width: min(285px, 88vw); z-index: 3; box-shadow: 0 6px 22px #30201928; display: none; }
  .pages-panel { left: 0; }
  .inspector-panel { right: 0; }
  body[data-pane="pages"] .pages-panel, body[data-pane="inspector"] .inspector-panel { display: flex; }
  .pages-scroller { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; padding: 9px; gap: 4px; }
  .pane-backdrop { display: block; position: absolute; inset: 48px 0 45px; z-index: 2; background: #291b1852; border: 0; }
  .mobile-tools { display: flex; gap: 0; }
  .studio-tools { padding: 0 8px; gap: 4px; }
  .stage-page-actions { margin-left: auto; gap: 0; }
  #stage { padding: 17px 15px; }
}
@media (max-width: 525px) {
  .share-button span { display: none; }
  .header-actions .icon-button { width: 29px; }
  .share-button { min-width: 31px; padding: 0 6px; }
  .export-button { padding: 0 7px; gap: 4px; font-size: 13px; }
  .export-button .icon { width: 15px; }
  #project-title { font-size: 14px; padding: 3px 2px; }
  .save-feedback { font-size: 11px; }
  .save-feedback .icon { display: none; }
  .studio-tools .icon-button { width: 31px; }
  .studio-insert { gap: 0; }
  .toolbar-button { gap: 5px; padding: 0 6px; font-size: 13px; }
  .toolbar-button .icon { width: 15px; }
  .resize-handle { width: 28px; height: 28px; right: -14px; bottom: -14px; }
}
@media (pointer: coarse) { #paper .paper-item:not(.is-selected):hover { outline: none; } }

#paper-wrap { overflow: clip; }
.paper-surface { width: 100%; height: 100%; overflow: hidden; }
.paper-text { display: flex; flex-direction: column; }
.paper-text[contenteditable] { display: block; }
.paper-placeholder-icon:empty { display: none; }
.save-feedback:has([data-state="saving"]) { color: #776452; }
.save-feedback:has([data-state="error"]) { color: var(--accent); }
.inspector-content .primary-button { background: var(--accent); color: white; border-color: var(--accent); min-height: 36px; font-weight: 650; }
.inspector-content .primary-button:hover { background: var(--accent-hover); }
.inspector-content .danger-button:hover { color: var(--accent-hover); }
#toast.is-error { background: var(--accent-hover); }
@media (max-width: 355px) {
  .history-actions { gap: 0; }
  .history-actions .icon-button { width: 25px; }
  .app-header { gap: 4px; padding-inline: 7px; }
  .header-actions { gap: 3px; }
}
