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

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f2f4f7;
  --text-primary: #101828;
  --text-secondary: #354052;
  --text-tertiary: #676f83;
  --text-quaternary: #98a2b2;
  --border-default: rgb(16 24 40 / 0.08);
  --border-strong: #d0d5dc;
  --border-subtle: rgb(16 24 40 / 0.04);
  --card: #ffffff;
  --primary: #155aef;
  --primary-hover: #004aeb;
  --accent-indigo: #444ce7;
  --shadow-card: 0 1px 2px rgb(16 24 40 / 0.05);
  --radius-md: 8px;
  --radius-lg: 12px;
}

/* Dark theme — applies when (a) user OS prefers dark and no .light override,
   or (b) :root has explicit .dark class (set by portal_theme cookie). */
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --bg-primary: #14181f;
    --bg-secondary: #1a1f29;
    --bg-tertiary: #232936;
    --text-primary: #f5f7fa;
    --text-secondary: #c8ccd5;
    --text-tertiary: #98a2b2;
    --text-quaternary: #676f83;
    --border-default: rgb(255 255 255 / 0.08);
    --border-strong: #354052;
    --border-subtle: rgb(255 255 255 / 0.04);
    --card: #1a1f29;
  }
}
:root.dark {
  --bg-primary: #14181f;
  --bg-secondary: #1a1f29;
  --bg-tertiary: #232936;
  --text-primary: #f5f7fa;
  --text-secondary: #c8ccd5;
  --text-tertiary: #98a2b2;
  --text-quaternary: #676f83;
  --border-default: rgb(255 255 255 / 0.08);
  --border-strong: #354052;
  --border-subtle: rgb(255 255 255 / 0.04);
  --card: #1a1f29;
}

body {
  font-family: "Geist", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Header ─────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 0.5px solid var(--border-default);
  background: color-mix(in srgb, var(--bg-secondary) 82%, transparent);
  backdrop-filter: blur(8px);
}
.header-inner {
  max-width: 1280px;   /* match portal max-w-7xl so brand doesn't shift */
  margin: 0 auto;
  height: 56px;        /* portal uses h-14 */
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;     /* portal px-4 */
  gap: 16px;
}
@media (min-width: 640px) {
  .header-inner { padding: 0 32px; }  /* portal sm:px-8 */
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-indigo) 100%);
  box-shadow: 0 1px 2px rgb(16 24 40 / 0.06), inset 0 1px 0 rgb(255 255 255 / 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: -0.04em;
  color: white;
}
.brand-name {
  font-size: 14px;       /* tailwind text-sm */
  font-weight: 600;
  letter-spacing: -0.025em;  /* tailwind tracking-tight */
  color: var(--text-primary);
}
.brand-ai { color: var(--primary); }
.header-crumb {
  font-size: 13px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Main ────────────────────────────────────────── */
.main {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}
@media (max-width: 640px) {
  .header-inner { padding: 0 16px; }
  .main { padding: 24px 16px 60px; }
}

/* ── Section intro ───────────────────────────────── */
.section-intro { margin-bottom: 24px; }
.section-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.section-desc {
  color: var(--text-tertiary);
  max-width: 580px;
  font-size: 14px;
  line-height: 1.6;
}

/* ── Examples panel ──────────────────────────────── */
.examples-panel {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-card);
  padding: 16px;
  margin-bottom: 16px;
}
.examples-header {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 12px;
}
.examples-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.examples-subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.5;
}
.examples-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
  margin-bottom: 10px;
}
.examples-list:empty::before {
  content: "Zatím žádné vzory — přidejte alespoň jeden níže";
  font-size: 12px;
  color: var(--text-quaternary);
  font-style: italic;
  padding: 6px 0;
}
.example-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: color-mix(in srgb, var(--primary) 10%, var(--bg-primary));
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  color: var(--text-primary);
  padding: 4px 4px 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-family: ui-monospace, monospace;
}
.example-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 0;
  transition: background 0.1s, color 0.1s;
}
.example-chip-remove:hover {
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  color: var(--text-primary);
}
.example-chip-remove svg {
  width: 12px;
  height: 12px;
}
.examples-input-row {
  display: flex;
  gap: 8px;
}
.example-input {
  flex: 1;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-width: 0;
}
.example-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.example-add-btn {
  flex-shrink: 0;
}

/* ── Drop zone ───────────────────────────────────── */
.drop-zone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--card);
  padding: 56px 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  box-shadow: var(--shadow-card);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 4%, var(--card));
}
.drop-icon {
  width: 44px;
  height: 44px;
  color: var(--text-quaternary);
  margin: 0 auto 18px;
  display: block;
  transition: color 0.15s;
}
.drop-zone:hover .drop-icon, .drop-zone.drag-over .drop-icon {
  color: var(--primary);
}
.drop-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.drop-or {
  font-size: 13px;
  color: var(--text-quaternary);
  margin-bottom: 14px;
}
.drop-formats {
  font-size: 12px;
  color: var(--text-quaternary);
  margin-top: 14px;
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, box-shadow 0.15s;
  line-height: 1;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgb(21 90 239 / 0.25);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover { background: var(--border-strong); }
.btn-icon { width: 15px; height: 15px; flex-shrink: 0; }

/* ── Processing card ─────────────────────────────── */
.processing-card {
  background: var(--card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 56px 32px;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 0 auto 22px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
}
.steps-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
  margin: 0 auto;
  text-align: left;
}
.step-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
}
.step-item.active {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--bg-primary));
}
.step-item.done { color: #17b26a; }
.step-item.error { color: #d92d20; background: #fef3f2; }
.step-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ── Results ─────────────────────────────────────── */
.results-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.results-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: 4px;
}
.results-meta {
  font-size: 13px;
  color: var(--text-tertiary);
}
.results-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Table ───────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  background: var(--card);
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 500px;
}
thead {
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-default);
}
th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  white-space: nowrap;
}
td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:nth-child(even) td { background: var(--bg-secondary); }
td[contenteditable]:focus {
  outline: none;
  background: color-mix(in srgb, var(--primary) 6%, var(--bg-primary));
  box-shadow: inset 0 0 0 1.5px var(--primary);
  border-radius: 3px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
}
.badge-rule { background: #d1e0ff; color: #004aeb; }
.badge-llm  { background: #d1fae5; color: #065f46; }
@media (prefers-color-scheme: dark) {
  .badge-rule { background: #1e3a8a; color: #93c5fd; }
  .badge-llm  { background: #064e3b; color: #6ee7b7; }
}

.table-hint {
  font-size: 12px;
  color: var(--text-quaternary);
  margin-top: 8px;
}

.hidden { display: none !important; }
