:root {
  --paper: #faf6f0;
  --card: #ffffff;
  --ink: #2b2b2b;
  --muted: #6b6b6b;
  --line: #e7ded3;
  --primary: #2c9c8f;
  --primary-dark: #217a70;
  --accent: #ef7b57;
  --accent-dark: #d5623f;
  --big: #3b82f6;
  --little: #eab308;
  --prek: #ec7fb0;
  --ok: #2f9e44;
  --err: #d64545;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(40,30,20,.05), 0 6px 20px rgba(40,30,20,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3 { line-height: 1.2; }
h1 { font-size: 1.7rem; margin: 0 0 .25rem; }
h2 { font-size: 1.25rem; margin: 1.6rem 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }

/* Layout */
.wrap { max-width: 960px; margin: 0 auto; padding: 0 1rem; }
.wrap-narrow { max-width: 560px; }
main { padding: 1.5rem 0 4rem; }

/* Header */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 34px; height: 34px; flex: 0 0 auto; }
.brand small { display:block; font-weight: 500; color: var(--muted); font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
nav.top a { color: var(--muted); font-weight: 600; margin-left: 1.1rem; font-size: .92rem; }
nav.top a.active, nav.top a:hover { color: var(--primary-dark); text-decoration: none; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.35rem; margin-bottom: 1rem; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

/* Hero */
.hero { background: linear-gradient(160deg, #fef1ea 0%, #f3f8f2 100%); border: 1px solid var(--line); border-radius: 20px; padding: 2.4rem 2rem; text-align: center; }
.hero h1 { font-size: 2.1rem; }
.hero p { color: var(--muted); max-width: 40ch; margin: .5rem auto 1.4rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .45rem; background: var(--primary); color: #fff; border: none; border-radius: 10px; padding: .62rem 1.05rem; font-size: .95rem; font-weight: 600; cursor: pointer; font-family: inherit; }
.btn:hover { background: var(--primary-dark); text-decoration: none; color:#fff; }
.btn.accent { background: var(--accent); }
.btn.accent:hover { background: var(--accent-dark); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f5efe7; color: var(--ink); }
.btn.danger { background: transparent; color: var(--err); border: 1px solid #f0c9c9; }
.btn.danger:hover { background: #fdeaea; }
.btn.sm { padding: .38rem .7rem; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* Forms */
label { display: block; font-weight: 600; font-size: .9rem; margin: .8rem 0 .25rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px; font-size: 1rem; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfe3dd; border-color: var(--primary); }
.field-inline { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }

/* Badges */
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 700; letter-spacing: .02em; }
.badge.big { background: #e3edff; color: #1e4bb8; }
.badge.little { background: #fdf3d2; color: #8a6d0b; }
.badge.prek { background: #fce4f0; color: #b03b76; }
.badge.gray { background: #eee; color: #666; }
.badge.ok { background: #e4f6e8; color: #1c7a34; }
.badge.warn { background: #fdeede; color: #a5641a; }
.badge.slot { background: #eef3f2; color: #43645e; }

/* Group left-accent bar */
.groupbar { border-left: 5px solid #ccc; }
.groupbar.big { border-left-color: var(--big); }
.groupbar.little { border-left-color: var(--little); }
.groupbar.prek { border-left-color: var(--prek); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: none; }

/* Stat tiles */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.stat .num { font-size: 1.8rem; font-weight: 700; color: var(--primary-dark); }
.stat .lbl { color: var(--muted); font-size: .82rem; }

/* Flash */
.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 500; }
.flash.success { background: #e4f6e8; color: #1c7a34; border: 1px solid #bfe6c8; }
.flash.error { background: #fdeaea; color: #a12b2b; border: 1px solid #f2c4c4; }

/* Ranking list (drag) */
.ranklist { list-style: none; margin: .5rem 0 0; padding: 0; }
.rankitem { display: flex; align-items: center; gap: .7rem; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; margin-bottom: .5rem; cursor: grab; }
.rankitem.dragging { opacity: .5; }
.rankitem.over { border-color: var(--primary); box-shadow: 0 0 0 2px #cdeae5; }
.rankitem .rk { font-weight: 700; color: var(--primary-dark); width: 1.6rem; text-align: center; flex: 0 0 auto; }
.rankitem .handle { color: #bbb; flex: 0 0 auto; }
.rankitem .body { flex: 1; }
.rankitem .body .cname { font-weight: 600; }
.rankitem .moves { display: flex; flex-direction: column; gap: 2px; }
.rankitem .moves button { border: 1px solid var(--line); background: #fff; border-radius: 6px; width: 26px; height: 20px; cursor: pointer; line-height: 1; padding: 0; }

/* Segmented control */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: .5rem .9rem; cursor: pointer; font-size: .9rem; font-weight: 600; color: var(--muted); }
.seg input:checked + span { background: var(--primary); color: #fff; }

/* Friend list */
.friendlist { list-style: none; padding: 0; margin: .5rem 0 0; }
.friendlist li { display: flex; align-items: center; gap: .5rem; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 8px; margin-bottom: .4rem; background: #fff; }
.friendlist li .fname { flex: 1; }

/* Sticky save bar */
.savebar { position: sticky; bottom: 0; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); padding: .8rem 0; margin-top: 1rem; backdrop-filter: blur(4px); }
.savebar .wrap { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.savestate { font-size: .88rem; color: var(--muted); }
.savestate.saved { color: var(--ok); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: .85rem; padding: 1.4rem 0; }
.site-footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }

.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.legend .dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: .35rem; vertical-align: baseline; }
.dot.big { background: var(--big); } .dot.little { background: var(--little); } .dot.prek { background: var(--prek); }

.notice { background: #fff7ed; border: 1px solid #f6ddb8; border-radius: 10px; padding: .7rem .9rem; font-size: .88rem; color: #8a5a1a; }
hr.soft { border: none; border-top: 1px solid var(--line); margin: 1.1rem 0; }
