    :root {
      --bg-color: #f1f5f9;
      --text-main: #0f172a;
      --text-muted: #64748b;
      --primary-color: #000000;
      --panel: #ffffff;
      --border: rgba(15, 23, 42, 0.08);
      --shadow: 0 18px 40px -28px rgba(15, 23, 42, 0.45);
      --radius: 16px;
      --accent: #0f172a;
      --accent-2: #333333;
      --control-height: 24px;
      --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
      --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      font-family: var(--sans);
      background-color: var(--bg-color);
      color: var(--text-main);
      min-height: 100vh;
      height: 100vh;
      display: flex;
      flex-direction: column;
      overflow-x: hidden;
      overflow-y: hidden;
    }

    header {
      padding: 20px 40px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      position: sticky;
      top: 0;
      z-index: 1000;
      background: rgba(248, 250, 252, 0.8);
      backdrop-filter: blur(12px);
      border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    }

    .brand-container {
      display: flex;
      align-items: center;
      gap: 8px;
      text-decoration: none;
      color: var(--text-main);
    }

    .logo-icon {
      width: 36px;
      height: 36px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .logo-text {
      font-size: 22px;
      font-weight: 700;
      letter-spacing: -0.5px;
      display: flex;
    }

    .logo-text span {
      display: inline-block;
    }

    .header-actions {
      display: flex;
      gap: 15px;
    }

    .btn {
      padding: 10px 24px;
      border-radius: 99px;
      font-size: 14px;
      font-weight: 600;
      text-decoration: none;
      transition: all 0.2s ease;
      cursor: pointer;
      border: 1px solid transparent;
    }

    .btn-ghost {
      color: var(--text-main);
      background: transparent;
    }

    .btn-ghost:hover {
      background: rgba(0, 0, 0, 0.05);
    }

    .btn-primary {
      background: var(--primary-color);
      color: #ffffff;
      border-color: var(--primary-color);
    }

    .btn-primary:hover {
      background: #333333;
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .app {
      display: grid;
      grid-template-columns: var(--left-width, 280px) 12px 1fr 12px var(--right-width, 280px);
      gap: 0;
      padding: 12px;
      flex: 1;
      min-height: 0;
      overflow: hidden;
    }

    aside, main {
      background: var(--panel);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      display: flex;
      flex-direction: column;
      overflow: hidden;
      min-height: 0;
      min-width: 0;
    }

    .splitter {
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      cursor: col-resize;
      user-select: none;
      background: transparent;
      opacity: 0;
    }

    .splitter::before {
      content: "";
      position: absolute;
      width: 2px;
      height: 50%;
      border-radius: 2px;
      background: rgba(15, 23, 42, 0.12);
    }

    .tri {
      width: 0;
      height: 0;
      border-top: 6px solid transparent;
      border-bottom: 6px solid transparent;
      opacity: 0.9;
    }

    .tri-left {
      border-right: 8px solid rgba(15, 23, 42, 0.55);
    }

    .tri-right {
      border-left: 8px solid rgba(15, 23, 42, 0.55);
    }

    .tri-left.disabled {
      border-right-color: rgba(148, 163, 184, 0.8);
      opacity: 0.5;
    }

    .tri-right.disabled {
      border-left-color: rgba(148, 163, 184, 0.8);
      opacity: 0.5;
    }

    body.resizing {
      cursor: col-resize;
      user-select: none;
    }

    aside::-webkit-scrollbar {
      width: 6px;
      height: 6px;
    }
    aside::-webkit-scrollbar-track {
      background: transparent;
    }
    aside::-webkit-scrollbar-thumb {
      background: rgba(15, 23, 42, 0.1);
      border-radius: 99px;
    }
    aside::-webkit-scrollbar-thumb:hover {
      background: rgba(15, 23, 42, 0.2);
    }

    .sidebar {
      padding: 12px;
      padding-right: 6px;
      gap: 12px;
      overflow-y: auto;
      overflow-x: hidden;
      scrollbar-gutter: stable;
    }

    .sidebar-brand {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 6px 4px 10px;
      border-bottom: 1px solid rgba(15, 23, 42, 0.08);
      margin-bottom: 6px;
    }

    .brand-avatar {
      width: 36px;
      height: 36px;
      border-radius: 12px;
      border: 1px solid rgba(15, 23, 42, 0.1);
      background: #ffffff;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 8px 16px -12px rgba(15, 23, 42, 0.4);
    }

    .brand-avatar img {
      width: 22px;
      height: 22px;
      object-fit: contain;
    }

    .brand-text {
      font-size: 16px;
      font-weight: 700;
      letter-spacing: -0.3px;
    }

    .sidebar-tabs {
      display: flex;
      gap: 6px;
      padding: 4px;
      border-radius: 999px;
      background: #eef2f7;
      border: 1px solid rgba(15, 23, 42, 0.08);
      margin-bottom: 8px;
    }

    .sidebar-sticky {
      position: sticky;
      top: 0;
      z-index: 12;
      background: #ffffff;
      margin-left: -12px;
      margin-right: -6px;
      padding-left: 12px;
      padding-right: 6px;
      padding-bottom: 0;
      margin-bottom: 0;
      isolation: isolate;
      transition: box-shadow 0.18s ease;
    }

    .sidebar-sticky.is-scrolled {
      box-shadow: 0 10px 18px -16px rgba(15, 23, 42, 0.45);
    }

    .sidebar-sticky::before {
      content: "";
      position: absolute;
      left: 0;
      right: 0;
      top: -12px;
      height: 12px;
      background: #ffffff;
      pointer-events: none;
      z-index: -1;
    }

    .assets-toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      padding: 0 4px 8px;
      border-bottom: 1px solid rgba(15, 23, 42, 0.08);
      margin-bottom: 0;
    }

    .assets-toolbar-title {
      font-size: 12px;
      font-weight: 700;
      color: var(--text-main);
      letter-spacing: 0.2px;
    }

    .assets-collapse-btn {
      border: none;
      background: transparent;
      color: var(--text-muted);
      font-size: 12px;
      font-weight: 600;
      padding: 4px 8px;
      border-radius: 8px;
      cursor: pointer;
      transition: background-color 0.16s ease, color 0.16s ease;
    }

    .assets-collapse-btn:hover {
      background: rgba(15, 23, 42, 0.06);
      color: var(--text-main);
    }

    .sidebar-tab {
      flex: 1;
      border: none;
      background: transparent;
      border-radius: 999px;
      padding: 6px 12px;
      font-size: 12px;
      font-weight: 600;
      color: var(--text-muted);
      cursor: pointer;
      transition: all 0.2s ease;
    }

    .sidebar-tab.is-active {
      background: #111111;
      color: #ffffff;
      box-shadow: 0 6px 12px -10px rgba(15, 23, 42, 0.4);
    }

    .sidebar-panel {
      display: none;
      flex-direction: column;
      gap: 8px;
    }

    .sidebar-panel.is-active {
      display: flex;
    }

    .layers-list {
      display: flex;
      flex-direction: column;
      gap: 8px;
      position: relative;
    }

    .layers-list.is-dragging .layer-item {
      pointer-events: none;
    }

    .layers-list.is-dragging .layer-item.is-dragging {
      pointer-events: auto;
    }

    .layer-item {
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 10px 12px;
      background: #ffffff;
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: 13px;
      font-weight: 600;
      color: var(--text-main);
      cursor: pointer;
      transition: all 0.2s ease;
    }

    .layer-main {
      display: flex;
      align-items: center;
      gap: 8px;
      min-width: 0;
      flex: 1;
    }

    .layer-name {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .layer-actions {
      display: flex;
      align-items: center;
      gap: 6px;
      flex-shrink: 0;
      margin-left: 8px;
    }

    .layer-action-btn {
      width: 24px;
      height: 24px;
      border: 1px solid var(--border);
      border-radius: 7px;
      background: #ffffff;
      color: var(--text-muted);
      padding: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: all 0.16s ease;
    }

    .layer-action-btn:hover {
      border-color: var(--text-main);
      color: var(--text-main);
      background: rgba(15, 23, 42, 0.03);
    }

    .layer-action-btn.is-active {
      border-color: var(--accent);
      color: var(--accent);
      background: rgba(14, 165, 233, 0.08);
    }

    .layer-action-btn svg {
      width: 14px;
      height: 14px;
      stroke: currentColor;
      stroke-width: 1.8;
      fill: none;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .layer-item:hover:not(.is-empty) {
      border-color: var(--text-main);
      box-shadow: 0 10px 20px -14px rgba(15, 23, 42, 0.35);
      transform: translateY(-1px);
    }

    .layer-item.is-active {
      border-color: var(--primary-color);
      background: rgba(15, 23, 42, 0.06);
    }

    .layer-item.is-dragging {
      background: rgba(59, 130, 246, 0.12);
      border-color: rgba(59, 130, 246, 0.6);
      color: var(--text-main);
    }

    .layer-item.is-empty {
      opacity: 0.45;
      cursor: default;
    }

    .layer-item.is-locked {
      border-style: dashed;
    }

    .layer-item.is-layer-hidden {
      opacity: 0.55;
    }

    .layer-item.is-dragging {
      opacity: 0.65;
      cursor: grabbing;
    }

    .layer-drop-indicator {
      position: absolute;
      left: 8px;
      right: 8px;
      height: 2px;
      background: #0f172a;
      border-radius: 999px;
      pointer-events: none;
    }

    .layer-meta {
      font-size: 11px;
      font-weight: 500;
      color: var(--text-muted);
    }

    .logo {
      font-weight: 700;
      font-size: 20px;
      letter-spacing: -0.4px;
      display: flex;
      align-items: center;
      gap: 8px;
      color: var(--text-main);
    }

    .logo span {
      display: inline-block;
      width: 12px;
      height: 12px;
      border-radius: 4px;
      background: var(--primary-color);
    }

    .section {
      margin-top: 0;
      background: #ffffff;
      border: 1px solid rgba(15, 23, 42, 0.08);
      border-radius: 14px;
      padding: 6px 10px;
      box-shadow: 0 12px 24px -20px rgba(15, 23, 42, 0.4);
    }

    .section-title {
      font-size: 13px;
      font-weight: 600;
      letter-spacing: -0.2px;
      text-transform: none;
      color: var(--text-main);
      margin-bottom: 0;
      padding: 8px 4px;
      border-bottom: none;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }

    .section.collapsible .section-title {
      cursor: pointer;
      user-select: none;
      margin-bottom: 0;
      list-style: none;
    }

    .section.collapsible[open] .section-title {
      margin-bottom: 8px;
      padding-bottom: 10px;
      border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    }

    /* Face 内的二级入口（更轻量，避免“卡片套卡片”的厚重感） */
    .section.section-sub {
      margin-top: 8px;
      padding: 0;
      background: transparent;
      border: none;
      box-shadow: none;
    }

    .section.section-sub .section-title {
      font-size: 12px;
      padding: 8px 10px;
      border: 1px solid rgba(15, 23, 42, 0.08);
      border-radius: 12px;
      background: rgba(15, 23, 42, 0.03);
    }

    .section.section-sub[open] .section-title {
      padding-bottom: 8px;
      border-bottom: none;
    }

    .section.section-sub .section-title .chevron {
      width: 9px;
      height: 9px;
    }

    .asset-empty {
      grid-column: 1 / -1;
      padding: 14px 12px;
      border-radius: 12px;
      border: 1px dashed var(--border);
      background: #f8fafc;
      color: var(--text-muted);
      font-size: 12px;
      text-align: center;
      line-height: 1.4;
    }

    .asset-subtitle {
      margin: 2px 2px 6px;
      font-size: 11px;
      font-weight: 600;
      letter-spacing: -0.1px;
      color: var(--text-muted);
    }

    .asset-subtitle-fold-title {
      list-style: none;
      cursor: pointer;
      user-select: none;
      border: none;
      border-radius: 0;
      background: transparent;
      padding: 0;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }

    .asset-subtitle-fold-title::-webkit-details-marker {
      display: none;
    }

    .asset-subtitle-fold-title::marker {
      content: "";
    }

    .asset-fold-subtitle .asset-subtitle-fold-title .chevron {
      width: 9px;
      height: 9px;
      border-right: 2px solid var(--text-muted);
      border-bottom: 2px solid var(--text-muted);
      transform: rotate(-45deg);
      transition: transform 160ms ease, opacity 160ms ease;
      opacity: 0.7;
      flex: 0 0 auto;
    }

    .asset-fold-subtitle[open] .asset-subtitle-fold-title .chevron {
      transform: rotate(45deg);
      opacity: 1;
    }

    .asset-fold {
      margin: 2px 0 6px;
    }

    .asset-fold-title {
      margin: 0 2px 6px;
      padding: 6px 8px;
      font-size: 11px;
      font-weight: 600;
      letter-spacing: -0.1px;
      color: var(--text-muted);
      list-style: none;
      cursor: pointer;
      user-select: none;
      border: 1px solid rgba(15, 23, 42, 0.08);
      border-radius: 10px;
      background: rgba(15, 23, 42, 0.03);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }

    .asset-fold-title::-webkit-details-marker {
      display: none;
    }

    .asset-fold-title::marker {
      content: "";
    }

    .asset-fold .asset-list {
      padding-top: 2px;
    }

    .asset-fold .asset-fold-title .chevron {
      width: 9px;
      height: 9px;
      border-right: 2px solid var(--text-muted);
      border-bottom: 2px solid var(--text-muted);
      transform: rotate(-45deg);
      transition: transform 160ms ease, opacity 160ms ease;
      opacity: 0.7;
      flex: 0 0 auto;
    }

    .asset-fold[open] .asset-fold-title .chevron {
      transform: rotate(45deg);
      opacity: 1;
    }

    .section-title::-webkit-details-marker {
      display: none;
    }

    .section-title::marker {
      content: "";
    }

    .section-title .chevron {
      width: 10px;
      height: 10px;
      border-right: 2px solid var(--text-muted);
      border-bottom: 2px solid var(--text-muted);
      transform: rotate(-45deg);
      transition: transform 160ms ease, opacity 160ms ease;
      opacity: 0.7;
      flex: 0 0 auto;
    }

    .section.collapsible[open] .section-title .chevron {
      transform: rotate(45deg);
      opacity: 1;
    }

    .section .asset-list {
      padding: 2px 2px 6px;
    }

    .asset-list {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
      gap: 8px;
      animation: slideDown 0.2s ease-out;
    }

    @keyframes slideDown {
      from { opacity: 0; transform: translateY(-5px); }
      to { opacity: 1; transform: translateY(0); }
    }

    .asset {
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 0;
      display: flex;
      flex-direction: column;
      gap: 0;
      background: #ffffff;
      cursor: pointer;
      overflow: hidden;
      transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    }

    .asset:hover {
      border-color: var(--text-main);
      box-shadow: 0 14px 26px -18px rgba(15, 23, 42, 0.4);
      transform: translateY(-2px);
    }

    .asset.selected {
      border-color: var(--primary-color);
      background: rgba(15, 23, 42, 0.06);
    }

    .thumb {
      width: 100%;
      aspect-ratio: 1 / 1.06;
      border-radius: 0 0 12px 12px;
      background: #edf1f5;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      border: none;
      padding: 8px;
    }

    .thumb img {
      display: block;
      min-width: 0;
      width: 100%;
      height: 100%;
      max-width: 100%;
      max-height: 100%;
      object-fit: contain;
      object-position: center;
    }

    .thumb.ear,
    .thumb.eye,
    .thumb.eyebrow {
      justify-content: center;
      align-items: center;
      padding: 8px;
      gap: 8px;
    }

    .thumb.ear img,
    .thumb.eye img,
    .thumb.eyebrow img {
      display: block;
      min-width: 0;
      width: calc((100% - 8px) / 2);
      height: calc(100% - 16px);
      max-width: calc((100% - 8px) / 2);
      max-height: calc(100% - 16px);
      object-fit: contain;
      object-position: center;
      flex: 0 0 calc((100% - 8px) / 2);
    }

    .thumb.hair {
      justify-content: center;
      align-items: center;
      padding: 8px;
      gap: 8px;
    }

    .asset-info {
      min-height: 32px;
      padding: 8px 8px 10px;
      display: flex;
      align-items: center;
      justify-content: center;
      text-align: center;
      background: #ffffff;
    }

    .thumb.hair img {
      display: block;
      min-width: 0;
      width: calc((100% - 8px) / 2);
      height: calc(100% - 16px);
      max-width: calc((100% - 8px) / 2);
      max-height: calc(100% - 16px);
      object-fit: contain;
      object-position: center;
      flex: 0 0 calc((100% - 8px) / 2);
    }

    /* 选区与手柄样式 */
    .selection-rect {
      fill: none;
      stroke: var(--accent);
      stroke-width: 1.5;
      stroke-dasharray: 4 2;
      pointer-events: none;
      vector-effect: non-scaling-stroke;
    }

    .hover-rect {
      fill: none;
      stroke: var(--accent);
      stroke-width: 1;
      stroke-dasharray: 3 2;
      pointer-events: none;
      opacity: 0.75;
      vector-effect: non-scaling-stroke;
    }

    .selection-hit {
      fill: transparent;
      stroke: none;
      cursor: move;
      pointer-events: all;
    }

    .canvas-wrap.grab-mode .selection-hit,
    .canvas-wrap.grab-mode .handle,
    .canvas-wrap.grab-mode .rotate-handle {
      cursor: grab !important;
    }

    .canvas-wrap.grabbing .selection-hit,
    .canvas-wrap.grabbing .handle,
    .canvas-wrap.grabbing .rotate-handle {
      cursor: grabbing !important;
    }

    .marquee-rect {
      fill: rgba(59, 130, 246, 0.08);
      stroke: var(--accent);
      stroke-width: 1;
      stroke-dasharray: 4 2;
      pointer-events: none;
      vector-effect: non-scaling-stroke;
    }

    .marquee-hit {
      fill: none;
      stroke: #3b82f6;
      stroke-width: 1;
      pointer-events: none;
      vector-effect: non-scaling-stroke;
    }

    .handle {
      fill: #ffffff;
      stroke: var(--accent);
      stroke-width: 1.2;
      cursor: pointer;
      vector-effect: non-scaling-stroke;
    }

    .rotate-handle {
      fill: #ffffff;
      stroke: var(--accent);
      stroke-width: 1.2;
      cursor: grab;
      vector-effect: non-scaling-stroke;
    }

    .handle:hover,
    .rotate-handle:hover {
      fill: var(--accent);
      stroke: var(--accent);
    }

    .layer-hit {
      fill: transparent;
      stroke: none;
      pointer-events: all;
    }

    .asset-name {
      font-weight: 600;
      font-size: 13px;
      line-height: 1.2;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .asset-meta {
      color: var(--text-muted);
      font-size: 10px;
      display: none;
    }

    .sidebar.is-compact .asset {
      padding: 0;
      gap: 0;
    }

    .sidebar.is-compact .asset-info {
      min-height: 30px;
      padding: 6px 8px 8px;
    }

    .sidebar.is-compact .asset-name {
      font-size: 12px;
    }

    .sidebar.is-compact .asset-meta {
      display: none;
    }

    .workspace-panel {
      padding: 12px;
      gap: 12px;
    }

    .toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 10px 12px;
      border: 1px solid var(--border);
      border-radius: 10px;
      background: rgba(248, 250, 252, 0.9);
      backdrop-filter: blur(10px);
    }

    .toolbar h1 {
      margin: 0;
      font-size: 16px;
      font-weight: 700;
      color: var(--text-main);
    }

    .toggle {
      display: inline-flex;
      align-items: center;
      gap: 10px;
      font-size: 13px;
      color: var(--text-muted);
      cursor: pointer;
      user-select: none;
    }

    .toggle input[type="checkbox"] {
      appearance: none;
      -webkit-appearance: none;
      width: 36px;
      height: 20px;
      background: #e2e8f0;
      border-radius: 99px;
      position: relative;
      cursor: pointer;
      outline: none;
      transition: background 0.3s;
      flex-shrink: 0;
    }

    .toggle input[type="checkbox"]::after {
      content: '';
      position: absolute;
      top: 2px;
      left: 2px;
      width: 16px;
      height: 16px;
      background: white;
      border-radius: 50%;
      box-shadow: 0 1px 3px rgba(0,0,0,0.1);
      transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    }

    .toggle input[type="checkbox"]:checked {
      background: var(--primary-color);
    }

    .toggle input[type="checkbox"]:checked::after {
      transform: translateX(16px);
    }

    .canvas-wrap {
      flex: 1;
      margin-top: 0;
      border: 1px solid var(--border);
      border-radius: 12px;
      position: relative;
      overflow: hidden;
      background: #ffffff;
    }

    .canvas-wrap.grab-mode {
      cursor: grab;
    }

    .canvas-wrap.grabbing {
      cursor: grabbing;
    }

    .scale-badge {
      position: absolute;
      top: 10px;
      right: 12px;
      z-index: 2;
      background: var(--primary-color);
      color: #ffffff;
      padding: 4px 8px;
      border-radius: 8px;
      font-size: 12px;
      font-weight: 600;
      letter-spacing: 0.02em;
      pointer-events: none;
      box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    }

    .context-menu {
      position: absolute;
      min-width: 160px;
      background: #0f172a;
      color: #e2e8f0;
      border: 1px solid rgba(148, 163, 184, 0.4);
      border-radius: 10px;
      padding: 6px;
      box-shadow: 0 12px 30px rgba(15, 23, 42, 0.35);
      z-index: 5;
      display: none;
    }

    .context-menu button {
      width: 100%;
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 10px;
      background: transparent;
      border: none;
      color: inherit;
      font-size: 13px;
      border-radius: 8px;
      cursor: pointer;
      text-align: left;
    }

    .context-menu button:hover {
      background: rgba(148, 163, 184, 0.18);
    }

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

    .context-menu button:disabled:hover {
      background: transparent;
    }

    .context-menu .divider {
      height: 1px;
      background: rgba(148, 163, 184, 0.35);
      margin: 6px 4px;
    }

    #gridOverlay {
      position: absolute;
      inset: 0;
      pointer-events: none;
      z-index: 1;
      background-image:
        repeating-linear-gradient(to right, rgba(15, 23, 42, 0.05), rgba(15, 23, 42, 0.05) 0.5px, transparent 0.5px, transparent var(--minor-step, 8px)),
        repeating-linear-gradient(to bottom, rgba(15, 23, 42, 0.05), rgba(15, 23, 42, 0.05) 0.5px, transparent 0.5px, transparent var(--minor-step, 8px)),
        repeating-linear-gradient(to right, rgba(15, 23, 42, 0.08), rgba(15, 23, 42, 0.08) 0.7px, transparent 0.7px, transparent var(--major-step, 80px)),
        repeating-linear-gradient(to bottom, rgba(15, 23, 42, 0.08), rgba(15, 23, 42, 0.08) 0.7px, transparent 0.7px, transparent var(--major-step, 80px));
      background-size: var(--minor-step, 8px) var(--minor-step, 8px),
        var(--minor-step, 8px) var(--minor-step, 8px),
        var(--major-step, 80px) var(--major-step, 80px),
        var(--major-step, 80px) var(--major-step, 80px);
      background-position: 0 0, 0 0, 0 0, 0 0;
      opacity: 0;
      transition: opacity 0.12s ease;
    }

    #workspace {
      width: 100%;
      height: 100%;
      display: block;
      /* 关键修改：移除默认的 touch-action 防止干扰 */
      touch-action: none;
    }

    #workspace text {
      font-family: var(--sans);
    }

    .inspector {
      padding: 12px;
      gap: 12px;
      overflow-y: auto;
      overflow-x: hidden;
    }

    .inspector-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      padding: 10px;
      border-radius: 14px;
      border: 1px solid rgba(15, 23, 42, 0.08);
      background: #ffffff;
      box-shadow: 0 10px 24px -18px rgba(15, 23, 42, 0.45);
    }

    .inspector-actions > .btn,
    .inspector-actions > .export-dropdown {
      flex: 1;
    }

    .inspector-actions > .language-switch {
      flex: 0 0 auto;
    }

    .inspector-actions .btn {
      text-align: center;
      padding: 8px 12px;
      font-size: 12px;
    }

    .inspector-actions .editor-account-status {
      flex: 1.2;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .editor-auth-modal[hidden] {
      display: none;
    }

    .editor-auth-modal {
      inset: 0;
      position: fixed;
      z-index: 2400;
    }

    .editor-auth-backdrop {
      background: rgba(15, 23, 42, 0.34);
      inset: 0;
      position: absolute;
    }

    .editor-auth-dialog {
      background: var(--panel);
      border: 1px solid var(--border);
      border-radius: var(--panel-radius);
      box-shadow: 0 28px 70px -32px rgba(15, 23, 42, 0.46);
      color: var(--text);
      left: 50%;
      max-height: min(720px, calc(100vh - 40px));
      overflow-y: auto;
      padding: 24px;
      position: absolute;
      top: 50%;
      transform: translate(-50%, -50%);
      width: min(420px, calc(100vw - 32px));
    }

    .editor-auth-close {
      align-items: center;
      background: var(--panel-soft);
      border: 1px solid var(--border);
      border-radius: 10px;
      color: var(--text);
      cursor: pointer;
      display: inline-flex;
      font-size: 22px;
      font-weight: 800;
      height: 32px;
      justify-content: center;
      line-height: 1;
      position: absolute;
      right: 16px;
      top: 16px;
      width: 32px;
    }

    .editor-auth-kicker {
      color: var(--accent);
      font-size: 11px;
      font-weight: 900;
      letter-spacing: 0.08em;
      margin: 0 0 8px;
      text-transform: uppercase;
    }

    .editor-auth-dialog h2 {
      color: var(--text);
      font-size: 24px;
      font-weight: 900;
      line-height: 1.15;
      margin: 0 42px 8px 0;
    }

    .editor-auth-desc {
      color: var(--muted);
      font-size: 13px;
      font-weight: 700;
      line-height: 1.5;
      margin: 0 0 18px;
    }

    .editor-auth-form {
      display: grid;
      gap: 12px;
    }

    .editor-auth-form label {
      color: var(--muted);
      display: grid;
      font-size: 12px;
      font-weight: 800;
      gap: 6px;
    }

    .editor-auth-form input[type="text"],
    .editor-auth-form input[type="password"] {
      background: var(--panel);
      border: 1px solid var(--border);
      border-radius: 10px;
      color: var(--text);
      font: inherit;
      font-size: 14px;
      font-weight: 700;
      height: 40px;
      outline: none;
      padding: 0 12px;
    }

    .editor-auth-form input:disabled {
      background: var(--panel-soft);
      color: var(--muted);
    }

    .editor-auth-form input:focus {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px var(--blue-a12);
    }

    .editor-auth-inline {
      display: grid;
      gap: 8px;
      grid-template-columns: minmax(0, 1fr) auto;
    }

    .editor-auth-inline button,
    .editor-profile-actions button,
    .editor-avatar-upload {
      align-items: center;
      background: var(--panel-soft);
      border: 1px solid var(--border);
      border-radius: 10px;
      color: var(--text);
      cursor: pointer;
      display: inline-flex;
      font: inherit;
      font-size: 13px;
      font-weight: 900;
      height: 40px;
      justify-content: center;
      padding: 0 14px;
    }

    .editor-auth-submit {
      background: var(--accent) !important;
      border-color: var(--accent) !important;
      color: #fff !important;
      width: 100%;
    }

    .editor-auth-submit:disabled,
    .editor-profile-actions button:disabled {
      cursor: not-allowed;
      opacity: 0.56;
    }

    .editor-draft-return-actions {
      display: grid;
      gap: 10px;
      grid-template-columns: 1fr;
      margin-top: 16px;
    }

    .editor-draft-return-btn {
      align-items: center;
      background: var(--panel-soft);
      border: 1px solid var(--border);
      border-radius: 10px;
      color: var(--text);
      cursor: pointer;
      display: inline-flex;
      font: inherit;
      font-size: 13px;
      font-weight: 900;
      height: 42px;
      justify-content: center;
      padding: 0 14px;
      width: 100%;
    }

    .editor-draft-return-btn.is-primary {
      background: var(--accent);
      border-color: var(--accent);
      color: #ffffff;
    }

    .editor-draft-return-btn.is-danger {
      background: #fff1f2;
      border-color: rgba(225, 29, 72, 0.28);
      color: #be123c;
    }

    .editor-draft-return-btn:disabled {
      cursor: not-allowed;
      opacity: 0.6;
    }

    .editor-auth-message {
      color: var(--muted);
      font-size: 12px;
      font-weight: 800;
      line-height: 1.45;
      margin: 0;
      min-height: 18px;
    }

    .editor-auth-message.is-error {
      color: #e11d48;
    }

    .editor-profile-avatar-row {
      align-items: center;
      display: flex;
      gap: 12px;
    }

    .editor-profile-avatar {
      align-items: center;
      background: var(--panel-soft);
      border: 1px solid var(--border);
      border-radius: 18px;
      display: inline-flex;
      height: 72px;
      justify-content: center;
      overflow: hidden;
      width: 72px;
    }

    .editor-profile-avatar img {
      height: 100%;
      object-fit: cover;
      width: 100%;
    }

    .editor-profile-meta {
      align-items: center;
      background: var(--panel-soft);
      border: 1px solid var(--border);
      border-radius: 10px;
      display: flex;
      justify-content: space-between;
      padding: 10px 12px;
    }

    .editor-profile-meta span {
      color: var(--muted);
      font-size: 12px;
      font-weight: 800;
    }

    .editor-profile-meta strong {
      color: var(--text);
      font-size: 14px;
      font-weight: 900;
    }

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

    .editor-account-status.is-logged-in {
      border-color: rgba(37, 99, 235, 0.22);
      background: rgba(37, 99, 235, 0.08);
      color: var(--accent);
    }

    .export-dropdown {
      position: relative;
    }

    .export-trigger {
      width: 100%;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
    }

    .export-trigger::after {
      content: "▾";
      font-size: 11px;
      line-height: 1;
      opacity: 0.9;
    }

    .export-menu {
      position: absolute;
      top: calc(100% + 6px);
      right: 0;
      min-width: 188px;
      padding: 6px;
      border: 1px solid rgba(15, 23, 42, 0.12);
      border-radius: 12px;
      background: #ffffff;
      box-shadow: 0 14px 30px -20px rgba(15, 23, 42, 0.45);
      display: flex;
      flex-direction: column;
      gap: 4px;
      z-index: 30;
    }

    .export-menu.is-hidden {
      display: none;
    }

    .export-item {
      border: none;
      border-radius: 8px;
      background: transparent;
      padding: 8px 10px;
      font-size: 12px;
      text-align: left;
      color: var(--text-main);
      cursor: pointer;
    }

    .export-item:hover {
      background: rgba(15, 23, 42, 0.06);
    }

    .btn-mini {
      padding: 4px 10px;
      font-size: 12px;
      line-height: 1.2;
    }

    .inspector h3 {
      margin: 0;
      font-size: 15px;
    }

    .card {
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 12px;
      background: #ffffff;
      margin-top: 10px;
      box-shadow: 0 10px 24px -18px rgba(15, 23, 42, 0.45);
    }

    .debug-card-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }

    .debug-card-body {
      margin-top: 8px;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    #documentCard.is-collapsed .debug-card-body {
      display: none;
    }

    .debug-collapse-btn {
      width: 24px;
      height: 24px;
      border: 1px solid rgba(15, 23, 42, 0.12);
      border-radius: 8px;
      background: rgba(148, 163, 184, 0.14);
      color: var(--text-main);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: background 0.12s ease, border-color 0.12s ease;
      padding: 0;
    }

    .debug-collapse-btn:hover {
      background: rgba(148, 163, 184, 0.22);
      border-color: rgba(15, 23, 42, 0.22);
    }

    .debug-collapse-btn .caret {
      font-size: 12px;
      line-height: 1;
      transition: transform 0.12s ease;
    }

    #documentCard.is-collapsed .debug-collapse-btn .caret {
      transform: rotate(-90deg);
    }

    .document-file-actions {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 6px;
    }

    .debug-action-btn {
      height: 26px;
      padding: 0 10px;
      border-radius: 8px;
      border: 1px solid rgba(15, 23, 42, 0.14);
      background: rgba(248, 250, 252, 0.95);
      color: var(--text-main);
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.12s ease, border-color 0.12s ease;
      white-space: nowrap;
    }

    .debug-action-btn:hover:not(:disabled) {
      background: rgba(148, 163, 184, 0.18);
      border-color: rgba(15, 23, 42, 0.22);
    }

    .debug-action-btn:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }

    .document-import-target {
      height: 26px;
      max-width: 116px;
      border-radius: 8px;
      border: 1px solid rgba(15, 23, 42, 0.14);
      background: rgba(255, 255, 255, 0.95);
      color: var(--text-main);
      font-size: 12px;
      padding: 0 8px;
    }

    .workspace-document-status {
      min-height: 16px;
      font-size: 11px;
      color: var(--text-muted);
      line-height: 1.45;
      word-break: break-word;
    }

    .workspace-document-status.is-success {
      color: #1d4ed8;
    }

    .workspace-document-status.is-error {
      color: #b91c1c;
    }

    .workspace-recent-wrap {
      position: relative;
      display: inline-flex;
      align-items: center;
    }

    .workspace-recent-menu {
      position: absolute;
      top: calc(100% + 6px);
      left: 0;
      min-width: 220px;
      max-width: 300px;
      max-height: 260px;
      overflow-y: auto;
      padding: 6px;
      border: 1px solid rgba(15, 23, 42, 0.14);
      border-radius: 10px;
      background: #ffffff;
      box-shadow: 0 18px 32px -24px rgba(15, 23, 42, 0.65);
      z-index: 30;
    }

    .workspace-recent-menu-item {
      width: 100%;
      border: 1px solid transparent;
      border-radius: 8px;
      background: transparent;
      color: var(--text-main);
      text-align: left;
      padding: 7px 8px;
      display: grid;
      gap: 2px;
      cursor: pointer;
    }

    .workspace-recent-menu-item:hover {
      border-color: rgba(59, 130, 246, 0.38);
      background: rgba(59, 130, 246, 0.08);
    }

    .workspace-recent-menu-item-title {
      font-size: 12px;
      font-weight: 600;
      line-height: 1.25;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .workspace-recent-menu-item-meta {
      font-size: 11px;
      color: var(--text-muted);
      line-height: 1.2;
    }

    .workspace-recent-menu-empty {
      padding: 8px;
      font-size: 11px;
      color: var(--text-muted);
    }

    .prop-row {
      display: flex;
      justify-content: space-between;
      font-size: 13px;
      color: var(--text-muted);
      margin: 4px 0;
    }

    .prop-row strong {
      color: var(--text-main);
      font-weight: 600;
    }

    .contour-warp-select {
      width: 220px;
      max-width: 60%;
      font-family: inherit;
      font-size: 12px;
      line-height: 1.2;
      background: #f8fafc;
      color: var(--text-main);
      appearance: auto;
      -webkit-appearance: menulist;
    }

    .selection-fields {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px 10px;
      margin-top: 8px;
    }

    .prop-field {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      font-size: 12px;
      color: var(--text-muted);
    }

    .prop-label {
      flex: 0 0 auto;
      font-weight: 600;
      color: var(--text-main);
    }

    .prop-control {
      display: flex;
      align-items: center;
      gap: 6px;
      flex: 1;
    }

    .prop-input {
      width: 100%;
      height: var(--control-height);
      padding: 0 8px;
      border-radius: 8px;
      border: 1px solid var(--border);
      font-family: var(--mono);
      font-size: 12px;
      color: var(--text-main);
      background: #f8fafc;
    }

    .prop-input[type="number"]::-webkit-outer-spin-button,
    .prop-input[type="number"]::-webkit-inner-spin-button {
      -webkit-appearance: none;
      margin: 0;
    }

    .prop-input[type="number"] {
      -moz-appearance: textfield;
    }

    .prop-input.is-dragging {
      cursor: ew-resize;
      border-color: rgba(59, 130, 246, 0.6);
      box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
    }

    .prop-input:focus {
      outline: none;
      border-color: rgba(15, 23, 42, 0.3);
      background: #ffffff;
    }

    .prop-input::placeholder {
      color: var(--text-muted);
    }

    .prop-unit {
      font-size: 11px;
      color: var(--text-muted);
      flex: 0 0 auto;
    }

    .ops-block {
      margin-top: 8px;
    }

    .align-row {
      display: flex;
      gap: 6px;
      align-items: center;
    }

    .align-group {
      flex: 1;
      min-width: 0;
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      border: 1px solid rgba(15, 23, 42, 0.08);
      border-radius: 8px;
      overflow: hidden;
      background: #f1f5f9;
    }

    .align-btn {
      height: var(--control-height);
      border: none;
      border-right: 1px solid rgba(15, 23, 42, 0.08);
      background: transparent;
      color: var(--text-main);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: background-color 0.12s ease;
    }

    .align-group .align-btn:last-child {
      border-right: none;
    }

    .align-btn:hover:not(:disabled),
    .rotation-btn:hover:not(:disabled) {
      background: rgba(15, 23, 42, 0.08);
    }

    .align-btn:disabled,
    .rotation-btn:disabled {
      opacity: 0.45;
      cursor: not-allowed;
    }

    .align-icon,
    .rotation-icon {
      width: 16px;
      height: 16px;
      stroke: currentColor;
      fill: none;
      stroke-width: 1.8;
      stroke-linecap: round;
      stroke-linejoin: round;
      pointer-events: none;
    }

    .rotation-row {
      display: flex;
      align-items: center;
      gap: 4px;
      min-width: 0;
    }

    .rotation-inline-field {
      flex: 1 1 0;
      min-width: 0;
      display: flex;
      align-items: center;
      gap: 4px;
    }

    .rotation-inline-field .prop-label {
      flex: 0 0 auto;
      white-space: nowrap;
    }

    .rotation-inline-field .prop-control {
      flex: 1 1 0;
      min-width: 0;
      max-width: 104px;
      gap: 4px;
    }

    .rotation-inline-field .prop-input {
      width: 100%;
      min-width: 0;
      padding: 6px;
    }

    .rotation-actions {
      display: grid;
      grid-template-columns: repeat(3, 30px);
      border: 1px solid rgba(15, 23, 42, 0.08);
      border-radius: 8px;
      overflow: hidden;
      background: #f1f5f9;
      flex: 0 0 auto;
    }

    .rotation-btn {
      width: 30px;
      height: var(--control-height);
      border: none;
      border-right: 1px solid rgba(15, 23, 42, 0.08);
      background: transparent;
      color: var(--text-main);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: background-color 0.12s ease;
    }

    .rotation-btn .rotation-icon {
      width: 14px;
      height: 14px;
    }

    @media (max-width: 1420px) {
      .rotation-inline-field .prop-control {
        max-width: 92px;
      }
    }

    .rotation-actions .rotation-btn:last-child {
      border-right: none;
    }

    .colorize-panel {
      margin-top: 10px;
      padding-top: 10px;
      border-top: 1px solid rgba(15, 23, 42, 0.08);
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

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

    .colorize-actions {
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }

    .colorize-line-toggle {
      display: inline-flex;
      justify-content: space-between;
      font-size: 12px;
      color: var(--text-muted);
      gap: 10px;
      padding: 0;
    }

    .colorize-line-toggle input[type="checkbox"] {
      width: 42px;
      height: 22px;
    }

    .colorize-title {
      font-size: 12px;
      font-weight: 700;
      color: var(--text-main);
    }

    .colorize-current {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }

    .colorize-swatch {
      width: var(--control-height);
      height: var(--control-height);
      border: 1px solid rgba(15, 23, 42, 0.12);
      border-radius: 8px;
      cursor: pointer;
      padding: 0;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
    }

    .colorize-swatch.is-active {
      border-color: var(--primary-color);
      background: rgba(15, 23, 42, 0.06);
      box-shadow: 0 0 0 1px var(--primary-color), inset 0 0 0 1px rgba(255, 255, 255, 0.35);
    }

    .colorize-swatch:hover {
      transform: translateY(-1px);
    }

    .colorize-presets {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .colorize-preset {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      width: 100%;
      border: 1px solid rgba(15, 23, 42, 0.08);
      border-radius: 10px;
      background: #f8fafc;
      padding: 6px 8px;
      cursor: pointer;
    }

    .colorize-preset:hover {
      background: rgba(59, 130, 246, 0.08);
      border-color: rgba(59, 130, 246, 0.25);
    }

    .colorize-preset-name {
      font-size: 12px;
      font-weight: 600;
      color: var(--text-main);
    }

    .colorize-preset-swatches {
      display: inline-flex;
      gap: 4px;
      align-items: center;
    }

    .colorize-preset-swatch {
      width: 12px;
      height: 12px;
      border-radius: 4px;
      border: 1px solid rgba(15, 23, 42, 0.12);
    }

    .colorize-picker {
      position: fixed;
      width: 24px;
      height: 24px;
      opacity: 0.001;
      pointer-events: auto;
      z-index: 99999;
    }

    .colorize-empty {
      width: 100%;
      font-size: 12px;
      color: var(--text-muted);
      background: rgba(148, 163, 184, 0.18);
      border: 1px dashed rgba(15, 23, 42, 0.12);
      border-radius: 10px;
      padding: 10px;
      text-align: center;
    }

    .is-hidden {
      display: none;
    }

    .guide-line {
      stroke: #ef4444;
      stroke-width: 1;
      stroke-dasharray: 4 4;
      vector-effect: non-scaling-stroke;
      pointer-events: none;
    }

    .guide-line.spacing {
      stroke: #a855f7;
    }

    .guide-cross {
      stroke: #ef4444;
      stroke-width: 1;
      vector-effect: non-scaling-stroke;
      pointer-events: none;
    }

    .guide-cross.spacing {
      stroke: #a855f7;
    }

    .guide-tick {
      stroke: currentColor;
      stroke-width: 1;
      vector-effect: non-scaling-stroke;
      pointer-events: none;
    }

    .guide-text {
      font-family: var(--mono);
      fill: #a855f7;
      paint-order: stroke;
      stroke: #ffffff;
      stroke-width: 3;
      stroke-linejoin: round;
      pointer-events: none;
    }

    .pill {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 6px 10px;
      border-radius: 999px;
      background: var(--primary-color);
      color: #ffffff;
      font-size: 12px;
      font-weight: 600;
    }

    .empty-tip {
      color: var(--text-muted);
      font-size: 13px;
      padding: 32px 16px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 12px;
      text-align: center;
      background: #f8fafc;
      border-radius: 8px;
      border: 1px dashed var(--border);
    }

    .empty-tip::before {
      content: "⚓";
      font-size: 24px;
      opacity: 0.3;
      filter: grayscale(100%);
    }

    /* Reference editor shell */
    :root {
      --blue: #2563eb;
      --blue-hover: rgba(37, 99, 235, 0.86);
      --blue-soft: rgba(37, 99, 235, 0.14);
      --blue-a06: rgba(37, 99, 235, 0.06);
      --blue-a08: rgba(37, 99, 235, 0.08);
      --blue-a10: rgba(37, 99, 235, 0.1);
      --blue-a12: rgba(37, 99, 235, 0.12);
      --blue-a14: rgba(37, 99, 235, 0.14);
      --blue-a15: rgba(37, 99, 235, 0.15);
      --blue-a16: rgba(37, 99, 235, 0.16);
      --blue-a18: rgba(37, 99, 235, 0.18);
      --blue-a20: rgba(37, 99, 235, 0.2);
      --blue-a24: rgba(37, 99, 235, 0.24);
      --blue-a28: rgba(37, 99, 235, 0.28);
      --blue-a30: rgba(37, 99, 235, 0.3);
      --blue-a32: rgba(37, 99, 235, 0.32);
      --blue-a36: rgba(37, 99, 235, 0.36);
      --blue-a38: rgba(37, 99, 235, 0.38);
      --blue-a40: rgba(37, 99, 235, 0.4);
      --blue-a42: rgba(37, 99, 235, 0.42);
      --blue-a50: rgba(37, 99, 235, 0.5);
      --blue-a56: rgba(37, 99, 235, 0.56);
      --blue-a62: rgba(37, 99, 235, 0.62);
      --blue-a72: rgba(37, 99, 235, 0.72);
      --bg-color: var(--blue-a06);
      --text: #1f2328;
      --text-main: #1f2328;
      --text-inverse: #ffffff;
      --muted: #70757f;
      --text-muted: #70757f;
      --border-strong: #cfcfcf;
      --control: #f2f2f2;
      --panel-radius: 8px;
      --workspace-bg: #ffffff;
      --workspace-shell-bg: var(--blue-a08);
      --left-sidebar-bg: #ffffff;
      --left-sidebar-rail-bg: var(--blue-a08);
      --right-sidebar-bg: #ffffff;
      --panel-soft: var(--blue-a06);
      --shadow: 0 16px 34px -28px rgba(31, 35, 40, 0.28), 0 1px 3px rgba(31, 35, 40, 0.06);
      --radius: var(--panel-radius);
      --accent: var(--blue);
      --primary-color: var(--blue);
    }

    body {
      background: var(--bg-color);
      color: var(--text);
    }

    .app {
      grid-template-columns: var(--left-width, 300px) 8px minmax(360px, 1fr) 8px var(--right-width, 300px);
      padding: 8px;
    }

    aside,
    main {
      border-radius: var(--panel-radius);
      box-shadow: var(--shadow);
    }

    .editor-sidebar {
      display: grid;
      grid-template-columns: 56px minmax(0, 1fr);
      padding: 0;
      gap: 0;
      overflow: hidden;
      background: var(--left-sidebar-bg);
    }

    .sidebar-rail {
      display: flex;
      min-width: 0;
      flex-direction: column;
      align-items: center;
      gap: 12px;
      border-right: 1px solid var(--border);
      background: var(--left-sidebar-rail-bg);
      padding: 12px 8px;
    }

    .rail-brand {
      width: 40px;
      height: 40px;
      display: grid;
      place-items: center;
      border: 1px solid var(--border);
      border-radius: 12px;
      background: var(--panel);
      box-shadow: 0 12px 24px -20px var(--blue-a40);
      margin-bottom: 4px;
      text-decoration: none;
      color: var(--text);
      cursor: pointer;
      overflow: hidden;
      padding: 0;
    }

    .rail-brand-logo {
      display: block;
      width: 22px;
      height: 22px;
      object-fit: contain;
    }

    .editor-profile-trigger.is-anonymous .rail-brand-logo {
      filter: grayscale(1);
      opacity: 0.42;
    }

    .editor-profile-trigger:not(.is-anonymous) {
      border-color: var(--text);
      background: var(--panel);
      box-shadow: 0 12px 24px -20px rgba(31, 35, 40, 0.5);
    }

    .editor-profile-trigger:not(.is-anonymous) .rail-brand-logo {
      display: none;
    }

    .editor-profile-trigger-name {
      display: -webkit-box;
      max-width: 34px;
      color: var(--text);
      font-size: 9px;
      font-weight: 900;
      line-height: 1.05;
      overflow: hidden;
      text-align: center;
      text-overflow: ellipsis;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      word-break: break-all;
    }

    .rail-btn {
      display: grid;
      width: 40px;
      height: 40px;
      flex: 0 0 40px;
      min-height: 40px;
      max-height: 40px;
      place-items: center;
      border: 1px solid transparent;
      border-radius: 12px;
      background: transparent;
      color: var(--muted);
      cursor: pointer;
      padding: 0;
      transition: background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
    }

    .rail-btn svg {
      width: 20px;
      height: 20px;
      stroke: currentColor;
      stroke-width: 1.8;
      fill: none;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .rail-btn:hover {
      background: var(--blue-a12);
      color: var(--text);
    }

    .rail-btn.is-active {
      border-color: var(--text);
      background: var(--text);
      color: var(--panel);
      box-shadow: 0 12px 24px -20px rgba(31, 35, 40, 0.56);
    }

    .sidebar-scroll {
      min-width: 0;
      min-height: 0;
      background: var(--left-sidebar-bg);
      overflow: hidden;
      scrollbar-gutter: auto;
    }

    .sidebar-scroll.is-resources-active {
      overflow-y: auto;
      overflow-x: hidden;
      scrollbar-gutter: stable;
    }

    .sidebar-panel {
      min-height: 0;
      height: 100%;
      display: none;
    }

    .sidebar-panel.is-active {
      display: flex;
      flex-direction: column;
    }

    .layer-manager-panel,
    .templates-panel,
    .drafts-panel {
      display: flex;
      min-height: 0;
      height: 100%;
      flex: 1;
      flex-direction: column;
      background: var(--left-sidebar-bg);
      padding: 12px 8px;
    }

    .templates-panel {
      gap: 8px;
      padding: 12px 4px 12px 12px;
    }

    .drafts-panel {
      gap: 10px;
      padding: 12px 8px;
    }

    .draft-item-action {
      height: 30px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: #ffffff;
      color: var(--text-main);
      font: inherit;
      font-size: 12px;
      font-weight: 800;
    }

    .draft-item-action {
      cursor: pointer;
    }

    .draft-item-action:hover {
      border-color: rgba(59, 130, 246, 0.42);
      color: var(--blue);
    }

    .draft-autosave-status {
      min-height: 18px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: rgba(241, 245, 249, 0.72);
      color: var(--muted);
      font-size: 11px;
      font-weight: 700;
      line-height: 1.45;
      padding: 7px 8px;
      word-break: break-word;
    }

    .draft-autosave-status.is-saving {
      color: var(--blue);
    }

    .draft-autosave-status.is-saved {
      color: #047857;
    }

    .draft-autosave-status.is-error {
      color: #b91c1c;
    }

    .draft-list {
      display: grid;
      gap: 8px;
      overflow-y: auto;
      padding-right: 2px;
    }

    .draft-item {
      width: 100%;
      border: 1px solid var(--border);
      border-radius: 10px;
      background: #ffffff;
      color: var(--text-main);
      display: grid;
      gap: 8px;
      padding: 10px;
      text-align: left;
      box-shadow: 0 10px 18px -18px rgba(15, 23, 42, 0.45);
    }

    .draft-item.is-active {
      border-color: rgba(59, 130, 246, 0.46);
      box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
    }

    .draft-item-main {
      border: 0;
      background: transparent;
      color: inherit;
      cursor: pointer;
      display: grid;
      gap: 3px;
      padding: 0;
      text-align: left;
    }

    .draft-item-title {
      font-size: 13px;
      font-weight: 900;
      line-height: 1.25;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .draft-item-meta {
      color: var(--muted);
      font-size: 11px;
      font-weight: 700;
      line-height: 1.3;
    }

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

    .draft-item-action {
      height: 26px;
      font-size: 11px;
    }

    .drafts-empty {
      align-items: center;
      color: var(--muted);
      display: grid;
      flex: 1;
      gap: 8px;
      justify-items: center;
      min-height: 220px;
      padding: 28px 12px;
      text-align: center;
    }

    .drafts-empty.is-hidden {
      display: none;
    }

    .drafts-empty svg {
      fill: none;
      height: 30px;
      stroke: currentColor;
      stroke-linecap: round;
      stroke-linejoin: round;
      stroke-width: 1.8;
      width: 30px;
    }

    .drafts-empty strong {
      color: var(--muted);
      font-size: 14px;
      font-weight: 900;
    }

    .drafts-empty span {
      font-size: 12px;
      font-weight: 700;
      line-height: 1.45;
    }

    .layer-manager-head,
    .sidebar-panel-head {
      position: sticky;
      top: 0;
      z-index: 4;
      display: grid;
      grid-template-columns: minmax(0, 1fr) repeat(2, 24px);
      align-items: center;
      gap: 4px;
      border-bottom: 1px solid var(--border);
      background: var(--left-sidebar-bg);
      padding: 0 0 12px;
    }

    .sidebar-panel-head {
      grid-template-columns: minmax(0, 1fr) auto;
    }

    .layer-manager-title {
      color: var(--text);
      font-size: 13px;
      font-weight: 800;
      line-height: 1.2;
    }

    .layer-manager-subtitle {
      margin-top: 2px;
      color: var(--muted);
      font-size: 11px;
      font-weight: 600;
      line-height: 1.2;
    }

    .sidebar-head-icon {
      width: 24px;
      height: 24px;
      display: grid;
      place-items: center;
      border: 0;
      border-radius: 6px;
      background: transparent;
      color: var(--muted);
      cursor: pointer;
      padding: 0;
    }

    .sidebar-head-icon:hover {
      background: var(--blue-a08);
      color: var(--text);
    }

    .sidebar-head-icon svg {
      width: 16px;
      height: 16px;
      stroke: currentColor;
      stroke-width: 1.8;
      fill: none;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .layers-list {
      position: relative;
      display: flex;
      min-height: 0;
      flex: 1;
      flex-direction: column;
      gap: 4px;
      overflow-y: auto;
      overflow-x: hidden;
      scrollbar-gutter: stable;
      padding: 8px 0 12px;
    }

    .layers-empty {
      min-height: 260px;
      display: grid;
      place-items: center;
      color: var(--muted);
      font-size: 12px;
      font-weight: 600;
      text-align: center;
    }

    .layers-empty-inner {
      display: grid;
      gap: 12px;
      justify-items: center;
    }

    .layers-empty svg {
      width: 22px;
      height: 22px;
      stroke: currentColor;
      stroke-width: 1.7;
      fill: none;
      opacity: 0.78;
    }

    .layer-item {
      border-radius: 8px;
      padding: 8px 10px;
      box-shadow: none;
      font-size: 12px;
    }

    .layer-item:hover:not(.is-empty) {
      border-color: var(--blue-a38);
      box-shadow: 0 12px 22px -18px rgba(31, 35, 40, 0.32);
      transform: none;
    }

    .layer-item.is-active {
      border-color: var(--blue);
      background: var(--blue-a08);
    }

    .assets-toolbar {
      display: none;
    }

    .assets-collapse-btn {
      height: 26px;
      border: 1px solid var(--border);
      background: var(--panel);
      color: var(--muted);
      font-size: 11px;
      font-weight: 700;
      padding: 0 10px;
      border-radius: 8px;
    }

    .assets-collapse-btn:hover {
      border-color: var(--blue-a38);
      background: var(--blue-a08);
      color: var(--blue);
    }

    .section {
      margin-top: 0;
      border-radius: 12px;
      box-shadow: none;
      padding: 0 12px;
    }

    .section[open] {
      padding-bottom: 12px;
    }

    .section-title {
      min-height: 48px;
      padding: 0;
      font-size: 16px;
      font-weight: 800;
    }

    .section.collapsible[open] .section-title {
      margin-bottom: 8px;
      padding-bottom: 0;
    }

    .asset-list {
      grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
      gap: 8px;
      padding-top: 8px;
    }

    .asset {
      border-radius: var(--panel-radius);
      transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
    }

    .asset:hover {
      border-color: var(--blue-a38);
      box-shadow: 0 16px 28px -22px rgba(31, 35, 40, 0.44);
      transform: translateY(-1px);
    }

    .asset.selected {
      border-color: var(--blue);
      background: var(--blue-a08);
    }

    .thumb {
      aspect-ratio: 1 / 1.08;
      border-radius: 0;
      background: #f5f7ff;
    }

    .asset-info {
      min-height: 44px;
      padding: 8px;
    }

    .asset-name {
      font-size: 12px;
    }

    .splitter {
      min-width: 8px;
      gap: 2px;
      opacity: 0;
      transition: opacity 140ms ease;
    }

    .splitter::before {
      width: 3px;
      height: 72px;
      border-radius: 999px;
      background: var(--border-strong);
      transition: background-color 140ms ease;
    }

    .splitter:hover,
    .splitter:focus-visible {
      opacity: 1;
    }

    body.resizing .splitter {
      opacity: 1;
    }

    body.resizing .splitter::before {
      background: var(--blue-a40);
    }

    .tri {
      display: none;
    }

    .workspace-panel {
      padding: 8px;
      gap: 8px;
      background: var(--workspace-bg);
    }

    .workspace-shell {
      position: relative;
      display: flex;
      flex: 1;
      flex-direction: column;
      min-width: 0;
      min-height: 0;
      overflow: hidden;
      border: 0;
      border-radius: 0;
      background: transparent;
    }

    .workspace-canvas-stage {
      position: relative;
      flex: 1;
      min-width: 0;
      min-height: 0;
      overflow: hidden;
      border: 1px solid var(--border);
      border-radius: var(--panel-radius);
      background: var(--workspace-shell-bg);
    }

    .canvas-wrap {
      position: absolute;
      inset: 0;
      margin-top: 0;
      border: 0;
      border-radius: 0;
      background: transparent;
    }

    #workspace {
      background: transparent;
    }

    .scale-badge {
      border-radius: 4px;
      background: var(--blue);
      box-shadow: 0 8px 16px rgba(31, 35, 40, 0.18);
      font-weight: 700;
      line-height: 1;
    }

    .right-panel {
      gap: 8px;
      overflow-y: auto;
      overflow-x: hidden;
      scrollbar-gutter: stable;
      background: var(--right-sidebar-bg);
      padding: 8px 4px 8px 12px;
    }

    .inspector-actions,
    .card {
      border-radius: var(--panel-radius);
      box-shadow: 0 12px 22px -20px rgba(31, 35, 40, 0.22);
    }

    .card {
      margin-top: 0;
    }

    .debug-card-head,
    .card > h3 {
      min-height: 32px;
    }

    .inspector h3 {
      color: var(--text);
      font-size: 13px;
      font-weight: 700;
    }

    .btn-primary {
      background: var(--blue);
      border-color: var(--blue);
    }

    .btn-primary:hover {
      background: var(--blue-hover);
      box-shadow: 0 6px 16px -12px var(--blue-a62);
    }

    .btn-ghost:hover,
    .debug-action-btn:hover:not(:disabled),
    .export-item:hover,
    .context-menu button:hover {
      background: var(--blue-a08);
      color: var(--blue);
    }

    body.theme-dark {
      color-scheme: dark;
      --bg-color: #020617;
      --border: rgba(148, 163, 184, 0.22);
      --border-strong: rgba(148, 163, 184, 0.34);
      --text: rgba(241, 245, 249, 0.92);
      --text-main: rgba(241, 245, 249, 0.92);
      --text-inverse: #ffffff;
      --muted: rgba(203, 213, 225, 0.72);
      --text-muted: rgba(203, 213, 225, 0.72);
      --panel: #0f172a;
      --panel-soft: rgba(30, 41, 59, 0.72);
      --control: rgba(51, 65, 85, 0.74);
      --workspace-bg: var(--panel);
      --workspace-shell-bg: #07111f;
      --left-sidebar-bg: var(--panel);
      --left-sidebar-rail-bg: var(--blue-a08);
      --right-sidebar-bg: var(--panel);
      --shadow: 0 18px 38px rgba(2, 6, 23, 0.5), 0 2px 10px rgba(2, 6, 23, 0.32);
    }

    body.theme-dark .inspector-actions,
    body.theme-dark .card,
    body.theme-dark .export-menu,
    body.theme-dark .context-menu {
      border-color: var(--border);
      background: var(--panel);
      color: var(--text);
    }

    body.theme-dark .debug-action-btn,
    body.theme-dark .document-import-target,
    body.theme-dark .draft-item,
    body.theme-dark .draft-item-action,
    body.theme-dark .draft-autosave-status,
    body.theme-dark .prop-input,
    body.theme-dark .rotation-btn,
    body.theme-dark .align-btn {
      border-color: var(--border);
      background: var(--control);
      color: var(--text);
    }

    body.theme-dark .debug-collapse-btn,
    body.theme-dark .btn-ghost {
      color: var(--text);
    }

    body.theme-dark .thumb,
    body.theme-dark .asset-empty,
    body.theme-dark .layers-empty {
      background: var(--panel-soft);
    }

    .card.is-collapsed > .debug-card-body {
      display: none;
    }

    .card.is-collapsed .debug-collapse-btn .caret {
      transform: rotate(-90deg);
    }

    .theme-settings-body,
    .theme-settings-section {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .theme-settings-section + .theme-settings-section {
      border-top: 1px solid var(--border);
      padding-top: 12px;
    }

    .theme-settings-label-row {
      display: flex;
      min-height: 20px;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }

    .theme-settings-label {
      color: var(--text);
      font-size: 12px;
      font-weight: 700;
    }

    .theme-settings-value {
      color: var(--muted);
      font-size: 11px;
      white-space: nowrap;
    }

    .theme-mode-toggle {
      display: inline-grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
      border: 1px solid var(--border);
      border-radius: 999px;
      background: var(--panel-soft);
      padding: 4px;
    }

    .theme-mode-btn {
      height: 28px;
      border: 1px solid transparent;
      border-radius: 999px;
      background: transparent;
      color: var(--muted);
      cursor: pointer;
      font-size: 12px;
      font-weight: 700;
      transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
    }

    .theme-mode-btn:hover {
      border-color: var(--border-strong);
      background: var(--control);
      color: var(--text);
    }

    .theme-mode-btn.is-active {
      border-color: var(--blue);
      background: var(--blue);
      box-shadow: 0 8px 18px -12px var(--blue-a62);
      color: var(--text-inverse);
    }

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

    .theme-color-swatch {
      height: 24px;
      border: 1px solid var(--border-strong);
      border-radius: 999px;
      background: var(--theme-swatch, var(--blue));
      cursor: pointer;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
      transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
    }

    .theme-color-swatch:hover {
      border-color: var(--text);
      transform: translateY(-1px);
    }

    .theme-color-swatch.is-active {
      border-color: var(--text);
      box-shadow: 0 0 0 2px var(--blue-a20), inset 0 1px 0 rgba(255, 255, 255, 0.55);
    }

    .theme-settings-radius-row {
      display: grid;
      grid-template-columns: minmax(0, 1fr) 78px 54px;
      align-items: center;
      gap: 8px;
    }

    .theme-settings-radius-range {
      width: 100%;
      margin: 0;
      accent-color: var(--blue);
    }

    .theme-settings-radius-input-wrap {
      position: relative;
      display: flex;
      min-width: 0;
    }

    .theme-settings-radius-input-wrap .prop-input {
      width: 100%;
      min-width: 0;
      height: 32px;
      border: 1px solid var(--border);
      border-radius: 8px;
      outline: none;
      background: var(--panel-soft);
      color: var(--text);
      font-family: var(--mono);
      font-size: 12px;
      font-weight: 650;
      padding: 0 24px 0 8px;
      text-align: right;
    }

    .theme-settings-radius-input-wrap .prop-input:focus {
      border-color: var(--blue);
      background: var(--panel);
      box-shadow: 0 0 0 2px var(--blue-a18);
    }

    .prop-unit-inside {
      position: absolute;
      right: 8px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--muted);
      font-size: 11px;
      pointer-events: none;
    }

    .theme-settings-reset-btn {
      min-width: 0;
      width: 54px;
      height: 32px;
      justify-content: center;
      padding: 0 10px;
    }

    :where(.right-panel, .sidebar-scroll.is-resources-active, .layers-list) {
      --editor-scrollbar-size: 8px;
      --editor-scrollbar-track: rgba(18, 22, 28, 0.08);
      --editor-scrollbar-thumb: rgba(106, 110, 118, 0.38);
      --editor-scrollbar-thumb-hover: rgba(106, 110, 118, 0.52);
      --editor-scrollbar-thumb-active: var(--blue-a40);
    }

    :where(.right-panel, .sidebar-scroll.is-resources-active, .layers-list)::-webkit-scrollbar {
      width: var(--editor-scrollbar-size);
      height: var(--editor-scrollbar-size);
    }

    :where(.right-panel, .sidebar-scroll.is-resources-active, .layers-list)::-webkit-scrollbar-track {
      border-radius: 999px;
      background: var(--editor-scrollbar-track);
    }

    :where(.right-panel, .sidebar-scroll.is-resources-active, .layers-list)::-webkit-scrollbar-thumb {
      border: 2px solid transparent;
      border-radius: 999px;
      background: var(--editor-scrollbar-thumb);
      background-clip: content-box;
    }

    :where(.right-panel, .sidebar-scroll.is-resources-active, .layers-list)::-webkit-scrollbar-thumb:hover {
      background: var(--editor-scrollbar-thumb-hover);
      background-clip: content-box;
    }

    :where(.right-panel, .sidebar-scroll.is-resources-active, .layers-list)::-webkit-scrollbar-thumb:active {
      background: var(--editor-scrollbar-thumb-active);
      background-clip: content-box;
    }

    @media (max-width: 1080px) {
      .app {
        grid-template-columns: var(--left-width, 300px) 8px minmax(360px, 1fr);
      }

      .splitter-right,
      .right-panel {
        display: none;
      }
    }
