:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #6b6b70;
  --border: #e2e0da;
  --hover: #eeede8;
  --accent: #1c1c1e;
  --accent-text: #ffffff;
  --danger: #b42318;
  --ok-bg: #e6f4ea;
  --ok-text: #1d6b33;
  --warn-bg: #fdf3da;
  --warn-text: #6f4c00;
  --error-bg: #fdecea;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;
    --surface: #1c1c1f;
    --text: #f2f2f4;
    --muted: #a3a3aa;
    --border: #303036;
    --hover: #26262b;
    --accent: #f2f2f4;
    --accent-text: #111113;
    --danger: #ff7b6e;
    --ok-bg: #15301d;
    --ok-text: #91d8a5;
    --warn-bg: #382c0e;
    --warn-text: #f1cf7c;
    --error-bg: #3a1714;
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

h1 {
  font-size: 1.5rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0 0 1rem;
}

.icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: currentColor;
}

.icon-stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Public page */

.profile {
  max-width: 34rem;
  margin: 0 auto;
  padding: 3.5rem 1.25rem 4rem;
  text-align: center;
}

.avatar {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-fallback {
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 2rem;
  font-weight: 600;
}

.profile h1 {
  margin: 0;
}

.bio {
  max-width: 28rem;
  margin: 0.5rem auto 0;
  color: var(--muted);
  white-space: pre-line;
}

.links {
  display: grid;
  gap: 0.75rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
}

.link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.5rem;
  padding: 0.85rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-weight: 550;
  text-decoration: none;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.link span {
  flex: 1;
  /* Mirror the icon width so the label sits in the optical centre. */
  margin-right: calc(22px + 0.75rem);
  overflow-wrap: anywhere;
}

.link:hover {
  background: var(--hover);
  transform: translateY(-1px);
}

.link:focus-visible,
.button:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .link {
    transition: none;
  }

  .link:hover {
    transform: none;
  }
}

/* Shared UI */

.narrow {
  max-width: 24rem;
  margin: 12vh auto 4rem;
  padding: 0 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

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

.notice {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
}

.notice-ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.notice-warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.notice-error {
  background: var(--error-bg);
  color: var(--danger);
}

button,
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--hover);
}

.icon-button {
  padding: 0.45rem 0.5rem;
}

.icon-small {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

button:disabled {
  opacity: 0.35;
  cursor: default;
}

button:disabled:hover {
  background: var(--surface);
}

.primary,
.primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.primary:hover {
  opacity: 0.88;
}

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

.danger-solid,
.danger-solid:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--surface);
}

/* Forms */

.stack {
  display: grid;
  gap: 1.1rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9375rem;
  font-weight: 550;
}

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-weight: 400;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}

input[type="file"] {
  font: inherit;
  font-size: 0.875rem;
  font-weight: 400;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
}

.checkbox input {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  accent-color: var(--accent);
}

.hint {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 400;
}

.error {
  color: var(--danger);
  font-size: 0.8125rem;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.avatar-field {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.avatar-field label {
  flex: 1;
}

.avatar-small {
  width: 64px;
  height: 64px;
  margin: 0;
}

/* Admin */

.admin {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 4rem;
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.admin-nav a {
  color: var(--muted);
  text-decoration: none;
}

.admin-nav a:hover,
.admin-nav a[aria-current="page"] {
  color: var(--text);
}

.admin-nav a[aria-current="page"] {
  font-weight: 600;
}

.admin-nav form {
  margin: 0 0 0 auto;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-head h1 {
  margin: 0;
}

.admin-links {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.admin-link.is-hidden .icon,
.admin-link.is-hidden .meta {
  opacity: 0.55;
}

.admin-link .label {
  font-weight: 600;
}

.admin-link .url {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.875rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  margin-left: 0.35rem;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 0.35rem;
}

.actions form {
  margin: 0;
}

.confirm summary {
  list-style: none;
}

.confirm summary::-webkit-details-marker {
  display: none;
}

.confirm form {
  margin-top: 0.35rem;
}

@media (max-width: 36rem) {
  .admin-link {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}
