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

body {
    font-family: 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'ヒラギノ角ゴ ProN W3', Meiryo, sans-serif;
    background: linear-gradient(135deg, #ff9a56 0%, #ff6a88 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 24px;
}

header h1 {
    font-size: 2.2em;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.25);
}

.subtitle {
    font-size: 1.05em;
    opacity: 0.95;
}

.progress-sync-status {
    display: inline-block !important;
    margin-top: 10px;
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #a04500;
    font-size: 1em;
    font-weight: 700;
    letter-spacing: 0.02em;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.progress-sync-status[data-state="syncing"] {
    background: #fff3cd;
    color: #856404;
}

.progress-sync-status[data-state="ok"] {
    background: #d4edda;
    color: #155724;
    border-color: #28a745;
}

.progress-sync-status[data-state="offline"],
.progress-sync-status[data-state="local"] {
    background: #f8d7da;
    color: #721c24;
    border-color: #dc3545;
}

.notice {
    background: rgba(255, 255, 255, 0.95);
    border-left: 5px solid #e67e22;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    color: #7d3c00;
    font-size: 0.95em;
    line-height: 1.5;
}

.stats-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    border-radius: 14px;
    padding: 16px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.stat-label {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 1.9em;
    font-weight: bold;
    color: #e67e22;
}

.controls {
    background: white;
    border-radius: 15px;
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.filter-row label {
    display: block;
    font-weight: bold;
    margin-bottom: 6px;
    color: #333;
    font-size: 0.9em;
}

select,
input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
}

.mode-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.btn {
    padding: 12px 18px;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-primary {
    background: linear-gradient(135deg, #ff9a56 0%, #ff6a88 100%);
    color: white;
}

.btn-resume {
    background: linear-gradient(135deg, #2563eb 0%, #60a5fa 100%);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    color: white;
}

.btn-outline {
    background: white;
    color: #e67e22;
    border: 2px solid #e67e22;
}

.btn-nav {
    background: #f0f0f0;
    color: #333;
}

.btn-ox-correct {
    background: #27ae60;
    color: white;
    flex: 1;
    min-height: 56px;
    font-size: 1.2em;
}

.btn-ox-wrong {
    background: #c0392b;
    color: white;
    flex: 1;
    min-height: 56px;
    font-size: 1.2em;
}

.btn-conf {
    flex: 1;
    min-height: 48px;
}

.btn-conf.high {
    background: #2980b9;
    color: white;
}

.btn-conf.mid {
    background: #f39c12;
    color: white;
}

.btn-conf.low {
    background: #8e44ad;
    color: white;
}

.card-container,
.browse-panel,
.welcome-screen {
    background: white;
    border-radius: 15px;
    padding: 24px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
    font-size: 0.95em;
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.85em;
}

.badge-subject {
    background: #ffe0c2;
    color: #a04500;
}

.badge-no {
    background: #ff6a88;
    color: white;
}

.badge-year {
    background: #2b6cb0;
    color: white;
}

.badge-rank {
    background: #edf2f7;
    color: #2d3748;
}

.badge-rank.rank-ap,
.badge-rank.rank-a {
    background: #f6e05e;
    color: #744210;
}

.badge-rank.rank-bp {
    background: #90cdf4;
    color: #2a4365;
}

.badge-rank.rank-b {
    background: #c6f6d5;
    color: #22543d;
}

.badge-rank.rank-bm,
.badge-rank.rank-cp,
.badge-rank.rank-c,
.badge-rank.rank-other {
    background: #e2e8f0;
    color: #4a5568;
}

.badge-exam {
    background: #edf2f7;
    color: #2d3748;
}

.badge-exam.exam-yobi {
    background: #bee3f8;
    color: #2a4365;
}

.badge-exam.exam-shihou {
    background: #fbb6ce;
    color: #702459;
}

.badge-exam.exam-both {
    background: #d6bcfa;
    color: #44337a;
}

.badge-exam.exam-unknown {
    background: #e2e8f0;
    color: #4a5568;
}

.source-line {
    margin: -4px 0 14px;
    padding: 0 4px;
    font-size: 0.88em;
    color: #718096;
    line-height: 1.4;
}

.badge-progress {
    background: #eee;
    color: #555;
    margin-left: auto;
}

.history-panel {
    margin: 0 0 14px;
    padding: 12px 14px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}

.history-title {
    font-weight: bold;
    color: #2d3748;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.history-trail {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.history-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.82em;
    font-weight: bold;
    background: #edf2f7;
    color: #4a5568;
}

.history-chip.ok {
    background: #c6f6d5;
    color: #276749;
}

.history-chip.ng {
    background: #fed7d7;
    color: #9b2c2c;
}

.history-chip.pending {
    background: #feebc8;
    color: #9c4221;
    border: 1px dashed #dd6b20;
}

.history-note {
    font-size: 0.9em;
    color: #4a5568;
    line-height: 1.5;
}

.history-note.mastered {
    color: #276749;
    font-weight: bold;
}

.history-note.warn {
    color: #c05621;
    font-weight: bold;
}

.history-note.danger {
    color: #c53030;
    font-weight: bold;
}

.question-box {
    background: #fff8f0;
    border: 2px solid #ffd7b5;
    border-radius: 12px;
    padding: 22px;
    font-size: 1.15em;
    line-height: 1.7;
    margin-bottom: 18px;
    min-height: 120px;
}

.answer-area {
    margin-top: 10px;
}

.ox-row,
.conf-row,
.nav-row,
.deep-dive-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.deep-dive {
    margin: 16px 0 8px;
    padding: 14px;
    background: #f4f8ff;
    border: 1px solid #c5d7f2;
    border-radius: 12px;
}

.deep-dive-title {
    font-weight: bold;
    color: #2c5282;
    margin-bottom: 6px;
}

.deep-dive-hint {
    font-size: 0.9em;
    color: #4a5568;
    line-height: 1.5;
    margin-bottom: 10px;
}

.btn-deep {
    background: #edf2f7;
    color: #2d3748;
    border: 1px solid #cbd5e0;
}

.btn-notion {
    background: linear-gradient(135deg, #000000 0%, #333333 100%);
    color: white;
}

.btn-save {
    background: linear-gradient(135deg, #2f855a 0%, #38a169 100%);
    color: white;
}

.btn-sync {
    background: linear-gradient(135deg, #2b6cb0 0%, #3182ce 100%);
    color: white;
}

.mac-sync-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 10px 0 6px;
    font-size: 0.92em;
}

.mac-sync-row label {
    font-weight: 600;
    color: #444;
}

.mac-sync-row input {
    flex: 1 1 160px;
    min-width: 140px;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
}

.mac-sync-status {
    color: #2f855a;
    font-size: 0.9em;
}

.notion-auto-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 4px 0 10px;
    font-size: 0.9em;
    color: #4a5568;
    line-height: 1.45;
    cursor: pointer;
}

.notion-auto-label input {
    margin-top: 3px;
    flex-shrink: 0;
}

.btn-keyword {
    background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
    color: white;
}

.keyword-wrap {
    grid-column: 1 / -1;
}

.keyword-wrap input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
}

.notion-hint {
    margin-top: 12px;
    font-size: 0.88em;
    color: #555;
    line-height: 1.5;
}

.notion-hint code {
    background: #fff3e0;
    padding: 1px 6px;
    border-radius: 4px;
    margin-right: 4px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.modal-card h2 {
    color: #c0392b;
    margin-bottom: 12px;
    font-size: 1.35em;
}

.modal-warn {
    color: #333;
    line-height: 1.6;
    margin-bottom: 12px;
}

.modal-list {
    margin: 0 0 14px 1.2em;
    color: #555;
    line-height: 1.6;
}

.modal-count {
    margin-bottom: 12px;
    color: #922b21;
}

.modal-type-label {
    font-size: 0.95em;
    color: #333;
    margin-bottom: 8px;
}

.modal-type-label code {
    background: #fdecea;
    color: #922b21;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
}

.modal-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e74c3c;
    border-radius: 8px;
    font-size: 1.1em;
    margin-bottom: 16px;
    font-family: inherit;
}

.modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.modal-actions .btn {
    flex: 1;
    min-width: 120px;
}

#resetConfirmBtn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.copy-toast {
    margin-top: 8px;
    padding: 8px 12px;
    background: #e6fffa;
    color: #234e52;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: bold;
}

.result-banner {
    padding: 14px 16px;
    border-radius: 10px;
    font-weight: bold;
    margin-bottom: 14px;
    font-size: 1.1em;
}

.result-banner.ok {
    background: #e8f8ef;
    color: #1e8449;
}

.result-banner.ng {
    background: #fdecea;
    color: #922b21;
}

.explain-box {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 16px;
    line-height: 1.7;
    margin-bottom: 12px;
}

.explain-box h3 {
    color: #e67e22;
    margin-bottom: 8px;
    font-size: 1em;
}

.meta-line {
    color: #666;
    font-size: 0.95em;
    margin-bottom: 6px;
}

.welcome-content h2 {
    color: #e67e22;
    margin-bottom: 16px;
    text-align: center;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin: 20px 0;
}

.feature {
    background: #fff8f0;
    border-radius: 10px;
    padding: 16px;
}

.feature h3 {
    color: #e67e22;
    margin-bottom: 8px;
    font-size: 1.05em;
}

.feature p {
    color: #555;
    line-height: 1.5;
    font-size: 0.95em;
}

.browse-list {
    max-height: 480px;
    overflow-y: auto;
}

.browse-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.browse-item:hover {
    background: #fff8f0;
}

.browse-item .no {
    font-weight: bold;
    color: #ff6a88;
    min-width: 48px;
}

.browse-item .q {
    flex: 1;
    color: #333;
    line-height: 1.5;
}

.browse-item .status {
    font-size: 0.85em;
    white-space: nowrap;
    text-align: right;
    min-width: 110px;
}

.browse-item .history-mini {
    font-size: 0.8em;
    color: #718096;
    margin-top: 2px;
    letter-spacing: 0.5px;
}

.footer-links {
    text-align: center;
    margin-top: 10px;
}

.footer-links a {
    color: white;
    font-weight: bold;
    margin: 0 10px;
}

@media (max-width: 600px) {
    header h1 {
        font-size: 1.6em;
    }

    .question-box {
        font-size: 1.05em;
        padding: 16px;
    }
}
