:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #14181f;
  --muted: #5d6673;
  --line: #dde1e7;
  --accent: #2f6df6;
  --ok: #0f7b4f;
  --warn: #9a6200;
  --danger: #b3261e;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --panel: #171b21;
    --ink: #e8ebef;
    --muted: #9aa4b1;
    --line: #2a313a;
    --accent: #6795ff;
    --ok: #4ec98a;
    --warn: #e0aa4a;
    --danger: #ff7b72;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* author display rules must not defeat `hidden` */

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

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

h1 { font-size: 24px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0; letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted); }

.head { margin-bottom: 24px; }
.sub { color: var(--muted); margin: 6px 0 0; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.row.tight { justify-content: flex-start; }
.row.tight input { flex: 1; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

label {
  display: block;
  font-weight: 500;
  margin-bottom: 14px;
}

input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  font: inherit;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 13px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
}
input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}

small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 400;
}

button {
  padding: 9px 15px;
  font: inherit;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { filter: brightness(1.07); }
button:disabled { opacity: 0.55; cursor: default; filter: none; }

button.ghost {
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
}
button.ghost.danger { color: var(--danger); }

.field {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.field:first-child { border-top: 0; padding-top: 4px; }
.field label { margin-bottom: 0; }

.badge {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.badge.set { color: var(--ok); border-color: currentColor; }
.badge.env { color: var(--warn); border-color: currentColor; }
.badge.unset { color: var(--muted); }

.msg {
  margin: 12px 0 0;
  font-size: 13.5px;
  white-space: pre-wrap;
}
.msg:empty { display: none; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--danger); }
.msg.warn { color: var(--warn); }

code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.9em;
  padding: 1px 5px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
}

.note {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}
.note + .note { margin-top: 8px; }

/* ---------------------------------------------------------------- designer ---- */

.wrap.wide { max-width: 1080px; }
.card.narrow { max-width: 480px; }

.btnlink {
  display: inline-block;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 7px;
  text-decoration: none;
  white-space: nowrap;
}
.btnlink:hover { border-color: var(--accent); color: var(--accent); }

.columns {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 760px) {
  .columns { grid-template-columns: 1fr; }
  .sidebar { order: 2; }
}

button.full { width: 100%; margin-bottom: 10px; }

.designs { display: flex; flex-direction: column; gap: 4px; }
.design-item {
  display: block;
  width: 100%;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 10px;
}
.design-item:hover { background: var(--panel); border-color: var(--line); filter: none; }
.design-item.active { background: var(--panel); border-color: var(--accent); }
.design-item .t {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.design-item .s { display: block; font-size: 11.5px; color: var(--muted); }

.chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 46vh;
  min-height: 60px;
  overflow-y: auto;
  padding: 4px 2px;
  margin-bottom: 12px;
}
.bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  white-space: pre-wrap;
}
.bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bubble.assistant {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.bubble.assistant ul { margin: 6px 0 0; padding-left: 18px; }
.bubble.assistant .why { color: var(--muted); font-size: 12.5px; }
.bubble.pending { color: var(--muted); font-style: italic; }
.bubble.warn { border-color: var(--warn); }

.composer {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.composer input { flex: 1; margin-top: 0; font-family: inherit; font-size: 14px; }

.wrap-row { flex-wrap: wrap; margin-top: 10px; }

.specbox summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.specbox textarea {
  width: 100%;
  margin: 12px 0 10px;
  padding: 10px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12.5px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  resize: vertical;
}

.empty-state { color: var(--muted); }
.empty-state em { color: var(--ink); }
.empty-art { text-align: center; margin: 10px 0 18px; opacity: 0.95; }

/* ---------------------------------------------------------------- branding ---- */

.brand { display: flex; align-items: center; gap: 12px; }
.brand img { border-radius: 10px; display: block; }

.hero { text-align: center; margin: 8vh 0 26px; }
.hero img { border-radius: 16px; margin-bottom: 14px; }
.hero .sub { max-width: 420px; margin-left: auto; margin-right: auto; }
.card.centered { margin-left: auto; margin-right: auto; }

.whoami { color: var(--muted); font-size: 13.5px; margin-right: 4px; }

/* ---------------------------------------------------------- filter + delete ---- */

.filter {
  width: 100%;
  margin: 10px 0 8px;
  padding: 8px 11px;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.filter:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.chip:hover { filter: none; color: var(--ink); }
.chip.active { color: #fff; background: var(--accent); border-color: var(--accent); }

.design-item {
  display: flex;
  align-items: stretch;
  border: 1px solid transparent;
  border-radius: 7px;
  overflow: hidden;
}
.design-item:hover { background: var(--panel); border-color: var(--line); }
.design-item.active { background: var(--panel); border-color: var(--accent); }
.design-item .open {
  flex: 1;
  min-width: 0;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 0;
  padding: 8px 4px 8px 10px;
}
.design-item .open:hover { filter: none; }
.design-item .del {
  flex: 0 0 auto;
  width: 28px;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: 16px;
  opacity: 0;
}
.design-item:hover .del { opacity: 1; }
.design-item .del:hover { color: var(--danger); filter: none; }

.note.dim { padding: 8px 4px; }

dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  background: transparent;
  max-width: 420px;
  width: 92%;
}
dialog::backdrop { background: rgba(10, 14, 20, 0.55); }
dialog .card { margin-bottom: 0; }
dialog h2 { margin-bottom: 14px; }

/* ------------------------------------------------------------------- users ---- */

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.user-row:first-child { border-top: 0; }
.user-row .u { font-weight: 500; min-width: 120px; }
.user-row .c { color: var(--muted); font-size: 12.5px; flex: 1; }
button.small { padding: 5px 10px; font-size: 12.5px; }

.useradd { margin-top: 14px; flex-wrap: wrap; }
.useradd input { flex: 1; min-width: 130px; margin-top: 0; }
.useradd select {
  padding: 9px 11px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
}
