:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #059669;
    --secondary-dark: #047857;
    --accent: #f59e0b;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 48px 0;
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.tagline {
    color: var(--text-muted);
    font-size: 1.125rem;
}

/* Main */
.main {
    flex: 1;
    padding: 48px 0;
}

/* Tools Navigation */
.tools-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 24px;
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-light);
}

.tool-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    line-height: 1;
}

.tool-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.tool-card p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Footer */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 24px 0;
    text-align: center;
    margin-top: auto;
}

.footer p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.footer a {
    color: var(--primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 640px) {
    .header h1 {
        font-size: 2rem;
    }
    
    .tools-nav {
        grid-template-columns: 1fr;
    }
    
    .tool-card {
        padding: 24px 16px;
    }
}

/* Tool-specific styles for subpages */
.tool-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 32px 0;
    margin-bottom: 32px;
}

.tool-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
}

.tool-header p {
    color: var(--text-muted);
    margin-top: 8px;
}

.tool-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.875rem;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-dark);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    color: var(--text);
    background: var(--primary-light);
}

.input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
    background: var(--bg-card);
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.textarea {
    min-height: 120px;
    resize: vertical;
    font-family: inherit;
}

.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

/* Flashcard specific */
.flashcard {
    perspective: 1000px;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 300px;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.flashcard-back {
    transform: rotateY(180deg);
    background: var(--primary-light);
    border-color: var(--primary);
}

.flashcard-content {
    text-align: center;
    width: 100%;
}

.flashcard-content h3 {
    font-size: 1.5rem;
    margin-bottom: 16px;
}

.flashcard-content p {
    font-size: 1.125rem;
    color: var(--text-muted);
}

.flashcard-hint {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Quiz specific */
.question-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 24px;
    margin-bottom: 16px;
}

.question-card.correct {
    border-color: var(--secondary);
    background: #f0fdf4;
}

.question-card.incorrect {
    border-color: #ef4444;
    background: #fef2f2;
}

.question-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.question-number {
    background: var(--primary);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.option input[type="radio"],
.option input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.option.correct {
    border-color: var(--secondary);
    background: #f0fdf4;
}

.option.incorrect {
    border-color: #ef4444;
    background: #fef2f2;
}

/* Mindmap specific */
.mindmap-canvas {
    width: 100%;
    height: 500px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    position: relative;
    overflow: hidden;
}

.mindmap-node {
    position: absolute;
    background: var(--bg-card);
    border: 2px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-weight: 500;
    cursor: move;
    box-shadow: var(--shadow);
    user-select: none;
    transition: var(--transition);
}

.mindmap-node:hover {
    box-shadow: var(--shadow-hover);
    z-index: 10;
}

.mindmap-node.root {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
}

.mindmap-connection {
    position: absolute;
    pointer-events: none;
}

/* Pomodoro specific */
.timer-display {
    font-size: 6rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    color: var(--text);
    line-height: 1;
}

.timer-controls {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 32px;
    flex-wrap: wrap;
}

.timer-presets {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 24px;
    flex-wrap: wrap;
}

.timer-preset {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
    transition: var(--transition);
}

.timer-preset:hover,
.timer-preset.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

/* Habits specific */
.habit-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.habit-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.habit-item:hover {
    border-color: var(--primary-light);
}

.habit-checkbox {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}

.habit-checkbox.checked {
    background: var(--secondary);
    border-color: var(--secondary);
    color: white;
}

.habit-checkbox.checked::before {
    content: '✓';
    font-weight: bold;
}

.habit-info {
    flex: 1;
}

.habit-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.habit-streak {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 600;
}

.habit-actions {
    display: flex;
    gap: 8px;
}

/* Notes specific */
.notes-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.notes-toolbar button {
    padding: 8px 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
}

.notes-toolbar button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.notes-editor {
    width: 100%;
    min-height: 400px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.7;
    resize: vertical;
    background: var(--bg-card);
}

.notes-editor:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.notes-preview {
    width: 100%;
    min-height: 400px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    line-height: 1.7;
}

.notes-preview h1, .notes-preview h2, .notes-preview h3 { margin: 1.5em 0 0.5em; }
.notes-preview p { margin: 1em 0; }
.notes-preview code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-family: monospace; }
.notes-preview pre { background: var(--bg); padding: 16px; border-radius: var(--radius-sm); overflow-x: auto; }
.notes-preview pre code { background: none; padding: 0; }
.notes-preview ul, .notes-preview ol { margin: 1em 0; padding-left: 1.5em; }
.notes-preview blockquote { border-left: 4px solid var(--primary); padding-left: 16px; margin: 1em 0; color: var(--text-muted); }
.notes-preview a { color: var(--primary); }

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.tab {
    padding: 12px 24px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: var(--transition);
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: var(--transition);
}

.modal-overlay.open .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.125rem;
    color: var(--text);
    margin-bottom: 8px;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 4px;
}