:root {
    --bg: #f4efe6;
    --paper: #fffdf8;
    --ink: #1e2a24;
    --muted: #66756d;
    --line: #e6dac8;
    --brand: #1c6b56;
    --brand-dark: #134c3d;
    --warn: #b47a12;
    --bad: #b4453a;
    --ok: #2c7a4b;
    --shadow: 0 10px 30px rgba(48, 36, 18, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top right, rgba(28, 107, 86, 0.08), transparent 28%),
        var(--bg);
    line-height: 1.55;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 .4rem; letter-spacing: .02em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.05rem; }
p { margin: 0 0 .8rem; }

.top {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 12px 22px;
    background: rgba(244, 239, 230, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.logo { font-weight: 800; color: var(--brand-dark); }
.top nav { display: flex; gap: 14px; flex: 1; }
.top nav a { color: var(--muted); font-weight: 600; }
.top nav i {
    display: inline-flex;
    min-width: 18px;
    height: 18px;
    margin-left: 4px;
    padding: 0 5px;
    border-radius: 99px;
    background: var(--brand);
    color: #fff;
    font-style: normal;
    font-size: 12px;
    align-items: center;
    justify-content: center;
}
.who { display: flex; gap: 12px; color: var(--muted); font-size: 14px; align-items: center; }
.kid-switch { margin: 0; }
.kid-switch select {
    width: auto;
    margin: 0;
    padding: 6px 10px;
    font-weight: 700;
    color: var(--ink);
}
.invite-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.invite-code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 1.15rem;
    letter-spacing: .12em;
    color: var(--brand-dark);
}
.auth-card a { color: var(--brand); font-weight: 700; }

.wrap, .auth-wrap { width: min(980px, calc(100% - 28px)); margin: 22px auto 80px; }
.auth-wrap { display: grid; min-height: 100vh; place-items: center; margin: 0 auto; }

.eyebrow { color: var(--brand); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 6px; }
.lead, .muted { color: var(--muted); }
.hero { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; margin-bottom: 18px; }
.hero.compact { align-items: center; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.optional {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    background: #efe6d6;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0;
    vertical-align: middle;
}
.required {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    background: #f8e2de;
    color: var(--bad);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0;
    vertical-align: middle;
}

.card {
    display: block;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.card.highlight { background: #f3f8f4; border-color: #cfe0d4; }
.card.empty, .card.latest .more { color: var(--muted); }
.quote { font-size: 1.2rem; font-weight: 700; margin: 0; }

.grid-2, .grid-3 { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1.4fr; margin-bottom: 12px; }

.chip, .tag {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 700;
    background: #e7f1ec;
    color: var(--brand-dark);
}
.tag.ok { background: #e3f4e8; color: var(--ok); }
.tag.warn { background: #f8edd3; color: var(--warn); }
.tag.bad { background: #f8e2de; color: var(--bad); }
.tag.late { background: #d32f2f; color: #fff; }
.card.row.late { border-color: #d32f2f; background: #fff1f0; }
.card.late-note { background: #fff1f0; border: 2px solid #d32f2f; color: #c62828; }
.card.late-note strong { color: #c62828; display: block; margin-bottom: 6px; font-size: 1.15rem; }
.card.late-note p { margin: 0; color: #c62828; font-weight: 700; }

.meta { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.plain, .comments { list-style: none; padding: 0; margin: 0; }
.plain li, .comments li { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.plain li:last-child, .comments li:last-child { border: 0; }
.grow { flex: 1; }

.timeline { display: grid; gap: 10px; }
.card.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 0; }
.card.unread { border-color: var(--brand); background: #f3faf6; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    padding: 10px 16px;
    font-weight: 700;
    cursor: pointer;
    background: #ece4d6;
    color: var(--ink);
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.wide { width: 100%; padding: 14px; font-size: 16px; }

label, .label { display: block; font-size: 13px; font-weight: 700; margin: 8px 0; }
input, select, textarea {
    width: 100%;
    margin-top: 6px;
    border: 1px solid #d9ccb8;
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
}
.stack { display: grid; gap: 10px; }
.sms-row { display: flex; gap: 8px; align-items: stretch; }
.sms-row input { flex: 1; margin: 0; min-width: 0; }
.sms-row .btn { white-space: nowrap; width: auto; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-option { margin: 0; }
.chip-option input { display: none; }
.chip-option span {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    font-weight: 700;
}
.chip-option input:checked + span { background: var(--brand); color: #fff; border-color: var(--brand); }

.point-list { display: grid; gap: 8px; margin-bottom: 14px; }
.point-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f0e7d8;
}
.point-row input[type="text"] {
    margin: 0;
    flex: 1;
    min-width: 0;
}
.seg { display: flex; gap: 6px; }
.seg label { margin: 0; }
.seg input { display: none; }
.seg span {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid var(--line);
    font-size: 12px;
    background: #fff;
}
.seg input[value="mastered"]:checked + span { background: var(--ok); color: #fff; border-color: var(--ok); }
.seg input[value="partial"]:checked + span { background: var(--warn); color: #fff; border-color: var(--warn); }
.seg input[value="none"]:checked + span { background: var(--bad); color: #fff; border-color: var(--bad); }

#issues { display: grid; gap: 8px; margin-bottom: 10px; }
.sticky-actions {
    position: sticky;
    bottom: 12px;
    margin-top: 12px;
}
.flash {
    border-radius: 12px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-weight: 700;
}
.flash.ok { background: #e5f5ea; color: var(--ok); }
.flash.bad { background: #fde8e4; color: var(--bad); }
.hint { margin-top: 18px; color: var(--muted); font-size: 13px; }
.hint p { margin: 4px 0; }
.auth-card { width: min(440px, 100%); background: var(--paper); padding: 32px; border-radius: 24px; box-shadow: var(--shadow); }
code { background: #efe6d6; padding: 1px 6px; border-radius: 6px; }

.table-wrap { overflow-x: auto; }
.scoreboard {
    width: 100%;
    min-width: 520px;
    border-collapse: collapse;
}
.scoreboard th, .scoreboard td {
    border: 1px solid var(--line);
    padding: 12px 10px;
    text-align: center;
    vertical-align: top;
    min-width: 120px;
}
.scoreboard thead th {
    background: #f7f1e6;
    font-size: 13px;
    color: var(--muted);
}
.scoreboard .subject {
    text-align: left;
    font-weight: 800;
    min-width: 72px;
    width: 72px;
    position: sticky;
    left: 0;
    background: var(--paper);
    z-index: 1;
}
.scoreboard thead .subject { background: #f7f1e6; }
.score-cell { position: relative; padding-right: 14px; }
.score-cell .num { font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.score-cell .sub {
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
    margin-left: auto;
    margin-right: auto;
}
.scoreboard .dash { color: #cbbba6; font-size: 1.1rem; }
.score-del {
    position: absolute;
    top: -6px;
    right: -4px;
    border: 0;
    background: transparent;
    color: #c4b5a0;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
}
.score-del:hover { color: var(--bad); }
.delta { font-weight: 800; font-size: 13px; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.score-add {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}
.score-add input, .score-add select { width: auto; margin: 0; }
.score-add input[type="date"] { width: 150px; }
.score-add input[name="exam_name"] { width: 150px; }
.score-add select { width: 90px; }
.score-add input[name="score"] { width: 88px; }
.score-add input[name="full_score"] { width: 118px; }
.tutor-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    padding: 12px 0;
    border-bottom: 1px dashed var(--line);
}
.tutor-row:first-child { padding-top: 0; }
.tutor-row:last-child { border: 0; padding-bottom: 0; }
.tutor-row .score-add { margin: 0; }
.attend-list { display: grid; gap: 0; }
.attend-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 8px 0;
    border-bottom: 1px dashed var(--line);
}
.attend-row:last-child { border: 0; }
.attend-row .check {
    display: flex;
    gap: 6px;
    align-items: center;
    font-weight: 700;
    margin: 0;
    width: auto;
}
.attend-row input[type="text"] { flex: 1; min-width: 160px; margin: 0; }
.subject-picker { width: 100%; }
.subject-picker .chips { margin-top: 6px; }
.kid-card {
    padding: 16px 0;
    border-bottom: 1px dashed var(--line);
}
.kid-card:last-child { border: 0; padding-bottom: 0; }
.kid-card:first-child { padding-top: 0; }
.attend-row .chips { width: 100%; }

@media (max-width: 800px) {
    .top { flex-wrap: wrap; }
    .top nav { order: 3; width: 100%; }
    .hero, .point-row, .card.row { display: grid; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .score-add input, .score-add select, .score-add .btn { width: 100%; }
    .sms-row { flex-wrap: wrap; }
    .sms-row .btn { width: 100%; }
    .who span { display: none; }
}
