﻿
  :root {
    --bg: #1a1a1a;
    --panel: #202020;
    --panel-2: #1c1c1c;
    --border: #383838;
    --text: #d4d4d4;
    --muted: #8a8a8a;
    --accent: #b388ff;
    --accent-2: #80cbc4;
    --button-bg: #2c2040;
    --button-border: #4a2e7a;
    --drawer-w: 368px;
    --drawer-handle-w: 36px;
  }
  * { margin: 0; padding: 0; box-sizing: border-box; }
  html, body {
    width: 100%; height: 100%; overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: "MS PGothic", "MS UI Gothic", sans-serif;
    font-size: 13px;
    line-height: 1.6;
  }
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: radial-gradient(1200px 700px at 75% 12%, rgba(179, 136, 255, 0.12), transparent 58%),
      radial-gradient(700px 500px at 14% 82%, rgba(128, 203, 196, 0.09), transparent 62%);
    pointer-events: none;
    z-index: 0;
  }
  canvas { display: block; cursor: crosshair; position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; }

  #ui {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 12;
    display: flex;
    flex-direction: row;
    width: var(--drawer-w);
    font-size: 12px;
    box-shadow: 10px 0 28px rgba(0, 0, 0, 0.35);
    transition: transform 180ms ease, box-shadow 220ms ease;
    animation: uiEnter 340ms ease-out;
  }
  #ui.drawer-collapsed {
    transform: translateX(calc(-1 * (var(--drawer-w) - var(--drawer-handle-w))));
    box-shadow: none;
  }
  #drawerContent {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--panel);
    padding: 14px 12px 12px;
  }
  #drawerHeader {
    flex-shrink: 0;
    margin-bottom: 8px;
  }
  #drawerSidebar {
    width: var(--drawer-handle-w);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #171717;
    border-right: 1px solid var(--border);
    border-left: 1px solid rgba(255,255,255,0.04);
  }
  #drawerLogo {
    width: 100%;
    padding: 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    border-bottom: 1px solid var(--border);
    background: none;
    transition: filter 160ms ease, background 160ms ease;
    flex-shrink: 0;
  }
  #drawerLogo:hover { filter: brightness(1.3); background: rgba(179,136,255,0.09); }
  #drawerVtabs {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    overflow: hidden;
    width: 100%;
    padding: 4px 0;
    gap: 1px;
  }
  .drawer-vtab {
    flex: 1;
    max-height: 90px;
    min-height: 28px;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: lowercase;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    transition: color 140ms ease, background 140ms ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 4px 0;
  }
  .drawer-vtab:hover {
    color: var(--accent);
    background: rgba(179, 136, 255, 0.07);
  }
  #sidebarToggle {
    width: 100%;
    padding: 8px 0;
    border: none;
    border-top: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 11px;
    transition: color 140ms ease, background 140ms ease;
    flex-shrink: 0;
  }
  #sidebarToggle:hover { color: var(--accent); background: rgba(179,136,255,0.07); }
  #ui .crumb {
    color: var(--accent);
    font-size: 11px;
    margin-bottom: 2px;
  }
  #ui .crumb a {
    color: var(--accent);
    text-decoration: none;
  }
  #ui .crumb a:hover { text-decoration: underline; }
  #ui .crumb .sep { color: #555; margin: 0 3px; }
  #ui .crumb .current { color: #9a9a9a; }
  #ui h1 {
    font-size: 18px;
    color: var(--accent);
    margin-bottom: 8px;
    font-weight: normal;
    line-height: 1.2;
  }
  #ui .tagline {
    color: var(--muted);
    font-size: 10px;
    margin-bottom: 10px;
  }
  #ui h1 .collapse { float: right; cursor: pointer; opacity: 0.6; user-select: none; }
  #ui h1 .collapse:hover { opacity: 1; }
  .row { margin-bottom: 9px; }
  .row { transition: background-color 180ms ease; }
  .row:hover { background: rgba(255, 255, 255, 0.02); }
  .row label { display: block; color: var(--accent); margin-bottom: 4px; font-size: 11px; }
  select, input, textarea, button {
    width: 100%;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 0;
    padding: 4px 7px;
    font-family: inherit;
    font-size: 12px;
    outline: none;
  }
  select:focus, input:focus, textarea:focus { border-color: var(--accent); }
  textarea { resize: vertical; min-height: 64px; font-size: 12px; background: var(--panel-2); }
  button {
    cursor: pointer;
    background: var(--button-bg);
    color: var(--accent);
    border-color: var(--button-border);
    transition: filter 0.15s;
  }
  button:hover { filter: brightness(1.1); }
  button:active { transform: translateY(1px); }
  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .slider-row { display: flex; align-items: center; gap: 8px; }
  .slider-row input[type=range] { flex: 1; padding: 0; }
  .slider-row .val { min-width: 40px; text-align: right; color: var(--muted); font-size: 10px; }
  .hint { color: var(--muted); font-size: 10px; line-height: 1.4; margin-top: 4px; }
  .error { color: #ff9eb5; font-size: 10px; margin-top: 4px; min-height: 12px; }
  .dock-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border: 1px solid var(--button-border);
    background: var(--button-bg);
    color: var(--accent);
    padding: 4px 7px;
    font-family: inherit;
    font-size: 12px;
    min-height: 28px;
  }
  .dock-link:hover { filter: brightness(1.1); }
  #postToGallery.ready {
    border-color: #79b89f;
    color: #c8ffe6;
    background: #20372f;
    box-shadow: 0 0 0 1px rgba(121, 184, 159, 0.3) inset;
  }

  .info-window {
    margin-top: 8px;
    border: 1px solid #3a3a3a;
    background: #171717;
    padding: 8px;
  }
  .info-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    color: var(--accent);
    font-size: 11px;
  }
  .info-head button {
    width: auto;
    min-width: 58px;
    padding: 2px 6px;
    font-size: 10px;
  }
  .info-copy p {
    margin: 0 0 6px;
    color: #b6b6b6;
    font-size: 11px;
    line-height: 1.38;
  }
  .info-copy p:last-child { margin-bottom: 0; }

  .section {
    color: var(--accent);
    border-top: 1px solid var(--border);
    margin: 10px 0 8px;
    padding-top: 8px;
    font-size: 11px;
  }

  #dockRoot {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    overflow: auto;
    padding-right: 2px;
    scrollbar-width: thin;
    scrollbar-color: #4b4b4b #1b1b1b;
  }
  #dockRoot::-webkit-scrollbar,
  .dock-section.popped::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }
  #dockRoot::-webkit-scrollbar-track,
  .dock-section.popped::-webkit-scrollbar-track {
    background: #1b1b1b;
  }
  #dockRoot::-webkit-scrollbar-thumb,
  .dock-section.popped::-webkit-scrollbar-thumb {
    background: #4a4a4a;
    border: 1px solid #2b2b2b;
  }
  #dockRoot::-webkit-scrollbar-thumb:hover,
  .dock-section.popped::-webkit-scrollbar-thumb:hover {
    background: #626262;
  }

  .dock-section {
    border: 1px solid var(--border);
    background: var(--panel-2);
    transition: box-shadow 180ms ease, transform 180ms ease, border-color 180ms ease;
    animation: sectionEnter 260ms ease-out;
  }
  .dock-section:hover {
    border-color: #4a4a4a;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
  }
  .dock-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 8px;
    border-bottom: 1px solid var(--border);
    background: #1b1b1b;
    cursor: grab;
    user-select: none;
  }
  .dock-head:active { cursor: grabbing; }
  .dock-title {
    color: var(--accent);
    font-size: 11px;
    letter-spacing: 0.2px;
  }
  .dock-sort {
    color: var(--muted);
    margin-right: 6px;
    cursor: ns-resize;
    user-select: none;
    font-size: 11px;
    letter-spacing: 1px;
  }
  .dock-actions {
    display: inline-flex;
    gap: 4px;
  }
  .dock-pop {
    width: auto;
    min-width: 50px;
    padding: 2px 6px;
    font-size: 10px;
    background: #2a2440;
  }
  .dock-section.simple-mode .advanced {
    display: none !important;
  }
  .dock-section.simple-mode .dock-body {
    padding-bottom: 6px;
  }
  .dock-section.simple-mode .dock-title::after {
    content: " Â· simple";
    color: var(--muted);
    font-size: 10px;
  }
  .dock-body {
    padding: 8px;
  }
  .dock-body .row:last-child {
    margin-bottom: 0;
  }
  .dock-section.dragging-sort {
    opacity: 0.55;
    border-color: var(--accent-2);
  }
  .dock-section.popped {
    position: fixed;
    z-index: 30;
    width: min(44vw, 380px);
    max-width: min(78vw, 540px);
    max-height: 80vh;
    min-width: 260px;
    min-height: 120px;
    overflow: auto;
    resize: both;
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.48);
    border-color: #5a5a5a;
    animation: popOut 220ms ease-out;
    scrollbar-width: thin;
    scrollbar-color: #4b4b4b #1b1b1b;
  }
  .dock-section.drag-pop {
    animation: dragPop 180ms ease-out;
  }
  .dock-section.popped .dock-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #1f1f1f;
  }
  #ui.drop-target #drawerContent {
    box-shadow: 0 0 24px rgba(128, 203, 196, 0.13) inset;
    background: color-mix(in srgb, var(--panel) 96%, #80cbc4);
  }

  #hud {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 11;
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 8px 10px;
    font-size: 11px;
    color: var(--text);
    min-width: 260px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    animation: uiEnter 420ms ease-out;
  }
  #hud .lbl { color: var(--muted); }
  #hud > div + div { margin-top: 2px; }

  #help {
    position: absolute;
    right: 14px;
    bottom: 14px;
    z-index: 11;
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 8px 10px;
    font-size: 10px;
    color: var(--muted);
    width: min(320px, calc(100vw - 28px));
    min-height: 66px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    transition: border-color 180ms ease, transform 180ms ease;
    animation: uiEnter 520ms ease-out;
  }
  #help.active {
    border-color: #585858;
    transform: translateY(-1px);
  }
  #help .tip-head {
    color: var(--accent-2);
    font-size: 10px;
    margin-bottom: 2px;
    letter-spacing: 0.2px;
  }
  #help .tip-text {
    color: var(--text);
    font-size: 11px;
    line-height: 1.35;
  }

  input[type=range] {
    appearance: none;
    -webkit-appearance: none;
    background: #2b2b2b;
    height: 3px;
    border: 0;
  }
  input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    background: var(--accent);
    border-radius: 0;
    cursor: pointer;
    border: 1px solid #8f6ed0;
  }
  input[type=range]::-moz-range-thumb {
    width: 10px;
    height: 10px;
    background: var(--accent);
    border-radius: 0;
    cursor: pointer;
    border: 1px solid #8f6ed0;
  }

  @media (max-width: 900px) {
    #ui {
      width: 100vw;
      --drawer-w: 100vw;
      top: 0;
      left: 0;
      bottom: 0;
    }
    #drawerContent {
      padding: 12px 10px 10px;
    }
    .dock-pop {
      min-width: 56px;
      min-height: 26px;
    }
    #hud {
      top: 0;
      left: 0;
      right: 0;
      bottom: auto;
      min-width: 0;
      max-width: none;
      width: auto;
      padding: 4px 8px;
      border-top: 0;
      border-left: 0;
      border-right: 0;
      background: rgba(32, 32, 32, 0.94);
      box-shadow: none;
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 6px;
      font-size: 10px;
      pointer-events: none;
    }
    #hud > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    #hud > div + div { margin-top: 0; }
    .two-col { grid-template-columns: 1fr; }
    .three-col { grid-template-columns: 1fr 1fr; }
    select, input, textarea { font-size: 16px; }
  }

  @media (max-width: 560px) {
    .three-col { grid-template-columns: 1fr; }
    .dock-actions { gap: 3px; }
    #hud {
      padding: 3px 6px;
      gap: 4px;
      font-size: 9px;
    }
  }

  @keyframes uiEnter {
    from { opacity: 0; transform: translateX(-18px); }
    to { opacity: 1; transform: translateX(0); }
  }

  @keyframes sectionEnter {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  @keyframes popOut {
    0% { opacity: 0.75; transform: scale(0.96); }
    100% { opacity: 1; transform: scale(1); }
  }

  @keyframes dragPop {
    0% { transform: scale(0.92); }
    70% { transform: scale(1.03); }
    100% { transform: scale(1); }
  }

  /* ── generator mode toggle ────────────────────────────────────────────── */
  .gen-mode-btn {
    background: var(--bg);
    border-color: var(--border);
    color: var(--muted);
    transition: color 140ms, border-color 140ms, background 140ms;
  }
  .gen-mode-btn:hover { color: var(--text); border-color: #666; }
  .gen-mode-btn.gen-mode-active {
    background: #2c2040;
    border-color: var(--accent);
    color: var(--accent);
  }

  /* ── patch notes ──────────────────────────────────────────────────────── */
  #patchNotesBtn {
    position: fixed;
    bottom: 14px;
    right: 14px;
    z-index: 20;
    background: rgba(32, 32, 32, 0.82);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 10px;
    padding: 3px 9px;
    cursor: pointer;
    width: auto;
    min-width: 0;
    letter-spacing: 0.3px;
    transition: color 140ms, border-color 140ms, background 140ms;
    backdrop-filter: blur(4px);
  }
  #patchNotesBtn:hover { color: var(--accent); border-color: var(--accent); background: rgba(44,32,64,0.88); }

  #patchNotesPanel {
    position: fixed;
    bottom: 44px;
    right: 14px;
    z-index: 20;
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 10px 12px;
    width: min(340px, calc(100vw - 28px));
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
    animation: patchNotesIn 160ms ease-out;
  }
  #patchNotesPanel[hidden] { display: none; }
  .pn-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    color: var(--accent);
    font-size: 11px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
  }
  .pn-head button {
    width: auto;
    min-width: 46px;
    padding: 2px 6px;
    font-size: 10px;
  }
  .pn-entry { margin-bottom: 10px; }
  .pn-entry:last-child { margin-bottom: 0; }
  .pn-ver { color: var(--accent-2); font-size: 10px; margin-bottom: 4px; letter-spacing: 0.2px; }
  .pn-notes { list-style: none; padding: 0; margin: 0; }
  .pn-notes li {
    color: #aaaaaa;
    font-size: 10px;
    line-height: 1.45;
    padding-left: 12px;
    margin-bottom: 2px;
    position: relative;
  }
  .pn-notes li::before { content: "·"; position: absolute; left: 2px; color: var(--muted); }
  .pn-notes strong { color: var(--text); font-weight: normal; }

  @keyframes patchNotesIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
  }

