:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #eef2ec;
  --text: #17231b;
  --muted: #5d6b61;
  --border: #d9e0d8;
  --brand: #1f6b3a;
  --brand-ink: #ffffff;
  --brand-soft: #e3f1e6;
  --ball: #d7f25c;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --ok: #1f6b3a;
  --ok-soft: #e3f1e6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 18, .06), 0 4px 16px rgba(16, 24, 18, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1511;
    --surface: #161e18;
    --surface-2: #1d2820;
    --text: #e6ede7;
    --muted: #9aaa9e;
    --border: #2a372d;
    --brand: #3fa463;
    --brand-ink: #06120a;
    --brand-soft: #1c3324;
    --danger: #f97066;
    --danger-soft: #3a1714;
    --warn: #fdb022;
    --warn-soft: #33270b;
    --ok: #4ade80;
    --ok-soft: #14301e;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }

/* Layout */
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 440px; margin: 0 auto; padding: 32px 16px; }
.topbar {
  background: var(--brand); color: var(--brand-ink);
  position: sticky; top: 0; z-index: 20;
}
.topbar .wrap { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.topbar .title { font-weight: 700; font-size: 1.05rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar button { background: transparent; color: inherit; border: 1px solid rgba(255,255,255,.35); }
.tabs {
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 56px; z-index: 19;
}
.tabs .wrap { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs .wrap::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 12px 12px; text-decoration: none; color: var(--muted); white-space: nowrap;
  border-bottom: 3px solid transparent; font-weight: 500; font-size: .95rem;
}
.tabs a.active { color: var(--text); border-bottom-color: var(--brand); }
.tabs .sep { width: 1px; background: var(--border); margin: 10px 4px; flex: none; }
main { padding: 20px 0 64px; }

/* Cards & lists */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stat .n { font-size: 1.5rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .85rem; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.item .main { flex: 1; min-width: 200px; }
.item .when { font-weight: 600; }
.day-head { margin: 18px 0 6px; font-weight: 700; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge.beginner { background: #e0f2fe; color: #075985; }
.badge.intermediate { background: #fef3c7; color: #92400e; }
.badge.advanced { background: #fce7f3; color: #9d174d; }
.badge.unrated { background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
@media (prefers-color-scheme: dark) {
  .badge.beginner { background: #0c2a3d; color: #7dd3fc; }
  .badge.intermediate { background: #3a2a07; color: #fcd34d; }
  .badge.advanced { background: #3b1028; color: #f9a8d4; }
}

/* Forms */
label { display: block; font-weight: 600; font-size: .9rem; margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: auto; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.form-row { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
/* Each cell is label / input / hint. Subgrid shares those three rows across
   the whole line, so a label that wraps to two lines doesn't push its input
   below its neighbours'. Short labels sit just above their input. */
.form-row > div { display: grid; grid-row: span 3; grid-template-rows: subgrid; align-content: start; }
.form-row > div > label { align-self: end; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 4px; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; font: inherit; font-weight: 600; font-size: .95rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover, .btn:hover { filter: brightness(.97); }
button:disabled { opacity: .55; cursor: not-allowed; }
.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.link { background: none; border: none; color: var(--brand); padding: 4px; font-weight: 600; }
.block { width: 100%; }
.sm { padding: 5px 10px; font-size: .85rem; }

/* Notices */
.notice { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid transparent; }
.notice.info { background: var(--brand-soft); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.error { background: var(--danger-soft); color: var(--danger); white-space: pre-line; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Modal & toast */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px; overflow-y: auto;
}
.modal { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 520px; padding: 20px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; max-width: calc(100% - 32px);
  box-shadow: 0 6px 20px rgba(0,0,0,.25); font-weight: 500;
}
.toast.error { background: var(--danger); color: #fff; }

/* Credits pill */
.credits { display: flex; gap: 8px; flex-wrap: wrap; }
.credit-pill { background: var(--brand-soft); border-radius: 999px; padding: 4px 12px; font-weight: 600; font-size: .9rem; }

/* Landing */
.hero { padding: 56px 0 32px; }
.hero h1 { font-size: 2.2rem; max-width: 640px; }
.hero p { font-size: 1.1rem; color: var(--muted); max-width: 600px; }
.feature h3 { margin-bottom: 4px; }
.price { font-size: 2rem; font-weight: 800; }
.brand-mark { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: var(--ball); box-shadow: inset -3px -2px 0 rgba(0,0,0,.12); margin-right: 8px; vertical-align: -1px; }

@media (max-width: 560px) {
  h1 { font-size: 1.35rem; }
  .hero h1 { font-size: 1.7rem; }
  .item { padding: 12px; }
  .item .main { min-width: 0; flex-basis: 100%; }
}
code { overflow-wrap: anywhere; word-break: break-word; }

/* Password show/hide eye + live length rule (added by common.js) */
.pw-box { position: relative; display: block; }
.pw-box input { padding-right: 46px; }
.pw-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 34px; padding: 0; border: none; background: transparent; color: var(--muted);
}
.pw-eye:hover { color: var(--text); filter: none; }
.pw-eye:focus-visible { outline: 2px solid var(--brand); border-radius: 6px; }
.pw-rule { color: var(--muted); font-size: .85rem; margin: 4px 0 0; }
.pw-rule.ok { color: var(--ok); }

/* Top-bar log out: on narrow phones drop the name so the button always fits. */
.topbar button { flex: none; }
@media (max-width: 480px) { #who { display: none; } }

/* Logo + academy name in the app bar go back to the home tab. */
.home-link { display: flex; align-items: center; flex: 1; min-width: 0; color: inherit; text-decoration: none; border-radius: 8px; }
.home-link:hover .title { text-decoration: underline; text-underline-offset: 3px; }
.home-link:focus-visible { outline: 2px solid var(--ball); outline-offset: 2px; }

/* An academy's own logo: on a white chip so dark logos show on the green bar */
.topbar img.ac-logo { height: 32px; max-width: 120px; object-fit: contain; background: #fff; border-radius: 6px; padding: 2px; margin-right: 10px; flex: none; }
.card-logo { display: block; max-height: 90px; max-width: 220px; object-fit: contain; margin: 0 auto 12px; }
.logo-preview { max-height: 80px; max-width: 220px; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; padding: 6px; background: #fff; }
.brand-mark[hidden] { display: none; }
