:root {
      --page-bg: #000000;
      --text: #ffffff;
      --muted: #aaaaaa;
      --soft-muted: #777777;
      --panel: #111111;
      --panel-hover: #222222;
      --line: #333333;
      --line-soft: rgba(255, 255, 255, 0.1);
      --accent: #ff7800;
      --accent-soft: rgba(255, 120, 0, 0.2);
      --accent-glow: rgba(212, 140, 49, 0.42);
      --white: #ffffff;
      --shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    }

    * {
      box-sizing: border-box;
    }

    html,
    body {
      min-height: 100%;
    }

    body {
      margin: 0;
      min-height: 100vh;
      background-color: var(--page-bg);
      background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
      background-position: -1px -1px;
      background-size: 38px 38px;
      color: var(--text);
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      overflow: hidden;
      user-select: none;
    }

    .tool-home-button {
      top: 24px;
      left: 24px;
      border-color: var(--line);
      border-radius: 5px;
      background: var(--panel);
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
      color: var(--muted);
    }

    .tool-home-button:hover {
      border-color: var(--accent);
      background: var(--panel-hover);
      color: var(--accent);
    }

    button,
    input,
    select {
      font: inherit;
    }

    button {
      border: 0;
    }

    .app {
      display: grid;
      grid-template-columns: 392px minmax(0, 1fr);
      height: 100vh;
      min-height: 620px;
      perspective: 100vw;
    }

    .sidebar {
      display: grid;
      grid-template-rows: auto auto auto;
      align-content: start;
      height: 100vh;
      min-width: 0;
      overflow-y: auto;
      overscroll-behavior: contain;
      border-right: 1px solid var(--line);
      background: rgba(15, 15, 15, 0.94);
      box-shadow: var(--shadow);
      scrollbar-color: rgba(255, 120, 0, 0.55) transparent;
      z-index: 2;
    }

    .sidebar::-webkit-scrollbar {
      width: 6px;
    }

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

    .sidebar::-webkit-scrollbar-thumb {
      border-radius: 3px;
      background: rgba(255, 255, 255, 0.12);
    }

    .sidebar::-webkit-scrollbar-thumb:hover {
      background: var(--accent);
    }

    .sidebar-head {
      display: grid;
      gap: 14px;
      padding: 24px 24px 18px;
      border-bottom: 1px solid var(--line);
      background: rgba(0, 0, 0, 0.28);
    }

    footer.sidebar-head {
      border-top: 1px solid var(--line);
      border-bottom: 0;
      padding-top: 18px;
    }

    .title-row {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 14px;
      align-items: start;
    }

    h1 {
      margin: 0;
      color: var(--text);
      font-size: 1.42rem;
      line-height: 1.02;
      letter-spacing: 0.08em;
      font-weight: 900;
      text-transform: uppercase;
      text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.42);
    }

    .shader-badge {
      display: inline-flex;
      min-height: 28px;
      align-items: center;
      border: 1px solid var(--accent);
      border-radius: 999px;
      padding: 0 9px;
      background: var(--accent);
      color: #000;
      font-size: 0.68rem;
      font-weight: 800;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      white-space: nowrap;
      box-shadow: 0 8px 25px rgba(212, 140, 49, 0.26);
    }

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

    .file-input {
      position: absolute;
      width: 1px;
      height: 1px;
      clip: rect(0, 0, 0, 0);
      overflow: hidden;
      white-space: nowrap;
    }

    .button {
      display: inline-grid;
      min-height: 42px;
      place-items: center;
      border: 1px solid var(--line);
      border-radius: 5px;
      padding: 0 14px;
      background: var(--panel);
      color: var(--text);
      cursor: pointer;
      font-size: 0.78rem;
      font-weight: 800;
      letter-spacing: 0.1em;
      text-align: center;
      text-decoration: none;
      text-transform: uppercase;
      transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease, color 180ms ease, transform 180ms ease;
    }

    .button:hover {
      border-color: var(--accent);
      background: var(--panel-hover);
      color: var(--accent);
      transform: translateY(-1px);
    }

    .button.secondary {
      border: 1px solid var(--line);
      background: transparent;
      color: var(--muted);
    }

    .button.secondary:hover {
      border-color: var(--accent);
      background: var(--panel-hover);
      color: var(--accent);
    }

    .button:disabled {
      cursor: not-allowed;
      opacity: 0.48;
      transform: none;
    }

    .controls {
      display: grid;
      align-content: start;
      gap: 14px;
      min-height: 0;
      overflow: visible;
      padding: 18px 24px 22px;
    }

    .section {
      display: grid;
      gap: 12px;
      padding: 14px;
      border: 1px solid var(--line);
      border-radius: 5px;
      background: var(--panel);
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
      transform: rotateY(-2deg) rotateX(0.6deg);
      transform-origin: left center;
      transform-style: preserve-3d;
      transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
    }

    .section:hover {
      border-color: rgba(255, 120, 0, 0.46);
      background: #151515;
      box-shadow: 0 0 20px rgba(255, 120, 0, 0.12), 0 4px 20px rgba(0, 0, 0, 0.45);
    }

    .section:last-child {
      margin-bottom: 4px;
    }

    .section-title {
      margin: 0;
      color: var(--accent);
      font-size: 0.68rem;
      font-weight: 800;
      letter-spacing: 0.12em;
      text-transform: uppercase;
    }

    .preset-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }

    .preset-button {
      min-height: 38px;
      border: 1px solid var(--line);
      border-radius: 5px;
      background: #0b0b0b;
      color: var(--muted);
      cursor: pointer;
      font-size: 0.76rem;
      font-weight: 800;
      letter-spacing: 0.06em;
      transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, color 160ms ease;
    }

    .preset-button:hover,
    .preset-button.is-active {
      border-color: var(--accent);
      background: var(--accent);
      color: #000;
      box-shadow: 0 0 24px rgba(212, 140, 49, 0.22);
    }

    .segmented {
      display: grid;
      gap: 4px;
      padding: 4px;
      border: 1px solid var(--line);
      border-radius: 5px;
      background: #080808;
    }

    .segmented[data-columns="2"] {
      grid-template-columns: 1fr 1fr;
    }

    .segmented[data-columns="3"] {
      grid-template-columns: repeat(3, 1fr);
    }

    .segmented button {
      min-height: 34px;
      border-radius: 4px;
      background: transparent;
      color: var(--muted);
      cursor: pointer;
      font-size: 0.72rem;
      font-weight: 800;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      white-space: nowrap;
    }

    .segmented button[aria-pressed="true"] {
      background: var(--accent);
      color: #000;
    }

    .control {
      display: grid;
      gap: 7px;
    }

    .control-head {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 10px;
      align-items: baseline;
      color: var(--text);
      font-size: 0.82rem;
      font-weight: 700;
    }

    .value {
      min-width: 58px;
      color: var(--accent);
      font-variant-numeric: tabular-nums;
      font-size: 0.76rem;
      font-weight: 800;
      text-align: right;
    }

    input[type="range"] {
      width: 100%;
      accent-color: var(--accent);
    }

    .control-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }

    .select-wrap {
      display: grid;
      gap: 7px;
    }

    select {
      min-height: 38px;
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 5px;
      padding: 0 10px;
      background: #0b0b0b;
      color: var(--text);
      font-size: 0.86rem;
      font-weight: 760;
    }

    .stage {
      position: relative;
      display: grid;
      grid-template-rows: auto 1fr auto;
      min-width: 0;
      min-height: 0;
      background: transparent;
      color: var(--text);
    }

    .stage-bar {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 18px;
      align-items: center;
      min-height: 62px;
      padding: 20px 32px 14px 80px;
      border-bottom: 1px solid var(--line);
      background: rgba(0, 0, 0, 0.28);
    }

    .image-meta {
      display: flex;
      min-width: 0;
      flex-wrap: wrap;
      gap: 9px 14px;
      color: var(--muted);
      font-size: 0.78rem;
      font-weight: 800;
      letter-spacing: 0.08em;
      text-transform: uppercase;
    }

    .image-meta strong {
      color: var(--text);
    }

    .status {
      color: var(--accent);
      font-size: 0.78rem;
      font-weight: 800;
      letter-spacing: 0.1em;
      text-align: right;
      text-transform: uppercase;
      white-space: nowrap;
    }

    .drop-zone {
      position: relative;
      display: grid;
      min-width: 0;
      min-height: 0;
      place-items: center;
      padding: 28px;
      outline: 0;
    }

    .drop-zone.is-dragging::after {
      content: "Drop image";
      position: absolute;
      inset: 28px;
      display: grid;
      place-items: center;
      border: 2px dashed var(--accent);
      border-radius: 5px;
      background: rgba(0, 0, 0, 0.78);
      color: var(--accent);
      font-size: 0.95rem;
      font-weight: 800;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      z-index: 4;
    }

    .canvas-frame {
      display: grid;
      width: 100%;
      height: 100%;
      min-width: 0;
      min-height: 0;
      place-items: center;
      perspective: 100vw;
    }

    canvas {
      display: none;
      width: auto;
      height: auto;
      max-width: 100%;
      max-height: calc(100vh - 156px);
      border: 1px solid var(--line);
      border-radius: 5px;
      background: #0d0c0b;
      box-shadow: 0 20px 50px rgba(0, 0, 0, 0.62);
      transform: rotateY(-1.2deg) rotateX(0.7deg);
      transform-style: preserve-3d;
    }

    .drop-zone.has-image canvas {
      display: block;
    }

    .empty-state {
      display: grid;
      width: min(520px, 100%);
      min-height: 240px;
      place-items: center;
      border: 1px solid var(--line);
      border-radius: 5px;
      padding: 32px;
      background: rgba(17, 17, 17, 0.86);
      box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
      color: var(--muted);
      font-size: 0.86rem;
      font-weight: 800;
      letter-spacing: 0.12em;
      line-height: 1.5;
      text-align: center;
      text-transform: uppercase;
      transform: rotateY(-1.2deg) rotateX(0.7deg);
    }

    .empty-state strong {
      display: block;
      margin-bottom: 8px;
      color: var(--accent);
      font-size: 1rem;
    }

    .drop-zone.has-image .empty-state {
      display: none;
    }

    .fallback {
      display: none;
      width: min(540px, 100%);
      border: 1px solid var(--line);
      border-radius: 5px;
      padding: 28px;
      background: rgba(17, 17, 17, 0.86);
      color: var(--text);
      font-size: 0.95rem;
      font-weight: 760;
      line-height: 1.45;
      text-align: center;
    }

    .stage-foot {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 18px;
      align-items: center;
      min-height: 56px;
      padding: 11px 32px;
      border-top: 1px solid var(--line);
      background: rgba(0, 0, 0, 0.28);
      color: var(--muted);
      font-size: 0.72rem;
      font-weight: 800;
      letter-spacing: 0.1em;
      text-transform: uppercase;
    }

    .stage-foot a {
      color: inherit;
      text-decoration: none;
    }

    .stage-foot a:hover {
      color: var(--accent);
      text-decoration: underline;
    }

    @media (max-width: 1020px) {
      body {
        overflow: auto;
      }

      .app {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100vh;
      }

      .sidebar {
        height: auto;
        overflow: visible;
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.12);
      }

      .controls {
        grid-template-columns: 1fr 1fr;
        overflow: visible;
      }

      .stage {
        min-height: 620px;
      }

      .stage-bar {
        padding-left: 72px;
      }

      canvas {
        max-height: 60vh;
      }
    }

    @media (max-width: 680px) {
      .sidebar > .sidebar-head:first-child {
        padding: 66px 16px 16px;
      }

      footer.sidebar-head {
        padding: 16px;
      }

      .controls {
        grid-template-columns: 1fr;
        padding: 16px;
      }

      .title-row,
      .stage-bar,
      .stage-foot {
        grid-template-columns: 1fr;
      }

      h1 {
        font-size: 1.42rem;
      }

      .shader-badge,
      .status {
        justify-self: start;
      }

      .stage-bar {
        padding: 16px;
      }

      .drop-zone {
        padding: 16px;
      }

      .stage {
        min-height: 560px;
      }

      canvas {
        max-height: 54vh;
      }
    }
