@font-face { font-family: 'Montserrat'; src: url('/fonts/montserrat.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('/fonts/jetbrains-mono.woff2') format('woff2'); font-weight: 400; font-display: swap; }

:root {
  /* The Coder by Shtim: black, white, and the logo's blue-to-purple */
  --paper: #F4F5FA;
  --surface: #FFFFFF;
  --navy: #12131C;          /* main text */
  --navy-2: #3B4057;        /* secondary text */
  --fog: #6D7287;
  --rule: #DCDEE8;
  --blue: #3C99FE;
  --purple: #8B5CF6;
  --brand: linear-gradient(100deg, #3C99FE 0%, #6F6CFB 55%, #9A5AFC 100%);
  --yellow: #6F6CFB;        /* accent (kept name for older rules) */
  --yellow-ink: #FFFFFF;
  --teal: #0F8A6E;
  --teal-bg: #E2F4EE;
  --red: #D23B3B;
  --red-bg: #FCECEC;
  --amber-bg: #FFF6DE;
  --amber-ink: #6B4E00;
  --log-bg: #0B0C12;
  --radius-s: 8px;
  --radius-m: 12px;
  --sans: 'Montserrat', ui-sans-serif, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--navy); font-family: var(--sans); font-size: 16px; line-height: 1.5; }
a { color: var(--navy); text-underline-offset: 3px; }
code, .mono { font-family: var(--mono); font-size: 0.86em; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 700; letter-spacing: -0.015em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); letter-spacing: -0.025em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
.muted { color: var(--fog); }
.small { font-size: 0.875rem; }
:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; border-radius: 3px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px clamp(14px, 4vw, 40px); background: #000; position: sticky; top: 0; z-index: 10; }
.topbar .brand img { height: 40px; width: auto; display: block; }
.topbar .btn-quiet { color: #E6E8F2; }
.topbar .btn-quiet:hover { background: #1A1C27; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.15rem; text-decoration: none; letter-spacing: -0.02em; }

.wrap { max-width: 1120px; margin: 0 auto; padding: clamp(20px, 4vw, 44px) clamp(16px, 4vw, 40px) 96px; }

/* ---------- buttons & inputs ---------- */
button, .btn { font: inherit; font-weight: 600; font-size: 0.95rem; border-radius: var(--radius-s); border: 1px solid var(--rule); background: var(--surface); color: var(--navy); padding: 9px 16px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; line-height: 1.2; white-space: nowrap; }
button:hover, .btn:hover { border-color: var(--navy-2); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--brand); filter: brightness(1.08); border-color: transparent; }
.btn-big { font-size: 1.05rem; padding: 13px 22px; }
.btn-quiet { border-color: transparent; background: transparent; padding: 6px 10px; }
.btn-quiet:hover { background: #ECEDF5; border-color: transparent; }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); }
.btn-tiny { font-size: 0.8rem; padding: 4px 10px; }

label.field { display: block; }
label.field > span { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=url], select, textarea { font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--surface); color: var(--navy); }
input.mono-input { font-family: var(--mono); font-size: 0.9rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25); }
input.has-error { border-color: var(--red); }
input.has-warn { border-color: #D9A400; }
.input-row { display: flex; gap: 8px; }
.input-row > input { flex: 1; min-width: 0; }

/* ---------- home ---------- */
.home-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.site-list { border-top: 1px solid var(--rule); }
.site-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 18px 4px; border-bottom: 1px solid var(--rule); text-decoration: none; color: inherit; }
.site-row:hover { background: #ECEDF5; }
.site-row .name { font-weight: 700; font-size: 1.1rem; }
.site-row .meta { color: var(--fog); font-size: 0.9rem; grid-column: 1; }
.site-row .state { grid-row: 1 / span 2; grid-column: 2; align-self: center; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: #ECEDF5; color: var(--navy-2); white-space: nowrap; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.live { background: var(--teal-bg); color: var(--teal); }
.pill.building, .pill.queued { background: var(--amber-bg); color: var(--amber-ink); }
.pill.building::before { animation: pulse 1s infinite alternate; }
.pill.failed { background: var(--red-bg); color: var(--red); }
.pill.plain::before { display: none; }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.25; } }

/* ---------- new site ---------- */
.new-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: clamp(20px, 4vw, 48px); margin-top: 28px; align-items: start; }
.drop { border: 2px dashed #A9B8C3; border-radius: var(--radius-m); background: var(--surface); padding: 48px 24px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; display: block; }
.drop:hover, .drop.over { border-color: var(--navy); background: #FBFCFD; }
.drop.over { background: #F3F0FF; border-color: var(--purple); }
.drop strong { display: block; font-size: 1.25rem; margin: 14px 0 6px; }
.drop svg { width: 44px; height: 44px; color: var(--navy-2); }
.or-side h2 { margin-bottom: 6px; }
.stack { display: grid; gap: 14px; }
details.more > summary { cursor: pointer; color: var(--navy-2); font-weight: 600; font-size: 0.92rem; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: '+ '; }
details.more[open] > summary::before { content: '− '; }
details.more[open] > summary { margin-bottom: 12px; }
.busy { display: flex; align-items: center; gap: 14px; padding: 28px 0; font-size: 1.1rem; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--rule); border-top-color: var(--navy); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- site page ---------- */
.site-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 32px; }
.site-head .url { display: inline-flex; gap: 8px; align-items: center; margin-top: 8px; font-size: 1.02rem; color: var(--navy-2); }
.site-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.layout { display: grid; grid-template-columns: 250px 1fr; gap: clamp(24px, 4vw, 56px); align-items: start; }

/* the pre-flight checklist */
.preflight { position: sticky; top: 84px; }
.preflight h3 { font-size: 0.95rem; color: var(--fog); font-weight: 600; margin-bottom: 10px; }
.preflight ol { list-style: none; margin: 0; padding: 0; counter-reset: pf; }
.preflight li { counter-increment: pf; }
.preflight a { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; padding: 9px 8px; border-radius: var(--radius-s); text-decoration: none; }
.preflight a:hover { background: #ECEDF5; }
.preflight .mark { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #B7C4CD; display: grid; place-items: center; font-size: 0.78rem; font-weight: 700; color: var(--fog); background: var(--surface); }
.preflight .mark::after { content: counter(pf); }
.preflight .done .mark { background: var(--teal); border-color: var(--teal); color: #fff; }
.preflight .done .mark::after { content: '✓'; font-size: 0.9rem; }
.preflight .todo .mark { border-color: var(--purple); color: var(--purple); background: #F3F0FF; }
.preflight .bad .mark { border-color: var(--red); color: #fff; background: var(--red); }
.preflight .bad .mark::after { content: '!'; }
.preflight .label { font-weight: 600; line-height: 1.25; display: block; }
.preflight .sub { font-size: 0.82rem; color: var(--fog); display: block; margin-top: 1px; }
.preflight .done .sub { color: var(--teal); }
.preflight .meter { height: 6px; border-radius: 3px; background: var(--rule); margin: 16px 8px 6px; overflow: hidden; }
.preflight .meter > i { display: block; height: 100%; background: var(--teal); transition: width .4s ease; }

section.block { padding: 32px 0; border-top: 1px solid var(--rule); scroll-margin-top: 80px; }
section.block:first-child { border-top: 0; padding-top: 0; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 6px; flex-wrap: wrap; }
.block-intro { color: var(--navy-2); max-width: 64ch; margin-bottom: 20px; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: var(--radius-m); overflow: hidden; margin-bottom: 18px; }
.facts > div { background: var(--surface); padding: 14px 16px; }
.facts dt { font-size: 0.82rem; color: var(--fog); }
.facts dd { margin: 2px 0 0; font-weight: 650; overflow-wrap: anywhere; }

.notice { border-left: 4px solid var(--fog); background: var(--surface); padding: 14px 16px; border-radius: 0 var(--radius-s) var(--radius-s) 0; margin-bottom: 12px; }
.notice h4 { margin: 0 0 4px; font-size: 1rem; }
.notice.error { border-color: var(--red); background: var(--red-bg); }
.notice.warn { border-color: #E3A008; background: var(--amber-bg); }
.notice.info { border-color: var(--navy-2); }
.notice.ok { border-color: var(--teal); background: var(--teal-bg); }
.notice pre { margin-top: 10px; }

/* variables */
.var { padding: 18px 0; border-bottom: 1px solid var(--rule); display: grid; gap: 8px; }
.var:last-child { border-bottom: 0; }
.var-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.var-name { font-family: var(--mono); font-size: 0.95rem; font-weight: 400; overflow-wrap: anywhere; }
.var-label { color: var(--navy-2); font-size: 0.95rem; }
.var-where { font-size: 0.88rem; color: var(--fog); }
.var-where a { color: var(--navy-2); font-weight: 600; }
.tag { font-size: 0.78rem; font-weight: 600; padding: 2px 9px; border-radius: 4px; white-space: nowrap; }
.tag.public { background: #E6F0FF; color: #1F5FBF; }
.tag.build { background: #EFE9FE; color: #5B34C2; }
.tag.unavailable { background: #EEF1F3; color: var(--fog); }
.tag.req { background: var(--amber-bg); color: var(--amber-ink); }
.issue { font-size: 0.88rem; display: flex; gap: 8px; align-items: flex-start; }
.issue.error { color: var(--red); }
.issue.warn { color: var(--amber-ink); }
.issue::before { content: '!'; flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 0.72rem; font-weight: 800; color: #fff; background: currentColor; margin-top: 2px; }
.issue.error::before { background: var(--red); color: #fff; }
.issue.warn::before { background: #D9A400; }
.issue span { color: inherit; }
.saved { font-size: 0.8rem; color: var(--teal); font-weight: 600; min-height: 1em; }
.group-title { font-weight: 650; margin: 22px 0 2px; color: var(--navy-2); }

/* database walkthrough (a real sequence, so it's numbered) */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: st; }
.step { counter-increment: st; display: grid; grid-template-columns: 40px 1fr; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--rule); }
.step:last-child { border-bottom: 0; }
.step-num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--surface); border: 2px solid #B7C4CD; color: var(--navy-2); }
.step-num::after { content: counter(st); }
.step.done .step-num { background: var(--teal); border-color: var(--teal); color: #fff; }
.step.done .step-num::after { content: '✓'; }
.step.done h3 { color: var(--fog); }
.step-body { display: grid; gap: 10px; min-width: 0; }
.step-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; font-weight: 600; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--teal); }

pre.code { background: var(--log-bg); color: #DCE6F2; font-family: var(--mono); font-size: 0.8rem; line-height: 1.55; padding: 14px 16px; border-radius: var(--radius-s); overflow: auto; max-height: 260px; margin: 0; white-space: pre; }
.codebox { position: relative; }
.codebox .copy { position: absolute; top: 8px; right: 8px; background: #23253A; color: #fff; border-color: #23253A; }
.codebox .copy:hover { background: #30334D; }
.filetitle { font-family: var(--mono); font-size: 0.82rem; color: var(--navy-2); margin-bottom: 4px; }
.copyline { display: flex; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-s); padding: 6px 6px 6px 12px; }
.copyline code { flex: 1; overflow-x: auto; white-space: nowrap; }

/* deploy panel */
.deploy-bar { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 22px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); }
.deploy-bar .grow { flex: 1; min-width: 220px; }
.blockers { margin: 14px 0 0; padding-left: 20px; color: var(--navy-2); }
.blockers li { margin: 4px 0; }
.blockers li.hard { color: var(--red); }
.log { background: var(--log-bg); color: #CFDBEA; font-family: var(--mono); font-size: 0.8rem; line-height: 1.6; padding: 16px 18px; border-radius: var(--radius-m); max-height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin-top: 16px; }
.log .step-line { color: #9DBBFF; font-weight: 400; }
.log .err-line { color: #FF8A80; }
.log .ok-line { color: #7FDBCA; }

.live-moment { margin-top: 16px; padding: 28px; border-radius: var(--radius-m); background: #000; color: #fff; display: grid; gap: 10px; animation: rise .5s ease both; position: relative; overflow: hidden; }
.live-moment::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--brand); }
.live-moment h2 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); }
.live-moment a.big { color: #A8C8FF; font-size: clamp(1.05rem, 2.6vw, 1.4rem); font-weight: 650; overflow-wrap: anywhere; }
.live-moment .row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.live-moment .btn { background: transparent; color: #fff; border-color: #3A3D52; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.history { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.history td { padding: 12px 8px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.history tr:last-child td { border-bottom: 0; }
.history .commit { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .acts { text-align: right; white-space: nowrap; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.toggle { display: flex; gap: 12px; align-items: flex-start; }
.toggle input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--purple); flex: none; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #000; color: #fff; padding: 12px 18px; border-radius: var(--radius-s); max-width: min(560px, 92vw); z-index: 100; box-shadow: 0 8px 24px rgba(19, 41, 75, 0.25); animation: rise .25s ease both; }
.toast.error { background: var(--red); }

.empty { padding: 40px 0 8px; max-width: 60ch; }
.empty h2 { font-size: 1.6rem; margin-bottom: 8px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .preflight { position: static; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 14px; }
  .new-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .history .hide-sm { display: none; }
}

/* sign in, nav, database viewer */
.topnav { display: flex; gap: 8px; align-items: center; }
.login { max-width: 420px; margin: 8vh auto 0; }
.login h1 { margin-bottom: 4px; }
.tag.worker { background: #E3F2EF; color: #0B5E53; }
.dbview:empty { display: none; }
.dbview { display: grid; gap: 14px; margin-top: 6px; padding: 16px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); }
.db-tables { display: flex; gap: 8px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius-s); }
table.rows { border-collapse: collapse; font-size: 0.82rem; width: 100%; }
table.rows th, table.rows td { padding: 7px 10px; border-bottom: 1px solid var(--rule); text-align: left; white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
table.rows th { background: #F7F9FA; font-weight: 650; font-family: var(--mono); font-size: 0.78rem; }
table.rows tr:last-child td { border-bottom: 0; }
textarea.mono-input { font-family: var(--mono); font-size: 0.85rem; resize: vertical; }

fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain legend { font-weight: 650; padding: 0; margin-bottom: 8px; }

/* sign-in screen with the full logo */
.brand-panel { background: #000; border-radius: var(--radius-m); padding: 22px 18px; display: grid; place-items: center; margin-bottom: 8px; }
.brand-panel img { width: 100%; max-width: 300px; height: auto; }
.preflight .meter > i { background: var(--brand); }
h1 { font-weight: 800; }
