:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1d2430;
  --muted: #677185;
  --border: #e1e5ec;
  --primary: #2f5bea;
  --primary-dark: #2448c0;
  --ok: #16833a;
  --ok-bg: #e5f5ea;
  --warn: #9a6200;
  --warn-bg: #fff3d6;
  --err: #b42318;
  --err-bg: #fdecea;
  --info: #2448c0;
  --info-bg: #e8eefd;
  --link: #2f5bea;
  --field: #ffffff;
  --btn: #ffffff;
  --on-primary: #ffffff;
  --topbar: #151b2b;
  --topbar-border: transparent;
  --code-bg: #f0f2f5;
}

/* Public pages (home, project): dark, content-first theme. The admin area keeps the light theme. */
body.theme-dark {
  --bg: #0a0a0b;
  --card: #131315;
  --text: #ededed;
  --muted: #8d8f96;
  --border: #26272c;
  --primary: #f5f5f5;
  --primary-dark: #d4d4d6;
  --on-primary: #0a0a0b;
  --ok: #4ade80;
  --ok-bg: rgba(74, 222, 128, .12);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, .12);
  --err: #f87171;
  --err-bg: rgba(248, 113, 113, .12);
  --info: #93b4ff;
  --info-bg: rgba(147, 180, 255, .12);
  --link: #c7d4ff;
  --field: #161618;
  --btn: #1c1c1f;
  --topbar: #0a0a0b;
  --topbar-border: #1f2023;
  --code-bg: #1c1c1f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 Inter, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); }
h1 { font-size: 22px; margin: 0 0 6px; word-break: break-all; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 10px; letter-spacing: -.01em; }
h3 { font-size: 15px; margin: 18px 0 6px; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }

.hidden { display: none !important; }
.muted { color: var(--muted); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: var(--topbar); color: #fff; border-bottom: 1px solid var(--topbar-border);
}
.brand { display: flex; align-items: center; gap: 9px; color: #fff; text-decoration: none; font-weight: 600; font-size: 17px; }
.brand-mark {
  width: 18px; height: 18px; border-radius: 5px;
  background: linear-gradient(135deg, #ffffff 0%, #9aa7ff 100%);
}
.model-badge { font-size: 12px; opacity: .55; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.admin-link { color: #fff; opacity: .8; font-size: 13px; text-decoration: none; }
.admin-link:hover { opacity: 1; text-decoration: underline; }

.login-card { max-width: 380px; margin: 40px auto; }
.login-card form { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.login-card label { font-weight: 600; font-size: 13px; margin-top: 6px; }
.login-card button { margin-top: 14px; }

.container { max-width: 980px; margin: 24px auto; padding: 0 16px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 20px 22px; margin-bottom: 18px;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 12px; text-decoration: none; }

.small { font-size: 13px; margin: 4px 0 0; }

/* --- Home hero --- */
body.theme-dark {
  background: radial-gradient(ellipse 900px 420px at 50% 0, rgba(140, 155, 255, .10), transparent 70%) no-repeat, var(--bg);
}
.hero { max-width: 720px; margin: 0 auto; padding: 96px 0 72px; text-align: center; }
.eyebrow {
  display: inline-block; margin: 0 0 22px; padding: 4px 12px; border: 1px solid var(--border); border-radius: 999px;
  font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: .02em;
}
.hero-title {
  font-size: clamp(38px, 6vw, 60px); line-height: 1.05; font-weight: 600; letter-spacing: -.035em;
  margin: 0 0 20px; word-break: normal;
}
.hero-sub { max-width: 600px; margin: 0 auto 40px; font-size: 18px; line-height: 1.55; color: var(--muted); }
.hero-sub code { font-size: .9em; color: var(--text); }

.hero-form { max-width: 600px; margin: 0 auto; text-align: left; }
.url-bar {
  display: flex; gap: 6px; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--field);
  transition: border-color .15s;
}
.url-bar:focus-within { border-color: #4b4d55; }
.url-bar input[type=text] { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 16px; padding: 10px 12px; }
.url-bar input[type=text]:focus { outline: none; }
.url-bar .btn { padding: 10px 22px; border-radius: 8px; font-weight: 600; }

.hero-options { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 18px; margin-top: 14px; font-size: 14px; }
.hero-options select { font-size: 13px; padding: 6px 10px; color: var(--muted); }
.optional { flex: 1 1 260px; }
.optional summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 6px 0; list-style: none; }
.optional summary::-webkit-details-marker { display: none; }
.optional summary:hover { color: var(--text); }
.optional[open] { flex-basis: 100%; }
.optional textarea { margin-top: 8px; min-height: 76px; }

.how {
  list-style: none; display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 28px;
  margin: 56px 0 0; padding: 0; font-size: 13px; color: var(--muted);
}
.how li { display: flex; align-items: center; gap: 8px; }
.how span {
  display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px;
  border: 1px solid var(--border); border-radius: 50%; font-size: 11px; color: var(--text);
}

.my-projects { max-width: 720px; margin: 0 auto 64px; padding-top: 32px; border-top: 1px solid var(--border); }
.my-projects h2 { font-size: 14px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.my-projects .small { margin-top: 12px; }
.my-projects .table td { vertical-align: middle; }

input[type=text], input[type=password], select, textarea {
  font: inherit; padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--field); color: var(--text);
}
textarea { width: 100%; min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--info-bg); border-color: var(--primary); }
input::placeholder, textarea::placeholder { color: #6b6d74; }

.btn {
  display: inline-block; font: inherit; padding: 9px 16px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--border); background: var(--btn); color: var(--text); text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-dark); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { color: var(--err); }
.btn:disabled { opacity: .6; cursor: default; }

.alert { margin-top: 14px; padding: 10px 14px; border-radius: 7px; }
.alert.error { background: var(--err-bg); color: var(--err); display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.table td.actions-cell { text-align: right; white-space: nowrap; }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--info-bg); color: var(--info); white-space: nowrap;
}
.badge.completed, .badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.waiting_input, .badge.medium { background: var(--warn-bg); color: var(--warn); }
.badge.failed, .badge.high, .badge.ko { background: var(--err-bg); color: var(--err); }
.badge.low { background: var(--bg); color: var(--muted); }

.steps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 16px 0 0; flex-wrap: wrap; }
.steps li {
  flex: 1 1 150px; padding: 8px 10px; border-radius: 7px; background: var(--bg); color: var(--muted);
  font-size: 13px; font-weight: 600; border-left: 4px solid var(--border);
}
.steps li.done { background: var(--ok-bg); color: var(--ok); border-left-color: var(--ok); }
.steps li.active { background: var(--info-bg); color: var(--info); border-left-color: var(--primary); }
.steps li.error { background: var(--err-bg); color: var(--err); border-left-color: var(--err); }

.progress { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: var(--info); }
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--info-bg); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.question { margin-bottom: 16px; }
.question label { display: block; font-weight: 600; margin-bottom: 6px; }

.qa { margin-bottom: 12px; }
.qa .q { font-weight: 600; }
.qa .a { white-space: pre-wrap; }

.output {
  background: #0c0d10; color: #e6e9ef; padding: 16px; border: 1px solid var(--border); border-radius: 8px; overflow: auto;
  max-height: 620px; white-space: pre-wrap; word-break: break-word; font-size: 13px;
  font-family: Consolas, "Cascadia Mono", Menlo, monospace;
}

.facts { display: grid; grid-template-columns: 160px 1fr; gap: 4px 14px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
ul.compact { margin: 4px 0; padding-left: 20px; }

@media (max-width: 640px) {
  .card-head { flex-direction: column; }
  .facts { grid-template-columns: 1fr; }
  .hero { padding: 56px 0 48px; }
  .hero-sub { font-size: 16px; }
  .topbar { padding: 12px 16px; }
  .model-badge { display: none; }
}
