/* ── Custom Dropdown ── */
.cd { position: relative; width: 100%; }
.cd-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--bg-input); color: var(--text-primary);
  font-size: 14.5px; font-family: inherit; width: 100%;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: var(--input-pad-y) var(--input-pad-x); cursor: pointer; min-height: var(--input-h);
  transition: border-color .15s, box-shadow .15s; user-select: none;
  box-shadow: var(--shadow-xs) inset;
}
.cd-trigger:hover { border-color: var(--border-strong); }
.cd.open .cd-trigger { border-color: var(--accent); box-shadow: var(--ring); background: var(--bg-input-focus); }
.cd-trigger .cd-chev { width: 18px; height: 18px; flex-shrink: 0; transition: transform .2s; color: var(--text-faint); }
.cd.open .cd-trigger .cd-chev { transform: rotate(180deg); color: var(--accent); }
.cd-trigger .cd-val { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-trigger .cd-placeholder { color: var(--text-faint); }
.cd-menu {
  position: fixed; z-index: 1000;
  background: var(--bg-card-solid); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 6px; max-height: 240px; overflow-y: auto;
  opacity: 0; transform: translateY(-6px) scale(.98); pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.cd-menu.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.cd-opt {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 11px; border-radius: var(--r-xs); font-size: 14px; cursor: pointer;
  color: var(--text-secondary); transition: background .1s, color .1s;
}
.cd-opt:hover { background: var(--bg-hover); color: var(--text-primary); }
.cd-opt.selected { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }
.cd-opt .cd-check { width: 16px; height: 16px; opacity: 0; color: var(--accent); flex-shrink: 0; }
.cd-opt.selected .cd-check { opacity: 1; }

/* ── Modals ── */
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal-overlay {
  position: fixed; inset: 0; background: rgba(6,7,12,.62); backdrop-filter: blur(10px);
  z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
[data-theme="light"] .modal-overlay { background: rgba(15,23,42,.32); backdrop-filter: blur(8px); }
.modal-overlay.open { opacity: 1; pointer-events: auto; animation: overlayIn .25s ease; }
.modal {
  position: relative; background: var(--bg-card-solid); border: 1px solid var(--border-strong);
  border-radius: var(--r-xl); padding: 0; width: 100%; max-width: 560px; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,.04) inset;
  transform: translateY(24px) scale(.96); opacity: 0;
  transition: transform .32s cubic-bezier(.16,1,.3,1), opacity .25s;
}
[data-theme="light"] .modal { box-shadow: var(--shadow-xl), 0 0 0 1px rgba(15,23,42,.03) inset; }
.modal-overlay.open .modal { transform: translateY(0) scale(1); opacity: 1; }
.modal-sm { max-width: 440px; }
.modal-lg { max-width: 700px; }
.modal-wide { max-width: 880px; }

/* Accent strip at the very top */
.modal::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--accent-grad); opacity: .9; }
.modal.accent-emerald::before { background: linear-gradient(135deg,#10b981,#059669); }
.modal.accent-amber::before { background: linear-gradient(135deg,#f59e0b,#d97706); }
.modal.accent-rose::before { background: linear-gradient(135deg,#f43f5e,#e11d48); }

.modal-header { padding: 24px 26px 20px; display: flex; align-items: center; gap: 15px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-header-icon { width: 46px; height: 46px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); }
.modal-header-text { min-width: 0; flex: 1; }
.modal-header h3 { font-size: 18px; font-weight: 700; color: var(--text-primary); margin: 0; letter-spacing: -.02em; }
.modal-header p { font-size: 13px; color: var(--text-muted); margin: 3px 0 0; }
.modal-close {
  margin-left: auto; width: 34px; height: 34px; border-radius: var(--r-sm); border: 1px solid transparent;
  background: var(--bg-hover); color: var(--text-muted); cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center; transition: all .15s; flex-shrink: 0; align-self: flex-start;
}
.modal-close:hover { background: rgba(239,68,68,.12); color: #f87171; border-color: rgba(239,68,68,.2); }
.modal-body { padding: 24px 26px; overflow-y: auto; flex: 1 1 auto; }
.modal-footer { padding: 18px 26px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-end; gap: 10px; background: var(--bg-subtle); flex-shrink: 0; }
.modal-footer .footer-spacer { margin-right: auto; }

/* Grouped fieldset within a modal */
.modal-fieldset { border: 1px solid var(--border); border-radius: var(--r-md); padding: 18px; background: var(--bg-subtle); }
.modal-fieldset + .modal-fieldset { margin-top: 16px; }
.fieldset-head { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; }
.fieldset-head .fh-icon { color: var(--text-muted); display: flex; }
.fieldset-head .fh-title { font-size: 13px; font-weight: 700; color: var(--text-primary); letter-spacing: -.01em; }

/* ── Detail view (record drawer) ── */
.detail-hero {
  display: flex; align-items: center; gap: 16px; padding: 4px 0 22px; margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.detail-hero .dh-avatar {
  width: 56px; height: 56px; border-radius: var(--r-md); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff;
  font-weight: 700; font-size: 21px; background: var(--accent-grad); box-shadow: var(--shadow-sm);
}
.detail-hero .dh-avatar.av-emerald { background: linear-gradient(135deg,#10b981,#059669); }
.detail-hero .dh-avatar.av-amber { background: linear-gradient(135deg,#f59e0b,#d97706); }
.detail-hero .dh-avatar.av-rose { background: linear-gradient(135deg,#f43f5e,#e11d48); }
.detail-hero .dh-avatar.av-slate { background: linear-gradient(135deg,#64748b,#475569); }
.detail-hero .dh-main { min-width: 0; flex: 1; }
.detail-hero .dh-title { font-size: 18px; font-weight: 700; color: var(--text-primary); letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-hero .dh-sub { font-size: 13.5px; color: var(--text-muted); margin-top: 4px; }

.detail-section { margin-top: 24px; }
.detail-section:first-child { margin-top: 0; }
.detail-section-title {
  display: flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin-bottom: 14px;
}
.detail-section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.detail-grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.detail-item { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--r-md); padding: 13px 15px; min-width: 0; }
.detail-item.full { grid-column: 1 / -1; }
.detail-item .di-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.detail-item .di-value { font-size: 14px; color: var(--text-primary); font-weight: 500; word-break: break-word; line-height: 1.5; }
.detail-item .di-value.mono { font-family: 'JetBrains Mono','SF Mono',ui-monospace,monospace; font-size: 12.5px; letter-spacing: -.01em; }
.detail-item .di-value.muted { color: var(--text-muted); font-weight: 400; }
.detail-item .di-value.big { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }

/* Copyable field */
.copy-field { display: flex; align-items: center; gap: 8px; }
.copy-field code {
  flex: 1; min-width: 0; font-family: 'JetBrains Mono','SF Mono',ui-monospace,monospace; font-size: 12.5px;
  color: var(--text-secondary); background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--r-xs); padding: 8px 11px; overflow: auto; white-space: nowrap; line-height: 1.5;
}
.copy-btn {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: var(--r-xs); border: 1px solid var(--border);
  background: var(--bg-hover); color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.copy-btn:hover { background: var(--accent-soft); color: var(--accent-hover); border-color: var(--border-hover); }
.copy-btn.copied { background: rgba(34,197,94,.14); color: #4ade80; border-color: rgba(34,197,94,.25); }

/* Review text preview block */
.text-preview {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 14px 16px; font-size: 14px; line-height: 1.6; color: var(--text-secondary);
  max-height: 180px; overflow-y: auto; white-space: pre-wrap;
}
.text-preview.empty { color: var(--text-faint); font-style: italic; }

/* Inline stars (read-only) */
.stars-ro { color: #fbbf24; letter-spacing: 2px; font-size: 15px; }
.stars-ro .off { color: var(--text-faint); }

/* ── Confirm dialog ── */
.confirm-modal { max-width: 420px; text-align: center; }
.confirm-modal::before { display: none; }
.confirm-modal .modal-body { padding: 32px 28px 8px; }
.confirm-icon {
  width: 60px; height: 60px; border-radius: 50%; margin: 0 auto 20px;
  display: flex; align-items: center; justify-content: center;
}
.confirm-icon.danger { background: rgba(239,68,68,.12); color: #f87171; box-shadow: 0 0 0 8px rgba(239,68,68,.05); }
.confirm-icon.warn { background: rgba(245,158,11,.12); color: #fbbf24; box-shadow: 0 0 0 8px rgba(245,158,11,.05); }
.confirm-icon.info { background: var(--accent-soft); color: var(--accent-hover); box-shadow: 0 0 0 8px rgba(99,102,241,.05); }
.confirm-title { font-size: 18px; font-weight: 700; color: var(--text-primary); margin: 0 0 8px; letter-spacing: -.02em; }
.confirm-text { font-size: 14px; color: var(--text-muted); margin: 0; line-height: 1.55; }
.confirm-text strong { color: var(--text-secondary); font-weight: 600; }
.confirm-actions { display: flex; gap: 10px; padding: 24px 28px 28px; }
.confirm-actions .btn { flex: 1; padding: 12px; }

/* ── Stars (interactive) ── */
.stars { display: flex; gap: 6px; padding: 4px 0; }
.star { width: 34px; height: 34px; cursor: pointer; fill: var(--border-strong); transition: fill .15s, transform .15s; filter: drop-shadow(0 1px 2px rgba(0,0,0,.1)); }
.star.active { fill: #fbbf24; filter: drop-shadow(0 1px 5px rgba(251,191,36,.4)); }
.star:hover { fill: #f59e0b; transform: scale(1.15); }
.star:active { transform: scale(.95); }

/* ── Toasts ── */
.toast {
  position: fixed; bottom: 30px; right: 30px; padding: 14px 18px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 600; z-index: 200; max-width: 380px;
  transform: translateY(90px) scale(.95); opacity: 0;
  transition: all .35s cubic-bezier(.16,1,.3,1);
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-lg); backdrop-filter: blur(14px); border: 1px solid transparent;
}
.toast .toast-ic { display: flex; flex-shrink: 0; }
.toast.show { transform: translateY(0) scale(1); opacity: 1; }
.toast-ok { background: rgba(20,83,45,.92); color: #86efac; border-color: rgba(34,197,94,.3); }
.toast-err { background: rgba(91,20,20,.92); color: #fca5a5; border-color: rgba(239,68,68,.32); }
[data-theme="light"] .toast-ok { background: rgba(240,253,244,.97); color: #15803d; border-color: rgba(34,197,94,.25); }
[data-theme="light"] .toast-err { background: rgba(254,242,242,.97); color: #b91c1c; border-color: rgba(239,68,68,.25); }

/* ── Utilities ── */
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; animation: pulse-dot 1.5s infinite; }
.page { display: none; animation: pageIn .35s ease; } .page.active { display: block; }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.2); border-top-color: currentColor; border-radius: 50%; animation: spin .6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 52px 24px; color: var(--text-muted); }
.empty-state svg { margin: 0 auto 16px; opacity: .35; }
.skeleton { background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-subtle) 50%, var(--bg-hover) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
/* ── Steps Tester (compact grid) ── */
.ts-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px;
}
.ts-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--border); cursor: pointer;
  transition: border-color .15s, background .15s;
  user-select: none; font-size: 13px;
}
.ts-item:hover { border-color: var(--border-hover); background: var(--bg-hover); }
.ts-item.running { border-color: #6366f1; background: rgba(99,102,241,.06); }
.ts-item.passed { border-color: rgba(34,197,94,.3); background: rgba(34,197,94,.04); }
.ts-item.failed { border-color: rgba(239,68,68,.3); background: rgba(239,68,68,.04); }

.ts-item .ts-cb { width: 14px; height: 14px; flex-shrink: 0; margin: 0; }
.ts-status {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  border: 1.5px solid var(--border); display: flex; align-items: center;
  justify-content: center; font-size: 10px; transition: all .2s;
}
.ts-item.passed .ts-status { border-color: #22c55e; background: #22c55e; color: #fff; }
.ts-item.passed .ts-status::after { content: '✓'; }
.ts-item.failed .ts-status { border-color: #ef4444; background: #ef4444; color: #fff; }
.ts-item.failed .ts-status::after { content: '✗'; }
.ts-item.running .ts-status { border-color: #6366f1; border-top-color: transparent; animation: spin .6s linear infinite; }

.ts-info { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.ts-num {
  width: 18px; height: 18px; border-radius: 4px; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: var(--bg-hover); color: var(--text-muted);
}
.ts-item.passed .ts-num { background: rgba(34,197,94,.12); color: #4ade80; }
.ts-item.failed .ts-num { background: rgba(239,68,68,.12); color: #f87171; }
.ts-name { color: var(--text-primary); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-item.passed .ts-name { color: #4ade80; }
.ts-item.failed .ts-name { color: #f87171; }
