:root {
      --bg: #ffffff;
      --bg-subtle: #f8fafc;
      --surface: #ffffff;
      --border: #e2e8f0;
      --border-strong: #cbd5e1;
      --text-main: #0f172a;
      --text-muted: #64748b;
      --text-sub: #475569;
      --brand: #2563eb;
      --brand-hover: #1d4ed8;
      --dark-btn: #0f172a;
      --dark-btn-hover: #1e293b;
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
      scrollbar-width: thin;
      scrollbar-color: #cbd5e1 transparent;
    }

    ::-webkit-scrollbar {
      width: 6px;
      height: 6px;
    }

    ::-webkit-scrollbar-track {
      background: transparent;
    }

    ::-webkit-scrollbar-thumb {
      background-color: #cbd5e1;
      border-radius: 9999px;
      border: 1.5px solid transparent;
      background-clip: content-box;
      transition: background-color 0.2s ease;
    }

    ::-webkit-scrollbar-thumb:hover {
      background-color: #94a3b8;
    }

    ::selection {
      background: #dbeafe;
      color: #1d4ed8;
    }

    body {
      font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", sans-serif;
      background-color: var(--bg);
      color: var(--text-main);
      line-height: 1.6;
      -webkit-font-smoothing: antialiased;
    }

    /* Container */
    .container {
      max-width: 1140px;
      margin: 0 auto;
      padding: 0 24px;
    }

    /* Navigation - Exactly matching index.html */
    .site-nav {
      position: sticky;
      top: 0;
      z-index: 100;
      background: rgba(255, 255, 255, 0.9);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      border-bottom: 1px solid var(--border);
    }

    .nav-inner {
      display: flex;
      align-items: center;
      justify-content: space-between;
      height: 60px;
    }

    .brand-link {
      display: flex;
      align-items: center;
      gap: 8px;
      text-decoration: none;
      color: var(--text-main);
      font-weight: 700;
      font-size: 16px;
      letter-spacing: -0.02em;
    }

    .brand-logo {
      width: 24px;
      height: 24px;
      border-radius: 5px;
      object-fit: cover;
    }

    .brand-tag {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      font-weight: 600;
      color: var(--text-muted);
      background: var(--bg-subtle);
      padding: 2px 6px;
      border-radius: 4px;
      border: 1px solid var(--border);
    }

    .nav-menu {
      display: flex;
      align-items: center;
      gap: 24px;
      list-style: none;
    }

    .nav-link {
      font-size: 14px;
      font-weight: 500;
      color: var(--text-muted);
      text-decoration: none;
      transition: color 0.15s ease;
    }

    .nav-link:hover, .nav-link.active {
      color: var(--text-main);
    }

    .nav-cta {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 7px 14px;
      font-size: 13px;
      font-weight: 600;
      color: #ffffff;
      background: var(--dark-btn);
      border-radius: 6px;
      text-decoration: none;
      transition: background 0.15s ease;
    }

    .nav-cta:hover {
      background: var(--dark-btn-hover);
    }

    /* Studio Header Bar - Compact horizontal layout for desktop */
    .gallery-hero {
      padding: 16px 0 12px;
    }

    .gallery-hero-inner {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 20px;
    }

    .gallery-hero-left {
      display: flex;
      flex-direction: column;
      gap: 3px;
    }

    .gallery-hero-title-row {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .pillar-tag {
      display: inline-block;
      font-family: 'JetBrains Mono', monospace;
      font-size: 10px;
      font-weight: 700;
      color: var(--brand);
      background: #eff6ff;
      border: 1px solid #bfdbfe;
      padding: 1px 6px;
      border-radius: 4px;
      letter-spacing: 0.04em;
    }

    .hero-title {
      font-size: 22px;
      font-weight: 800;
      letter-spacing: -0.02em;
      line-height: 1.2;
      color: var(--text-main);
      margin: 0;
    }

    .hero-subtitle {
      font-size: 13.5px;
      color: var(--text-muted);
      margin: 0;
      line-height: 1.4;
    }

    /* Segmented Controls - Matching benchmark & index */
    .controls-center {
      display: flex;
      align-items: center;
      gap: 12px;
      margin: 0;
      flex-shrink: 0;
    }

    .segmented-control {
      display: inline-flex;
      align-items: center;
      background: var(--bg-subtle);
      padding: 3px;
      border-radius: 8px;
      border: 1px solid var(--border);
      gap: 2px;
    }

    .seg-btn {
      font-size: 12.5px;
      font-weight: 500;
      padding: 5px 12px;
      border-radius: 6px;
      border: none;
      background: transparent;
      color: var(--text-muted);
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      transition: all 0.15s ease;
      font-family: inherit;
    }

    .seg-btn:hover {
      color: var(--text-main);
    }

    .seg-btn.active {
      color: var(--text-main);
      background: #ffffff;
      font-weight: 600;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    }

    /* Showcase Layout */
    .gallery-grid {
      display: grid;
      grid-template-columns: 280px 1fr;
      gap: 20px;
      align-items: start;
      margin-bottom: 36px;
    }

    /* Sidebar Navigation Card - Matching workbench height with internal scrolling */
    .sidebar-card {
      background: #ffffff;
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 14px 12px 14px 14px;
      height: calc(100vh - 148px);
      min-height: 520px;
      max-height: 750px;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    }

    .sidebar-search-wrapper {
      position: relative;
      margin-bottom: 10px;
      flex-shrink: 0;
    }

    .search-input {
      width: 100%;
      background: var(--bg-subtle);
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 7px 10px;
      font-size: 12.5px;
      color: var(--text-main);
      font-family: inherit;
      outline: none;
      margin-bottom: 0;
      transition: all 0.15s ease;
    }

    .search-input:focus {
      background: #ffffff;
      border-color: var(--brand);
      box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
    }

    .sidebar-menu-scroll {
      overflow-y: auto;
      flex: 1;
      padding-right: 4px;
      scrollbar-width: thin;
      scrollbar-color: #cbd5e1 transparent;
    }

    .category-title {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.05em;
      margin: 14px 0 6px 6px;
    }

    .category-title:first-of-type {
      margin-top: 0;
    }

    .comp-menu {
      list-style: none;
      display: flex;
      flex-direction: column;
      gap: 2px;
    }

    .comp-btn {
      width: 100%;
      text-align: left;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 8px 12px;
      border-radius: 6px;
      color: var(--text-sub);
      font-size: 13px;
      font-weight: 500;
      background: transparent;
      border: none;
      cursor: pointer;
      transition: all 0.15s ease;
      font-family: inherit;
      white-space: nowrap;
    }

    .comp-btn span:first-child {
      white-space: nowrap;
    }

    .comp-btn:hover {
      background: var(--bg-subtle);
      color: var(--text-main);
    }

    .comp-btn.active {
      background: #eff6ff;
      color: var(--brand);
      font-weight: 600;
    }

    .comp-subtag {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      padding: 2px 7px;
      border-radius: 4px;
      background: var(--bg-subtle);
      border: 1px solid var(--border);
      color: var(--text-muted);
      white-space: nowrap;
      flex-shrink: 0;
    }

    .comp-btn.active .comp-subtag {
      background: #ffffff;
      border-color: rgba(37, 99, 235, 0.25);
      color: var(--brand);
    }

    /* Main Showcase Workbench Window - Perfectly aligned alongside sidebar */
    .workbench-window {
      background: #ffffff;
      border: 1px solid var(--border);
      border-radius: 12px;
      box-shadow: 0 16px 36px -8px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
      overflow: hidden;
      scroll-margin-top: 80px;
    }

    .workbench-header {
      height: 42px;
      background: var(--bg-subtle);
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 16px;
      font-size: 13px;
      font-weight: 500;
      color: var(--text-muted);
    }

    .header-dots {
      display: flex;
      align-items: center;
      gap: 6px;
      flex-wrap: nowrap;
      overflow: hidden;
    }

    .dot {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background: #cbd5e1;
      flex-shrink: 0;
    }

    .header-title-text {
      font-size: 13px;
      font-weight: 600;
      color: var(--text-main);
      margin-left: 8px;
      white-space: nowrap;
      flex-shrink: 0;
    }

    .header-signature {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      color: var(--brand);
      background: #ffffff;
      border: 1px solid var(--border);
      padding: 2px 6px;
      border-radius: 4px;
      margin-left: 8px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      flex-shrink: 1;
    }

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

    .mini-btn {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 4px 8px;
      font-size: 11px;
      font-weight: 600;
      font-family: 'JetBrains Mono', monospace;
      color: var(--text-sub);
      background: #ffffff;
      border: 1px solid var(--border);
      border-radius: 5px;
      cursor: pointer;
      transition: all 0.15s ease;
    }

    .mini-btn:hover {
      background: var(--bg-subtle);
      color: var(--text-main);
      border-color: var(--border-strong);
    }

    /* Curtain Split Stage */
    .stage-container {
      position: relative;
      width: 100%;
      height: calc(100vh - 228px);
      min-height: 440px;
      max-height: 670px;
      overflow: hidden;
      user-select: none;
    }

    /* Layer 1: Code Underlay (Bottom Layer) - Matching index.html code-block */
    .code-underlay {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: #0f172a;
      overflow: auto;
      padding: 24px;
      font-family: 'JetBrains Mono', monospace;
      font-size: 13px;
      line-height: 1.6;
      color: #f8fafc;
    }

    .code-underlay pre {
      margin: 0;
      white-space: pre;
    }

    /* Syntax Tokens from index.html */
    .code-kw { color: #f43f5e; font-weight: 600; }
    .code-type { color: #38bdf8; font-weight: 500; }
    .code-fn { color: #34d399; font-weight: 500; }
    .code-str { color: #fbbf24; }
    .code-comment { color: #64748b; font-style: italic; }

    /* Layer 2: Live Component UI (Foreground Curtain Layer) */
    .ui-curtain-layer {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: #ffffff;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      clip-path: inset(0 0 0 0%);
      will-change: clip-path;
      box-shadow: -4px 0 16px rgba(0, 0, 0, 0.06);
      background-image: 
        radial-gradient(#e2e8f0 1px, transparent 1px);
      background-size: 20px 20px;
    }

    /* Native MoonBit Canvas Stage Inside UI Layer */
    .sandbox-box,
    .sandbox-box-window {
      width: 100%;
      height: 100%;
      max-width: none;
      padding: 0;
      border: none;
      background: transparent;
      box-shadow: none;
      overflow: hidden;
      display: block;
    }

    .sandbox-header {
      font-size: 12px;
      font-weight: 700;
      font-family: 'JetBrains Mono', monospace;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.05em;
      margin-bottom: 16px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .sandbox-body {
      margin-bottom: 16px;
    }

    .sandbox-tip {
      font-size: 13px;
      color: var(--text-sub);
      line-height: 1.5;
    }

    /* Draggable Vertical Curtain Handle (帘幕把手) */
    .curtain-divider {
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0%;
      width: 40px;
      margin-left: -20px;
      z-index: 50;
      cursor: ew-resize;
      display: flex;
      align-items: center;
      justify-content: center;
      touch-action: none;
    }

    .curtain-handle-pill {
      position: relative;
      z-index: 2;
      width: 28px;
      height: 48px;
      background: #ffffff;
      border: 1px solid var(--border-strong);
      border-radius: 14px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 3px;
      box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
      transition: transform 0.1s ease, border-color 0.15s ease, box-shadow 0.15s ease;
      cursor: ew-resize;
    }

    .curtain-divider:hover .curtain-handle-pill,
    .curtain-divider.dragging .curtain-handle-pill {
      transform: scale(1.08);
      border-color: var(--brand);
      box-shadow: 0 4px 16px rgba(37, 99, 235, 0.25);
    }

    .curtain-arrows {
      font-size: 8px;
      font-weight: 700;
      color: var(--text-muted);
    }

    .curtain-divider:hover .curtain-arrows,
    .curtain-divider.dragging .curtain-arrows {
      color: var(--brand);
    }

    .curtain-dots {
      display: flex;
      flex-direction: column;
      gap: 3px;
    }

    .curtain-dot {
      width: 3px;
      height: 3px;
      border-radius: 50%;
      background: var(--border-strong);
    }


    /* Workbench Footer Status Bar */
    .workbench-footer {
      height: 38px;
      background: var(--bg-subtle);
      border-top: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 16px;
      font-size: 12px;
      color: var(--text-sub);
    }

    .ratio-badge {
      font-family: 'JetBrains Mono', monospace;
      font-weight: 600;
      color: var(--brand);
    }

    .status-stream {
      display: flex;
      align-items: center;
      gap: 12px;
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
    }

    .status-item b {
      color: var(--text-main);
    }



    /* Global Toast Notification */
    .toast-msg {
      position: fixed;
      bottom: 24px;
      right: 24px;
      background: var(--dark-btn);
      color: #ffffff;
      padding: 10px 18px;
      border-radius: 8px;
      font-size: 13px;
      font-weight: 500;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
      transform: translateY(100px);
      opacity: 0;
      transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
      z-index: 1000;
    }

    .toast-msg.show {
      transform: translateY(0);
      opacity: 1;
    }

    /* Footer - Exactly matching index.html */
    .site-footer {
      border-top: 1px solid var(--border);
      padding: 32px 0;
      font-size: 13px;
      color: var(--text-muted);
    }

    .footer-inner {
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .footer-links {
      display: flex;
      align-items: center;
      gap: 16px;
    }

    .footer-links a {
      color: var(--text-muted);
      text-decoration: none;
    }

    .footer-links a:hover {
      color: var(--text-main);
    }

    @media (max-width: 840px) {
      .gallery-grid { grid-template-columns: 1fr; }
      .sidebar-card { position: static; max-height: 420px; }
      .workbench-window { position: static; }
      .footer-inner { flex-direction: column; gap: 12px; }
      .hero-title { font-size: 28px; }
    }
