    * { margin: 0; padding: 0; box-sizing: border-box; }

    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
      display: flex;
      flex-direction: column;
      height: 100vh;
      overflow: hidden;
      background: #1a1a2e;
      color: #e0e0e0;
    }

    nav {
      background: #16213e;
      border-bottom: 1px solid #0f3460;
      padding: 0 16px;
      height: 44px;
      display: flex;
      align-items: center;
      gap: 16px;
      flex-shrink: 0;
    }
    nav a { color: #e94560; text-decoration: none; font-weight: 600; font-size: 14px; }
    nav a:hover { text-decoration: underline; }
    .nav-title { font-weight: 700; font-size: 16px; }
    .nav-status { margin-left: auto; font-size: 11px; color: #8892a4; }

    .main { display: flex; flex: 1; overflow: hidden; }

    /* Sidebar */
    #sidebar {
      width: 320px;
      min-width: 320px;
      background: #16213e;
      padding: 20px;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: 14px;
      border-right: 1px solid #0f3460;
    }

    #sidebar h1 {
      font-size: 18px;
      color: #e94560;
      margin-bottom: 0;
      display: none; /* moved to nav */
    }

    .control-group {
      display: flex;
      flex-direction: column;
      gap: 5px;
    }

    .control-group > label {
      font-size: 11px;
      font-weight: 600;
      text-transform: uppercase;
      color: #8899aa;
      letter-spacing: 0.5px;
    }

    input[type="text"], select {
      width: 100%;
      padding: 7px 10px;
      border: 1px solid #0f3460;
      border-radius: 6px;
      background: #1a1a2e;
      color: #e0e0e0;
      font-size: 14px;
      outline: none;
      transition: border-color 0.2s;
    }

    input[type="text"]:focus, select:focus {
      border-color: #e94560;
    }

    .radio-group {
      display: flex;
      gap: 4px;
    }

    .radio-group label {
      flex: 1;
      text-align: center;
      padding: 6px 6px;
      border: 1px solid #0f3460;
      border-radius: 6px;
      cursor: pointer;
      font-size: 11px;
      font-weight: 500;
      text-transform: none;
      color: #8899aa;
      transition: all 0.2s;
    }

    .radio-group input[type="radio"] { display: none; }
    .radio-group input[type="radio"]:checked + label {
      background: #e94560;
      border-color: #e94560;
      color: #fff;
    }

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

    .slider-row input[type="range"] {
      flex: 1;
      -webkit-appearance: none;
      height: 4px;
      border-radius: 2px;
      background: #0f3460;
      outline: none;
    }

    .slider-row input[type="range"]::-webkit-slider-thumb {
      -webkit-appearance: none;
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background: #e94560;
      cursor: pointer;
    }

    .slider-value {
      min-width: 32px;
      text-align: right;
      font-size: 13px;
      color: #e94560;
      font-weight: 600;
      cursor: text;
    }
    .slider-value-input {
      width: 48px;
      background: rgba(233, 69, 96, 0.1);
      border: none;
      border-radius: 4px;
      color: #e94560;
      font-size: 13px;
      font-weight: 600;
      text-align: right;
      outline: none;
      padding: 1px 4px;
      font-family: inherit;
      -moz-appearance: textfield;
    }
    .slider-value-input::-webkit-inner-spin-button,
    .slider-value-input::-webkit-outer-spin-button { display: none; }

    #qualityVal {
      min-width: 72px;
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.3px;
    }

    .upload-btn {
      display: inline-block;
      padding: 6px 12px;
      background: #0f3460;
      border: 1px solid #0f3460;
      border-radius: 6px;
      color: #8899aa;
      font-size: 12px;
      cursor: pointer;
      text-align: center;
      transition: all 0.2s;
    }

    .upload-btn:hover {
      background: #e94560;
      border-color: #e94560;
      color: #fff;
    }

    #fontUpload, #fontUpload2 { display: none; }

    .export-btn {
      width: 100%;
      padding: 12px;
      background: #e94560;
      border: none;
      border-radius: 8px;
      color: #fff;
      font-size: 14px;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.2s;
    }

    .export-btn:hover { background: #c73e54; }
    .export-btn:disabled { background: #444; cursor: not-allowed; }

    #inlayExportWrap {
      display: flex;
      flex-direction: column;
      gap: 8px;
      margin-top: auto;
    }

    #exportBtn {
      margin-top: auto;
    }

    .separator {
      height: 1px;
      background: #0f3460;
      margin: 2px 0;
    }
    #projectBtns {
      display: flex;
      gap: 8px;
    }
    .project-btn {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 3px;
      padding: 8px 4px;
      background: #1a2a4a;
      border: 1px solid #0f3460;
      border-radius: 8px;
      color: #8892a4;
      cursor: pointer;
      transition: background 0.2s, color 0.2s, border-color 0.2s;
    }
    .project-btn:hover {
      background: #0f3460;
      color: #fff;
      border-color: #1f5099;
    }
    .project-btn-icon { font-size: 18px; line-height: 1; }
    .project-btn-label { font-size: 11px; font-weight: 500; }

    /* Canvas area */
    #canvas-container {
      flex: 1;
      position: relative;
      background: #1a1a2e;
    }

    #canvas-container canvas {
      display: block;
      width: 100%;
      height: 100%;
    }

    #loading-overlay {
      position: absolute;
      inset: 0;
      display: none;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 12px;
      background: rgba(26, 26, 46, 0.75);
      z-index: 12;
      pointer-events: none;
      white-space: pre-line;
      color: #e94560;
      font-size: 13px;
      text-align: center;
    }
    #loading-overlay.visible {
      display: flex;
    }
    #loading-overlay::before {
      content: '';
      width: 32px;
      height: 32px;
      border: 3px solid rgba(233, 69, 96, 0.3);
      border-top-color: #e94560;
      border-radius: 50%;
      animation: regen-spin 0.7s linear infinite;
    }

    #error-msg {
      position: absolute;
      bottom: 20px;
      left: 50%;
      transform: translateX(-50%);
      background: #c73e54;
      color: #fff;
      padding: 8px 16px;
      border-radius: 6px;
      font-size: 13px;
      display: none;
    }
    #spike-warning {
      position: absolute;
      top: 12px;
      left: 50%;
      transform: translateX(-50%);
      background: #e68a00;
      color: #fff;
      padding: 8px 32px 8px 14px;
      border-radius: 6px;
      font-size: 13px;
      max-width: 340px;
      text-align: center;
      z-index: 20;
      white-space: normal;
    }
    #spike-warning-close {
      position: absolute;
      right: 8px;
      top: 50%;
      transform: translateY(-50%);
      background: none;
      border: none;
      color: #fff;
      cursor: pointer;
      font-size: 14px;
      line-height: 1;
      padding: 0;
    }
    #export-notice {
      position: absolute;
      bottom: 56px;
      left: 50%;
      transform: translateX(-50%);
      background: #b8890a;
      color: #fff;
      padding: 8px 32px 8px 14px;
      border-radius: 6px;
      font-size: 12px;
      max-width: 360px;
      text-align: center;
      z-index: 20;
      white-space: normal;
      line-height: 1.4;
    }
    #export-notice-close {
      position: absolute;
      right: 8px;
      top: 50%;
      transform: translateY(-50%);
      background: none;
      border: none;
      color: #fff;
      cursor: pointer;
      font-size: 14px;
      line-height: 1;
      padding: 0;
    }

    #regen-overlay {
      position: absolute;
      inset: 0;
      display: none;
      align-items: center;
      justify-content: center;
      background: rgba(26, 26, 46, 0.45);
      z-index: 11;
      pointer-events: none;
    }
    #regen-overlay.active {
      display: flex;
    }
    #regen-overlay::after {
      content: '';
      width: 28px;
      height: 28px;
      border: 3px solid rgba(233, 69, 96, 0.3);
      border-top-color: #e94560;
      border-radius: 50%;
      animation: regen-spin 0.7s linear infinite;
    }
    @keyframes regen-spin {
      to { transform: rotate(360deg); }
    }

    #view-tools {
      position: absolute;
      top: 14px;
      right: 14px;
      display: flex;
      flex-direction: column;
      gap: 8px;
      z-index: 5;
      user-select: none;
    }

    .view-btn {
      border: 1px solid #0f3460;
      background: rgba(18, 33, 62, 0.88);
      color: #c8d4e6;
      border-radius: 8px;
      height: 30px;
      min-width: 40px;
      padding: 0 10px;
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 0.4px;
      cursor: pointer;
      transition: all 0.2s;
    }

    .view-btn:hover {
      border-color: #e94560;
      color: #fff;
    }

    .view-btn.active {
      border-color: #e94560;
      background: rgba(233, 69, 96, 0.18);
      color: #e94560;
    }

    .author-link {
      color: #8892a4;
      text-decoration: underline;
      transition: color 0.15s;
    }
    .author-link:hover { color: #e94560; }
    .notice { font-size: 10px; color: #8892a4; line-height: 1.5; }

    #viewGrid {
      display: grid;
      grid-template-columns: repeat(3, 40px);
      gap: 6px;
      justify-content: end;
    }

    #viewGrid [data-view="bottom"] {
      grid-column: 2;
    }

    #fitViewBtn {
      width: 132px;
      justify-self: end;
    }

    #screenshotBtn {
      width: 132px;
      font-size: 14px;
    }

    /* Base plate controls wrapper for show/hide */
    .base-controls { transition: opacity 0.2s; }
    .base-controls.hidden { opacity: 0.3; pointer-events: none; }

    /* Line 2 controls for show/hide */
    .line2-controls { transition: all 0.3s; }
    .line2-controls.hidden { display: none; }

    .is-hidden { display: none !important; }

    /* Line 2 inner container with proper gaps */
    .line2-inner {
      display: flex;
      flex-direction: column;
      gap: 14px;
      padding-top: 4px;
    }

    /* Language toggle */
    .lang-toggle {
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .lang-toggle span {
      font-size: 12px;
      color: #556;
      cursor: pointer;
      padding: 2px 6px;
      border-radius: 4px;
      transition: all 0.2s;
      user-select: none;
    }

    .lang-toggle span.active {
      color: #e94560;
      font-weight: 700;
    }

    .lang-toggle span:hover {
      color: #e94560;
    }

    /* Case buttons */
    .case-buttons {
      display: flex;
      gap: 4px;
    }

    .case-btn {
      flex: 1;
      padding: 5px 6px;
      border: 1px solid #0f3460;
      border-radius: 6px;
      background: transparent;
      color: #8899aa;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      text-align: center;
      transition: all 0.2s;
      font-family: inherit;
    }

    .case-btn:hover {
      border-color: #e94560;
      color: #e94560;
    }

    .case-btn.active {
      background: #e94560;
      border-color: #e94560;
      color: #fff;
    }

    /* Font row: select + weight */
    .font-row {
      display: flex;
      gap: 6px;
    }

    .font-row select:first-child {
      flex: 1;
      min-width: 0;
    }

    .font-row .weight-select {
      width: 110px;
      flex-shrink: 0;
    }

    /* Font picker */
    .font-picker {
      position: relative;
      flex: 1;
      min-width: 0;
    }
    .font-picker-display {
      width: 100%;
      padding: 7px 28px 7px 10px;
      border: 1px solid #0f3460;
      border-radius: 6px;
      background: #1a1a2e;
      color: #e0e0e0;
      font-size: 14px;
      cursor: pointer;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      box-sizing: border-box;
      transition: border-color 0.2s;
      position: relative;
    }
    .font-picker-display::after {
      content: '▾';
      position: absolute;
      right: 9px;
      top: 50%;
      transform: translateY(-50%);
      font-size: 12px;
      color: #8888aa;
      pointer-events: none;
    }
    .font-picker-display:hover,
    .font-picker.open .font-picker-display {
      border-color: #e94560;
    }
    .font-picker-dropdown {
      display: none;
      position: absolute;
      top: 100%;
      left: 0;
      right: 0;
      margin-top: 2px;
      background: #16213e;
      border: 1px solid #0f3460;
      border-radius: 8px;
      box-shadow: 0 8px 24px rgba(0,0,0,0.5);
      z-index: 1000;
      overflow: hidden;
    }
    .font-picker.open .font-picker-dropdown {
      display: block;
    }
    .font-picker-search {
      width: 100%;
      padding: 8px 10px;
      border: none;
      border-bottom: 1px solid #0f3460;
      background: #1a1a2e;
      color: #e0e0e0;
      font-size: 13px;
      outline: none;
      box-sizing: border-box;
    }
    .font-picker-search::placeholder { color: #556; }
    .font-picker-cats {
      display: flex;
      gap: 3px;
      padding: 6px 6px 4px;
      flex-wrap: wrap;
    }
    .font-picker-cat {
      padding: 2px 7px;
      border: 1px solid #0f3460;
      border-radius: 10px;
      background: transparent;
      color: #8888aa;
      font-size: 11px;
      cursor: pointer;
      white-space: nowrap;
      transition: all 0.15s;
    }
    .font-picker-cat:hover { color: #e0e0e0; border-color: #335; }
    .font-picker-cat.active {
      background: #e94560;
      border-color: #e94560;
      color: #fff;
    }
    .font-picker-list {
      max-height: 280px;
      overflow-y: auto;
      scrollbar-width: thin;
      scrollbar-color: #0f3460 transparent;
    }
    .font-picker-list::-webkit-scrollbar { width: 6px; }
    .font-picker-list::-webkit-scrollbar-track { background: transparent; }
    .font-picker-list::-webkit-scrollbar-thumb { background: #0f3460; border-radius: 3px; }
    .font-picker-item {
      padding: 5px 10px;
      cursor: pointer;
      font-size: 13px;
      color: #ccc;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .font-picker-item:hover { background: #1a2744; color: #fff; }
    .font-picker-item.selected {
      background: #e94560;
      color: #fff;
    }
    .font-picker-empty {
      padding: 12px 10px;
      color: #556;
      font-size: 12px;
      text-align: center;
    }

    /* Section label */
    .section-label {
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      color: #e94560;
      letter-spacing: 1px;
      padding: 2px 0;
    }