:root {
    --bg-color: #1a1a2e;
    --bg-card: #16213e;
    --bg-card-hover: #1a2540;
    --bg-card-back: #1a2540;
    
    --text-main: #e0e0e0;
    --text-muted: #888;
    
    --primary: #2196F3;
    --primary-hover: #1565C0;
    
    --border-front: #FF9800;
    --border-front-hover: #FFC107;
    --text-front: #FFC107;
    
    --border-back: #4CAF50;
    --border-back-hover: #81C784;
    --text-back: #64B5F6;
    
    /* SM2 Colors */
    --c-rate-0: #e94560;
    --c-rate-1: #e94560;
    --c-rate-2: #FF9800;
    --c-rate-3: #FFC107;
    --c-rate-4: #66BB6A;
    --c-rate-5: #4CAF50;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.hide { display: none !important; }

/* --- HEADER --- */
.app-header {
    padding: 15px 20px;
    background-color: rgba(22, 33, 62, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.header-content h1 {
    font-size: 20px;
    color: var(--text-front);
}

.counter { color: var(--text-muted); font-weight: bold; }

.stats-bar {
    font-size: 13px;
    margin-bottom: 15px;
    text-align: center;
}

.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

select {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-card);
    color: var(--text-main);
    border: 2px solid #333;
    border-radius: 8px;
    font-size: 14px;
}

.toggle-shuffle {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* --- MAIN CONT --- */
.flashcard-container {
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
    min-height: calc(100vh - 150px);
    display: flex;
    flex-direction: column;
}

.empty-message {
    text-align: center;
    margin-top: 50px;
}

.empty-message h2 { color: var(--border-front); margin-bottom: 10px;}

/* --- 3D CARD FLIP --- */
.scene {
    width: 100%;
    height: 350px;
    perspective: 1000px;
    margin-bottom: 20px;
}

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

.card.is-flipped {
    transform: rotateY(180deg);
}

.card__face {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 16px;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    overflow-y: auto;
}

.card__face--front {
    background: var(--bg-card);
    border: 3px solid var(--border-front);
}

.card__face--front:active { border-color: var(--border-front-hover); background: var(--bg-card-hover); }

.card__face--back {
    background: var(--bg-card-back);
    border: 3px solid var(--border-back);
    transform: rotateY(180deg);
    align-items: flex-start;
    justify-content: flex-start;
    text-align: left;
}

/* Card Texts */
.word-main {
    font-size: 28px;
    font-weight: bold;
    color: var(--text-front);
    margin-bottom: 20px;
    word-break: break-word;
}

.tap-hint {
    color: var(--text-muted);
    font-size: 14px;
}

.word-meaning {
    font-size: 18px;
    color: var(--text-back);
    white-space: pre-wrap;
    margin-bottom: 20px;
    width: 100%;
    font-weight: bold;
}

.word-examples {
    font-size: 15px;
    color: #e0e0e0;
    white-space: pre-wrap;
    margin-bottom: 15px;
    padding-top: 10px;
    border-top: 1px dashed #4CAF50;
    width: 100%;
}

.word-origin {
    font-size: 14px;
    color: #FFC107;
    margin-top: auto;
    width: 100%;
}


/* --- TOOLBAR --- */
.card-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.btn-audio {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
}
.btn-audio:active { background: var(--primary); color: white; }

.sm2-info {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: bold;
}


/* --- RATING --- */
.rating-panel {
    background: rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    text-align: center;
}

.rating-panel p {
    color: var(--text-muted);
    margin-bottom: 10px;
    font-weight: bold;
}

.rating-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 10px;
}

.btn-rate {
    padding: 12px;
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    font-size: 13px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-rate:active { opacity: 0.7; transform: scale(0.98); }

.rate-0 { background: var(--c-rate-0); }
.rate-1 { background: var(--c-rate-1); }
.rate-2 { background: var(--c-rate-2); }
.rate-3 { background: var(--c-rate-3); }
.rate-4 { background: var(--c-rate-4); }
.rate-5 { background: var(--c-rate-5); }


/* --- NAV --- */
.nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-bottom: 20px;
}

.btn-nav {
    background: #0f3460;
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 12px;
    font-size: 18px;
    cursor: pointer;
    font-weight: bold;
}

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

.btn-flip {
    flex: 1;
    margin: 0 15px;
    background: rgba(33, 150, 243, 0.2);
    color: var(--primary);
    border: 2px solid var(--primary);
}


/* --- LOGIN PAGE --- */
.login-body {
    display: flex;
    height: 100vh;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.login-container {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 16px;
    border: 2px solid var(--primary);
    width: 90%;
    max-width: 400px;
}

.login-container h1 { color: #FF9800; margin-bottom: 5px; }
.login-container h2 { color: var(--text-muted); font-size: 16px; margin-bottom: 30px; }

.login-container input {
    width: 100%;
    padding: 15px;
    background: var(--bg-color);
    border: 1px solid #333;
    border-radius: 8px;
    color: white;
    font-size: 16px;
    margin-bottom: 20px;
}

.btn-login {
    width: 100%;
    padding: 15px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
}

.error-msg {
    color: #e94560;
    background: rgba(233, 69, 96, 0.1);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
}
