/* Knot.

   Light and warm by default: paper ground, clay accent, pill buttons. This is
   its own product rather than a copy of dwynlabs.com, which is dark navy -
   the brand's own palette is kept as the `dwyn` theme so the three themes
   together show the range rather than one house style.

   Deliberately not the default framework blue anywhere.

   Typography uses a system stack rather than a webfont, so there is no font
   request on a 3G first load. The custom properties below are the theming
   contract: every surface, border and accent reads from them, so a theme is
   a dozen values and nothing else. */

:root {
  /* Paper ground */
  --bg: #fbf9f6;
  --surface: #ffffff;
  --surface-2: #f4f0ea;
  --fg: #1d1a16;
  --muted: #6f6962;
  --border: #e8e2d9;
  --border-strong: #d4ccbe;

  /* Clay, the one accent */
  --accent: #b8502a;
  --accent-ink: #ffffff;
  --accent-soft: rgba(184, 80, 42, 0.09);
  --danger: #a3301f;
  --neutral-soft: rgba(29, 26, 22, 0.07);

  --radius: 14px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(29, 26, 22, 0.05), 0 10px 28px rgba(29, 26, 22, 0.06);

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

/* .theme-classic is the default above; these two are the alternatives a
   profile can choose, which is what demonstrates the range. */

.theme-midnight {
  --bg: #0b0b0d;
  --surface: #16171a;
  --surface-2: #121316;
  --fg: #ededee;
  --muted: #9b9ba1;
  --border: #26272b;
  --border-strong: #3a3b41;
  --accent: #e2714a;
  --accent-ink: #1a0f09;
  --accent-soft: rgba(226, 113, 74, 0.14);
  --danger: #e0685c;
  --neutral-soft: rgba(237, 237, 238, 0.1);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
}

/* The dwynlabs.com palette, for anyone who wants the house look. */
.theme-dwyn {
  --bg: #060b16;
  --surface: #0f1a2e;
  --surface-2: #0c1527;
  --fg: #eceff4;
  --muted: #9fb0cc;
  --border: #1b2a47;
  --border-strong: #33405a;
  --accent: #e08a4c;
  --accent-ink: #1a1005;
  --accent-soft: rgba(224, 138, 76, 0.14);
  --danger: #e0685c;
  --neutral-soft: rgba(159, 176, 204, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Layout -------------------------------------------------------------- */

.wrap {
  max-width: 30rem;
  margin: 0 auto;
  padding: 3.5rem 1.25rem 1.5rem;
  text-align: center;
}

.wrap-wide { max-width: 64rem; text-align: left; padding-top: 2.25rem; }

.foot {
  padding: 1.5rem 1.25rem 2.5rem;
  color: var(--muted);
  font-size: 0.8125rem;
  text-align: center;
}

.foot a { color: inherit; text-decoration: none; }

.foot a:hover { color: var(--accent); }

/* --- Type ---------------------------------------------------------------- */

.brand {
  margin: 0 0 0.375rem;
  font-size: 1.75rem;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.lead { margin: 0 0 0.625rem; font-size: 1.0625rem; }

.body { margin: 0 0 2rem; color: var(--muted); }

.section-title {
  font-size: 0.9375rem;
  font-weight: 650;
  letter-spacing: -0.005em;
  margin: 0 0 0.75rem;
}

/* --- Buttons ------------------------------------------------------------- */

.actions { display: grid; gap: 0.625rem; margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 46px;
  padding: 0.6875rem 1.25rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.08s;
}

.btn:hover { border-color: var(--accent); background: var(--accent-soft); }

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: var(--accent);
  filter: brightness(1.08);
  border-color: var(--accent);
}

.btn-icon {
  min-height: 38px;
  padding: 0.3125rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--fg);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-icon:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger { color: var(--danger); }

.btn-danger:hover { border-color: var(--danger); color: var(--danger); }

/* --- Surfaces ------------------------------------------------------------ */

.card {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
}

/* --- Forms --------------------------------------------------------------- */

.form { display: grid; gap: 0.875rem; }

.field { display: grid; gap: 0.3125rem; text-align: left; }

.field-label {
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-prefix { font-size: 0.8125rem; color: var(--muted); }

.field-hint { font-size: 0.8125rem; color: var(--muted); margin: 0 0 0.75rem; }

.form-error, .form-status {
  font-size: 0.875rem;
  margin: 0;
  min-height: 1.25rem;
  color: var(--muted);
}

.is-error { color: var(--danger); }

input, textarea, select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font: inherit;
  color: var(--fg);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
}

input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.7; }

input:focus, textarea:focus, select:focus { border-color: var(--accent); }

textarea { resize: vertical; }

/* --- Tabs ---------------------------------------------------------------- */

.tab-bar {
  display: flex;
  gap: 0.375rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.tab {
  padding: 0.4375rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.tab:hover { color: var(--fg); border-color: var(--border-strong); }

.tab-on, .tab-on:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.tab-radio { position: absolute; opacity: 0; pointer-events: none; }

#tab-edit:checked ~ .tab-bar .tab[for="tab-edit"],
#tab-preview:checked ~ .tab-bar .tab[for="tab-preview"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* --- Editor -------------------------------------------------------------- */

.editor-head { margin-bottom: 1.25rem; }

.editor-who { color: var(--muted); font-size: 0.875rem; margin: 0; }

.publish {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.875rem;
  flex-wrap: wrap;
  padding: 0.875rem 1.125rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
}

.publish-state { margin: 0; font-size: 0.9375rem; color: var(--muted); }

.publish-live { color: var(--fg); }

.publish-live a { color: var(--accent); }

.panes { display: grid; gap: 1.25rem; }

#tab-edit:checked ~ .panes .pane-preview,
#tab-preview:checked ~ .panes .pane-edit { display: none; }

.phone {
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
}

.phone-screen {
  display: block;
  width: 100%;
  height: 34rem;
  border: 0;
  border-radius: 18px;
  background: var(--bg);
}

@media (min-width: 60rem) {
  .tab-bar.tabs-mobile { display: none; }
  .panes { grid-template-columns: 1fr 21rem; align-items: start; }
  #tab-edit:checked ~ .panes .pane-preview,
  #tab-preview:checked ~ .panes .pane-edit { display: block; }
  .pane-preview { position: sticky; top: 1.5rem; }
}

/* --- Block list ---------------------------------------------------------- */

.blocks { display: grid; gap: 0.5rem; margin-bottom: 1.25rem; }

.block {
  padding: 0.875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.block-hidden { opacity: 0.5; }

.block-head { display: flex; gap: 0.625rem; align-items: baseline; }

.block-type {
  flex: none;
  padding: 0.0625rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.block-title { font-weight: 600; overflow-wrap: anywhere; }

.block-actions { display: flex; gap: 0.375rem; margin-top: 0.75rem; flex-wrap: wrap; }

.block-edit { margin-top: 0.75rem; }

.block-edit summary {
  font-size: 0.875rem;
  color: var(--muted);
  cursor: pointer;
}

.block-edit summary:hover { color: var(--accent); }

.block-edit form { margin-top: 0.75rem; }

/* --- Stats --------------------------------------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: 0.625rem;
  margin-bottom: 1.25rem;
}

.stat {
  display: grid;
  gap: 0.125rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-n {
  font-size: 1.625rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-l { font-size: 0.8125rem; color: var(--muted); }

.table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }

.table td { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }

.table tr:last-child td { border-bottom: 0; }

.table .num { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block;
  padding: 0.0625rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 650;
}

.pill-off { background: var(--neutral-soft); color: var(--muted); }

/* --- Card page ----------------------------------------------------------- */

.qr-box {
  display: flex;
  justify-content: center;
  padding: 1.125rem;
  /* The QR needs white quiet zone regardless of the active theme. */
  background: #ffffff;
  border-radius: var(--radius);
}

.qr-img { display: block; width: 200px; height: 200px; }

.code-line {
  margin: 0 0 0.875rem;
  padding: 0.625rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }

/* --- Avatar upload ------------------------------------------------------- */

.avatar-row { display: flex; align-items: center; gap: 1rem; }

.avatar-actions { display: grid; gap: 0.5rem; min-width: 0; }

.avatar-buttons { display: flex; gap: 0.375rem; flex-wrap: wrap; }

.avatar-actions .field-hint { margin: 0; }

label.btn-icon { display: inline-flex; align-items: center; }

.avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  flex: none;
}

.avatar-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1.5rem;
  font-weight: 650;
}

/* --- Public profile ------------------------------------------------------ */

.p-head { text-align: center; margin-bottom: 1.5rem; }

.p-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border-strong);
}

.p-name {
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin: 0.75rem 0 0.25rem;
}

.p-headline { margin: 0 0 0.5rem; }

.p-bio { margin: 0; color: var(--muted); font-size: 0.9375rem; }

.p-blocks { display: grid; gap: 0.625rem; }

.p-block { width: 100%; }

.p-empty { color: var(--muted); text-align: center; }

.p-group {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  margin: 1rem 0 0;
}

.p-text { margin: 0; white-space: pre-line; }

.p-divider { border: 0; border-top: 1px solid var(--border); margin: 0.5rem 0; }

.p-contact { display: grid; gap: 0.625rem; }

.p-service {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
}

.p-service-title { margin: 0 0 0.25rem; font-size: 1rem; }

.p-service-price { margin: 0 0 0.25rem; font-weight: 650; color: var(--accent); }

.p-service-desc { margin: 0 0 0.75rem; color: var(--muted); font-size: 0.9375rem; }

/* --- Admin --------------------------------------------------------------- */

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.875rem;
  flex-wrap: wrap;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border);
}

.admin-row:last-child { border-bottom: 0; }

.admin-who { display: grid; gap: 0.1875rem; min-width: 0; }

.admin-email { font-weight: 600; overflow-wrap: anywhere; }

.admin-meta { font-size: 0.8125rem; color: var(--muted); }

.admin-meta a { color: var(--accent); text-decoration: none; }
