:root {
    --primary-color: #3498db;
    --success-color: #2ecc71;
    --danger-color: #e74c3c;
    --secondary-color: #9b59b6;
    --review-color: #e67e22;
    --save-color: #16a085;
    --background-color: #f4f7f6;
    --card-background: #ffffff;
    --text-color: #333;
    --border-color: #eee;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    background-color: var(--card-background);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

header {
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 20px;
    margin-bottom: 30px;
}

h1 { color: var(--primary-color); }

.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px;
    margin-top: 15px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
}

/* sync status badge */
.sync-status {
    font-size: 0.82em;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 500;
}
.sync-loading { background: #fff3cd; color: #856404; }
.sync-success { background: #d1edda; color: #155724; }
.sync-error   { background: #f8d7da; color: #721c24; }
.sync-info    { background: #d1ecf1; color: #0c5460; }

/* buttons */
.btn {
    padding: 12px 28px;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.97); }
.btn-primary   { background-color: var(--primary-color); color: white; }
.btn-success   { background-color: var(--success-color); color: white; }
.btn-secondary { background-color: var(--secondary-color); color: white; }
.btn-save      { background-color: var(--save-color); color: white; }
.btn-review    { background-color: var(--review-color); color: white; }
.btn-compact   { padding: 8px 16px; font-size: 0.88em; }

/* layout */
.layout {
    display: flex;
    gap: 20px;
}

.sidebar {
    width: 280px;
    flex: 0 0 280px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    background: #fafafa;
    max-height: 70vh;
    overflow: auto;
}

.content { flex: 1; min-width: 0; }

/* nav */
.nav-section + .nav-section { margin-top: 14px; }
.nav-title { font-weight: bold; margin-bottom: 8px; cursor: pointer; }
.nav-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
}
.nav-grid.collapsed { display: none; }
.nav-box {
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 6px;
    padding: 7px 0;
    font-size: 0.85em;
    cursor: pointer;
    text-align: center;
    user-select: none;
    transition: all 0.15s;
}
.nav-box:hover { border-color: var(--primary-color); background: #f0f7ff; }
.nav-box.is-current { outline: 2px solid var(--primary-color); border-color: var(--primary-color); }
.nav-box.is-done    { background: #eefaf1; border-color: #bfe7c8; }
.nav-box.is-wrong   { background: #fdeeee; border-color: #f3b3b3; }
.nav-box.is-marked  { box-shadow: inset 0 0 0 2px var(--secondary-color); }

/* question */
.question-card {
    background-color: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 5px solid var(--primary-color);
}

.options-group { margin-bottom: 25px; }
.options-group label {
    display: block;
    padding: 11px 15px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 9px;
    cursor: pointer;
    transition: all 0.15s;
}
.options-group label:hover { background-color: #f0f7ff; border-color: var(--primary-color); }
.options-group input { margin-right: 10px; }

.action-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
}

.feedback-area { border-top: 1px solid var(--border-color); padding-top: 20px; }

#result { font-size: 1.1em; margin-bottom: 15px; }
.correct { color: #27ae60; font-weight: bold; }
.wrong   { color: var(--danger-color); font-weight: bold; }

.tag-wrong   { background: #fde2e2; color: #c0392b; border-radius: 4px; padding: 2px 8px; font-size: 0.82em; }
.tag-marked  { background: #ede0f7; color: #6c3483; border-radius: 4px; padding: 2px 8px; font-size: 0.82em; }

#explanation { background-color: #fffde7; padding: 15px; border-radius: 6px; margin-bottom: 15px; }
#stats { color: #555; font-size: 0.9em; margin-bottom: 20px; }

#note-area textarea {
    width: 100%;
    height: 100px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 10px;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
}

/* profile */
.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
.profile-stats {
    background: #f9f9f9;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 20px;
}
.profile-section + .profile-section { margin-top: 20px; }
.profile-type { margin-top: 10px; }
.profile-type-title { font-weight: bold; margin-bottom: 8px; }

/* review view */
.review-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.review-filter-btn {
    background: #f0f0f0;
    color: #555;
    border: 1px solid #ddd;
}
.review-filter-btn.active {
    background: var(--review-color);
    color: white;
    border-color: var(--review-color);
}

.review-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 14px;
    border-left: 4px solid var(--danger-color);
    transition: box-shadow 0.15s;
}
.review-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.08); }

.review-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.review-type { font-weight: bold; font-size: 0.88em; color: #888; }
.review-tags { display: flex; gap: 6px; }
.review-question {
    font-size: 0.95em;
    color: #333;
    margin-bottom: 12px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.review-actions { display: flex; gap: 8px; }

.empty-tip { color: #aaa; text-align: center; padding: 40px 0; font-size: 0.95em; }

/* mobile */
@media (max-width: 640px) {
    .container { padding: 15px; }
    .controls { flex-direction: column; align-items: flex-start; }
    .layout { flex-direction: column; }
    .sidebar { width: auto; flex: 0 0 auto; max-height: none; }
    .nav-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
    .review-card-header { flex-direction: column; align-items: flex-start; gap: 6px; }
}
