:root {
        --bg: #ffffff;
        --surface: #f7f7f5;
        --surface-2: #efefec;
        --border: #e8e8e3;
        --border-strong: #d8d9d2;
        --text: #232620;
        --muted: #676e60;
        --accent: #cf4933;
        --accent-dark: #bd3d28;
        --accent-bg: #fff0eb;
        --danger: #dc2626;
        --danger-bg: #fef2f2;
        --danger-border: #fecaca;
        --success: #16a34a;
        --success-bg: #f0fdf4;
        --success-border: #bbf7d0;
        --warning: #b45309;
        --warning-bg: #fffbeb;
        --warning-border: #fde68a;
        --radius: 8px;
        --radius-lg: 14px;
        --btn-padding: 10px 16px;
        --btn-font-size: 13px;
      }

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

      body {
        margin: 0;
        font-size: 14px;
        line-height: 1.6;
        font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
        color: var(--text);
        background: var(--bg);
        -webkit-font-smoothing: antialiased;
      }

      a { color: var(--accent); text-decoration: none; }
      a:hover { text-decoration: underline; }

      /* ── Typography ── */
      h1 { font-size: 30px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.02em; line-height: 1.3; }
      h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; color: var(--text); }
      h3 { font-size: 13px; font-weight: 600; margin: 0 0 8px; }
      p { margin: 0 0 12px; }
      p:last-child { margin-bottom: 0; }

      code {
        font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
        font-size: 12px;
        background: var(--surface-2);
        border: 1px solid var(--border);
        border-radius: 3px;
        padding: 1px 5px;
      }

      /* ── Page header ── */
      .page-header { margin-bottom: 28px; }
      .page-header h1 { margin-bottom: 4px; }
      .page-header .subtitle { color: var(--muted); font-size: 13px; margin: 0; }

      /* ── Section ── */
      .section { margin-top: 36px; }
      .section-header {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        margin-bottom: 14px;
      }
      .section-header h2 { margin: 0; }

      /* ── Stat cards ── */
      .stats-grid {
        display: grid;
        gap: 12px;
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        margin-bottom: 36px;
      }
      .stat-card {
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        padding: 24px;
      }
      .stat-value {
        font-size: 32px;
        font-weight: 700;
        line-height: 1;
        margin-bottom: 6px;
        letter-spacing: -0.03em;
        color: var(--text);
      }
      .stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }

      /* ── Cards ── */
      .card {
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        padding: 24px;
      }
      .card + .card { margin-top: 12px; }
      .card > h2:first-child { margin-bottom: 16px; }

      /* ── Tables ── */
      .table-wrapper {
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        overflow-x: auto;
      }
      table { width: 100%; border-collapse: collapse; }
      thead { background: var(--surface); }
      th {
        padding: 12px 18px;
        text-align: left;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--muted);
        border-bottom: 1px solid var(--border);
        white-space: nowrap;
      }
      td {
        padding: 18px;
        vertical-align: middle;
        border-bottom: 1px solid var(--border);
        font-size: 13px;
      }
      tr:last-child td { border-bottom: 0; }
      tbody tr:hover { background: var(--surface); }
      .table-note {
        padding: 12px 18px;
        font-size: 12px;
        color: var(--muted);
        background: var(--surface);
        border-top: 1px solid var(--border);
      }
      .cell-primary { font-weight: 500; color: var(--text); }
      .cell-secondary { font-size: 12px; color: var(--muted); margin-top: 2px; }

      /* ── Badges ── */
      .badge {
        display: inline-flex;
        align-items: center;
        padding: 2px 7px;
        border-radius: 99px;
        font-size: 11px;
        font-weight: 500;
        line-height: 1.5;
        white-space: nowrap;
      }
      .badge-green  { background: #dcfce7; color: #15803d; }
      .badge-yellow { background: #fef9c3; color: #854d0e; }
      .badge-red    { background: #fee2e2; color: #b91c1c; }
      .badge-blue   { background: #dbeafe; color: #1d4ed8; }
      .badge-gray   { background: var(--surface-2); color: var(--muted); }

      /* ── Forms ── */
      form { margin: 0; }
      form p { margin: 0 0 18px; }
      form p:last-of-type { margin-bottom: 24px; }
      label,
      form p label {
        display: block;
        font-size: 13px;
        font-weight: 600;
        margin-bottom: 5px;
        color: var(--text);
      }
      input[type="text"],
      input[type="email"],
      input[type="password"],
      input[type="number"],
      input[type="file"],
      select,
      textarea {
        display: block;
        width: 100%;
        max-width: 560px;
        padding: 8px 11px;
        border: 1px solid var(--border-strong);
        border-radius: var(--radius);
        font: inherit;
        font-size: 13px;
        background: var(--bg);
        color: var(--text);
        outline: none;
        transition: border-color 0.15s, box-shadow 0.15s;
        -webkit-appearance: none;
        appearance: none;
      }
      input:focus, select:focus, textarea:focus {
        border-color: var(--accent);
        box-shadow: 0 0 0 3px rgba(221, 80, 56, 0.12);
      }
      textarea { resize: vertical; min-height: 96px; }
      select {
        background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 10px center;
        padding-right: 30px;
      }
      input[type="file"] { padding: 6px 10px; cursor: pointer; font-size: 12px; }
      .helptext { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
      .errorlist { margin: 0 0 6px; padding: 0; list-style: none; font-size: 12px; color: var(--danger); }

      /* ── Buttons ── */
      /* Base: shared layout for all button variants — change padding/size/radius here only */
      button, .btn, .button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: var(--btn-padding);
        border: 1px solid transparent;
        border-radius: var(--radius);
        font: inherit;
        font-size: var(--btn-font-size);
        font-weight: 500;
        cursor: pointer;
        white-space: nowrap;
        transition: background 0.1s, border-color 0.1s, opacity 0.1s;
        text-decoration: none;
      }
      /* Primary (default for bare <button> and .button) */
      button[type="submit"]:not([class]),
      button:not([class]),
      .btn-primary,
      .button {
        background: var(--accent);
        border-color: var(--accent);
        color: #fff;
      }
      button[type="submit"]:not([class]):hover,
      button:not([class]):hover,
      .btn-primary:hover,
      .button:hover {
        background: var(--accent-dark);
        border-color: var(--accent-dark);
        text-decoration: none;
        color: #fff;
      }
      /* Secondary */
      .btn-secondary,
      .button.secondary,
      button.secondary {
        background: var(--bg);
        border-color: var(--border-strong);
        color: var(--text);
      }
      .btn-secondary:hover,
      .button.secondary:hover,
      button.secondary:hover { background: var(--surface); color: var(--text); }
      /* Danger */
      .btn-danger,
      button.danger {
        background: var(--danger);
        border-color: var(--danger);
        color: #fff;
      }
      .btn-danger:hover,
      button.danger:hover { opacity: 0.88; }

      /* ── Alerts ── */
      .messages { margin: 0 0 24px; padding: 0; list-style: none; }
      .messages li {
        padding: 11px 16px;
        border-radius: var(--radius);
        margin-bottom: 8px;
        font-size: 13px;
        background: var(--surface);
        border: 1px solid var(--border);
        color: var(--text);
      }
      .messages li.success { background: var(--success-bg); border-color: var(--success-border); color: #15803d; }
      .messages li.error   { background: var(--danger-bg);  border-color: var(--danger-border);  color: var(--danger); }
      .messages li.warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
      .messages li.info    { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }

      /* ── Pre / code blocks ── */
      pre {
        margin: 0;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 14px 16px;
        font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
        font-size: 12px;
        line-height: 1.7;
        color: var(--text);
        max-height: 280px;
        overflow-y: auto;
      }

      /* ── Comparison layout ── */
      .split {
        display: grid;
        gap: 16px;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
      }
      .split-label {
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--muted);
        margin-bottom: 8px;
      }

      /* ── Actions row ── */
      .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

      /* ── Asset grid ── */
      .asset-grid {
        display: grid;
        gap: 14px;
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
      }
      .asset-card {
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        overflow: hidden;
        background: var(--bg);
      }
      .asset-card img {
        width: 100%;
        aspect-ratio: 16 / 9;
        object-fit: cover;
        display: block;
        border-bottom: 1px solid var(--border);
      }
      .asset-card-body { padding: 11px 12px 12px; }
      .asset-card-name {
        font-size: 12px;
        font-weight: 500;
        color: var(--text);
        margin-bottom: 3px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .asset-card-tags { font-size: 11px; color: var(--muted); margin-bottom: 10px; min-height: 16px; }

      /* ── Connection status ── */
      .connection-row {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        border-radius: var(--radius);
        font-size: 13px;
      }
      .connection-row.connected    { background: var(--success-bg); border: 1px solid var(--success-border); color: #15803d; }
      .connection-row.disconnected { background: var(--danger-bg);  border: 1px solid var(--danger-border);  color: var(--danger); }

      /* ── Video meta panel ── */
      .meta-panel {
        display: flex;
        flex-wrap: wrap;
        gap: 24px;
        padding: 16px 20px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        margin-bottom: 28px;
      }
      .meta-item {}
      .meta-label {
        font-size: 10px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.07em;
        color: var(--muted);
        margin-bottom: 3px;
      }
      .meta-value { font-size: 13px; font-weight: 500; }

      /* ── Clip review grid ── */
      .clip-grid {
        display: grid;
        gap: 14px;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        align-items: start;
      }
      .clip-grid .card + .card { margin-top: 0; }
      .clip-card {
        padding: 14px;
        display: flex;
        flex-direction: column;
        gap: 12px;
        min-width: 0;
      }
      .clip-card-archived { opacity: 0.92; }
      .clip-preview video,
      .clip-preview .empty-state {
        width: 100%;
        aspect-ratio: 9 / 16;
        max-height: 520px;
        background: #000;
        border-radius: var(--radius);
        display: block;
      }
      .clip-preview .empty-state {
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--surface);
      }
      .clip-card-body {
        display: grid;
        gap: 10px;
        min-width: 0;
      }
      .clip-card-heading {
        display: grid;
        gap: 6px;
      }
      .clip-card-heading h2 {
        margin: 0;
        line-height: 1.35;
        overflow-wrap: anywhere;
      }
      .clip-badges,
      .clip-task-stack,
      .clip-actions {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 6px;
      }
      .clip-task-note {
        width: 100%;
        padding: 7px 9px;
        border: 1px solid #bfdbfe;
        border-radius: var(--radius);
        background: #eff6ff;
        color: #1d4ed8;
        font-size: 12px;
        font-weight: 600;
      }
      .clip-task-note .cell-secondary {
        margin-left: 6px;
        color: #2563eb;
      }
      .clip-meta { margin-bottom: 0; }
      .clip-card input,
      .clip-card select,
      .clip-card textarea {
        max-width: none;
      }
      .clip-upload-form,
      .clip-control-form,
      .clip-upload-summary {
        display: grid;
        gap: 10px;
      }
      .clip-control-form {
        padding-top: 10px;
        border-top: 1px solid var(--border);
      }
      .clip-form-grid,
      .clip-rerender-grid {
        display: grid;
        gap: 10px;
      }
      .clip-rerender-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
      }
      .clip-upload-title {
        margin: 0;
        font-weight: 600;
        overflow-wrap: anywhere;
      }
      .revision-drawer {
        margin-top: 18px;
        border: 1px dashed var(--border-strong);
        border-radius: var(--radius-lg);
        padding: 12px 14px 14px;
        background: var(--surface);
      }
      .revision-drawer summary {
        cursor: pointer;
        font-size: 13px;
        font-weight: 600;
        color: var(--text);
      }
      .revision-grid { margin-top: 14px; }
      @media (max-width: 980px) {
        .clip-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      }
      @media (max-width: 680px) {
        .clip-grid { grid-template-columns: 1fr; }
      }

      /* ── Utilities ── */
      .muted { color: var(--muted); font-size: 13px; }
      .text-sm  { font-size: 13px; }
      .text-xs  { font-size: 12px; }
      .text-danger  { color: var(--danger); }
      .text-success { color: var(--success); }

      /* ── Empty state ── */
      .empty-state {
        padding: 40px 24px;
        text-align: center;
        color: var(--muted);
        font-size: 13px;
        border-radius: var(--radius-lg);
        border: 1px dashed var(--border-strong);
      }

      /* ── Nav badge ── */
      .nav-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 17px;
        height: 17px;
        padding: 0 5px;
        border-radius: 99px;
        font-size: 10px;
        font-weight: 700;
        background: var(--danger);
        color: #fff;
        line-height: 1;
        margin-left: 4px;
      }

      /* ── Responsive table columns ── */
      @media (max-width: 860px) {
        .col-hide { display: none; }
      }
