:root {
        --bg: #0f1117;
        --surface: #1e2130;
        --surface2: #252a3d;
        --border: #2d3348;
        --text: #e2e8f0;
        --text-muted: #64748b;
        --text-dim: #94a3b8;
        --accent: #3b82f6;
        --accent-hover: #2563eb;
        --ok: #22c55e;
        --err: #ef4444;
        --warn: #f59e0b;
        --tag-bg: #1e3a5f;
        --tag-color: #60a5fa;
        --log-bg: #0a0d14;
        --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
        --radius: 12px;
        --radius-sm: 8px;
      }
      [data-theme="light"] {
        --bg: #f1f5f9;
        --surface: #ffffff;
        --surface2: #f8fafc;
        --border: #e2e8f0;
        --text: #0f172a;
        --text-muted: #94a3b8;
        --text-dim: #64748b;
        --accent: #2563eb;
        --accent-hover: #1d4ed8;
        --ok: #16a34a;
        --err: #dc2626;
        --warn: #d97706;
        --tag-bg: #dbeafe;
        --tag-color: #1d4ed8;
        --log-bg: #f8fafc;
        --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
      }
      *,
      *::before,
      *::after {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
      }
      html {
        transition:
          background 0.35s,
          color 0.35s;
      }
      body {
        font-family: "SF Mono", "Consolas", "Menlo", monospace;
        background: var(--bg);
        color: var(--text);
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        padding: 32px 20px 60px;
        transition:
          background 0.35s,
          color 0.35s;
      }
      /* header */
      .header {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 24px;
        position: relative;
      }
      .header-title {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
      }
      .header-title {
        font-size: 13px;
        font-weight: 700;
        color: var(--text-dim);
        letter-spacing: 0.12em;
        text-transform: uppercase;
      }
      /* layout */
      .layout {
        display: flex;
        align-items: flex-start;
        gap: 20px;
        width: 100%;
      }
      /* sidebar */
      .sidebar {
        width: 220px;
        flex-shrink: 0;
        position: sticky;
        top: 32px;
        display: flex;
        flex-direction: column;
        gap: 12px;
      }
      .sidebar-title {
        font-size: 13px;
        font-weight: 700;
        color: var(--text-dim);
        letter-spacing: 0.12em;
        text-transform: uppercase;
        padding-bottom: 12px;
        border-bottom: 1px solid var(--border);
        margin-bottom: 4px;
      }
      .sidebar-section {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 16px;
        box-shadow: var(--shadow);
        transition:
          background 0.35s,
          border-color 0.35s;
      }
      .sidebar-section-label {
        font-size: 10px;
        font-weight: 700;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.12em;
        margin-bottom: 10px;
      }
      .sidebar-round {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 10px;
      }
      .sidebar-actions {
        display: flex;
        flex-direction: column;
        gap: 6px;
      }
      .sidebar-actions .btn {
        width: 100%;
        justify-content: flex-start;
      }
      /* main content */
      .main {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
      }
      .main-title-spacer {
        font-size: 13px;
        font-weight: 700;
        letter-spacing: 0.12em;
        padding-bottom: 12px;
        border-bottom: 1px solid transparent;
        margin-bottom: 12px;
        visibility: hidden;
        pointer-events: none;
        user-select: none;
      }
      /* log panel (right column) */
      .log-panel {
        width: 360px;
        flex-shrink: 0;
        position: sticky;
        top: 32px;
        align-self: flex-start;
        max-height: calc(100vh - 64px);
        display: flex;
        flex-direction: column;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        overflow: hidden;
        transition:
          background 0.35s,
          border-color 0.35s;
      }
      .log-panel-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 14px 10px;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
      }
      .log-filter-tabs {
        display: flex;
        gap: 4px;
        padding: 6px 10px;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
      }
      .log-tab {
        border: none;
        background: transparent;
        color: var(--text-muted);
        font-size: 11px;
        font-family: inherit;
        padding: 3px 10px;
        border-radius: 5px;
        cursor: pointer;
        transition: background 0.15s, color 0.15s;
      }
      .log-tab:hover { color: var(--text); background: var(--surface2); }
      .log-tab.active { background: var(--accent); color: #fff; }
      .log-panel .log-body {
        flex: 1;
        overflow-y: auto;
        padding: 10px 14px;
        min-height: 0;
      }
      /* drag-sort list */
      .run-order-list {
        display: flex;
        flex-direction: column;
        gap: 4px;
        margin-bottom: 8px;
      }
      .run-order-item {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 5px 8px;
        background: var(--surface2);
        border: 1px solid var(--border);
        border-radius: 6px;
        cursor: grab;
        font-size: 12px;
        color: var(--text);
        user-select: none;
        transition:
          opacity 0.15s,
          background 0.15s;
      }
      .run-order-left {
        display: flex;
        align-items: center;
        gap: 4px;
        flex-shrink: 0;
      }
      .run-order-item:active {
        cursor: grabbing;
      }
      .run-order-item.drag-over {
        background: var(--tag-bg);
        border-color: var(--accent);
      }
      .run-order-item.dragging {
        opacity: 0.4;
      }
      .run-order-item .drag-handle {
        color: var(--text-muted);
        font-size: 10px;
      }
      /* responsive */
      @media (max-width: 900px) {
        .log-panel {
          display: none;
        }
      }
      @media (max-width: 720px) {
        body {
          padding: 16px 12px 40px;
        }
        .layout {
          flex-direction: column;
        }
        .sidebar {
          width: 100%;
          position: static;
          flex-direction: row;
          flex-wrap: wrap;
          gap: 10px;
        }
        .sidebar-section {
          flex: 1;
          min-width: 140px;
        }
        .main-title-spacer {
          display: none;
        }
      }
      /* theme switcher */
      .theme-group {
        display: flex;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 999px;
        padding: 3px;
        gap: 2px;
        box-shadow: var(--shadow);
        transition:
          background 0.35s,
          border-color 0.35s;
      }
      .theme-btn {
        border: none;
        background: transparent;
        color: var(--text-muted);
        font-size: 15px;
        width: 32px;
        height: 32px;
        border-radius: 999px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition:
          background 0.2s,
          color 0.2s;
      }
      .theme-btn:hover {
        color: var(--text);
      }
      .theme-btn.active {
        background: var(--accent);
        color: #fff;
      }
      /* card */
      .card {
        width: 100%;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 28px;
        margin-bottom: 16px;
        box-shadow: var(--shadow);
        transition:
          background 0.35s,
          border-color 0.35s,
          box-shadow 0.35s;
      }
      .section-label {
        font-size: 10px;
        font-weight: 700;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.12em;
        margin-bottom: 14px;
      }
      .row {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 14px;
        flex-wrap: wrap;
      }
      label {
        font-size: 12px;
        color: var(--text-muted);
        white-space: nowrap;
      }
      input {
        flex: 1;
        min-width: 200px;
        background: var(--surface2);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        padding: 10px 14px;
        color: var(--text);
        font-size: 14px;
        font-family: inherit;
        outline: none;
        transition:
          border-color 0.2s,
          background 0.35s;
      }
      input:focus {
        border-color: var(--accent);
      }
      input::placeholder {
        color: var(--border);
      }
      /* buttons */
      .btn {
        padding: 10px 24px;
        border-radius: var(--radius-sm);
        border: none;
        font-size: 14px;
        font-family: inherit;
        font-weight: 600;
        cursor: pointer;
        transition:
          opacity 0.15s,
          background 0.2s,
          transform 0.1s;
        white-space: nowrap;
        display: inline-flex;
        align-items: center;
        gap: 8px;
      }
      .btn:active:not(:disabled) {
        transform: scale(0.97);
      }
      .btn:disabled {
        opacity: 0.45;
        cursor: not-allowed;
      }
      .btn-primary {
        background: var(--accent);
        color: #fff;
      }
      .btn-primary:hover:not(:disabled) {
        background: var(--accent-hover);
      }
      .btn-ghost {
        background: transparent;
        color: var(--text-muted);
        border: 1px solid var(--border);
        padding: 6px 14px;
        font-size: 12px;
      }
      .btn-ghost:hover:not(:disabled) {
        color: var(--text);
        border-color: var(--text-muted);
      }
      /* spinner */
      .spinner {
        width: 14px;
        height: 14px;
        border: 2px solid rgba(255, 255, 255, 0.3);
        border-top-color: #fff;
        border-radius: 50%;
        animation: spin 0.7s linear infinite;
        display: none;
        flex-shrink: 0;
      }
      .btn.loading .spinner {
        display: block;
      }
      .btn.loading .btn-label::after {
        content: "…";
      }
      @keyframes spin {
        to {
          transform: rotate(360deg);
        }
      }
      /* status */
      .status-bar {
        font-size: 12px;
        color: var(--text-muted);
        min-height: 18px;
        margin-top: 4px;
        transition: color 0.2s;
      }
      .status-bar.ok {
        color: var(--ok);
      }
      .status-bar.err {
        color: var(--err);
      }
      .status-bar.loading {
        color: var(--warn);
      }
      /* phone display */
      .phone-display {
        display: none;
        margin-top: 10px;
        font-size: 14px;
        color: var(--text);
        background: var(--surface2);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        padding: 10px 14px;
        transition: background 0.35s;
      }
      .tag {
        display: inline-block;
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.08em;
        padding: 2px 7px;
        border-radius: 4px;
        text-transform: uppercase;
        vertical-align: middle;
      }
      .tag-phone {
        background: var(--tag-bg);
        color: var(--tag-color);
      }
      /* json box */
      .json-box {
        background: var(--surface2);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        padding: 16px;
        font-size: 13px;
        line-height: 1.7;
        overflow-x: auto;
        min-height: 56px;
        white-space: pre-wrap;
        word-break: break-all;
        transition:
          background 0.35s,
          border-color 0.35s;
      }
      .jk {
        color: var(--accent);
      }
      .jstr {
        color: var(--ok);
      }
      .jnum {
        color: var(--warn);
      }
      .jbool {
        color: #a78bfa;
      }
      .jnull {
        color: var(--text-muted);
      }
      /* copy btn */
      .copy-btn {
        border: 1px solid var(--border);
        background: transparent;
        color: var(--text-muted);
        font-size: 11px;
        font-family: inherit;
        padding: 3px 10px;
        border-radius: 6px;
        cursor: pointer;
        transition:
          background 0.18s,
          color 0.18s,
          border-color 0.18s;
        white-space: nowrap;
        min-width: 64px;
        text-align: center;
        margin-left: 20px;
        flex-shrink: 0;
      }
      .copy-btn:hover {
        background: var(--surface2);
        color: var(--text);
        border-color: var(--text-muted);
      }
      .copy-btn.copied {
        background: var(--ok);
        color: #fff;
        border-color: var(--ok);
      }
      /* extract panel */
      .extract-row {
        display: flex;
        align-items: flex-start;
        gap: 12px;
        margin-top: 8px;
      }
      .extract-label {
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.08em;
        color: var(--text-muted);
        text-transform: uppercase;
        flex-shrink: 0;
        padding-top: 3px;
        width: 42px;
      }
      .extract-value {
        flex: 1;
        font-size: 12px;
        color: var(--text);
        background: var(--surface2);
        border: 1px solid var(--border);
        border-radius: 6px;
        padding: 6px 10px;
        word-break: break-all;
        line-height: 1.6;
        transition:
          background 0.35s,
          border-color 0.35s;
      }
      .extract-value.url-val {
        color: var(--accent);
      }
      .extract-card {
        display: none;
      }
      .extract-card.visible {
        display: block;
      }
      /* section row */
      .section-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 12px;
      }
      /* collapsible */
      .collapse-toggle {
        background: none;
        border: none;
        cursor: pointer;
        color: var(--text-muted);
        font-size: 13px;
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 0;
        font-family: inherit;
        transition: color 0.2s;
      }
      .collapse-toggle:hover {
        color: var(--text);
      }
      .collapse-arrow {
        display: inline-block;
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        font-style: normal;
        line-height: 1;
      }
      .collapse-toggle.open .collapse-arrow {
        transform: rotate(90deg);
      }
      .collapse-body {
        overflow: hidden;
        max-height: 0;
        opacity: 0;
        transition:
          max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
          opacity 0.25s ease;
      }
      .collapse-body.open {
        max-height: 3000px;
        opacity: 1;
      }
      /* divider */
      .divider {
        height: 1px;
        background: var(--border);
        margin: 16px 0;
        transition: background 0.35s;
      }
      /* log panel */
      .log-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 12px;
      }
      .log-body {
        background: var(--log-bg);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        padding: 12px 14px;
        max-height: 70vh;
        overflow-y: auto;
        font-size: 12px;
        line-height: 1.8;
        transition:
          background 0.35s,
          border-color 0.35s;
      }
      .log-body:empty::before {
        content: "暂无日志";
        color: var(--text-muted);
      }
      .log-entry {
        display: flex;
        gap: 10px;
      }
      .log-time {
        color: var(--text-muted);
        flex-shrink: 0;
      }
      .log-msg {
        color: var(--text);
      }
      .log-entry.ok .log-msg {
        color: var(--ok);
      }
      .log-entry.err .log-msg {
        color: var(--err);
      }
      .log-entry.warn .log-msg {
        color: var(--warn);
      }
      /* round badge */
      .round-badge {
        font-size: 11px;
        font-weight: 700;
        color: var(--accent);
        background: var(--tag-bg);
        border-radius: 5px;
        padding: 2px 9px;
        letter-spacing: 0.05em;
      }
      /* history modal */
      .history-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 1000;
        align-items: flex-start;
        justify-content: center;
        padding: 48px 20px;
      }
      .history-overlay.open {
        display: flex;
      }
      .history-modal {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        width: 100%;
        max-width: 760px;
        max-height: 80vh;
        overflow-y: auto;
        padding: 28px;
        box-shadow: var(--shadow);
      }
      .history-modal-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 20px;
      }
      .history-round-block {
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        margin-bottom: 12px;
        overflow: hidden;
      }
      .history-round-title {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 14px;
        background: var(--surface2);
        cursor: pointer;
        font-size: 12px;
        font-weight: 700;
        color: var(--text-dim);
        user-select: none;
      }
      .history-round-title:hover {
        background: var(--border);
      }
      .history-round-body {
        background: var(--log-bg);
        padding: 10px 14px;
        font-size: 12px;
        line-height: 1.8;
        display: none;
      }
      .history-round-body.open {
        display: block;
      }
      .history-log-entry {
        display: flex;
        gap: 10px;
      }
      .history-log-entry .log-time {
        color: var(--text-muted);
        flex-shrink: 0;
      }
      .history-log-entry .log-msg {
        color: var(--text);
      }
      .history-log-entry.ok .log-msg {
        color: var(--ok);
      }
      .history-log-entry.err .log-msg {
        color: var(--err);
      }
      .history-log-entry.warn .log-msg {
        color: var(--warn);
      }
      .history-resp-toggle {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 2px 0 2px 0;
        font-size: 11px;
        color: var(--text-muted);
        cursor: pointer;
        user-select: none;
        margin: 2px 0;
      }
      .history-resp-toggle:hover {
        color: var(--text);
      }
      .history-resp-body {
        display: none;
        background: var(--surface2);
        border: 1px solid var(--border);
        border-radius: 6px;
        padding: 10px 12px;
        font-size: 12px;
        line-height: 1.7;
        white-space: pre-wrap;
        word-break: break-all;
        margin-bottom: 4px;
        overflow-x: auto;
      }
      .history-resp-body.open {
        display: block;
      }
      /* fade-in for log entries */
      @keyframes fadeSlide {
        from {
          opacity: 0;
          transform: translateY(4px);
        }
        to {
          opacity: 1;
          transform: translateY(0);
        }
      }
      .log-entry {
        animation: fadeSlide 0.2s ease;
      }
      /* link chips */
      .link-chips {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
        align-items: center;
      }
      .link-chip-wrap {
        position: relative;
        display: inline-block;
      }
      .link-chip {
        display: inline-block;
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.08em;
        padding: 3px 10px;
        border-radius: 4px;
        background: var(--tag-bg);
        color: var(--tag-color);
        cursor: default;
        user-select: none;
        border: 1px solid var(--border);
        transition: background 0.15s;
      }
      .link-chip-wrap:hover .link-chip {
        background: var(--accent);
        color: #fff;
      }
      .link-tooltip {
        position: absolute;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.15s, visibility 0.15s;
        transition-delay: 0s;
        left: 0;
        top: calc(100% + 6px);
        z-index: 999;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        box-shadow: var(--shadow);
        padding: 10px 12px;
        font-size: 11px;
        color: var(--accent);
        word-break: break-all;
        white-space: pre-wrap;
        line-height: 1.6;
        width: 480px;
        max-width: 90vw;
        user-select: text;
        cursor: text;
      }
      .link-chip-wrap::after {
        content: '';
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        height: 6px;
      }
      .link-chip-wrap:hover .link-tooltip {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transition-delay: 0.35s;
      }
      /* density: compact */
      [data-density="compact"] body {
        padding: 16px 12px 32px;
      }
      [data-density="compact"] .layout {
        gap: 12px;
      }
      [data-density="compact"] .card {
        padding: 14px 16px;
        margin-bottom: 8px;
      }
      [data-density="compact"] .section-label {
        margin-bottom: 8px;
      }
      [data-density="compact"] .row {
        gap: 6px;
        margin-bottom: 8px;
      }
      [data-density="compact"] input {
        padding: 6px 10px;
        font-size: 13px;
      }
      [data-density="compact"] .sidebar {
        gap: 6px;
      }
      [data-density="compact"] .sidebar-section {
        padding: 10px 12px;
      }
      [data-density="compact"] .extract-row {
        gap: 8px;
        margin-top: 4px;
      }
      [data-density="compact"] .section-row {
        margin-bottom: 6px;
      }
      [data-density="compact"] .status-bar {
        margin-top: 2px;
      }
      /* scrollbar */
      ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
      }
      ::-webkit-scrollbar-track {
        background: transparent;
      }
      ::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 3px;
      }