*,
    *::before,
    *::after {
      box-sizing: border-box;
    }

    

    html {
      scroll-behavior: smooth;
      scrollbar-width: thin;
      scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
    }

    * {
      scrollbar-width: thin;
      scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
    }

    *::-webkit-scrollbar {
      width: 10px;
      height: 10px;
    }

    *::-webkit-scrollbar-track {
      background: var(--scrollbar-track);
    }

    *::-webkit-scrollbar-thumb {
      min-height: 42px;
      border: 2px solid transparent;
      border-radius: var(--radius-pill);
      background: var(--scrollbar-thumb);
      background-clip: padding-box;
    }

    *::-webkit-scrollbar-thumb:hover {
      background: var(--scrollbar-thumb-hover);
      background-clip: padding-box;
    }

    *::-webkit-scrollbar-corner {
      background: var(--scrollbar-corner);
    }

    body {
      margin: 0;
      min-height: 100vh;
      font-family: var(--font-body);
      color: var(--ink);
      background: var(--bg);
    }

    button,
    input,
    select,
    textarea {
      font: inherit;
    }

    button {
      color: inherit;
    }

    .page {
      width: min(1440px, 100%);
      margin: 0 auto;
      padding: 24px;
    }

    .topbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 18px;
      margin-bottom: 18px;
    }

    .brand {
      min-width: 0;
    }

    .brand h1 {
      margin: 0;
      font-size: clamp(28px, 4vw, 52px);
      line-height: 1;
      letter-spacing: 0;
      color: var(--ink);
    }

    .brand p {
      margin: 10px 0 0;
      color: var(--ink-secondary);
      font-size: 14px;
    }

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

    .workspace {
      display: grid;
      gap: 18px;
    }

    .main-grid {
      position: relative;
      z-index: 2;
      display: grid;
      grid-template-columns: minmax(420px, 0.82fr) minmax(0, 1.18fr);
      gap: 18px;
      align-items: stretch;
      min-height: clamp(420px, calc(100vh - 250px), 760px);
    }

    .command-field {
      display: flex;
      flex-direction: column;
      gap: 5px;
      min-width: 0;
    }

    .command-field label {
      margin: 0;
      font-size: 11px;
      letter-spacing: 0.04em;
    }

    .field-label-row {
      position: relative;
      display: flex;
      align-items: center;
      gap: 6px;
      min-width: 0;
    }

    .help-icon-btn {
      display: inline-grid;
      place-items: center;
      width: 15px;
      height: 15px;
      border: 1px solid var(--border);
      border-radius: 50%;
      background: transparent;
      color: var(--ink-tertiary);
      font-size: 10px;
      line-height: 1;
      padding: 0;
      cursor: pointer;
      transition: all 0.15s ease;
    }

    .help-icon-btn:hover,
    .help-icon-btn:focus-visible,
    .help-icon-btn[aria-expanded="true"] {
      color: var(--accent);
      border-color: var(--accent);
      background: var(--accent-subtle);
      outline: none;
    }

    .pricing-popover {
      position: absolute;
      z-index: 20;
      top: calc(100% + 8px);
      left: 0;
      width: min(330px, calc(100vw - 36px));
      padding: 12px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--surface-elevated);
      box-shadow: var(--shadow-lg);
      color: var(--ink);
      font-size: 12px;
      line-height: 1.45;
    }

    .pricing-popover[hidden] {
      display: none;
    }

    .pricing-section + .pricing-section {
      margin-top: 10px;
      padding-top: 10px;
      border-top: 1px solid var(--border);
    }

    .pricing-title {
      margin-bottom: 6px;
      color: var(--ink-secondary);
      font-weight: 700;
    }

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

    .pricing-row span {
      overflow-wrap: anywhere;
    }

    .pricing-row strong {
      font-weight: 700;
      white-space: nowrap;
    }

    .pricing-note {
      margin: 10px 0 6px;
      color: var(--ink-secondary);
    }

    .pricing-link {
      color: var(--accent);
      text-decoration: none;
      overflow-wrap: anywhere;
    }

    .pricing-link:hover {
      text-decoration: underline;
    }

    .command-field select,
    .command-field input {
      height: 38px;
    }

    .command-field--model {
      width: 260px;
      flex: 0 0 260px;
    }

    .command-field--keys {
      width: 122px;
      flex: 0 0 122px;
      position: relative;
    }

    .command-field--concurrency {
      width: 96px;
      flex-shrink: 0;
    }

    .command-settings {
      display: grid;
      grid-template-columns: 260px 122px 96px;
      align-items: end;
      gap: 14px;
      min-width: 0;
    }

    .prompt-section-title {
      margin-bottom: 12px;
    }

    .key-selector {
      position: relative;
    }

    .key-selector-btn {
      width: 100%;
      height: 38px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      padding: 0 10px;
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      background: var(--surface-input);
      color: var(--ink);
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    }

    .key-selector-btn::after {
      content: "";
      width: 7px;
      height: 7px;
      border-right: 1.5px solid currentColor;
      border-bottom: 1.5px solid currentColor;
      transform: translateY(-2px) rotate(45deg);
      flex: 0 0 auto;
      opacity: 0.75;
    }

    .key-selector-btn:hover,
    .key-selector-btn[aria-expanded="true"] {
      border-color: var(--border-strong);
      background: var(--surface-elevated);
      box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
    }

    .key-selector-popover {
      position: absolute;
      top: calc(100% + 8px);
      left: 0;
      z-index: 40;
      width: 286px;
      max-width: min(286px, calc(100vw - 32px));
      padding: 8px;
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      background: var(--surface-elevated);
      box-shadow: var(--shadow-lg);
    }

    .key-selector-popover[hidden] {
      display: none;
    }

    .key-selector-list {
      display: grid;
      gap: 4px;
      max-height: 230px;
      overflow: auto;
      padding-right: 2px;
    }

    .key-selector-hint {
      margin: 7px 2px 2px;
      color: color-mix(in srgb, var(--ink-secondary) 72%, transparent);
      font-size: 11px;
      line-height: 1.4;
    }

    .key-selector-option {
      min-height: 34px;
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 7px 8px;
      border-radius: 8px;
      color: var(--ink);
      font-size: 13px;
      cursor: pointer;
    }

    .key-selector-option:hover {
      background: var(--surface-secondary);
    }

    .key-selector-option input {
      width: 16px;
      height: 16px;
      flex: 0 0 auto;
      accent-color: var(--accent);
    }

    .key-selector-option span {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .key-selector-empty {
      padding: 10px 8px;
      color: var(--ink-secondary);
      font-size: 13px;
      line-height: 1.45;
    }

    .key-selector-actions {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-top: 8px;
      padding-top: 8px;
      border-top: 1px solid var(--border-subtle);
    }

    .key-selector-actions button,
    .key-selector-actions a {
      border: none;
      background: transparent;
      color: var(--accent);
      font-size: 12px;
      font-weight: 700;
      text-decoration: none;
      cursor: pointer;
      padding: 4px 2px;
    }

    .key-selector-actions a {
      margin-left: auto;
    }

    .command-actions {
      display: flex;
      gap: 8px;
      align-items: center;
      flex-shrink: 0;
    }

    .start-action-slot {
      display: flex;
      flex-shrink: 0;
    }

    .mobile-start-slot {
      display: none;
    }

    .command-actions .btn {
      min-height: 38px;
    }

    .command-status {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }

    .prompt-toolbar {
      display: flex;
      align-items: end;
      justify-content: space-between;
      gap: 14px;
      flex-wrap: wrap;
      margin-bottom: 14px;
    }

    .sr-only {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border: 0;
    }

    .input-panel,
    .logs-panel {
      min-width: 0;
    }

    .logs-panel {
      position: relative;
      z-index: 1;
    }

    .results-panel {
      min-width: 0;
      display: flex;
      flex-direction: column;
      contain: size;
    }

    .results-panel>.section {
      flex: 1;
      display: flex;
      flex-direction: column;
      min-height: 0;
    }

    .panel {
      border: 1px solid var(--border);
      background: var(--panel);
      border-radius: var(--radius-md);
      box-shadow: var(--shadow);
      backdrop-filter: var(--backdrop-blur);
    }

    .section {
      padding: 18px;
    }

    .section+.section {
      border-top: 1px solid var(--border-subtle);
    }

    .section-title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 14px;
    }

    .section-title h2 {
      margin: 0;
      font-size: 14px;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: var(--accent);
    }

    .config-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 14px;
    }

    .settings-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 14px;
    }

    .field {
      min-width: 0;
    }

    .field.full {
      grid-column: 1 / -1;
    }

    label {
      display: block;
      margin-bottom: 7px;
      color: var(--ink-secondary);
      font-size: 13px;
      font-weight: 600;
    }

    input,
    select,
    textarea {
      width: 100%;
      color: var(--ink);
      background: var(--surface-input);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      outline: none;
      transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    }

    input,
    select {
      height: 42px;
      padding: 0 12px;
    }

    textarea {
      min-height: 180px;
      resize: vertical;
      padding: 12px;
      line-height: 1.55;
    }

    input:focus,
    select:focus,
    textarea:focus {
      border-color: var(--border-strong);
      box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.16);
      background: var(--surface-elevated);
    }

    input:disabled,
    select:disabled,
    textarea:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }

    select option {
      background: var(--bg);
      color: var(--ink);
    }

    .prompt-area textarea {
      min-height: 236px;
    }

    .custom-size-picker {
      position: relative;
    }

    .custom-size-suggestions {
      position: absolute;
      z-index: 20;
      left: 0;
      right: 0;
      top: calc(100% + 6px);
      max-height: 220px;
      overflow: auto;
      padding: 6px;
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      background: var(--surface-elevated);
      box-shadow: 0 18px 45px var(--shadow);
      backdrop-filter: var(--backdrop-blur);
    }

    .custom-size-suggestions[hidden] {
      display: none;
    }

    .custom-size-option {
      width: 100%;
      min-height: 38px;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 5px;
      padding: 10px 12px;
      border: 0;
      border-radius: 6px;
      background: transparent;
      color: var(--ink);
      cursor: pointer;
      text-align: left;
    }

    .custom-size-option:hover {
      background: var(--surface-primary);
    }

    .custom-size-option strong {
      font-size: 13px;
      font-weight: 700;
      line-height: 1.25;
      white-space: nowrap;
    }

    .custom-size-option span {
      display: block;
      width: 100%;
      color: var(--ink-secondary);
      font-size: 12px;
      line-height: 1.35;
      white-space: normal;
      overflow-wrap: anywhere;
    }

    .ratio-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
      gap: 8px;
      margin-top: 4px;
    }

    .ratio-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px;
      padding: 10px 4px;
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      background: var(--surface-primary);
      cursor: pointer;
      transition: all 0.18s ease;
      user-select: none;
    }

    .ratio-item:hover {
      background: var(--border-subtle);
      border-color: var(--border-strong);
    }

    .ratio-item.active {
      background: var(--accent-subtle);
      border-color: var(--accent);
      box-shadow: 0 0 0 1px var(--accent);
    }

    .ratio-visual-container {
      width: 28px;
      height: 28px;
      display: flex;
      align-items: center;
      justify-content: center;
      pointer-events: none;
    }

    .ratio-visual {
      border: 1.5px solid currentColor;
      border-radius: 2px;
      background: var(--accent-subtle);
      transition: all 0.18s ease;
    }

    .ratio-item.active .ratio-visual {
      background: var(--accent);
      border-color: var(--bg);
    }

    .ratio-label {
      font-size: 11px;
      font-weight: 600;
      color: var(--ink-secondary);
      pointer-events: none;
    }

    .ratio-item.active .ratio-label {
      color: var(--ink);
    }

    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      min-height: 40px;
      padding: 0 15px;
      border-radius: var(--radius-md);
      border: 1px solid var(--border);
      background: var(--surface-secondary);
      cursor: pointer;
      text-decoration: none;
      font-size: 14px;
      font-weight: 700;
      transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
      white-space: nowrap;
    }

    .btn:hover {
      transform: translateY(-1px);
    }
    .btn:active {
      transform: var(--btn-active-transform);
      border-color: var(--border-strong);
    }

    .btn:disabled {
      cursor: not-allowed;
      opacity: 0.5;
      transform: none;
    }

    .btn svg {
      width: 17px;
      height: 17px;
      flex: 0 0 auto;
    }

    .btn-primary {
      border-color: var(--accent-subtle);
      background: var(--accent);
      color: var(--ink-on-accent);
      box-shadow: 0 14px 35px var(--accent-glow);
    }

    .btn-blue {
      border-color: var(--border-strong);
      background: var(--accent-subtle);
      color: var(--accent);
    }

    .btn-blue:hover {
      background: var(--accent-glow);
    }

    .btn-warn {
      border-color: var(--btn-danger-border, var(--error));
      color: var(--btn-danger-text, var(--error));
      background: var(--btn-danger-bg, transparent);
    }
    
    .btn-warn:hover {
      background: var(--btn-danger-hover-bg, var(--error));
      color: var(--btn-danger-hover-text, var(--ink-on-accent));
    }

    .prompt-area textarea {
      min-height: 236px;
    }


    .icon-btn {
      width: 42px;
      height: 42px;
      padding: 0;
    }

    .dropzone {
      position: relative;
      min-height: 124px;
      display: grid;
      place-items: center;
      padding: 18px;
      border: 1px dashed var(--border-strong);
      border-radius: var(--radius-md);
      background: var(--surface-primary);
      text-align: center;
      color: var(--ink-secondary);
      cursor: pointer;
      transition: border-color 0.18s ease, background 0.18s ease;
    }

    .upload-provider {
      display: flex;
      gap: 6px;
      margin-bottom: 8px;
    }
    
    .upload-provider label {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-height: 32px;
      padding: 0 12px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--surface-primary);
      color: var(--ink-secondary);
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s ease;
      margin-bottom: 0;
    }

    .upload-provider label[hidden] {
      display: none !important;
    }
    
    .upload-provider input {
      position: absolute;
      opacity: 0;
      pointer-events: none;
    }
    
    .upload-provider label:has(input:checked) {
      background: var(--accent-subtle);
      color: var(--accent);
      border-color: var(--accent);
      box-shadow: none;
    }

    .upload-provider label:hover:not(:has(input:checked)) {
      background: var(--surface-secondary);
      border-color: var(--border-strong);
    }

    .upload-provider-hint {
      margin: 0 0 10px;
      color: var(--ink-secondary);
      font-size: 12px;
      line-height: 1.45;
    }

    .dropzone.dragging {
      border-color: var(--accent);
      background: var(--accent-subtle);
    }

    .dropzone strong {
      display: block;
      color: var(--ink);
      margin-bottom: 6px;
    }

    .upload-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-top: 12px;
      color: var(--ink-secondary);
      font-size: 13px;
    }

    .url-input-row {
      display: flex;
      gap: 10px;
      margin-bottom: 14px;
    }

    .thumbs {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
      gap: 10px;
      margin-top: 12px;
    }

    .thumb {
      display: flex;
      flex-direction: column;
      overflow: hidden;
      border-radius: var(--radius-md);
      border: 1px solid var(--border);
      background: var(--surface-primary);
    }

    .thumb-img {
      position: relative;
      aspect-ratio: 1;
      overflow: hidden;
    }

    .thumb-img img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
    }

    .thumb-img button {
      position: absolute;
      right: 5px;
      top: 5px;
      width: 26px;
      height: 26px;
      border: 0;
      border-radius: 50%;
      background: var(--surface-elevated);
      cursor: pointer;
    }

    .thumb-label {
      padding: 4px 6px;
      font-size: 10px;
      font-weight: 600;
      color: var(--ink-secondary);
      text-align: center;
      background: var(--overlay);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      line-height: 1.4;
    }

    .control-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 14px;
      flex-wrap: wrap;
    }

    .status-pill {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      min-height: 34px;
      padding: 0 12px;
      border-radius: 999px;
      border: 1px solid var(--border);
      background: var(--surface-primary);
      color: var(--ink-secondary);
      font-size: 13px;
    }

    .info-label {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      min-height: 34px;
      padding: 0 4px;
      color: var(--ink-secondary);
      font-size: 13px;
    }

    .dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: var(--ink-tertiary);
    }

    .dot.ok {
      background: var(--green);
      box-shadow: 0 0 12px var(--success);
    }

    .dot.busy {
      background: var(--amber);
      box-shadow: 0 0 12px var(--warning);
    }

    .dot.bad {
      background: var(--red);
      box-shadow: 0 0 12px var(--error);
    }

    .progress-wrap {
      --progress: 0%;
      position: relative;
      display: block;
      height: 3px;
      overflow: visible;
      border-radius: 999px;
      isolation: isolate;
    }

    .progress-track,
    .progress-bar {
      position: absolute;
      inset: 0;
      border-radius: inherit;
    }

    .progress-track {
      background: var(--surface-primary);
      box-shadow: inset 0 1px 2px var(--shadow);
    }

    .progress-bar {
      width: var(--progress);
      background: var(--accent);
      box-shadow: 0 0 8px var(--accent-glow);
      transition: width 0.28s ease;
    }

    .progress-glow {
      position: absolute;
      left: var(--progress);
      top: 50%;
      width: 10px;
      height: 5px;
      border-radius: 999px;
      background: var(--accent-glow);
      box-shadow:
        0 0 10px var(--accent-glow);
      transform: translate(-50%, -50%);
      animation: progressBreathe 1.55s ease-in-out infinite;
      pointer-events: none;
      z-index: 2;
    }

    .progress-wrap.is-zero .progress-glow {
      left: 0%;
      transform: translate(0, -50%);
    }

    .run-progress {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;
    }

    @keyframes progressBreathe {

      0%,
      100% {
        opacity: 0.68;
      }

      50% {
        opacity: 1;
      }
    }

    @media (prefers-reduced-motion: reduce) {
      .progress-glow {
        animation: none;
      }
    }

    .logs {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 12px;
    }

    .logbox {
      min-height: 250px;
      max-height: 410px;
      overflow: auto;
      padding: 12px;
      border-radius: var(--radius-md);
      background: var(--surface-code);
      border: 1px solid var(--border);
      color: var(--ink-on-code);
      font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
      font-size: 12px;
      line-height: 1.55;
      white-space: pre-wrap;
    }

    .result-browser {
      display: grid;
      grid-template-columns: 230px minmax(0, 1fr);
      gap: 14px;
      min-height: 0;
      flex: 1;
    }

    .run-list,
    .result-detail {
      min-height: 0;
      height: 100%;
      overflow: auto;
      scrollbar-gutter: stable;
    }

    .run-list {
      display: grid;
      align-content: start;
      gap: 8px;
      padding-right: 8px;
    }

    .run-date-divider {
      margin: 4px 2px 0;
      color: var(--ink-secondary);
      font-size: 11px;
      line-height: 1;
      opacity: 0.72;
    }

    .result-group {
      width: 100%;
      min-height: 74px;
      position: relative;
      overflow: hidden;
      display: grid;
      grid-template-columns: 58px minmax(0, 1fr);
      gap: 10px;
      align-items: center;
      padding: 8px 8px 11px;
      text-align: left;
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      background: var(--surface-primary);
      color: inherit;
      cursor: pointer;
    }

    .result-group.active {
      border-color: var(--accent);
      background: var(--accent-subtle);
    }

    .run-cover {
      width: 58px;
      height: 58px;
      display: grid;
      place-items: center;
      overflow: hidden;
      border-radius: var(--radius-md);
      background: var(--surface-secondary);
      color: var(--ink-secondary);
      font-size: 11px;
    }

    .run-cover img,
    .run-cover video {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
    }

    .run-card-title {
      margin: 0 0 5px;
      color: var(--ink);
      font-size: 13px;
      font-weight: 700;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .run-card-meta {
      display: grid;
      gap: 3px;
      color: var(--ink-secondary);
      font-size: 11px;
      line-height: 1.25;
    }

    .result-detail {
      min-width: 0;
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      background: var(--surface-primary);
    }

    .detail-header {
      display: grid;
      grid-template-columns: 1fr auto;
      grid-template-rows: auto auto;
      gap: 12px 16px;
      padding: 14px 16px;
      border-bottom: 1px solid var(--border-subtle);
    }

    .detail-actions {
      display: flex;
      justify-content: flex-end;
      align-items: flex-start;
    }

    .detail-actions--primary {
      grid-column: 2;
      grid-row: 1;
    }

    .detail-actions--danger {
      grid-column: 2;
      grid-row: 2;
    }

    .detail-actions .btn {
      min-height: 26px;
      padding: 0 8px;
      font-size: 13px;
    }

    .detail-title {
      margin: 0;
      font-size: 15px;
      color: var(--ink);
      line-height: 1.5;
    }

    .status-label {
      flex-shrink: 0;
    }

    .result-summary {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px;
      color: var(--ink-secondary);
      font-size: 13px;
      line-height: 1.4;
    }

    .run-log-link {
      appearance: none;
      border: 0;
      border-bottom: 1px dotted currentColor;
      padding: 0;
      background: transparent;
      color: var(--ink-secondary);
      font: inherit;
      line-height: 1.2;
      cursor: pointer;
    }

    .run-log-link:hover {
      color: var(--ink);
    }

    .btn-small {
      min-height: 32px;
      padding: 0 10px;
      font-size: 12px;
    }

    .gallery {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
      gap: 12px;
      padding: 12px;
    }

    .empty-state {
      min-height: 180px;
      display: grid;
      place-items: center;
      color: var(--ink-secondary);
      border: 1px dashed var(--border);
      border-radius: var(--radius-md);
      background: var(--surface-primary);
      text-align: center;
    }

    .empty-state.compact {
      min-height: 120px;
    }

    .logs-panel summary {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 14px 18px;
      cursor: pointer;
      color: var(--accent);
      font-size: 14px;
      font-weight: 700;
      letter-spacing: 0.06em;
      text-transform: uppercase;
    }

    .logs-panel summary::marker {
      display: none;
    }

    .image-card {
      overflow: hidden;
      border-radius: var(--radius-md);
      border: 1px solid var(--border);
      background: var(--surface-primary);
    }

    .image-card .preview {
      display: block;
      width: 100%;
      padding: 0;
      border: 0;
      background: transparent;
      cursor: zoom-in;
    }

    .image-card .video-preview {
      cursor: default;
    }

    .image-card img,
    .image-card video {
      display: block;
      width: 100%;
      aspect-ratio: 1;
      object-fit: cover;
    }

    .image-meta {
      display: grid;
      gap: 7px;
      padding: 10px;
      color: var(--ink-secondary);
      font-size: 12px;
    }

    .image-meta-main,
    .image-details {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      min-width: 0;
    }

    .image-details {
      color: var(--ink-on-code);
    }

    .image-meta-main span,
    .image-details span {
      min-width: 0;
      overflow-wrap: anywhere;
    }

    .image-meta a {
      color: var(--accent);
      text-decoration: none;
      font-weight: 700;
    }

    .notice {
      display: none;
      margin-bottom: 18px;
      padding: 12px 14px;
      border-radius: var(--radius-md);
      border: 1px solid var(--warning);
      background: var(--surface-primary);
      color: var(--warning);
      font-size: 14px;
    }

    .notice.show {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }

    .hf-storage-notice {
      color: var(--ink-secondary);
    }

    .hf-storage-notice .btn {
      flex: 0 0 auto;
      border-color: var(--border-strong);
      color: var(--ink);
      background: transparent;
    }

    .lightbox {
      position: fixed;
      inset: 0;
      z-index: 20;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 24px;
      background: var(--overlay);
    }

    .lightbox.show {
      display: flex;
    }

    .lightbox img,
    .lightbox video {
      max-width: min(100%, 1180px);
      max-height: 88vh;
      border-radius: var(--radius-md);
      box-shadow: 0 28px 80px var(--shadow-heavy);
    }

    .lightbox video {
      display: none;
      background: #000;
    }

    .lightbox button {
      position: fixed;
      right: 22px;
      top: 22px;
      border: 1px solid var(--border-strong);
      background: var(--border-subtle);
    }

    .run-log-modal-content {
      width: min(720px, calc(100vw - 32px));
      max-height: min(78vh, 720px);
      display: grid;
      grid-template-rows: auto 1fr;
      overflow: hidden;
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      background: var(--surface-primary);
      box-shadow: 0 28px 80px var(--shadow-heavy);
    }

    .run-log-modal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 14px 16px;
      border-bottom: 1px solid var(--border-subtle);
    }

    .run-log-modal-header h3 {
      min-width: 0;
      margin: 0;
      overflow: hidden;
      color: var(--ink);
      font-size: 15px;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .run-log-modal-header .btn {
      position: static;
      flex: 0 0 auto;
      border: 0;
      background: transparent;
      color: var(--ink-secondary);
    }

    .run-log-content {
      min-height: 240px;
      max-height: calc(78vh - 54px);
      margin: 0;
      overflow: auto;
      padding: 14px 16px;
      background: var(--surface-secondary);
      color: var(--ink);
      font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
      font-size: 12px;
      line-height: 1.6;
      white-space: pre-wrap;
      word-break: break-word;
    }

    @media (max-width: 980px) {
      .main-grid {
        grid-template-columns: 1fr;
        min-height: 0;
      }

      .results-panel {
        contain: none;
      }

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

      .result-browser {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 0;
      }

      .run-list {
        grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
        height: auto;
        max-height: min(360px, 55vh);
      }

      .result-detail {
        height: auto;
        max-height: none;
      }
    }

    @media (max-width: 640px) {
      html,
      body {
        width: 100%;
        overflow-x: hidden;
      }

      .page {
        padding: 10px;
      }

      .topbar {
        display: grid;
        grid-template-columns: auto auto minmax(0, 1fr) auto;
        align-items: center;
        gap: 10px 12px;
        margin-bottom: 14px;
      }

      .brand {
        grid-column: 1;
        grid-row: 1;
        display: flex;
        align-items: center;
        gap: 8px;
      }

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

      .brand p {
        display: none; /* 手机端隐藏“工作台”字样 */
      }

      .top-actions {
        display: contents;
      }

      .theme-controls {
        grid-column: 3 / 5;
        grid-row: 2;
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) 42px;
        align-items: center;
        gap: 8px !important;
        min-width: 0;
      }

      #theme-style-select {
        width: 100% !important;
        min-width: 0 !important;
        height: 42px !important;
        padding: 0 34px 0 14px;
        font-size: 13px !important;
      }

      .top-actions .btn-ghost.icon-btn,
      .top-actions .btn-blue {
        height: 42px;
        min-height: 42px;
        padding: 0 12px;
        font-size: 13px;
      }

      .top-actions .btn-blue svg,
      .top-actions .btn-ghost.icon-btn svg {
        width: 17px;
        height: 17px;
      }

      .top-actions>a.btn-ghost.icon-btn {
        grid-column: 1;
        grid-row: 2;
        width: 42px;
      }

      .top-actions>a.btn-blue {
        grid-column: 2;
        grid-row: 2;
        width: 42px;
        padding: 0;
        gap: 0;
        font-size: 0;
      }

      #theme-mode-toggle {
        width: 42px;
      }

      .command-status {
        grid-column: 2 / 5;
        grid-row: 1;
        justify-self: end;
        display: flex;
        gap: 6px;
        background: var(--surface-primary);
        padding: 5px 9px;
        border-radius: 999px;
        border: 1px solid var(--border-subtle);
      }

      .status-pill {
        background: transparent;
        border: none;
        padding: 0 4px;
        font-size: 11px;
        min-height: 24px;
        gap: 4px;
      }

      .notice.show {
        flex-direction: row;
        padding: 8px 12px;
        font-size: 12px;
        gap: 8px;
      }

      .notice.show .btn-warn {
        min-height: 28px;
        padding: 0 10px;
        font-size: 11px;
      }

      .section {
        padding: 14px;
      }

      .command-actions .btn,
      .url-input-row .btn {
        width: 100%;
      }

      .top-actions .btn {
        width: auto;
      }

      .section-title {
        flex-wrap: wrap;
      }

      .section-title>div {
        flex-wrap: wrap;
      }

      .workspace,
      .main-grid {
        gap: 12px;
      }

      .panel {
        border-radius: 12px;
      }

      .section-title {
        align-items: flex-start;
      }

      .prompt-toolbar,
      .command-actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
      }

      .command-settings {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 112px;
        width: 100%;
        gap: 10px;
      }

      .command-field--model,
      .command-field--keys,
      .command-field--concurrency {
        width: auto;
        flex: 1 1 auto;
      }

      .command-field--model {
        grid-column: 1 / -1;
      }

      .key-selector-popover {
        left: auto;
        right: 0;
      }

      .command-actions .btn-primary {
        width: 100%;
        min-height: 46px;
      }

      .mobile-start-slot {
        display: block;
        margin-top: 14px;
      }

      .prompt-area textarea {
        min-height: 168px;
        padding-right: 48px;
      }

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

      .ratio-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
      }

      .upload-tabs,
      .url-input-row {
        width: 100% !important;
      }

      .upload-tabs .btn {
        flex: 1 1 0;
        width: auto;
      }

      .url-input-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        margin-bottom: 14px;
      }

      .result-browser {
        gap: 12px;
      }

      .run-list {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: minmax(220px, 82vw);
        grid-template-columns: none;
        overflow-x: auto;
        overflow-y: hidden;
        max-height: none;
        padding: 0 2px 8px;
        scroll-snap-type: x mandatory;
        scrollbar-gutter: auto;
      }

      .result-group {
        min-height: 86px;
        scroll-snap-align: start;
      }

      .result-detail {
        overflow: visible;
      }

      .detail-header {
        grid-template-columns: 1fr;
        grid-template-rows: none;
        gap: 10px;
        padding: 12px;
      }

      .detail-title,
      .result-summary,
      .detail-actions {
        grid-column: 1 !important;
        grid-row: auto !important;
      }

      .detail-actions {
        justify-content: stretch;
        align-items: stretch;
      }

      .detail-actions .btn {
        width: 100%;
        min-height: 34px;
      }

      .gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        padding: 10px;
      }

      .image-meta-main,
      .image-details {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
      }

      .lightbox {
        padding: 10px;
      }

      .lightbox img,
      .lightbox video {
        max-width: 100%;
        max-height: 82vh;
      }

      .lightbox button {
        right: 12px;
        top: 12px;
      }
    }

    @media (max-width: 380px) {
      .command-settings,
      .gallery {
        grid-template-columns: 1fr;
      }

      .command-field--model {
        grid-column: auto;
      }

      .run-list {
        grid-auto-columns: minmax(210px, 88vw);
      }
    }

    /* History Prompt Styles */
    .prompt-input-wrapper {
      position: relative;
    }

    .history-toggle-btn {
      position: absolute;
      top: 10px;
      right: 10px;
      width: 28px;
      height: 28px;
      padding: 0;
      border: none;
      background: var(--border-subtle);
      border-radius: 6px;
      color: var(--ink-secondary);
      cursor: pointer;
      display: grid;
      place-items: center;
      transition: background 0.18s, color 0.18s;
      z-index: 5;
    }

    .history-toggle-btn:hover {
      background: var(--surface-secondary);
      color: var(--ink);
    }

    .history-popover {
      position: absolute;
      top: 45px;
      right: 10px;
      width: 420px;
      background: var(--surface-elevated);
      border: 1px solid var(--border-subtle);
      border-radius: 12px;
      box-shadow: 0 10px 40px var(--shadow-heavy);
      backdrop-filter: blur(12px);
      z-index: 10;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    .history-popover[hidden] {
      display: none !important;
    }

    .history-tabs {
      display: flex;
      padding: 8px 16px 0;
      border-bottom: 1px solid var(--border);
      background: transparent;
      gap: 16px;
    }

    .history-tab {
      padding: 10px 4px;
      background: transparent;
      border: none;
      color: var(--ink-secondary);
      font-size: 13px;
      font-weight: 500;
      cursor: pointer;
      position: relative;
      transition: color 0.18s;
    }

    .history-tab::after {
      content: '';
      position: absolute;
      bottom: -1px;
      left: 0;
      right: 0;
      height: 2px;
      background: transparent;
      transition: background 0.18s;
    }

    .history-tab.active {
      color: var(--ink);
      font-weight: 600;
    }

    .history-tab.active::after {
      background: var(--accent);
    }

    .history-search {
      padding: 12px 16px;
      position: relative;
      border-bottom: none;
    }

    .history-search svg {
      position: absolute;
      left: 28px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--ink-secondary);
      pointer-events: none;
    }

    .history-search input {
      width: 100%;
      height: 36px;
      padding: 0 12px 0 32px;
      background: var(--surface-primary);
      border: none;
      border-radius: 8px;
      font-size: 13px;
      color: var(--ink);
    }

    .history-search input::placeholder {
      color: var(--ink-tertiary);
    }

    .history-list {
      max-height: 280px;
      overflow-y: auto;
      padding: 0;
      display: flex;
      flex-direction: column;
      scrollbar-width: thin;
    }

    .history-item {
      padding: 14px 16px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
      cursor: pointer;
      transition: background 0.18s;
      border-bottom: 1px solid var(--border-subtle);
    }

    .history-item:hover {
      background: var(--surface-primary);
    }

    .history-item-text {
      flex: 1;
      font-size: 13px;
      line-height: 1.4;
      color: var(--ink);
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
      word-break: break-all;
    }

    .history-item-actions {
      display: flex;
      gap: 6px;
      opacity: 0;
      transition: opacity 0.18s;
    }

    .history-item:hover .history-item-actions {
      opacity: 1;
    }

    .history-action-btn {
      width: 24px;
      height: 24px;
      padding: 0;
      background: transparent;
      border: none;
      color: var(--ink-secondary);
      cursor: pointer;
      display: grid;
      place-items: center;
      border-radius: 4px;
    }

    .history-action-btn:hover {
      background: var(--border);
      color: var(--ink);
    }

    .history-action-btn.star-active {
      color: var(--success);
    }

    .history-action-btn.delete-btn:hover {
      color: var(--red);
    }

    .history-footer {
      display: flex;
      justify-content: space-between;
      padding: 12px 16px;
      background: transparent;
      border-top: none;
    }

    .history-modal-content {
      width: min(600px, 90vw);
      max-height: 80vh;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      box-shadow: var(--shadow);
      display: flex;
      flex-direction: column;
      position: relative;
    }

    .history-modal-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 16px 20px;
      border-bottom: 1px solid var(--border);
    }

    .history-modal-header h3 {
      margin: 0;
      font-size: 16px;
      color: var(--ink);
    }

    .history-modal-body {
      flex: 1;
      overflow-y: auto;
      padding: 12px 0;
    }

    .history-modal-body .history-item {
      padding: 12px 20px;
    }

    .history-modal-body .history-item-text {
      -webkit-line-clamp: 3;
    }

    .empty-history {
      padding: 30px;
      text-align: center;
      color: var(--ink-secondary);
      font-size: 13px;
    }

    @media (max-width: 640px) {
      .history-popover {
        position: absolute;
        left: 10px;
        right: 10px;
        top: 45px;
        bottom: auto;
        width: auto;
        max-height: min(60vh, 420px);
      }

      .history-list {
        max-height: 42vh;
      }

      .history-item-actions {
        opacity: 1;
      }

      .history-modal-content {
        width: min(100%, calc(100vw - 20px));
        max-height: calc(100vh - 24px);
      }
    }
