:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-contrast: #ffffff;
    --danger: #dc2626;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --nav-height: 64px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
}

a {
    color: var(--accent);
    text-decoration: none;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.15rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
}

.app-logout {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Main */
.app-main {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.25rem 1.15rem 2rem;
}

/* Hero */
.hero {
    margin-bottom: 1.5rem;
}

.hero h1 {
    font-size: 1.6rem;
    margin: 0 0 0.25rem;
}

.hero-sub {
    color: var(--text-muted);
    margin: 0;
}

/* Module grid */
.module-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.module-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    color: var(--text);
    transition: transform 0.12s ease, border-color 0.12s ease;
}

.module-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

.module-icon {
    font-size: 1.8rem;
    display: block;
    margin-bottom: 0.5rem;
}

.module-card h2 {
    font-size: 1.1rem;
    margin: 0 0 0.35rem;
}

.module-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.92rem;
}

/* Bottom nav */
.app-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 20;
}

.app-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-muted);
    font-size: 0.72rem;
}

.app-nav a:hover {
    color: var(--accent);
}

.app-nav-icon {
    font-size: 1.3rem;
    line-height: 1;
}

/* Auth */
.auth {
    display: flex;
    justify-content: center;
    padding-top: 2rem;
}

.auth-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    width: 100%;
    max-width: 380px;
}

.auth-form h1 {
    margin: 0 0 1rem;
    font-size: 1.35rem;
}

.auth-form label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    margin-top: 0.85rem;
}

.auth-form input {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg);
    color: var(--text);
}

.auth-form input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}

.auth-form button {
    margin-top: 1.25rem;
    width: 100%;
    padding: 0.7rem;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-contrast);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.auth-form button:hover {
    background: var(--accent-hover);
}

.auth-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

/* Larger screens: cards side by side, nav stays bottom for app feel */
@media (min-width: 640px) {
    .module-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ---------- Generic inline TTS listen button ---------- */
.tts-button {
    border: none;
    background: transparent;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0.1rem;
    opacity: 0.55;
    transition: opacity 0.15s;
}
.tts-button:hover {
    opacity: 1;
}

/* ---------- Shared buttons ---------- */
.btn {
    display: inline-block;
    padding: 0.7rem 1.4rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-contrast);
}

.btn-primary:hover {
    background: var(--accent-hover);
    color: var(--accent-contrast);
}
