:root {
  --bg: #0b1220;
  --bg-elev: #111a2b;
  --surface: #141e31;
  --surface-2: #1a2740;
  --border: #24334d;
  --border-strong: #33456a;
  --text: #e7eefb;
  --muted: #92a4c1;
  --faint: #6b7d9b;
  --accent: #38bdf8;
  --accent-ink: #04121d;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 40px rgba(2, 8, 20, 0.45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(1100px 600px at 12% -8%, rgba(56, 189, 248, 0.13), transparent 60%),
    radial-gradient(900px 500px at 95% 0%, rgba(129, 140, 248, 0.1), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 1.5rem;
}

h2 {
  font-size: 1.05rem;
}

h3 {
  font-size: 0.95rem;
}

p {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.faint {
  color: var(--faint);
}

.mono {
  font-family: var(--mono);
  font-size: 0.86em;
}

.small {
  font-size: 0.85rem;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 22px;
  background: rgba(11, 18, 32, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 650;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 26px;
  height: 26px;
  display: block;
}

.brand small {
  display: block;
  font-weight: 450;
  color: var(--faint);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar-spacer {
  flex: 1;
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--surface);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- layout */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 22px 72px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-head .grow {
  flex: 1;
  min-width: 240px;
}

.page-head p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-elev));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card + .card {
  margin-top: 18px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.card-head .grow {
  flex: 1;
}

.section-title {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 550;
  cursor: pointer;
}

.btn:hover {
  background: #22304e;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: #7dd3fc;
}

.btn-sm {
  height: 30px;
  padding: 0 11px;
  font-size: 0.82rem;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

/* ---------------------------------------------------------------- app grid */

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.app-card {
  --accent: #38bdf8;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  background: linear-gradient(180deg, var(--surface), var(--bg-elev));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.app-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent);
  opacity: 0.85;
}

.app-card h2 {
  font-size: 1.08rem;
}

.app-card .desc {
  color: var(--muted);
  font-size: 0.88rem;
  min-height: 2.6em;
}

.app-card .meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--faint);
  border-top: 1px solid var(--border);
  padding-top: 11px;
}

.app-card .meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.app-card .meta-row span:last-child {
  color: var(--muted);
  text-align: right;
  overflow-wrap: anywhere;
}

.app-card .actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

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

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-built {
  color: var(--ok);
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.3);
}

.status-none {
  color: var(--warn);
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.3);
}

.status-error {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.3);
}

.status-planned {
  color: var(--muted);
  background: var(--surface-2);
  border-color: var(--border-strong);
}

/* ---------------------------------------------------------------- info grid */

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px 20px;
}

.info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.info dt {
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
}

.info dd {
  margin: 0;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- current build */

.current-build {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}

.current-build .figures {
  display: flex;
  gap: 26px;
  flex-wrap: wrap;
  flex: 1;
}

.figure {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.figure .k {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
}

.figure .v {
  font-size: 1.02rem;
  font-weight: 600;
}

/* ---------------------------------------------------------------- preview */

.preview-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.segmented button {
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  background: var(--surface-2);
  color: var(--text);
}

input[type="number"],
input[type="text"],
input[type="password"] {
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  width: 100%;
}

input:focus-visible,
button:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.dims {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.dims .field {
  width: 92px;
}

.dims .x {
  color: var(--faint);
  padding-bottom: 8px;
}

.preview-stage {
  /* The device geometry lives here so both the wrapper and the device inherit
     it; the console scales the whole phone visually rather than resizing the
     frame, which would change the viewport the preview is judged at. */
  --device-w: 390px;
  --device-h: 844px;
  --device-scale: 1;
  display: flex;
  justify-content: center;
  padding: 20px 8px 26px;
  border-top: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(56, 189, 248, 0.03), transparent),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.012) 0 10px, transparent 10px 20px);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.device-wrap {
  width: calc(var(--device-w) * var(--device-scale));
  height: calc(var(--device-h) * var(--device-scale));
  display: flex;
  justify-content: center;
  flex: none;
}

.device {
  width: var(--device-w);
  height: var(--device-h);
  flex: none;
  overflow: hidden;
  border-radius: 26px;
  background: #060b14;
  box-shadow:
    0 0 0 9px #1b2433,
    0 0 0 11px #3a4a68,
    0 22px 48px rgba(0, 0, 0, 0.5);
  transform: scale(var(--device-scale));
  transform-origin: top center;
}

.device iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.preview-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 4px;
  padding: 11px 13px;
  border: 1px solid rgba(251, 191, 36, 0.28);
  background: rgba(251, 191, 36, 0.07);
  border-radius: var(--radius-sm);
  color: #e8d9a8;
  font-size: 0.84rem;
}

.preview-note strong {
  color: var(--warn);
}

.preview-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 46px 20px;
  color: var(--muted);
  text-align: center;
}

/* ---------------------------------------------------------------- table */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
  background: var(--bg);
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: rgba(56, 189, 248, 0.05);
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

td .row-current {
  margin-left: 8px;
}

.empty {
  padding: 30px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.notice {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.08);
  color: #fecaca;
  font-size: 0.86rem;
}

/* ---------------------------------------------------------------- login */

body.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, var(--surface), var(--bg-elev));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 26px;
}

.login-card .brand-mark {
  width: 34px;
  height: 34px;
  margin-bottom: 14px;
}

.login-card h1 {
  font-size: 1.25rem;
  margin-bottom: 4px;
}

.login-card > p {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 20px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-card label {
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
  margin-top: 10px;
}

.login-card .btn {
  margin-top: 18px;
  width: 100%;
}

.error {
  margin-top: 12px;
  color: var(--danger);
  font-size: 0.86rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
}

@media (max-width: 640px) {
  .page {
    padding: 18px 14px 60px;
  }
  .who .role {
    display: none;
  }
}
