:root {
  --ink: #1a1d21;
  --muted: #5c6470;
  --line: #d9dde3;
  --bg: #f4f5f7;
  --card: #ffffff;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --error-bg: #fdecea;
  --error-ink: #8a1f17;
  --notice-bg: #e8f4ec;
  --notice-ink: #1d5c33;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 650; letter-spacing: 0.01em; }

.mainnav { display: flex; gap: 1.1rem; margin-right: auto; margin-left: 1.5rem; }
.mainnav a { text-decoration: none; color: var(--muted); font-size: 0.9rem; font-weight: 550; }
.mainnav a:hover { color: var(--ink); }

.usernav { display: flex; align-items: center; gap: 0.75rem; }
.username { color: var(--muted); font-size: 0.9rem; }

.page { max-width: 60rem; margin: 2.5rem auto; padding: 0 1.25rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.75rem 2rem;
}

.card.narrow { max-width: 24rem; margin: 0 auto; }

h1 { font-size: 1.3rem; margin: 0 0 1rem; }

label { display: block; margin: 0.9rem 0 0.3rem; font-size: 0.9rem; font-weight: 550; }

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: var(--card);
}

input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

button[type="submit"] {
  margin-top: 1.25rem;
  width: 100%;
  padding: 0.6rem 1rem;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button[type="submit"]:hover { filter: brightness(1.07); }

button.linklike {
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  padding: 0;
}

button.linklike:hover { text-decoration: underline; }

.usernav form { margin: 0; }
.usernav button.linklike { width: auto; margin: 0; font-weight: 500; }

.form-error {
  background: var(--error-bg);
  color: var(--error-ink);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
}

.notice {
  background: var(--notice-bg);
  color: var(--notice-ink);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
}

a { color: var(--accent); }

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

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card-head h1 { margin: 0; }

.btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}
.btn:hover { filter: brightness(1.07); }

/* Wide tables scroll inside their own box so they never widen the card/page. */
.table-wrap { overflow-x: auto; margin-top: 1.25rem; }
.table-wrap > table.grid { margin-top: 0; min-width: 34rem; }

table.grid { width: 100%; border-collapse: collapse; margin-top: 1.25rem; }
table.grid th, table.grid td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid td.wrap, table.grid th.wrap { white-space: normal; }
table.grid th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
td.actions { display: flex; gap: 0.9rem; align-items: center; }
td.actions form { margin: 0; }
td.actions button.linklike { width: auto; margin: 0; }

select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: var(--card);
}
input[type="number"] {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: var(--card);
}

label.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
label.check input { width: auto; }

.toggle { margin-top: 1.25rem; font-size: 0.9rem; }

.hint { color: var(--muted); font-size: 0.82rem; margin: 0.35rem 0 0; }

.tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  vertical-align: middle;
}

.link-box {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.7rem 0.8rem;
  word-break: break-all;
}
.link-box code { font-size: 0.9rem; }

/* ── Design-profile editor ─────────────────────────────────────────────── */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 21rem); gap: 1.5rem; align-items: start; }
@media (max-width: 48rem) { .editor { grid-template-columns: 1fr; } }
.editor-preview { position: sticky; top: 1rem; }

fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem 1.1rem 1.1rem; margin: 1rem 0; }
legend { font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 0 0.4rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin: 0.4rem 0; }
.role-row { display: grid; grid-template-columns: 5.5rem 7rem repeat(3, 1fr); gap: 0.5rem; align-items: center; margin: 0.45rem 0; }
.role-row .role-name { font-size: 0.85rem; color: var(--muted); }
.role-row input, .role-row select { width: 100%; }
.publish-form { margin-top: 0.75rem; }

/* ── Specimen (consumes the linked tokens.css vars, scoped to .specimen) ── */
.specimen h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0 0 0.75rem; }
.sw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(4rem, 1fr)); gap: 0.5rem; margin-bottom: 1.25rem; }
.sw-item { margin: 0; text-align: center; }
.sw { height: 2.75rem; border-radius: 6px; border: 1px solid rgba(0, 0, 0, 0.12); }
.sw-item figcaption { font-size: 0.68rem; color: var(--muted); margin-top: 0.2rem; word-break: break-all; }

.type-scale { border-top: 1px solid var(--line); padding-top: 1rem; margin-bottom: 1.25rem; }
.type-scale p { margin: 0.25rem 0; }
.specimen .type-display { font-size: calc(1rem * var(--type-display-scale, 3)); font-weight: var(--type-display-weight, 700); line-height: var(--type-display-line-height, 1.05); font-family: var(--type-display-font, inherit); }
.specimen .type-heading { font-size: calc(1rem * var(--type-heading-scale, 1.8)); font-weight: var(--type-heading-weight, 700); line-height: var(--type-heading-line-height, 1.15); font-family: var(--type-heading-font, inherit); }
.specimen .type-subheading { font-size: calc(1rem * var(--type-subheading-scale, 1.3)); font-weight: var(--type-subheading-weight, 600); font-family: var(--type-subheading-font, inherit); }
.specimen .type-body { font-size: calc(1rem * var(--type-body-scale, 1)); font-weight: var(--type-body-weight, 400); line-height: var(--type-body-line-height, 1.5); font-family: var(--type-body-font, inherit); }
.specimen .type-caption { font-size: calc(1rem * var(--type-caption-scale, 0.8)); color: var(--color-muted, var(--muted)); font-family: var(--type-caption-font, inherit); }

.demo-card { margin-top: 1.25rem; background: var(--color-surface, #f4f5f7); color: var(--color-ink, #1a1d21); border-radius: var(--radius, 8px); padding: calc(1.25rem * var(--density, 1)); }
.demo-card-title { margin: 0 0 0.4rem; }
.demo-btn { display: inline-block; margin-top: 0.75rem; padding: 0.5rem 1rem; border-radius: var(--radius, 8px); background: var(--color-primary, #1f6feb); color: var(--color-on-primary, #fff); font-size: 0.9rem; font-weight: 600; }
