:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --background-color: #f8f9fa;
    --card-background: #fff;
    --text-color: #212529;
    --border-color: #dee2e6;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    margin: 0;
    padding: 0;
    color: var(--text-color);
    line-height: 1.6;
}

header {
    background-color: var(--card-background);
    border-bottom: 1px solid var(--border-color);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    text-align: center;
    flex: 1;
    min-width: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.hidden {
    display: none !important;
}

main {
    padding: 2rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
    min-height: calc(100vh - 140px);
}

.auth-container {
    max-width: 450px;
    margin: 4rem auto;
    padding: 2.5rem;
    background: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.auth-tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
    gap: 0;
}

.auth-tab {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-size: 1rem;
    color: var(--secondary-color);
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.auth-tab:hover {
    color: var(--primary-color);
}

.auth-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.auth-tab-content {
    display: none;
}

.auth-tab-content.active {
    display: block;
}

.auth-tab-content h2 {
    margin-bottom: 1.5rem;
    color: var(--text-color);
    text-align: center;
}

.auth-tab-content form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
}

.app-selector {
    padding: 2rem;
}

.app-selector h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
    font-size: 2rem;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.app-card {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.app-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
    transform: translateY(-2px);
}

.app-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.app-card h3 {
    color: var(--text-color);
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.app-card p {
    color: var(--secondary-color);
    margin: 0;
    font-size: 0.9rem;
}

.notification {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    padding: 1rem 2rem;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 2000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    min-width: 250px;
    text-align: center;
}

.notification.success {
    background-color: var(--success-color);
}

.notification.error {
    background-color: var(--danger-color);
}

.notification.info {
    background-color: var(--info-color);
}

.nav-bottom {
    padding: 0.5rem 2rem;
    background-color: var(--background-color);
}

.nav-links {
    display: flex;
    gap: 0;
    justify-content: flex-start;
}

.nav-tab {
    background: none;
    border: none;
    font-size: 1rem;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    color: var(--secondary-color);
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.nav-tab:hover,
.nav-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.tab-header h2 {
    margin: 0;
    color: var(--primary-color);
}

.deck-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.deck-card {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.2s;
}

.deck-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.deck-card h3 {
    margin-top: 0;
    color: var(--primary-color);
}

.deck-stats {
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-top: 1rem;
}

.deck-actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow-y: auto;
}

.modal-content {
    background-color: white;
    margin: 50px auto;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    position: relative;
}

.modal-content h2 {
    margin-top: 0;
    color: var(--primary-color);
}

.close {
    color: var(--secondary-color);
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: var(--danger-color);
}

.flashcard-container {
    perspective: 1000px;
    width: 100%;
    max-width: 500px;
    height: 350px;
    margin: 2rem auto;
}

.flashcard {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    border-radius: 12px;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
}

.card-front {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.card-back {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    transform: rotateY(180deg);
}

.study-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

.structured-note-grid-container {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

.grid-header {
    display: flex;
    font-weight: bold;
    background-color: var(--background-color);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 0;
}

.cue-col-header {
    width: 40%;
    border-right: 1px solid var(--border-color);
    padding: 0 10px;
}

.note-col-header {
    width: 60%;
    padding: 0 10px;
}

.grid-body {
    max-height: 60vh;
    overflow-y: auto;
}

.grid-row {
    display: flex;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}

.cue-cell,
.note-cell {
    border: none;
    resize: none;
    padding: 10px;
    font-size: 1em;
    font-family: inherit;
    line-height: 1.4;
    min-height: 60px;
}

.cue-cell {
    width: 40%;
    border-right: 1px solid #f0f0f0;
}

.note-cell {
    width: 60%;
}

.cue-cell:focus,
.note-cell:focus {
    outline: none;
    background-color: #f8f9fa;
}

@media (max-width: 768px) {
    .header-top {
        flex-direction: column;
        padding: 1rem;
    }
    
    .auth-container {
        margin: 2rem 1rem;
        padding: 1.5rem;
    }
    
    .app-grid {
        grid-template-columns: 1fr;
    }
    
    .deck-grid {
        grid-template-columns: 1fr;
    }
}