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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.15;
  margin: 0 0 var(--space-3);
  letter-spacing: 0.01em;
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 var(--space-3); }

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

img { max-width: 100%; display: block; }

table {
  border-collapse: collapse;
  width: 100%;
}

th, td {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}

th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

input, select, textarea, button {
  font: inherit;
  color: inherit;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
}

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

::placeholder { color: var(--text-faint); }

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-7);
}

.page-title {
  margin-bottom: var(--space-5);
}

.text-dim { color: var(--text-dim); }
.text-faint { color: var(--text-faint); }
.nowrap { white-space: nowrap; }
.table-scroll { overflow-x: auto; }
.inline-form { display: inline; }

/* Top navigation */
.topnav {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: var(--nav-height);
  padding: 0 var(--space-4);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-flame { font-size: 1.2rem; }

.navlinks {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.navlinks a {
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.navlinks a:hover {
  color: var(--text);
  background: var(--card);
  text-decoration: none;
}

.navlinks a.active {
  color: var(--accent-soft);
  background: var(--card);
}

.nav-admin { color: var(--beast-gold) !important; }

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.nav-user {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.nav-toggle { display: none; }

@media (max-width: 760px) {
  .navlinks {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    padding: var(--space-3);
  }
  .navlinks.open { display: flex; }
  .nav-toggle {
    display: block;
    background: none;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    cursor: pointer;
  }
  .nav-user { display: none; }
}

/* Messages / flash */
.messages {
  max-width: 1100px;
  margin: var(--space-3) auto 0;
  padding: 0 var(--space-4);
  display: grid;
  gap: var(--space-2);
}

.message {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
}

.message-success { border-color: var(--good); background: var(--good-bg); }
.message-error { border-color: var(--bad); background: var(--danger-bg); }
.message-warning { border-color: var(--warn); background: var(--warn-bg); }

/* Centered auth pages */
.centered-page .page {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: max(8vh, var(--space-6));
}

/* htmx request indicators (we provide these because htmx's own injected
   <style> block is blocked by our strict CSP — see base.html). */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }
