:root {
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --card-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --success-color: #10b981;
    --danger-color: #ef4444;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,0.2) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,30%,0.2) 0, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.glass-header {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Header */
.header-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1rem 5vw;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: clamp(1.1rem, 4vw, 1.5rem);
    font-weight: 700;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

nav {
    display: flex;
    gap: 1rem;
}

/* Buttons */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s ease;
}

.nav-btn {
    background: transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 8px;
}

.nav-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
    color: var(--accent-color);
    background: rgba(59, 130, 246, 0.1);
}

.btn-primary {
    background: var(--accent-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Main Layout */
#main-content {
    max-width: 1000px;
    margin: 2rem auto;
    padding: 0 2rem;
}

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

.view-section.active {
    display: block;
}

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

/* Pattern Grid & Deck Grid */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.list-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-back {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
}
.btn-back:hover {
    background: rgba(255, 255, 255, 0.1);
}

.pattern-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* Card Styles (used for both patterns and groups) */
.pattern-card {
    padding: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.pattern-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.5);
    border-color: rgba(255, 255, 255, 0.2);
}

.deck-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 150px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
    border-top: 4px solid var(--accent-color);
}

.deck-card h3 {
    font-size: 1.4rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.deck-card .deck-meta {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.pattern-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--accent-color);
}

.pattern-card .meaning-kr {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.pattern-card .example-count {
    font-size: 0.85rem;
    background: rgba(255,255,255,0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    display: inline-block;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state h2 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal.hidden {
    display: none;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.modal-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

input, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

/* Learn Mode Styles */
.flashcard-container {
    max-width: 600px;
    margin: 0 auto;
    perspective: 1000px;
}

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

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

.flashcard-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem 2rem;
    text-align: center;
    border-radius: 16px;
}

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

.click-hint {
    position: absolute;
    bottom: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    opacity: 0.7;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.4; }
    50% { opacity: 0.8; }
    100% { opacity: 0.4; }
}

.card-type-badge {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    background: rgba(255,255,255,0.1);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.audio-btn {
    position: absolute;
    top: 1.2rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.4rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.audio-btn:hover {
    background: rgba(59, 130, 246, 0.4);
    transform: scale(1.1);
}

.card-content-main {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.card-content-sub {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.highlight {
    color: var(--accent-color);
    font-weight: bold;
    text-decoration: underline;
    text-decoration-color: rgba(59, 130, 246, 0.4);
    text-underline-offset: 4px;
}

.learn-controls {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 3rem;
}

.learn-controls button {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    border-radius: 30px;
}

.hidden {
    display: none !important;
}

.progress-text {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-weight: 600;
}
