:root {
    --bg: #fff8ec;
    --surface: #ffffff;
    --ink: #2b2d42;
    --muted: #6c6f80;
    --line: #f0e4cf;
    --primary: #ff7a59;
    --primary-dark: #e85d3c;
    --blue: #4d96ff;
    --green: #2bb673;
    --purple: #9b5de5;
    --yellow: #ffc93c;
    --danger: #e63946;
    --radius: 22px;
    --shadow: 0 8px 24px rgba(43, 45, 66, .08);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    font-family: 'Nunito', system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 18px;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--blue); }

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px 16px 60px;
}

/* ---------- Üst bar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar form { margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: 900; font-size: 22px;
    color: var(--ink); text-decoration: none;
}
.brand-icon { width: 40px; height: 40px; border-radius: 50%; display: block; }

/* ---------- Butonlar ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-weight: 800;
    border: none; border-radius: 16px;
    padding: 14px 26px; cursor: pointer;
    text-decoration: none;
    transition: transform .1s ease, background .2s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled, .hw-check:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 5px 0 var(--primary-dark); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--muted); padding: 10px 16px; }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-block { width: 100%; font-size: 20px; }

/* ---------- Giriş ekranı ---------- */
.auth-wrap {
    min-height: calc(100vh - 80px);
    display: grid; place-items: center;
}
.auth-card {
    width: 100%; max-width: 420px;
    background: var(--surface);
    border-radius: 28px;
    box-shadow: var(--shadow);
    padding: 36px 28px;
    text-align: center;
}
.auth-emoji { font-size: 64px; line-height: 1; }
.auth-logo { display: block; margin: -12px auto 0; max-width: 100%; height: auto; }
.auth-card h1 { margin: 12px 0 4px; font-size: 30px; font-weight: 900; }
.auth-card p.sub { margin: 0 0 24px; color: var(--muted); }
.auth-card form { text-align: left; }

/* ---------- Form ---------- */
.field { margin-bottom: 18px; }
.field label {
    display: block; font-weight: 800; margin-bottom: 6px;
}
.field .hint { font-weight: 600; color: var(--muted); font-size: 15px; }
.input, textarea.input {
    width: 100%;
    font: inherit;
    padding: 14px 16px;
    border: 3px solid var(--line);
    border-radius: 16px;
    background: #fffdf8;
    color: var(--ink);
    outline: none;
    transition: border-color .2s;
}
.input:focus { border-color: var(--blue); background: #fff; }
textarea.input { min-height: 140px; resize: vertical; }
.field-error { color: var(--danger); font-weight: 700; font-size: 15px; margin-top: 4px; display: block; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 20px; }
.check input { width: 22px; height: 22px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.alert {
    padding: 14px 18px; border-radius: 16px; font-weight: 700; margin-bottom: 20px;
}
.alert-error { background: #ffe3e3; color: #a4161a; }
.alert-success { background: #d8f5e3; color: #146c43; }
.alert-info { background: #e0edff; color: #1d4ed8; }

/* ---------- Dashboard ---------- */
.hello { margin: 8px 0 24px; }
.hello h1 { font-size: 34px; font-weight: 900; margin: 0; }
.hello p { margin: 4px 0 0; color: var(--muted); font-size: 19px; }

.stats {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
    margin-bottom: 28px;
}
.stat {
    background: var(--surface); border-radius: var(--radius);
    padding: 18px; box-shadow: var(--shadow); text-align: center;
}
.stat .num { font-size: 34px; font-weight: 900; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-weight: 700; font-size: 15px; }

.cards {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px;
}
.card {
    position: relative;
    display: flex; flex-direction: column; justify-content: space-between;
    min-height: 200px;
    padding: 24px;
    border-radius: var(--radius);
    color: #fff;
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: transform .15s ease, box-shadow .15s ease;
    overflow: hidden;
}
.card:hover { transform: translateY(-4px) rotate(-.5deg); box-shadow: 0 14px 30px rgba(43, 45, 66, .16); }
.card .icon { font-size: 56px; line-height: 1; }
.card h2 { margin: 12px 0 2px; font-size: 26px; font-weight: 900; }
.card p { margin: 0; opacity: .92; font-weight: 600; font-size: 16px; }
.card-reading { background: linear-gradient(135deg, #ff7a59, #ffb347); }
.card-soon { background: linear-gradient(135deg, #b8bccb, #9aa0b4); cursor: default; }
.card-soon:hover { transform: none; box-shadow: var(--shadow); }
.badge {
    position: absolute; top: 16px; right: 16px;
    background: rgba(255,255,255,.3); padding: 4px 12px;
    border-radius: 999px; font-size: 13px; font-weight: 800;
}

/* ---------- Okuma sayfası ---------- */
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.page-head .back {
    display: grid; place-items: center;
    width: 48px; height: 48px; border-radius: 14px;
    background: var(--surface); box-shadow: var(--shadow);
    text-decoration: none; font-size: 22px; color: var(--ink);
}
.page-head h1 { margin: 0; font-size: 30px; font-weight: 900; }

.panel {
    background: var(--surface); border-radius: var(--radius);
    padding: 26px; box-shadow: var(--shadow); margin-bottom: 26px;
}
.panel h2 { margin: 0 0 18px; font-size: 22px; font-weight: 900; }

.log-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.log {
    border: 3px solid var(--line); border-radius: 18px; padding: 16px 18px;
}
.log-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.log-title { font-weight: 900; font-size: 19px; }
.log-date { color: var(--muted); font-weight: 700; font-size: 15px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.chip {
    background: var(--bg); border-radius: 999px; padding: 4px 12px;
    font-weight: 800; font-size: 14px;
}
.log-summary { margin: 0; color: var(--ink); white-space: pre-wrap; }
.log-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.btn-edit {
    background: var(--bg); color: var(--ink);
    padding: 8px 16px; font-size: 15px; border-radius: 12px;
}
.btn-edit:hover { background: var(--line); }
.chip-edited { background: #ede4ff; color: #6a3fb5; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; }
.empty { text-align: center; color: var(--muted); padding: 20px; }

/* ---------- Ödevler ---------- */
.card-homework { background: linear-gradient(135deg, #2bb673, #4d96ff); }

.day-nav {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: var(--surface); border-radius: var(--radius);
    padding: 12px; box-shadow: var(--shadow); margin-bottom: 8px;
}
.day-arrow {
    display: grid; place-items: center;
    width: 52px; height: 52px; border-radius: 16px;
    background: var(--bg); color: var(--ink);
    font-size: 32px; font-weight: 900; text-decoration: none; line-height: 1;
}
.day-arrow:hover { background: var(--line); }
.day-arrow.disabled { opacity: .3; }
.day-label { text-align: center; display: flex; flex-direction: column; }
.day-label strong { font-size: 24px; font-weight: 900; }
.day-label span { color: var(--muted); font-weight: 700; font-size: 15px; }
.today-link { text-align: center; margin: 0 0 16px; font-weight: 800; }
.day-nav + .panel { margin-top: 18px; }

.hw-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.hw-head h2 { margin: 0; }
.hw-count { font-weight: 900; font-size: 20px; color: var(--green); }
.progress { height: 14px; background: var(--bg); border-radius: 999px; overflow: hidden; margin-bottom: 18px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, #2bb673, #4d96ff); border-radius: 999px; transition: width .4s; }

.hw-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.hw {
    display: flex; align-items: center; gap: 14px;
    border: 3px solid var(--line); border-radius: 18px; padding: 12px 14px;
}
.hw form { margin: 0; }
.hw-check {
    width: 40px; height: 40px; flex: none;
    border: 3px solid #c9cdd8; border-radius: 12px;
    background: #fff; cursor: pointer;
    font: inherit; font-size: 24px; font-weight: 900; color: #fff; line-height: 1;
}
.hw-check:hover { border-color: var(--green); }
.hw-body { flex: 1; min-width: 0; }
.hw-subject { font-weight: 900; }
.hw-desc { color: var(--ink); overflow-wrap: anywhere; }
.btn-done { background: var(--green); color: #fff; padding: 10px 16px; font-size: 16px; box-shadow: 0 4px 0 #1f8f59; }
.hw-delete { background: none; border: none; cursor: pointer; font-size: 20px; opacity: .45; padding: 6px; }
.hw-delete:hover { opacity: 1; }

.hw.done { background: #effcf4; border-color: #bfeccf; }
.hw.done .hw-check { background: var(--green); border-color: var(--green); }
.hw.done .hw-desc { text-decoration: line-through; color: var(--muted); }

.subject-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.subject-option input { position: absolute; opacity: 0; pointer-events: none; }
.subject-option span {
    display: inline-block; padding: 10px 14px; border-radius: 14px;
    border: 3px solid var(--line); background: #fffdf8;
    font-weight: 800; font-size: 16px; cursor: pointer;
}
.subject-option input:checked + span { border-color: var(--blue); background: #e0edff; }
.subject-option input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }

span.hw-check { display: grid; place-items: center; cursor: default; }
.hw-status {
    flex: none; font-weight: 800; font-size: 14px;
    padding: 6px 12px; border-radius: 999px;
    background: #fff3d6; color: #9a6700;
}
.hw-status.is-done { background: #d8f5e3; color: #146c43; }

/* ---------- Sınıf (öğretmen) ---------- */
.card-students { background: linear-gradient(135deg, #9b5de5, #f15bb5); }
.stat .num small { font-size: 20px; color: var(--muted); font-weight: 800; }

.hw-group { border: 3px solid var(--line); border-radius: 18px; padding: 14px 16px; }
.hw-group-top { display: flex; align-items: center; gap: 12px; }
.hw-group-top form { margin: 0; }
.hw-target { color: var(--muted); font-weight: 700; font-size: 14px; margin-top: 2px; }
.progress-sm { height: 8px; margin: 10px 0 6px; }
.hw-who summary { cursor: pointer; font-weight: 800; color: var(--blue); font-size: 15px; }
.hw-who ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.hw-who li { display: flex; justify-content: space-between; font-weight: 700; font-size: 15px; padding: 4px 8px; border-radius: 10px; }
.hw-who li.is-done { background: #effcf4; }
.who-time { color: var(--muted); font-size: 14px; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; }
.pill-muted { background: #eceef3; color: #6c6f80; }
.pill-success { background: #d8f5e3; color: #146c43; }
.row-inactive td { opacity: .55; }
.row-link { color: var(--ink); text-decoration: none; }
.row-link:hover { color: var(--blue); text-decoration: underline; }
.actions-col { text-align: right; white-space: nowrap; }
.actions-col .btn-edit { padding: 6px 12px; font-size: 14px; }
.hint { display: block; color: var(--muted); font-weight: 600; font-size: 14px; margin-top: 4px; }
label .hint, .check .hint { display: inline; margin: 0; }
select.input { appearance: auto; }

/* ---------- Kurulum ---------- */
.setup-section { margin: 22px 0 12px; font-size: 19px; font-weight: 900; }
.setup-section:first-of-type { margin-top: 0; }

/* ---------- Admin: kitap tablosu ---------- */
.table-wrap { overflow-x: auto; }
.book-table { width: 100%; border-collapse: collapse; font-size: 16px; }
.book-table th {
    text-align: left; color: var(--muted); font-weight: 800; font-size: 14px;
    padding: 8px 10px; border-bottom: 3px solid var(--line);
}
.book-table td { padding: 12px 10px; border-bottom: 2px solid var(--line); vertical-align: top; }
.book-table tr:last-child td { border-bottom: none; }
.book-table .num-col { text-align: right; white-space: nowrap; font-weight: 800; }
.book-table .date-col { white-space: nowrap; color: var(--muted); font-weight: 700; font-size: 15px; }
.book-author { color: var(--muted); font-weight: 600; font-size: 15px; }

@media (max-width: 640px) {
    .hw { flex-wrap: wrap; }
    .hw-body { flex-basis: calc(100% - 60px); }
    .hw .btn-done { flex: 1; }
}

@media (max-width: 640px) {
    body { font-size: 17px; }
    .row-2 { grid-template-columns: 1fr; }
    .stats { grid-template-columns: 1fr; }
    .hello h1 { font-size: 28px; }
}
