@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Nunito+Sans:wght@400;600;700;800&display=swap');

:root {
  color-scheme: light;
  --bg: #faf5ea;
  --bg-soft: #f2e9d8;
  --card: #fffdf8;
  --ink: #2b2013;
  --muted: #8a7a61;
  --line: #e8dcc3;
  --brand: #7a4526;
  --brand-2: #a5652f;
  --brand-dark: #4f2c17;
  --brand-ink: #fff8ef;
  --accent: #56713e;
  --accent-ink: #f3f6ea;
  --gold: #bf8b2b;
  --gold-bg: #faf0d8;
  --danger: #ab4128;
  --danger-bg: #fbeae1;
  --ok-bg: #eaf1de;
  --ok-ink: #45602e;
  --warn-bg: #fbeed2;
  --warn-ink: #8a5c14;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(43, 32, 19, .04), 0 8px 24px -12px rgba(43, 32, 19, .18);
  --shadow-sm: 0 1px 3px rgba(43, 32, 19, .08);
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Nunito Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding-inline: 18px;
  padding-block: max(0px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-bottom));
  background:
    radial-gradient(1100px 420px at 50% -180px, color-mix(in srgb, var(--gold) 14%, transparent), transparent),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-2); }
a:hover { color: var(--brand); }

.wrap { max-width: 760px; margin: 0 auto; }
.wrap-wide { max-width: 1180px; }
.wrap-wide .login-card { max-width: 380px; }

img { max-width: 100%; }

/* ---------- Topbar / nav ---------- */

.topbar {
  padding: 16px 0 14px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--line);
  position: relative;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(155deg, var(--brand-2), var(--brand-dark));
  color: var(--brand-ink);
  font-size: 1.2rem;
  flex: 0 0 auto;
  box-shadow: var(--shadow-sm);
}

.brand-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.28rem;
  letter-spacing: 0.2px;
  line-height: 1.1;
}
.brand-text small {
  display: block;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.62rem;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: 1px;
}

.nav-toggle-checkbox { position: absolute; opacity: 0; pointer-events: none; }
.nav-toggle-btn {
  display: none;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--brand);
  user-select: none;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: center;
  font-size: 0.88rem;
  margin-top: 12px;
}

.topbar nav a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
}
.topbar nav a.active { color: var(--brand-ink); background: var(--brand); }
.topbar nav a:not(.active):hover { color: var(--brand); background: var(--bg-soft); }
.topbar nav .nav-user {
  color: var(--muted);
  font-weight: 600;
  padding: 6px 4px;
  margin-left: auto;
}
.topbar nav .nav-user::before { content: '👤 '; }

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

@media (max-width: 720px) {
  .nav-toggle-btn { display: inline-flex; }
  .topbar nav {
    flex-direction: column;
    align-items: stretch;
    max-height: 0;
    overflow: hidden;
    margin-top: 0;
    transition: max-height .28s ease, margin-top .28s ease;
  }
  .topbar nav a, .topbar nav .nav-user { width: 100%; padding: 10px 12px; }
  .topbar nav .nav-user { margin-left: 0; order: -1; }
  .nav-toggle-checkbox:checked ~ nav { max-height: 480px; margin-top: 12px; }
}

/* ---------- Cards & headings ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}
.card-grid .card { margin-bottom: 0; }
@media (min-width: 860px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1180px) {
  .card-grid-3 { grid-template-columns: repeat(3, 1fr); }
}

.horse-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

.session-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.session-title { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; }
.session-meta { font-size: 0.86rem; color: var(--muted); margin-top: 2px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: .2px;
  white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge-ok::before { content: '✓'; }
.badge-cancel { background: var(--danger-bg); color: var(--danger); }
.badge-cancel::before { content: '✕'; }
.badge-warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge-warn::before { content: '⚠'; }

ul.plist { list-style: none; margin: 0; padding: 0; }
ul.plist li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px dashed var(--line);
}
ul.plist li:last-child { border-bottom: none; }
.p-absent { color: var(--muted); text-decoration: line-through; }

/* ---------- Buttons & forms ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 9px 17px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  letter-spacing: .1px;
  box-shadow: 0 1px 2px rgba(43,32,19,.05);
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease, background-color .14s ease, color .14s ease;
}
.btn:hover {
  border-color: var(--brand-2);
  box-shadow: 0 4px 14px -6px rgba(43,32,19,.28);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0) scale(.97); box-shadow: 0 1px 2px rgba(43,32,19,.08); }
.btn:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(155deg, var(--brand-2), var(--brand-dark));
  color: var(--brand-ink);
  border-color: var(--brand-dark);
}
.btn-primary:hover {
  background: linear-gradient(155deg, var(--brand-2), var(--brand));
  border-color: var(--brand-dark);
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--brand-dark) 60%, transparent);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, var(--danger-bg));
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--danger) 55%, transparent);
}

.btn-sm { padding: 6px 13px; font-size: 0.8rem; }
.btn-block { display: flex; justify-content: center; width: 100%; text-align: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

form.inline { display: inline; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.85rem; color: var(--muted); font-weight: 700; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font-body);
  background: #fff;
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--brand-2) 45%, transparent);
  outline-offset: 1px;
  border-color: var(--brand-2);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .grid-2 { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table th { text-align: left; padding: 8px 6px; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; border-bottom: 2px solid var(--line); }
table td { text-align: left; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }

.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 0.92rem; font-weight: 600; box-shadow: var(--shadow-sm); }
.flash-ok { background: var(--ok-bg); color: var(--ok-ink); }
.flash-error { background: var(--danger-bg); color: var(--danger); }

/* ---------- Login hero ---------- */

.hero {
  min-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 0;
  text-align: center;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  margin-inline: -18px;
  padding-inline: 18px;
}
.hero > * { position: relative; z-index: 1; }

.hero-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.hero-mark {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.1rem;
  background: linear-gradient(155deg, var(--brand-2), var(--brand-dark));
  color: var(--brand-ink);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.7rem;
  margin: 0 0 4px;
}
.hero .tagline { color: var(--muted); font-size: 0.94rem; margin-bottom: 26px; }

.login-card {
  width: 100%;
  max-width: 380px;
  text-align: left;
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--brand-2), var(--gold), var(--accent));
}
.login-card h2 { font-family: var(--font-display); font-size: 1.15rem; margin: 4px 0 4px; }

.hero-links { margin-top: 18px; font-size: 0.88rem; display: flex; flex-direction: column; gap: 6px; }

/* ---------- Sections ---------- */

.section-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 30px 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px dotted var(--line);
}
.section-title:first-child { margin-top: 0; }

/* ---------- Collapsible "add new" forms ---------- */

.details-form { margin-bottom: 26px; }
.details-form summary {
  cursor: pointer;
  list-style: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.details-form summary::-webkit-details-marker { display: none; }
.details-form summary::before {
  content: '+';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 1rem;
  font-weight: 800;
  flex: 0 0 auto;
  transition: transform .18s ease;
}
.details-form[open] summary::before { content: '–'; }
.details-form summary:hover::before { transform: scale(1.08); }
.details-form form { margin-top: 16px; }

.empty {
  color: var(--muted);
  font-style: italic;
  padding: 18px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}

.page-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; margin: 0 0 18px; }

footer.site-foot {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  margin: 40px 0 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #211a10;
    --bg-soft: #2b2216;
    --card: #2c2317;
    --ink: #f3ecdd;
    --muted: #b3a284;
    --line: #4a3c27;
    --brand: #e0a768;
    --brand-2: #e0a768;
    --brand-dark: #c98f4f;
    --brand-ink: #241a0d;
    --accent: #8fae6f;
    --gold: #e0b955;
    --gold-bg: #3a2f16;
    --danger: #ec9074;
    --danger-bg: #402420;
    --ok-bg: #2b3320;
    --ok-ink: #b9d29a;
    --warn-bg: #3d3320;
    --warn-ink: #e5be79;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #211a10;
  --bg-soft: #2b2216;
  --card: #2c2317;
  --ink: #f3ecdd;
  --muted: #b3a284;
  --line: #4a3c27;
  --brand: #e0a768;
  --brand-2: #e0a768;
  --brand-dark: #c98f4f;
  --brand-ink: #241a0d;
  --accent: #8fae6f;
  --gold: #e0b955;
  --gold-bg: #3a2f16;
  --danger: #ec9074;
  --danger-bg: #402420;
  --ok-bg: #2b3320;
  --ok-ink: #b9d29a;
  --warn-bg: #3d3320;
  --warn-ink: #e5be79;
}
