:root {
    --bg-color: #fcfaff;
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-border: rgba(0, 0, 0, 0.06);
    --primary-color: #8a2be2;
    --primary-gradient: linear-gradient(135deg, #8a2be2 0%, #da70d6 100%);
    --secondary-color: #f0f0f0;
    --secondary-text: #4a4a4a;
    --text-color: #1a1a1a;
    --text-muted: #666666;
    --accent-glow: 0 4px 15px rgba(138, 43, 226, 0.15);
    --shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.1);
    --nav-height: 80px;
}

.glass-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    margin-bottom: 20px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

#header-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    box-shadow: var(--accent-glow);
}

#logo {
    font-size: 1.5rem;
    font-weight: 800;
}

#logo span {
    color: var(--primary-color);
}


* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    background-image: 
        radial-gradient(circle at 10% 10%, rgba(138, 43, 226, 0.03) 0%, transparent 40%),
        radial-gradient(circle at 90% 90%, rgba(218, 112, 214, 0.03) 0%, transparent 40%);
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
}

#app {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: calc(var(--nav-height) + 40px);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Auth Overlay */
.glass-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(15px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.auth-card {
    max-width: 400px;
    text-align: center;
}

.auth-card h2 { margin-bottom: 10px; }
.auth-card p { color: var(--text-muted); margin-bottom: 25px; font-size: 0.9rem; }

.divider {
    margin: 25px 0;
    display: flex;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.7rem;
}
.divider::before, .divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--card-border);
    margin: 0 10px;
}

.input-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
}
.input-group-vertical label { font-size: 0.75rem; color: var(--text-muted); }
.input-group-vertical input {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--card-border);
    padding: 12px;
    border-radius: 12px;
    color: white;
}

.status-msg { margin-top: 15px; font-size: 0.85rem; color: #ffeb3b; }
.small { font-size: 0.75rem; margin-top: 10px; }

.link-glow {
    display: inline-block;
    padding: 10px 20px;
    background: var(--primary-gradient);
    color: white;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(138, 43, 226, 0.3);
    margin: 15px 0;
}

/* Views */
.view {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Glass Cards */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* Lesson Content */
#lesson-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

#lesson-title {
    font-size: 1.8rem;
    margin: 10px 0 20px 0;
    line-height: 1.2;
}

.markdown-content {
    line-height: 1.6;
    color: #333333;
}

.markdown-content h1, .markdown-content h2 { margin-top: 20px; margin-bottom: 10px; color: #000; }
.markdown-content p { margin-bottom: 15px; }
.markdown-content code { background: rgba(0,0,0,0.05); padding: 2px 4px; border-radius: 4px; color: var(--primary-color); }

/* Buttons */
.btn-primary {
    background: var(--primary-gradient);
    border: none;
    color: white;
    padding: 12px 24px;
    border-radius: 14px;
    font-weight: 600;
    width: 100%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--accent-glow);
}

.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
    background: var(--secondary-color);
    border: 1px solid var(--card-border);
    color: var(--secondary-text);
    padding: 10px 15px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
}

/* Topics Grid */
#topics-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.topic-tag {
    padding: 8px 14px;
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    font-size: 0.85rem;
    color: var(--secondary-text);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.topic-tag.active {
    background: var(--primary-gradient);
    border-color: transparent;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#new-topic {
    flex: 1;
    background: #fff;
    border: 1px solid var(--card-border);
    padding: 10px 15px;
    border-radius: 10px;
    color: var(--text-color);
}

/* Bottom Nav */
.glass-nav {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 460px;
    height: var(--nav-height);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 30px;
    border: 1px solid var(--card-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    z-index: 1000;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s;
    flex: 1;
}

.nav-item.active {
    color: white;
}

.nav-item .icon { font-size: 1.4rem; margin-bottom: 4px; }
.nav-item .label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

/* Loader */
.loader {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-style: italic;
}

.hidden { display: none; }

/* Custom Generation Form */
.gen-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
    padding-top: 15px;
    border-top: 1px solid var(--card-border);
}

.gen-controls input[type="text"] {
    background: #fff;
    border: 1px solid var(--card-border);
    padding: 12px;
    border-radius: 12px;
    color: var(--text-color);
    width: 100%;
}

.gen-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

.gen-row label {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.gen-row input[type="number"] {
    width: 60px;
    background: #fff;
    border: 1px solid var(--card-border);
    padding: 8px;
    border-radius: 8px;
    color: var(--text-color);
    text-align: center;
}

.gen-row button {
    flex: 1;
}

/* New Features UI */
.topics-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 5px;
}

.pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(138, 43, 226, 0.1);
    border: 1px solid rgba(138, 43, 226, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--primary-color);
    animation: scaleIn 0.2s ease-out;
}

.pill .remove-pill {
    cursor: pointer;
    font-weight: bold;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.pill .remove-pill:hover { opacity: 1; }

@keyframes scaleIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.accent-glow {
    background: #fff !important;
    box-shadow: 0 4px 15px rgba(138, 43, 226, 0.15) !important;
    border: 1px solid var(--card-border) !important;
    color: var(--primary-color) !important;
}

.spacer { flex: 1; }

/* Media Content */
.lesson-img {
    width: 100%;
    border-radius: 16px;
    margin: 15px 0;
    box-shadow: var(--shadow);
    border: 1px solid var(--card-border);
    max-height: 250px;
    object-fit: cover;
}

.lesson-link {
    color: #da70d6;
    text-decoration: none;
    border-bottom: 1px dashed #da70d6;
    transition: all 0.2s;
}

.lesson-link:hover {
    color: #fff;
    border-bottom-style: solid;
}

blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 15px;
    margin: 15px 0;
    font-style: italic;
    color: var(--text-muted);
}

/* History Actions Always Visible */
.history-item.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--card-border);
}

.history-item.clickable:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
    box-shadow: 0 5px 15px rgba(138, 43, 226, 0.1);
    background: #fff;
}

.history-item-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-read {
    background: var(--primary-gradient);
    color: white;
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.btn-delete {
    background: rgba(255, 0, 0, 0.1);
    color: #ff4d4d;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    border: 1px solid rgba(255, 0, 0, 0.2);
}

.btn-delete:hover {
    background: #ff4d4d;
    color: white;
}

.delete-text {
    font-size: 0.65rem;
    text-transform: uppercase;
}
