/* ==========================================================================
   Pipora Workflow Landing — unified design system
   Style: minimalist, flat, monochrome. Black primary actions, white/gray surfaces.
   No gradients, no drop shadows, no glass. Borders carry structure.
   ========================================================================== */

:root {
  /* Surfaces */
  --bg: oklch(0.982 0 0);          /* page gray #F9F9F9 */
  --surface: oklch(1 0 0);         /* card white */
  --surface-2: oklch(0.968 0 0);   /* subtle fill #F3F3F3 */
  --surface-3: oklch(0.952 0 0);   /* deeper fill #EEEEEE */

  /* Ink */
  --ink: oklch(0.20 0 0);          /* #161616 headings / primary button */
  --ink-2: oklch(0.38 0 0);        /* #484848 body-strong */
  --ink-3: oklch(0.52 0 0);        /* #6B6B6B muted, 4.6:1 on white */
  --ink-4: oklch(0.60 0 0);        /* #808080 placeholders, 4.5:1 on white */

  /* Lines */
  --line: oklch(0.908 0 0);        /* #E6E6E6 hairline */
  --line-strong: oklch(0.85 0 0);  /* #D3D3D3 control border */

  /* Semantic (flat tones; always paired with dot + text, never color alone) */
  --success: oklch(0.50 0.11 155);   /* #2E7D4F */
  --success-bg: oklch(0.955 0.02 155);
  --warning: oklch(0.55 0.11 75);    /* #8A6D00 */
  --warning-bg: oklch(0.96 0.03 90);
  --error: oklch(0.50 0.16 27);      /* #B3261E */
  --error-bg: oklch(0.96 0.02 27);
  --info: oklch(0.45 0.09 250);      /* #3556B8 */
  --info-bg: oklch(0.96 0.015 250);
  --running: var(--info);

  /* Shape */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  /* Z scale */
  --z-sticky: 10;
  --z-dropdown: 20;
  --z-modal-backdrop: 30;
  --z-modal: 40;
  --z-toast: 50;
}

/* ---------- Reset / base ---------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-2);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { color: var(--ink); margin: 0; font-weight: 600; text-wrap: balance; }
h1 { font-size: 22px; line-height: 1.3; letter-spacing: -0.01em; }
h2 { font-size: 17px; line-height: 1.4; }
h3 { font-size: 15px; line-height: 1.45; }
p { margin: 0; }
a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: #000; }
code, pre, .mono { font-family: var(--mono); font-size: 0.92em; }
img, video { max-width: 100%; display: block; }
button { font-family: inherit; }
::placeholder { color: var(--ink-4); opacity: 1; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection { background: var(--ink); color: #fff; }

/* ---------- Layout ---------- */

.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.container-wide { max-width: 1280px; margin: 0 auto; padding: 0 24px; }

.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 28px; height: 28px; flex: none;
  background: var(--ink); color: #fff;
  border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; line-height: 1;
}
.brand-name { font-size: 15px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.brand-sub { font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) { .brand-sub { display: none; } }

.page { padding: 32px 0 64px; }
.page-head { margin-bottom: 24px; max-width: 72ch; }
.page-title { font-size: 26px; margin-bottom: 6px; }
.page-desc { color: var(--ink-3); font-size: 14px; max-width: 65ch; }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.grid-sidebar { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 980px) { .grid-sidebar { grid-template-columns: 380px 1fr; align-items: start; } }
.stack { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }

/* ---------- Card / panel ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  min-height: 52px;
}
.card-head h2, .card-head h3 { font-size: 14px; }
.card-title-note { font-size: 12px; color: var(--ink-3); font-weight: 400; }
.card-body { padding: 20px; }
.card-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  font-size: 12px; color: var(--ink-3);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  font-size: 14px; font-weight: 500; line-height: 1;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer; user-select: none;
  text-decoration: none; white-space: nowrap;
  transition: background-color 150ms ease-out, color 150ms ease-out, border-color 150ms ease-out;
}
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: oklch(0.30 0 0); border-color: oklch(0.30 0 0); }
.btn-primary:active { background: #000; }
.btn-primary:disabled, .btn-primary[disabled] {
  background: var(--surface-3); border-color: var(--surface-3);
  color: var(--ink-3); cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface); color: var(--ink);
  border-color: var(--line-strong);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn-secondary:disabled { color: var(--ink-3); background: var(--surface-2); cursor: not-allowed; }

.btn-ghost { background: transparent; color: var(--ink-3); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-ghost:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger { background: var(--surface); color: var(--error); border-color: var(--line-strong); }
.btn-danger:hover { background: var(--error-bg); border-color: var(--error); }

.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { min-height: 50px; padding: 0 28px; font-size: 15px; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.label { font-size: 13px; font-weight: 500; color: var(--ink); }
.label-req::after { content: " *"; color: var(--error); }
.hint { font-size: 12px; color: var(--ink-3); }
.field-error { font-size: 12px; color: var(--error); }

.input, .select, .textarea {
  width: 100%;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  color: var(--ink);
  font-family: inherit; font-size: 14px; line-height: 1.5;
  padding: 10px 12px;
  min-height: 44px;
  transition: border-color 150ms ease-out, background-color 150ms ease-out;
}
.textarea { min-height: 120px; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--surface-2); color: var(--ink-3); cursor: not-allowed;
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--error); }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6B6B' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; min-height: 32px; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--ink); flex: none; }
.check-label { font-size: 14px; color: var(--ink-2); }

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

/* Upload dropzone */
.dropzone {
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 24px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 150ms ease-out, background-color 150ms ease-out;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--ink); background: var(--surface-2); color: var(--ink-2); }

/* ---------- Badge / status ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge-success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.badge-error   { background: var(--error-bg);   color: var(--error);   border-color: transparent; }
.badge-info    { background: var(--info-bg);    color: var(--info);    border-color: transparent; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.dot-success { background: var(--success); }
.dot-warning { background: var(--warning); }
.dot-error   { background: var(--error); }
.dot-running { background: var(--running); animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- Steps / progress monitor ---------- */

.steps { display: flex; flex-direction: column; }
.step {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 0; position: relative;
}
.step + .step { border-top: 1px solid var(--line); }
.step-indicator {
  width: 24px; height: 24px; flex: none;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-3);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 500;
}
.step.is-done .step-indicator { background: var(--ink); border-color: var(--ink); color: #fff; }
.step.is-running .step-indicator { border-color: var(--ink); color: var(--ink); }
.step.is-running .step-indicator::after {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink); animation: pulse 1.2s ease-in-out infinite;
}
.step.is-error .step-indicator { background: var(--error); border-color: var(--error); color: #fff; }
.step-name { font-size: 14px; color: var(--ink); font-weight: 500; }
.step.is-pending .step-name { color: var(--ink-3); font-weight: 400; }
.step-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

.progress {
  height: 4px; background: var(--surface-3); border-radius: 999px; overflow: hidden;
}
.progress-bar {
  height: 100%; background: var(--ink); border-radius: 999px;
  transition: width 300ms ease-out;
}

/* ---------- Alerts / callouts ---------- */

.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px; color: var(--ink-2);
}
.alert svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.alert-error { background: var(--error-bg); border-color: transparent; color: var(--error); }
.alert-warning { background: var(--warning-bg); border-color: transparent; color: var(--warning); }
.alert-info { background: var(--info-bg); border-color: transparent; color: var(--info); }
.alert-success { background: var(--success-bg); border-color: transparent; color: var(--success); }

/* ---------- Empty state / loading ---------- */

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 48px 24px;
  color: var(--ink-3); font-size: 13px; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--r-md);
  background: var(--surface);
}

.spinner {
  width: 20px; height: 20px; flex: none;
  border: 2px solid var(--line-strong);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: var(--surface-2);
  border-radius: var(--r-sm);
  animation: pulse 1.4s ease-in-out infinite;
}

/* ---------- Artifacts / paths / media ---------- */

.path-chip {
  display: inline-flex; align-items: center; gap: 8px;
  max-width: 100%;
  font-family: var(--mono); font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 4px 8px;
  color: var(--ink-2);
}
.path-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.artifact-list { display: flex; flex-direction: column; }
.artifact {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
}
.artifact + .artifact { border-top: 1px solid var(--line); }
.artifact-name { font-size: 13px; font-weight: 500; color: var(--ink); }
.artifact-path { font-family: var(--mono); font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.media-frame {
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.media-frame video, .media-frame img { width: 100%; height: auto; }

.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.thumb {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  overflow: hidden; background: var(--surface-2);
  aspect-ratio: 16 / 9;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Tabs ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 10px 14px; margin-bottom: -1px;
  font-size: 13px; font-weight: 500; color: var(--ink-3);
  background: none; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; min-height: 44px;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"], .tab.is-active { color: var(--ink); border-bottom-color: var(--ink); }

/* ---------- Table ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 500; color: var(--ink-3);
  padding: 8px 12px; border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }

/* ---------- KV list ---------- */

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--ink-3); margin: 0; }
.kv dd { color: var(--ink-2); margin: 0; font-family: var(--mono); font-size: 12px; word-break: break-all; }

/* ---------- Footer ---------- */

.footer {
  border-top: 1px solid var(--line);
  padding: 24px 0;
  color: var(--ink-3); font-size: 12px;
}

/* ---------- Utilities ---------- */

.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.strong { color: var(--ink); font-weight: 500; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.center { text-align: center; }

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .spinner, .spinner-lg { animation: spin 1s linear infinite !important; }
}
