:root {
    --ink: #1a1c1e;
    --muted: #6c7278;
    --accent: #b8422e;
    --bg: #f7f5f2;
    --surface: #fff;
    --border: #e5e2dc;
    --success: #2e7d32;
    --warning: #f9a825;
    --danger: #c62828;
    --radius: 8px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
    padding-bottom: 70px; /* space for bottom nav */
}

/* Topbar */
.topbar {
    background: var(--ink);
    color: var(--bg);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar .logo { font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--bg);
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: auto;
    padding: 0 4px;
}
.nav-links { display: flex; gap: 12px; flex-wrap: wrap; }
.nav-links a { color: #b0b5b8; text-decoration: none; font-size: 0.9rem; padding: 4px 0; white-space: nowrap; }
.nav-links a:hover { color: var(--bg); }

/* Bottom navigation (mobile) */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding: 4px 0 env(safe-area-inset-bottom, 4px) 0;
    justify-content: space-around;
}
.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: var(--muted);
    font-size: 0.65rem;
    padding: 6px 8px;
    border-radius: 6px;
    transition: color 0.2s;
}
.bottom-nav a span { font-size: 0.6rem; }
.bottom-nav a.active {
    color: var(--accent);
}
.bottom-nav a:hover { color: var(--ink); }

/* App */
#app {
    max-width: 1000px;
    margin: 0 auto;
    padding: 16px;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}
.card h2 { font-size: 1.1rem; margin-bottom: 12px; }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* Stats */
.stat { text-align: center; padding: 12px; }
.stat-number { font-size: 1.8rem; font-weight: 700; }
.stat-label { font-size: 0.8rem; color: var(--muted); }
.stat-good .stat-number { color: var(--success); }
.stat-bad .stat-number { color: var(--danger); }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}
.badge-up { background: #e8f5e9; color: var(--success); }
.badge-down { background: #ffebee; color: var(--danger); }
.badge-stable { background: #efeeea; color: var(--muted); }
.badge-homework { background: #e3f2fd; color: #1565c0; }
.badge-exam { background: #fce4ec; color: #c62828; }
.badge-test { background: #f3e5f5; color: #7b1fa2; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th { text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--border); color: var(--muted); font-weight: 600; font-size: 0.8rem; }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); }

/* Forms */
form { display: flex; flex-direction: column; gap: 10px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label { font-size: 0.8rem; font-weight: 500; color: var(--muted); }
input, select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--surface);
    width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    background: var(--ink);
    color: var(--bg);
    transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* Upcoming list */
.upcoming-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.upcoming-item:last-child { border-bottom: none; }
.days-left { font-weight: 600; font-size: 0.85rem; }

/* Flash messages */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: 0.9rem;
}
.flash-good { background: #e8f5e9; color: var(--success); }
.flash-bad { background: #ffebee; color: var(--danger); }

/* Chart wrapper */
.chart-wrapper { max-width: 300px; margin: 0 auto; }

/* Responsive preview mode */
.responsive-btn {
    background: none;
    border: none;
    color: var(--bg);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    margin-left: 4px;
}
.resp-mobile {
    max-width: 375px !important;
    margin: 0 auto !important;
    border: 4px solid var(--ink);
    border-radius: 24px;
    min-height: 812px;
    box-shadow: 0 0 40px rgba(0,0,0,0.2);
    overflow-x: hidden;
    padding: 0 12px;
}
/* Force mobile layout when resp-mobile is active */
.resp-mobile .grid-2,
.resp-mobile .grid-3 { grid-template-columns: 1fr; }
.resp-mobile .form-row { grid-template-columns: 1fr; }
.resp-mobile .hamburger { display: block; }
.resp-mobile .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--ink);
    flex-direction: column;
    padding: 8px 16px 16px;
    gap: 4px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
}
.resp-mobile .nav-links.open { display: flex; }
.resp-mobile .bottom-nav { display: flex; }
.resp-mobile { padding-bottom: 60px; }

.resp-tablet {
    max-width: 768px !important;
    margin: 0 auto !important;
    border: 4px solid var(--ink);
    border-radius: 16px;
    min-height: 1024px;
    box-shadow: 0 0 40px rgba(0,0,0,0.2);
    overflow-x: hidden;
}
.resp-tablet .grid-2,
.resp-tablet .grid-3 { grid-template-columns: 1fr; }
.resp-tablet .form-row { grid-template-columns: 1fr; }
.resp-tablet .hamburger { display: block; }
.resp-tablet .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--ink);
    flex-direction: column;
    padding: 8px 16px 16px;
    gap: 4px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
}
.resp-tablet .nav-links.open { display: flex; }
.resp-tablet .bottom-nav { display: flex; }
.resp-tablet { padding-bottom: 60px; }
@media (max-width: 768px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .hamburger { display: block; }
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--ink);
        flex-direction: column;
        padding: 8px 16px 16px;
        gap: 4px;
        box-shadow: 0 8px 16px rgba(0,0,0,0.3);
    }
    .nav-links.open { display: flex; }
    .bottom-nav { display: flex; }
    body { padding-bottom: 60px; }
}

@media (min-width: 769px) {
    .bottom-nav { display: none !important; }
    body { padding-bottom: 0; }
}