/*
  Copyright 2026 Wenhao Yang

  Author: Wenhao Yang
  Contributor: Wenhao Yang

  Pico-Eurorack Bootloader Apps client styles.
*/

    @font-face {
      font-family: "Jost";
      src: url("./fonts/Jost-400-Book.ttf") format("truetype");
      font-weight: 400;
      font-style: normal;
      font-display: swap;
    }

    @font-face {
      font-family: "Jost";
      src: url("./fonts/Jost-500-Medium.ttf") format("truetype");
      font-weight: 500;
      font-style: normal;
      font-display: swap;
    }

    @font-face {
      font-family: "Jost";
      src: url("./fonts/Jost-700-Bold.ttf") format("truetype");
      font-weight: 700;
      font-style: normal;
      font-display: swap;
    }

    :root {
      --bg: #f5f5f7;
      --surface: rgba(255, 255, 255, 0.84);
      --surface-solid: #ffffff;
      --surface-soft: rgba(250, 250, 252, 0.88);
      --ink: #1d1d1f;
      --muted: #6e6e73;
      --line: rgba(60, 60, 67, 0.16);
      --line-strong: rgba(60, 60, 67, 0.28);
      --accent: #5f6368;
      --accent-strong: #2f3134;
      --accent-soft: rgba(95, 99, 104, 0.1);
      --danger: #d70015;
      --shadow: 0 18px 48px rgba(0, 0, 0, 0.08);
      --radius: 8px;
      --column-height: clamp(520px, calc(100vh - 196px), 650px);
      font-family: "Jost", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    }

    * {
      box-sizing: border-box;
    }

    body {
      margin: 0;
      min-height: 100vh;
      color: var(--ink);
      background:
        linear-gradient(90deg, rgba(60, 60, 67, 0.07) 1px, transparent 1px),
        linear-gradient(0deg, rgba(60, 60, 67, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(60, 60, 67, 0.12) 1px, transparent 1px),
        linear-gradient(0deg, rgba(60, 60, 67, 0.12) 1px, transparent 1px),
        linear-gradient(180deg, #fbfbfd 0%, #f5f5f7 56%, #eceef2 100%),
        var(--bg);
      background-size: 24px 24px, 24px 24px, 120px 120px, 120px 120px, auto, auto;
      letter-spacing: 0;
      -webkit-font-smoothing: antialiased;
      text-rendering: optimizeLegibility;
    }

    button,
    input {
      font: inherit;
    }

    button {
      cursor: pointer;
      color: inherit;
    }

    .app {
      min-height: 100vh;
    }

    .app.generating .workspace {
      filter: saturate(0.62) opacity(0.42);
      pointer-events: none;
      user-select: none;
    }

    .build-overlay {
      position: fixed;
      inset: 0;
      z-index: 100;
      display: none;
      place-items: center;
      background: rgba(247, 248, 250, 0.72);
      -webkit-backdrop-filter: blur(3px);
      backdrop-filter: blur(3px);
    }

    .app.generating .build-overlay {
      display: grid;
    }

    .site-footer {
      position: fixed;
      left: 0;
      right: 0;
      bottom: 0;
      z-index: 8;
      display: grid;
      place-items: center;
      gap: 6px;
      padding: 18px 24px 24px;
      border-top: 1px solid rgba(60, 60, 67, 0.12);
      background: #ffffff;
      color: var(--muted);
      font-size: 15px;
      line-height: 1.35;
      text-align: center;
      opacity: var(--footer-progress, 0);
      pointer-events: none;
      transform: translateY(calc((1 - var(--footer-progress, 0)) * 100%));
      transition: opacity 0.08s linear, transform 0.08s linear;
      will-change: opacity, transform;
    }

    .footer-help {
      position: absolute;
      right: 18px;
      bottom: 16px;
      pointer-events: auto;
    }

    .footer-help-button {
      width: 30px;
      height: 30px;
      border: 1px solid rgba(60, 60, 67, 0.18);
      border-radius: 50%;
      display: grid;
      place-items: center;
      background: #ffffff;
      color: var(--accent-strong);
      font-size: 14px;
      font-weight: 700;
      line-height: 1;
      box-shadow: 0 8px 22px rgba(60, 60, 67, 0.12);
      transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
    }

    .footer-help-button:hover,
    .footer-help-button:focus-visible {
      border-color: rgba(60, 60, 67, 0.34);
      box-shadow: 0 14px 34px rgba(60, 60, 67, 0.18);
      transform: translateY(-1px);
      outline: none;
    }

    .footer-help-popover {
      position: absolute;
      right: 0;
      bottom: 40px;
      width: min(360px, calc(100vw - 36px));
      padding: 14px 16px 15px;
      border: 1px solid rgba(60, 60, 67, 0.14);
      border-radius: 14px;
      background: #ffffff;
      color: #30353b;
      box-shadow: 0 20px 48px rgba(0, 0, 0, 0.16);
      text-align: left;
      opacity: 0;
      pointer-events: none;
      transform: translateY(6px) scale(0.98);
      transform-origin: bottom right;
      transition: opacity 0.18s ease, transform 0.18s ease;
    }

    .footer-help:hover .footer-help-popover,
    .footer-help:focus-within .footer-help-popover {
      opacity: 1;
      pointer-events: auto;
      transform: translateY(0) scale(1);
    }

    .footer-help-popover strong {
      display: block;
      margin-bottom: 9px;
      color: var(--ink);
      font-size: 14px;
      line-height: 1.25;
    }

    .footer-help-popover ol {
      margin: 0;
      padding-left: 18px;
      display: grid;
      gap: 6px;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.38;
    }

    .footer-reveal-space {
      height: 118px;
    }

    .site-footer img {
      display: block;
      width: min(80px, 42vw);
      height: auto;
      object-fit: contain;
    }

    .build-progress {
      width: min(520px, calc(100vw - 40px));
      display: grid;
      gap: 12px;
    }

    .build-progress-head {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      gap: 16px;
      color: var(--ink);
      font-weight: 700;
    }

    .build-progress-head span {
      color: var(--muted);
      font-size: 13px;
      font-weight: 500;
    }

    .build-progress-row {
      display: grid;
      grid-template-columns: minmax(0, 1fr) 32px;
      gap: 12px;
      align-items: center;
    }

    .build-progress-track {
      height: 12px;
      overflow: hidden;
      border: 1px solid rgba(60, 60, 67, 0.16);
      border-radius: 999px;
      background: rgba(118, 118, 128, 0.16);
    }

    .build-progress-fill {
      width: 0%;
      height: 100%;
      border-radius: inherit;
      background: #000000;
      transition: width 0.18s ease;
    }

    .build-cancel {
      width: 32px;
      height: 32px;
      border: 1px solid rgba(60, 60, 67, 0.16);
      border-radius: 50%;
      display: grid;
      place-items: center;
      background: rgba(255, 255, 255, 0.86);
      color: var(--ink);
      font-size: 20px;
      line-height: 1;
      cursor: pointer;
      transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
    }

    .build-cancel:hover,
    .build-cancel:focus-visible {
      border-color: rgba(215, 0, 21, 0.28);
      background: #fff1f2;
      color: var(--danger);
      outline: none;
    }

    .workspace {
      min-height: 100vh;
      display: grid;
      grid-template-rows: 86px auto 1fr;
      max-width: 1680px;
      margin: 0 auto;
    }

    .topbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      padding: 0 28px;
      border-bottom: 1px solid rgba(60, 60, 67, 0.12);
      background: #ffffff;
      position: sticky;
      top: 0;
      z-index: 10;
      box-shadow: 0 1px 0 rgba(255, 255, 255, 0.68);
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 14px;
      min-width: 0;
    }

    .mark {
      width: 140px;
      height: 54px;
      border-radius: 10px;
      object-fit: cover;
      flex: none;
    }

    .brand h1 {
      margin: 0;
      font-size: 32px;
      white-space: nowrap;
      font-weight: 700;
      line-height: 1.12;
    }

    .brand span {
      color: var(--muted);
      font-size: 13px;
      display: block;
      margin-top: 3px;
    }

    .top-actions {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .status-chip {
      min-width: 92px;
      color: var(--muted);
      font-size: 12px;
      text-align: right;
      white-space: nowrap;
    }

    .status-chip.error {
      color: var(--danger);
    }

    .generate-button {
      border: 0;
      border-radius: 999px;
      min-height: 36px;
      padding: 0 18px;
      background: linear-gradient(180deg, #979797 0%, var(--accent) 100%);
      color: #ffffff;
      font-weight: 500;
      box-shadow: 0 8px 20px rgba(60, 60, 67, 0.22);
      transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease, background 0.18s ease;
    }

    .generate-button.ready {
      background: linear-gradient(180deg, #42d27a 0%, #168f45 100%);
      box-shadow: 0 8px 20px rgba(22, 143, 69, 0.24);
    }

    .generate-button.blocked {
      background: linear-gradient(180deg, #b8bcc2 0%, #7f858d 100%);
      box-shadow: none;
    }

    .generate-button:disabled {
      cursor: not-allowed;
      opacity: 0.68;
      transform: none;
      box-shadow: none;
    }

    .generate-button:not(:disabled):hover,
    .generate-button:not(:disabled):focus-visible {
      transform: translateY(-1px);
      box-shadow: 0 14px 28px rgba(60, 60, 67, 0.28);
      filter: saturate(1.08);
      outline: none;
    }

    .generate-button.ready:not(:disabled):hover,
    .generate-button.ready:not(:disabled):focus-visible {
      box-shadow: 0 14px 28px rgba(22, 143, 69, 0.3);
    }

    .slot-bar {
      position: relative;
      z-index: 1;
      display: grid;
      grid-template-columns: auto minmax(0, 1fr) auto;
      grid-template-rows: auto auto;
      gap: 14px;
      align-items: center;
      margin: 16px 24px 0;
      padding: 14px;
      border: 1px solid rgba(60, 60, 67, 0.12);
      border-radius: 14px;
      background: rgba(255, 255, 255, 0.66);
      -webkit-backdrop-filter: saturate(180%) blur(22px);
      backdrop-filter: saturate(180%) blur(22px);
      box-shadow: var(--shadow);
    }

    .slot-bar h2 {
      grid-column: 1;
      grid-row: 1;
      margin: 0;
      font-size: 13px;
      color: var(--muted);
      letter-spacing: 0;
      text-transform: uppercase;
      white-space: nowrap;
    }

    .slot-help {
      position: relative;
      grid-column: 1;
      grid-row: 2;
      align-self: end;
      justify-self: start;
      z-index: 3;
    }

    .slot-help-button {
      width: 28px;
      height: 28px;
      border: 1px solid rgba(60, 60, 67, 0.18);
      border-radius: 50%;
      display: grid;
      place-items: center;
      background: #ffffff;
      color: var(--accent-strong);
      font-size: 13px;
      font-weight: 700;
      line-height: 1;
      box-shadow: 0 8px 20px rgba(60, 60, 67, 0.1);
      transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
    }

    .slot-help-button:hover,
    .slot-help-button:focus-visible {
      border-color: rgba(60, 60, 67, 0.34);
      box-shadow: 0 14px 30px rgba(60, 60, 67, 0.16);
      transform: translateY(-1px);
      outline: none;
    }

    .slot-help-popover {
      position: fixed;
      inset: 0;
      z-index: 10000;
      display: grid;
      place-items: center;
      padding: 24px;
      background: rgba(247, 248, 250, 0.78);
      -webkit-backdrop-filter: blur(10px);
      backdrop-filter: blur(10px);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.18s ease;
    }

    .slot-help-popover.open {
      opacity: 1;
      pointer-events: none;
    }

    .slot-help-card {
      width: min(480px, 100%);
      padding: 20px 22px 22px;
      border: 1px solid rgba(60, 60, 67, 0.14);
      border-radius: 16px;
      background: #ffffff;
      color: #30353b;
      box-shadow: 0 28px 70px rgba(0, 0, 0, 0.18);
      text-align: left;
      transform: translateY(10px) scale(0.98);
      transition: transform 0.18s ease;
    }

    .slot-help-popover.open .slot-help-card {
      transform: translateY(0) scale(1);
    }

    .slot-help-card strong {
      display: block;
      margin-bottom: 12px;
      color: var(--ink);
      font-size: 22px;
      line-height: 1.25;
    }

    .slot-help-card ol {
      margin: 0;
      padding-left: 20px;
      display: grid;
      gap: 9px;
      color: var(--muted);
      font-size: 17px;
      line-height: 1.5;
    }

    .device-switch,
    .page-tabs {
      position: relative;
      display: flex;
      border: 1px solid rgba(60, 60, 67, 0.14);
      border-radius: 999px;
      overflow: hidden;
      background: rgba(118, 118, 128, 0.12);
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
      padding: 3px;
      --slider-x: 3px;
      --slider-width: 0px;
    }

    .device-switch::before,
    .page-tabs::before {
      content: "";
      position: absolute;
      top: 3px;
      left: 0;
      width: var(--slider-width);
      height: calc(100% - 6px);
      border-radius: 999px;
      background: var(--surface-solid);
      box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
      transform: translateX(var(--slider-x));
      transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), width 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
      pointer-events: none;
    }

    .device-switch button,
    .page-tabs button {
      position: relative;
      z-index: 1;
      flex: 0 0 auto;
      border: 0;
      background: transparent;
      min-height: 32px;
      padding: 0 15px;
      border-radius: 999px;
      color: var(--muted);
      font-weight: 500;
      transition: color 0.18s ease;
    }

    .device-switch button.active,
    .page-tabs button.active {
      color: var(--ink);
    }

    .page-tabs {
      margin-top: 14px;
      max-width: 100%;
      overflow-x: auto;
      overflow-y: hidden;
      scrollbar-width: none;
      scroll-behavior: smooth;
      white-space: nowrap;
    }

    .page-tabs::-webkit-scrollbar {
      display: none;
    }

    .main {
      display: grid;
      grid-template-columns: minmax(340px, 1fr) minmax(112px, 160px) minmax(340px, 1fr);
      gap: 20px;
      padding: 20px 24px 28px;
      align-items: stretch;
    }

    .panel {
      background: var(--surface);
      border: 1px solid rgba(60, 60, 67, 0.12);
      border-radius: 14px;
      box-shadow: var(--shadow);
      -webkit-backdrop-filter: saturate(180%) blur(22px);
      backdrop-filter: saturate(180%) blur(22px);
      height: var(--column-height);
      min-height: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    .details {
      overflow: visible;
    }

    .details .panel-body {
      overflow: visible;
    }

    .panel-head {
      padding: 15px 16px 13px;
      border-bottom: 1px solid rgba(60, 60, 67, 0.12);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      background: rgba(255, 255, 255, 0.48);
    }

    .panel-head h2 {
      margin: 0;
      font-size: 14px;
      letter-spacing: 0;
      text-transform: uppercase;
      font-weight: 700;
    }

    .panel-body {
      padding: 16px;
      flex: 1;
      min-height: 0;
      overflow: auto;
      scrollbar-width: thin;
      scrollbar-color: var(--line-strong) transparent;
    }

    .catalog-search {
      width: 100%;
      border: 1px solid rgba(60, 60, 67, 0.12);
      border-radius: 999px;
      min-height: 40px;
      padding: 0 15px;
      margin-bottom: 14px;
      background: rgba(118, 118, 128, 0.1);
      outline: none;
      transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    }

    .catalog-search:focus {
      border-color: rgba(95, 99, 104, 0.48);
      background: var(--surface-solid);
      box-shadow: 0 0 0 4px rgba(95, 99, 104, 0.12);
    }

    .app-list {
      display: grid;
      gap: 8px;
      padding-right: 4px;
    }

    .app-card-wrap {
      position: relative;
      display: grid;
    }

    .app-card {
      position: relative;
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 4px 10px;
      border: 1px solid rgba(60, 60, 67, 0.12);
      border-radius: 12px;
      background: rgba(255, 255, 255, 0.7);
      padding: 11px 40px 11px 12px;
      text-align: left;
      user-select: none;
      will-change: transform;
      transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease, background 0.18s ease;
    }

    .app-card-wrap.has-sample-settings .app-card {
      padding-right: 90px;
    }

    .app-card:hover {
      border-color: rgba(95, 99, 104, 0.24);
      box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
      transform: translateY(-1px);
      background: var(--surface-solid);
    }

    .app-card.active {
      border-color: rgba(95, 99, 104, 0.38);
      background: linear-gradient(180deg, #ffffff 0%, rgba(95, 99, 104, 0.07) 100%);
      box-shadow: inset 3px 0 0 var(--accent), 0 12px 28px rgba(60, 60, 67, 0.12);
    }

    .app-card[draggable="true"] {
      cursor: grab;
    }

    .app-card[draggable="true"]:active {
      cursor: grabbing;
    }

    .app-card.dragging {
      opacity: 0.56;
      transform: scale(0.99);
    }

    .app-card strong {
      font-size: 16px;
      line-height: 1.18;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .app-card span {
      color: var(--muted);
      font-size: 13px;
      line-height: 1.48;
    }

    .app-card::after {
      content: "";
      position: absolute;
      top: 13px;
      right: 12px;
      width: 18px;
      height: 18px;
      border-radius: 6px;
      background:
        radial-gradient(circle, var(--line-strong) 1.4px, transparent 1.6px) 2px 2px / 7px 7px;
    }

    .app-card.active::after {
      background:
        radial-gradient(circle, var(--accent) 1.4px, transparent 1.6px) 2px 2px / 7px 7px;
    }

    .sample-settings {
      position: absolute;
      top: 9px;
      right: 40px;
      z-index: 2;
      min-height: 26px;
      border: 1px solid rgba(60, 60, 67, 0.14);
      border-radius: 999px;
      padding: 0 9px;
      background: rgba(255, 255, 255, 0.86);
      color: var(--accent-strong);
      font-size: 12px;
      font-weight: 500;
      transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
    }

    .sample-settings:hover,
    .sample-settings:focus-visible {
      border-color: rgba(95, 99, 104, 0.38);
      background: #ffffff;
      transform: translateY(-1px);
      outline: none;
    }

    .app-card.in-slot::after {
      content: "\2713";
      display: grid;
      place-items: center;
      border: 1px solid rgba(95, 99, 104, 0.42);
      border-radius: 50%;
      background: var(--surface-solid);
      color: var(--accent-strong);
      font-size: 12px;
      font-weight: 700;
      line-height: 1;
    }

    .empty-state {
      border: 1px dashed var(--line-strong);
      border-radius: 12px;
      padding: 18px 14px;
      color: var(--muted);
      background: var(--surface-soft);
      text-align: center;
      font-size: 13px;
    }

    .sample-modal {
      position: fixed;
      inset: 0;
      z-index: 80;
      display: none;
      place-items: center;
      padding: 24px;
      background: rgba(245, 245, 247, 0.78);
      -webkit-backdrop-filter: blur(8px);
      backdrop-filter: blur(8px);
    }

    .sample-modal.open {
      display: grid;
    }

    .sample-dialog {
      width: min(760px, 100%);
      max-height: min(760px, calc(100vh - 48px));
      display: grid;
      grid-template-rows: auto minmax(0, 1fr) auto;
      overflow: hidden;
      border: 1px solid rgba(60, 60, 67, 0.14);
      border-radius: 14px;
      background: #ffffff;
      box-shadow: 0 28px 70px rgba(0, 0, 0, 0.16);
    }

    .sample-dialog-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      padding: 18px 20px;
      border-bottom: 1px solid rgba(60, 60, 67, 0.12);
    }

    .sample-dialog-head h2 {
      margin: 0;
      font-size: 22px;
      line-height: 1.15;
    }

    .sample-dialog-head p {
      margin: 4px 0 0;
      color: var(--muted);
      font-size: 13px;
    }

    .sample-close {
      width: 34px;
      height: 34px;
      border: 1px solid rgba(60, 60, 67, 0.16);
      border-radius: 50%;
      background: #ffffff;
      color: var(--ink);
      font-size: 22px;
      line-height: 1;
    }

    .sample-uploader {
      display: grid;
      grid-template-columns: minmax(150px, 1fr) minmax(180px, 1.4fr);
      gap: 10px;
      padding: 16px 20px;
      border-top: 1px solid rgba(60, 60, 67, 0.12);
      background: rgba(250, 250, 252, 0.86);
    }

    .sample-uploader input {
      min-height: 38px;
      min-width: 0;
      border: 1px solid rgba(60, 60, 67, 0.14);
      border-radius: 10px;
      padding: 0 10px;
      background: #ffffff;
    }

    .sample-upload-button {
      grid-column: 1 / -1;
      min-height: 40px;
      border: 0;
      border-radius: 999px;
      padding: 0 16px;
      background: #1d1d1f;
      color: #ffffff;
      font-weight: 500;
    }

    .sample-upload-button:disabled {
      opacity: 0.48;
      cursor: not-allowed;
    }

    .sample-content {
      min-height: 0;
      overflow: auto;
      padding: 18px 20px 20px;
    }

    .sample-status {
      min-height: 20px;
      margin-bottom: 12px;
      color: var(--muted);
      font-size: 13px;
    }

    .sample-status.error {
      color: var(--danger);
    }

    .sample-bank-list {
      display: grid;
      gap: 10px;
    }

    .sample-bank {
      border: 1px solid rgba(60, 60, 67, 0.12);
      border-radius: 12px;
      padding: 12px;
      background: rgba(250, 250, 252, 0.78);
    }

    .sample-bank-head {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 8px;
    }

    .sample-bank-title {
      display: flex;
      align-items: baseline;
      gap: 10px;
      min-width: 0;
    }

    .sample-bank-head strong {
      font-size: 15px;
    }

    .sample-bank-head span,
    .sample-file-list {
      color: var(--muted);
      font-size: 12px;
    }

    .sample-file-list {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      line-height: 1.4;
    }

    .sample-file-pill {
      border: 1px solid rgba(60, 60, 67, 0.12);
      border-radius: 999px;
      padding: 4px 8px;
      background: #ffffff;
    }

    button.sample-file-pill:not(:disabled):hover,
    button.sample-file-pill:not(:disabled):focus-visible {
      border-color: rgba(215, 0, 21, 0.3);
      background: #fff1f3;
      color: var(--danger);
      outline: none;
    }

    button.sample-file-pill:disabled {
      cursor: default;
      opacity: 0.74;
    }

    .sample-delete-bank {
      border: 1px solid rgba(215, 0, 21, 0.18);
      border-radius: 999px;
      min-height: 26px;
      padding: 0 10px;
      background: rgba(255, 59, 48, 0.08);
      color: var(--danger);
      font-size: 12px;
      font-weight: 500;
    }

    .sample-delete-bank:hover,
    .sample-delete-bank:focus-visible {
      border-color: rgba(215, 0, 21, 0.36);
      background: #ffe7ea;
      outline: none;
    }

    .sample-delete-bank:disabled {
      cursor: default;
      opacity: 0.5;
    }

    .slots {
      display: grid;
      grid-column: 2;
      grid-row: 1;
      grid-template-columns: repeat(6, minmax(126px, 1fr));
      gap: 10px;
      min-width: 0;
    }

    .slot-usage {
      grid-column: 2;
      grid-row: 2;
      display: grid;
      grid-template-columns: minmax(180px, 1150px) auto;
      gap: 10px;
      align-items: center;
      min-width: 0;
    }

    .usage-track {
      height: 8px;
      overflow: hidden;
      border-radius: 999px;
      background: rgba(118, 118, 128, 0.16);
      border: 1px solid rgba(60, 60, 67, 0.12);
    }

    .usage-fill {
      width: 0%;
      height: 100%;
      border-radius: inherit;
      background: #000000;
      transition: width 0.18s ease;
    }

    .usage-label {
      color: var(--muted);
      font-size: 12px;
      white-space: nowrap;
    }

    .slot-actions {
      grid-column: 3;
      grid-row: 1 / span 2;
      min-width: 96px;
      display: grid;
      grid-template-rows: 1fr 1fr;
      gap: 10px;
      align-self: stretch;
    }

    .slot-trash,
    .slot-clear {
      border: 1px solid rgba(215, 0, 21, 0.16);
      border-radius: 12px;
      background: rgba(255, 59, 48, 0.08);
      color: var(--danger);
      display: grid;
      place-items: center;
      padding: 8px 10px;
      text-align: center;
      user-select: none;
      transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
    }

    .slot-trash {
      align-self: stretch;
    }

    .slot-trash-label,
    .slot-clear-all {
      font-size: 12px;
      line-height: 1.2;
      white-space: nowrap;
    }

    .slot-clear {
      cursor: pointer;
    }

    .slot-clear-all {
      border: 0;
      background: transparent;
      color: inherit;
      min-height: auto;
      padding: 0;
      font-size: 12px;
      font-weight: 500;
      cursor: pointer;
    }

    .slot-clear:hover,
    .slot-clear:focus-within,
    .slot-clear-all:hover,
    .slot-clear-all:focus-visible {
      background: #ffe7ea;
      border-color: rgba(215, 0, 21, 0.32);
      color: #b00013;
      transform: translateY(-1px);
      outline: none;
      box-shadow: 0 14px 30px rgba(215, 0, 21, 0.16), 0 0 0 4px rgba(215, 0, 21, 0.08);
    }

    .slot-trash.drag-over {
      border-color: rgba(215, 0, 21, 0.38);
      background: #ffe2e6;
      box-shadow: 0 16px 36px rgba(215, 0, 21, 0.22), 0 0 0 4px rgba(215, 0, 21, 0.12);
      transform: translateY(-1px);
    }

    .slot-empty {
      color: #98a2ad;
    }

    .slot-index.empty {
      background: #a8b1bb;
    }

    .slot-row {
      display: grid;
      grid-template-columns: 26px minmax(0, 1fr) auto 18px;
      gap: 7px;
      align-items: center;
      min-height: 42px;
      padding: 6px 9px;
      border: 1px solid rgba(60, 60, 67, 0.12);
      border-radius: 12px;
      background: rgba(255, 255, 255, 0.64);
      user-select: none;
      will-change: transform;
      transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
    }

    .slot-row strong {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .slot-row:hover {
      border-color: rgba(95, 99, 104, 0.28);
      background: rgba(255, 255, 255, 0.92);
      box-shadow: 0 10px 24px rgba(60, 60, 67, 0.1);
      transform: translateY(-1px);
    }

    .slot-row.drag-over {
      border-color: rgba(95, 99, 104, 0.38);
      background: rgba(255, 255, 255, 0.94);
      box-shadow: 0 16px 36px rgba(60, 60, 67, 0.14), 0 0 0 4px rgba(95, 99, 104, 0.1);
    }

    .app-dragging .slot-row,
    .slot-dragging .slot-row {
      border-color: rgba(60, 60, 67, 0.2);
      background: rgba(255, 255, 255, 0.76);
    }

    .slot-row.active {
      border-color: rgba(95, 99, 104, 0.42);
      background: var(--surface-solid);
      box-shadow: 0 10px 24px rgba(60, 60, 67, 0.12), 0 0 0 3px rgba(95, 99, 104, 0.08);
    }

    .slot-row.active:hover {
      border-color: rgba(95, 99, 104, 0.52);
      box-shadow: 0 14px 30px rgba(60, 60, 67, 0.14), 0 0 0 3px rgba(95, 99, 104, 0.1);
    }

    .app-dragging .slot-row.drag-over,
    .slot-dragging .slot-row.drag-over,
    .slot-row.active.drag-over {
      border-color: rgba(95, 99, 104, 0.42);
      background: rgba(255, 255, 255, 0.94);
      box-shadow: 0 16px 36px rgba(60, 60, 67, 0.14), 0 0 0 4px rgba(95, 99, 104, 0.1);
    }

    .slot-row[draggable="true"] {
      cursor: grab;
    }

    .slot-row[draggable="true"]:active {
      cursor: grabbing;
    }

    .slot-row.dragging {
      opacity: 0.56;
      transform: scale(0.99);
    }

    .slot-index {
      width: 26px;
      height: 26px;
      border-radius: 50%;
      display: grid;
      place-items: center;
      color: #fff;
      background: linear-gradient(180deg, #636366 0%, #3a3a3c 100%);
      font-weight: 700;
      font-size: 12px;
    }

    .slot-index.orange {
      background: linear-gradient(180deg, #ff9f0a 0%, #c75f00 100%);
    }

    .slot-index.yellow {
      background: linear-gradient(180deg, #ffd60a 0%, #c99a00 100%);
    }

    .slot-index.tiffany {
      background: linear-gradient(180deg, #5de4d9 0%, #0abab5 100%);
    }

    .slot-index.aqua {
      background: linear-gradient(180deg, #64d2ff 0%, #0096d6 100%);
    }

    .slot-index.blue {
      background: linear-gradient(180deg, #5e9bff 0%, #2458d3 100%);
    }

    .slot-index.violet {
      background: linear-gradient(180deg, #bf8cff 0%, #6c3ecf 100%);
    }

    .slot-size {
      color: var(--muted);
      font-size: 11px;
      white-space: nowrap;
      justify-self: end;
    }

    .drag-handle {
      width: 18px;
      height: 18px;
      border-radius: 6px;
      background:
        radial-gradient(circle, var(--line-strong) 1.4px, transparent 1.6px) 2px 2px / 7px 7px;
      opacity: 0;
      transition: opacity 0.18s ease, background 0.18s ease;
    }

    .slot-row[draggable="true"] .drag-handle {
      opacity: 1;
    }

    .slot-row.active .drag-handle {
      background:
        radial-gradient(circle, var(--accent) 1.4px, transparent 1.6px) 2px 2px / 7px 7px;
    }


    .preview {
      display: grid;
      place-items: start center;
      justify-self: center;
      background: transparent;
      border: 0;
      border-radius: 0;
      padding: 12px 8px;
      height: var(--column-height);
      min-height: 0;
      max-height: var(--column-height);
      overflow: hidden;
      box-shadow: none;
    }

    .module {
      position: relative;
      width: min(140px, 13vw);
      min-width: 90px;
      justify-self: center;
      margin-inline: auto;
      --led-color: #ff3b30;
      --led-hot: #ffd1cc;
      --led-dark: #9f1d15;
      --led-glow: rgba(255, 59, 48, 0.42);
      --led-glow-soft: rgba(255, 59, 48, 0.24);
      --led-x: 50%;
      --led-y: 20.6%;
      --focus-x: 50%;
      --focus-y: 50%;
      --focus-scale: 1;
    }

    .module-stage {
      position: relative;
      isolation: isolate;
      width: 100%;
      max-height: calc(var(--column-height) - 16px);
      transform: scale(var(--focus-scale));
      transform-origin: var(--focus-x) var(--focus-y);
      transition: transform 0.24s ease, transform-origin 0.24s ease, filter 0.24s ease;
    }

    .module img {
      position: relative;
      z-index: 1;
      width: 100%;
      max-height: calc(var(--column-height) - 16px);
      display: block;
      object-fit: contain;
      object-position: top center;
      filter: drop-shadow(0 26px 38px rgba(0, 0, 0, 0.2));
    }

    .module.focusing img {
      filter: drop-shadow(0 30px 46px rgba(0, 0, 0, 0.26));
    }

    .module-led {
      position: absolute;
      left: var(--led-x);
      top: var(--led-y);
      z-index: 3;
      width: 10.714%;
      aspect-ratio: 1;
      border-radius: 50%;
      background:
        radial-gradient(circle at center, var(--led-hot) 0 24%, var(--led-color) 58%, var(--led-dark) 100%);
      box-shadow:
        0 0 8px 3px var(--led-glow),
        0 0 22px 8px var(--led-glow-soft);
      transform: translate(-50%, -50%);
      pointer-events: none;
    }

    .selected-title {
      display: grid;
      gap: 6px;
      padding-bottom: 14px;
      border-bottom: 1px solid rgba(60, 60, 67, 0.12);
    }

    .selected-title-row {
      position: relative;
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 12px;
      align-items: start;
    }

    .selected-title h2 {
      margin: 0;
      font-size: 30px;
      line-height: 1.1;
      font-weight: 700;
    }

    .selected-title p {
      margin: 0;
      color: var(--muted);
      line-height: 1.5;
    }

    .info-button {
      position: relative;
      z-index: 4;
      width: 28px;
      height: 28px;
      border: 1px solid rgba(60, 60, 67, 0.18);
      border-radius: 50%;
      display: grid;
      place-items: center;
      background: #ffffff;
      color: var(--muted);
      box-shadow: 0 8px 22px rgba(60, 60, 67, 0.1);
      transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
    }

    .info-symbol {
      position: relative;
      display: block;
      width: 10px;
      height: 16px;
    }

    .info-symbol::before,
    .info-symbol::after {
      content: "";
      position: absolute;
      left: 50%;
      background: currentColor;
      transform: translateX(-50%);
    }

    .info-symbol::before {
      top: 1px;
      width: 3.5px;
      height: 3.5px;
      border-radius: 50%;
    }

    .info-symbol::after {
      top: 6px;
      width: 3px;
      height: 9px;
      border-radius: 999px;
    }

    .info-button:hover,
    .info-button:focus-visible {
      border-color: rgba(60, 60, 67, 0.34);
      color: var(--accent-strong);
      box-shadow: 0 14px 34px rgba(60, 60, 67, 0.16);
      transform: translateY(-1px);
      outline: none;
    }

    .info-popover {
      position: absolute;
      top: 36px;
      right: 0;
      width: min(280px, calc(100vw - 48px));
      padding: 11px 12px;
      border: 1px solid rgba(60, 60, 67, 0.14);
      border-radius: 12px;
      background: #ffffff;
      color: #30353b;
      font-size: 12px;
      font-weight: 400;
      line-height: 1.45;
      text-align: left;
      box-shadow: 0 18px 42px rgba(0, 0, 0, 0.14);
      opacity: 0;
      pointer-events: none;
      transform: translateY(-6px) scale(0.98);
      transform-origin: top right;
      transition: opacity 0.18s ease, transform 0.18s ease;
      white-space: pre-line;
    }

    .info-button:hover .info-popover,
    .info-button:focus-visible .info-popover {
      opacity: 1;
      transform: translateY(0) scale(1);
    }

    .chip {
      border: 1px solid rgba(60, 60, 67, 0.12);
      border-radius: 999px;
      padding: 5px 9px;
      font-size: 12px;
      color: var(--muted);
      background: rgba(255, 255, 255, 0.62);
    }

    .chip.live {
      color: var(--accent);
      border-color: rgba(95, 99, 104, 0.34);
      background: var(--accent-soft);
    }

    .function-list {
      display: grid;
      gap: 8px;
      margin-top: 16px;
    }

    .function-row {
      position: relative;
      z-index: 2;
      display: grid;
      grid-template-columns: 86px minmax(0, 1fr);
      gap: 12px;
      padding: 11px 12px;
      border: 1px solid rgba(60, 60, 67, 0.12);
      border-radius: 12px;
      background: rgba(255, 255, 255, 0.64);
      align-items: start;
      overflow: visible;
      transition: transform 0.18s ease;
    }

    .function-row:hover {
      transform: scale(1.018);
    }

    .function-row::before {
      content: "\2190";
      position: absolute;
      top: -1px;
      left: 0;
      display: grid;
      place-items: center;
      width: 40px;
      height: calc(100%);
      border: 1px solid rgba(95, 99, 104, 0.82);
      border-radius: 10px 0 0 10px;
      background: linear-gradient(180deg, #7b7f85 0%, var(--accent) 100%);
      color: #ffffff;
      font-size: 18px;
      line-height: 1;
      opacity: 0;
      z-index: -1;
      transform: translate(0, 0);
      pointer-events: none;
      transition: opacity 0.18s ease, transform 0.22s ease, box-shadow 0.18s ease;
    }

    .function-row:hover::before {
      opacity: 1;
      transform: translate(-30px, 0);
    }

    .function-row b {
      width: fit-content;
      max-width: 100%;
      border: 1px solid rgba(60, 60, 67, 0.12);
      border-radius: 999px;
      padding: 3px 7px;
      margin-left: 10px;
      background: rgba(255, 255, 255, 0.86);
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: 0;
      color: #3a3a3c;
    }

    .function-row span {
      color: #30353b;
      line-height: 1.45;
      font-size: 14px;
    }

    @media (max-width: 1180px) {
      .slot-bar {
        grid-template-columns: auto minmax(0, 1fr) auto;
      }

      .slot-usage {
        grid-column: 2;
      }

      .slot-actions {
        grid-column: 3;
        grid-row: 1 / span 2;
      }
    }

    @media (max-width: 900px) {
      .main {
        grid-template-columns: minmax(280px, 1fr) minmax(96px, 126px);
      }

      .details {
        grid-column: 1 / -1;
      }
    }

    @media (max-width: 820px) {
      .main,
      .slot-bar {
        width: 100%;
      }

      .workspace {
        grid-template-rows: auto auto 1fr;
      }

      .slot-bar {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        margin: 12px;
        padding: 12px;
      }

      .slot-bar h2 {
        grid-column: 1;
        grid-row: auto;
      }

      .slot-usage {
        grid-column: 1;
        grid-row: auto;
      }

      .slot-actions {
        grid-column: 1;
        grid-row: auto;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto;
      }

      .slot-trash {
        min-height: 48px;
      }

      .slots {
        grid-column: 1;
        grid-row: auto;
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .topbar {
        height: auto;
        min-height: 64px;
        align-items: flex-start;
        padding: 12px;
        flex-direction: column;
      }

      .brand h1 {
        font-size: 28px;
      }

      .top-actions {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
      }

      .status-chip {
        order: 3;
        width: 100%;
        text-align: left;
      }

      .generate-button {
        flex: none;
      }

      .device-switch {
        width: 100%;
      }

      .device-switch button {
        flex: 1;
      }

      .main {
        grid-template-columns: 1fr;
        padding: 14px 12px 18px;
      }

      .module {
        width: min(132px, 38vw);
        margin: 0 auto;
      }

      .panel,
      .preview {
        height: auto;
        min-height: auto;
        max-height: none;
      }

      .module img {
        max-height: 320px;
      }

      .function-row {
        grid-template-columns: 76px minmax(0, 1fr);
      }
    }

    @media (max-width: 520px) {
      .brand h1 {
        font-size: 24px;
        white-space: normal;
      }

      .slot-usage {
        grid-template-columns: 1fr;
        gap: 6px;
      }

      .usage-label {
        white-space: normal;
      }

      .slots {
        grid-template-columns: 1fr;
      }

      .slot-row {
        grid-template-columns: 28px minmax(0, 1fr) auto 18px;
      }

      .selected-title h2 {
        font-size: 24px;
      }
    }
