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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

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

.screen {
    display: none;
    min-height: 100vh;
    padding: 40px 20px;
}

.screen.active {
    display: block;
}

h1 {
    text-align: center;
    color: white;
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

h2 {
    color: white;
    text-align: center;
    margin-bottom: 30px;
}

h3 {
    color: #667eea;
    margin-bottom: 15px;
}

.subtitle {
    text-align: center;
    color: rgba(255,255,255,0.9);
    font-size: 1.1em;
    margin-bottom: 20px;
}

/* 登録問題数バッジ */
.question-count-badge {
    text-align: center;
    margin: 0 auto 30px;
    padding: 12px 24px;
    background: rgba(255,255,255,0.15);
    border-radius: 25px;
    max-width: 300px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

.count-label {
    color: rgba(255,255,255,0.9);
    font-size: 0.95em;
    margin-right: 8px;
}

.count-number {
    color: #fff;
    font-size: 1.3em;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

/* 凡例カード */
.legend-card, .login-card {
    background: white;
    border-radius: 12px;
    padding: 30px 40px;
    margin: 30px auto;
    max-width: 500px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.login-card h2 {
    color: #667eea;
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.8em;
}

.legend-list {
    list-style: none;
    padding: 0;
}

.legend-list li {
    display: flex;
    align-items: center;
    padding: 10px 0;
    font-size: 1.1em;
}

.dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 15px;
    display: inline-block;
}

.dot.gray { background: #999; }
.dot.orange { background: #ff9800; }
.dot.green { background: #4caf50; }
.dot.red { background: #f44336; }

/* ボタン */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 500px;
    margin: 0 auto;
}

.btn {
    padding: 15px 30px;
    font-size: 1.1em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.btn-primary {
    background: #4caf50;
    color: white;
}

.btn-primary:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-secondary {
    background: white;
    color: #667eea;
    position: relative;
}

.btn-secondary:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
}

.btn-secondary .badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #f44336;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.8em;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
}

.btn-warning {
    background: #ff9800;
    color: white;
}

.btn-danger {
    background: #f44336;
    color: white;
    margin-top: 20px;
}

.btn-flag {
    background: #f44336;
    color: white;
}

.admin-link {
    text-align: center;
    margin-top: 30px;
}

.admin-link a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 0.9em;
}

.admin-link a:hover {
    color: white;
}

/* 試験画面 */
.exam-header {
    background: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.timer {
    font-size: 1.5em;
    font-weight: bold;
    color: #f44336;
}

.question-counter {
    font-size: 1.2em;
    color: #667eea;
}

.exam-container {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.question-panel {
    flex: 2;
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.question-status {
    font-size: 0.9em;
    color: #999;
    margin-bottom: 10px;
}

.question-text {
    font-size: 1.3em;
    margin-bottom: 30px;
    line-height: 1.6;
    color: #333;
}

.choices {
    margin-bottom: 30px;
}

.choice {
    background: #f5f5f5;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
}

.choice:hover {
    background: #e8e8e8;
}

.choice.selected {
    background: #e3f2fd;
    border-color: #2196f3;
}

.choice-label {
    font-weight: bold;
    margin-right: 15px;
    color: #667eea;
    font-size: 1.2em;
}

/* ナビゲーションパネル */
.navigation-panel {
    flex: 1;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    max-height: 80vh;
    overflow-y: auto;
}

.question-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.question-nav-btn {
    padding: 10px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.question-nav-btn:hover {
    transform: scale(1.05);
}

.question-nav-btn.answered {
    background: #4caf50;
    color: white;
    border-color: #4caf50;
}

.question-nav-btn.later {
    background: #ff9800;
    color: white;
    border-color: #ff9800;
}

.question-nav-btn.flagged {
    background: #f44336;
    color: white;
    border-color: #f44336;
}

.question-nav-btn.current {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.5);
}

/* 結果画面 */
.result-summary {
    background: white;
    border-radius: 12px;
    padding: 40px;
    margin-bottom: 30px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.result-summary h2 {
    color: #667eea;
}

.result-summary .pass {
    color: #4caf50;
    font-size: 3em;
    font-weight: bold;
    margin: 20px 0;
}

.result-summary .fail {
    color: #f44336;
    font-size: 3em;
    font-weight: bold;
    margin: 20px 0;
}

.result-details {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.question-result {
    border-bottom: 1px solid #eee;
    padding: 20px 0;
    position: relative;
}

.question-result:last-child {
    border-bottom: none;
}

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

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.95em;
    color: #666;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.flag-badge {
    background: #f44336;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: bold;
}

.question-result h4 {
    color: #667eea;
    margin-bottom: 10px;
}

.correct-answer {
    color: #4caf50;
    font-weight: bold;
}

.wrong-answer {
    color: #f44336;
    font-weight: bold;
}

.result-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    justify-content: center;
}

.result-actions .btn {
    min-width: 200px;
}

/* 復習リスト */
.review-list-header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.review-list-stats {
    margin-bottom: 15px;
}

.review-list-stats p {
    font-size: 1.1em;
    color: #666;
}

.review-list-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.review-list-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.review-list-filters select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    background: white;
    cursor: pointer;
}

.review-item {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.review-item-header {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
}

.review-item-chapter {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: bold;
}

.review-item-difficulty {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: bold;
    color: white;
}

.difficulty-beginner {
    background: #4caf50;
}

.difficulty-intermediate {
    background: #ff9800;
}

.difficulty-advanced {
    background: #f44336;
}

.btn-remove {
    margin-left: auto;
    padding: 6px 12px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
}

.btn-remove:hover {
    background: #d32f2f;
}

.review-item-question {
    margin-bottom: 10px;
    line-height: 1.6;
}

.review-item-answer {
    margin-bottom: 15px;
}

.review-item details {
    margin-top: 15px;
}

.review-item summary {
    cursor: pointer;
    color: #667eea;
    font-weight: bold;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 6px;
    user-select: none;
}

.review-item summary:hover {
    background: #e8e8e8;
}

.review-item-explanation {
    padding: 15px;
    background: #f9f9f9;
    border-radius: 6px;
    margin-top: 10px;
}

.empty-message {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 1.1em;
}

/* 管理画面 */
.admin-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 20px;
    background: white;
    border: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-weight: 600;
    color: #667eea;
    transition: all 0.3s;
}

.tab-btn.active {
    background: white;
    color: #667eea;
}

.admin-tab {
    display: none;
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

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

.stats-card, .import-card {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.admin-actions {
    background: #fff9e6;
    border: 1px solid #ffa726;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.admin-actions .help-text {
    margin-top: 10px;
    font-size: 0.9em;
    color: #666;
    line-height: 1.5;
}

.btn-warning {
    background: #ff9800;
    color: white;
}

.btn-warning:hover {
    background: #f57c00;
}

.import-section {
    margin: 20px 0;
    padding: 20px;
    background: white;
    border-radius: 8px;
    border: 1px solid #ddd;
}

#csv-file {
    display: block;
    margin: 10px 0;
    padding: 10px;
    width: 100%;
}

code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    display: block;
    margin: 10px 0;
    padding: 10px;
    overflow-x: auto;
}

.import-preview {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 6px;
    margin: 15px 0;
}

.import-preview h5 {
    color: #667eea;
    margin-bottom: 10px;
}

.error-log {
    background: #ffebee;
    border: 1px solid #f44336;
    border-radius: 6px;
    padding: 15px;
    margin: 10px 0;
    max-height: 300px;
    overflow-y: auto;
}

.error-item {
    padding: 8px;
    margin: 5px 0;
    background: white;
    border-left: 4px solid #f44336;
    border-radius: 4px;
}

.warning-log {
    background: #fff3e0;
    border: 1px solid #ff9800;
    border-radius: 6px;
    padding: 15px;
    margin: 10px 0;
}

.success-log {
    background: #e8f5e9;
    border: 1px solid #4caf50;
    border-radius: 6px;
    padding: 15px;
    margin: 10px 0;
}

/* オーバーレイ */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.overlay.show {
    display: flex;
}

.spinner {
    border: 8px solid #f3f3f3;
    border-top: 8px solid #667eea;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.overlay p {
    color: white;
    font-size: 1.5em;
    margin-top: 20px;
}

/* フィルタ */
.filter-group {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.filter-group select {
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #ddd;
    font-size: 1em;
}

/* ログイン画面 */
.login-card .form-group {
    margin-bottom: 20px;
}

.login-card .form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
    font-size: 1em;
    text-align: left;
}

.login-card .form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    transition: all 0.3s;
    box-sizing: border-box;
}

.login-card .form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.login-card .error-message {
    background: #ffebee;
    border: 1px solid #f44336;
    border-radius: 6px;
    padding: 12px 15px;
    margin-bottom: 15px;
    color: #d32f2f;
    font-weight: 500;
}

.login-card .button-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 25px;
}

/* エージェントIDフッター */
.agent-id-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.2);
    text-align: center;
}

.agent-id-footer p {
    color: rgba(255,255,255,0.6);
    font-size: 0.85em;
    font-family: 'Courier New', monospace;
}

/* 問題一覧 */
#questions-list {
    max-height: 600px;
    overflow-y: auto;
}

.question-item {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    transition: all 0.3s;
}

.question-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

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

.question-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
}

.chapter-badge {
    background: #e3f2fd;
    color: #1976d2;
}

.difficulty-badge {
    color: white;
}

.difficulty-badge.beginner {
    background: #4caf50;
}

.difficulty-badge.intermediate {
    background: #ff9800;
}

.difficulty-badge.advanced {
    background: #f44336;
}

.question-number {
    margin-left: auto;
    color: #999;
    font-size: 0.9em;
}

.question-item-text {
    font-size: 1em;
    color: #333;
    margin-bottom: 12px;
    line-height: 1.5;
}

.question-item-actions {
    display: flex;
    gap: 10px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.9em;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-edit {
    background: #2196f3;
    color: white;
}

.btn-edit:hover {
    background: #1976d2;
}

.btn-delete {
    background: #f44336;
    color: white;
}

.btn-delete:hover {
    background: #d32f2f;
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    overflow-y: auto;
    padding: 20px;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 800px;
    width: 100%;
    margin: 40px auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    margin: 0;
    color: #667eea;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2em;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.modal-close:hover {
    color: #333;
}

.edit-form {
    padding: 30px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 1px solid #eee;
    margin-top: 20px;
}

/* レスポンシブ */
@media (max-width: 1024px) {
    .exam-container {
        flex-direction: column;
    }
    
    .navigation-panel {
        max-height: none;
    }
    
    .question-grid {
        grid-template-columns: repeat(10, 1fr);
    }
}
