html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: "Yu Gothic", "Hiragino Sans", sans-serif;
    background: #f7f8fc;
    color: #223;
    display: flex;
    flex-direction: column;
}

.site-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.site-header .site-logo {
    margin: 0;
    font-size: 1.2rem;
}

.site-header a {
    color: white;
    text-decoration: none;
}

.menu-toggle {
    border: 0;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 999px;
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
    cursor: pointer;
}

.container {
    display: flex;
    align-items: stretch;
    overflow: hidden;
    flex: 1 0 auto;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    padding: 20px;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.04);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    position: relative;
    min-height: 100%;
    margin-right: 0;
    overflow-y: auto;
    box-sizing: border-box;
    z-index: 100;
}

.sidebar:not(.is-open) {
    width: 0;
    padding: 0;
    border-right: 0;
    box-shadow: none;
    transform: translateX(-100%);
}

.sidebar.is-open {
    width: 240px;
    padding: 20px;
    transform: translateX(0);
}

.site-note {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.8rem;
    line-height: 1.5;
    margin-bottom: 16px;
}

.sidebar h3 {
    margin-top: 0;
    font-size: 1.15rem;
    font-weight: 600;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
}

.sidebar li + li {
    margin-top: 10px;
}

.sidebar a {
    color: #374151;
    text-decoration: none;
    font-size: 1rem;
}

.sidebar a:hover {
    color: #2563eb;
    text-decoration: underline;
}

main {
    flex: 1;
    padding: 24px;
    margin-left: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

footer {
    margin-top: auto;
    padding: 16px 24px;
    background: linear-gradient(135deg, #1d4ed8, #6d28d9);
    color: white;
    text-align: center;
    font-weight: 600;
    flex-shrink: 0;
}

.breadcrumb {
    margin-bottom: 20px;
    color: #666;
    font-size: 0.9rem;
}

.breadcrumb a {
    color: #666;
    text-decoration: none;
}

.breadcrumb a:hover {
    color: #2563eb;
}

.choices-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
}

.choice {
    display: flex;
    align-items: center;
    border: 1px solid #ccc;
    padding: 15px;
    cursor: pointer;
    border-radius: 8px;
    background: white;
    font-size: 1rem;
    line-height: 1.5;
    transition: all 0.2s ease;
}

.choice:hover {
    background: #f4f4f4;
    border-color: #999;
}

.choice:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
    background: #eff6ff;
    border-color: #2563eb;
}

.choice.correct {
    background: #dcfce7;
    border-color: #22c55e;
    color: #15803d;
}

.choice.incorrect {
    background: #fee2e2;
    border-color: #ef4444;
    color: #991b1b;
}

.mark {
    display: inline-block;
    width: 30px;
    font-weight: bold;
    text-align: center;
    margin-right: 10px;
}

.explanation-box {
    margin-top: 20px;
    padding: 20px;
    border-radius: 8px;
    background: #f3f4f6;
    border-left: 4px solid #2563eb;
}

.explanation-box h2 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.explanation-box p {
    margin: 0;
    line-height: 1.6;
}

.explanation-content {
    line-height: 1.6;
}

.explanation-content p {
    margin: 0 0 0.75em;
}

.explanation-content p:last-child {
    margin-bottom: 0;
}

.explanation-content h3 {
    margin: 0.75em 0 0.4em;
    font-size: 1rem;
}

.explanation-content ul,
.explanation-content ol {
    margin: 0 0 0.75em;
    padding-left: 1.5em;
}

.explanation-content li {
    margin: 0.2em 0;
}

.explanation-content code {
    padding: 0.1em 0.35em;
    border-radius: 4px;
    background: #e5e7eb;
    font-size: 0.95em;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.explanation-content a {
    color: #2563eb;
    text-decoration: underline;
    word-break: break-all;
}

/* Chemical structure figures embedded via {{struct:<id>}} in explanations. */
.explanation-content .chem-structure {
    margin: 1em auto;
    padding: 12px;
    max-width: 340px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    text-align: center;
}

.explanation-content .chem-structure__svg svg {
    display: block;
    width: 100%;
    max-width: 260px;
    height: auto;
    margin: 0 auto;
}

.explanation-content .chem-structure figcaption {
    margin-top: 8px;
    font-size: 0.85rem;
    color: #6b7280;
}

.hidden {
    display: none;
}

main h1 {
    margin-top: 0;
    font-size: 1.8rem;
    color: #1f2937;
}

main ul {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}

main li {
    margin: 10px 0;
}

main a {
    color: #2563eb;
    text-decoration: none;
}

main a:hover {
    text-decoration: underline;
}

/* Mobile responsive */
@media (max-width: 768px) {
    body {
        margin: 0;
        padding: 0;
    }

    .container {
        display: flex;
        flex-direction: column;
        flex: 1 0 auto;
    }

    .site-header {
        padding: 14px 16px;
    }

    .site-header .site-logo {
        font-size: 1.05rem;
        flex: 1;
    }

    .menu-toggle {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }

    .sidebar {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-width: 240px;
        border-right: 1px solid #e5e7eb;
        border-bottom: none;
        padding: 60px 16px 16px;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
        z-index: 100;
    }

    .sidebar:not(.is-open) {
        display: none;
    }

    .sidebar h3 {
        font-size: 1.1rem;
    }

    .sidebar a {
        font-size: 0.95rem;
    }

    main {
        padding: 16px;
        margin: 0;
        flex: 1;
        overflow-y: auto;
    }

    main h1 {
        font-size: 1.5rem;
        margin: 0 0 16px 0;
    }

    .breadcrumb {
        font-size: 0.85rem;
        margin-bottom: 16px;
    }

    .choices-area {
        gap: 12px;
        margin: 16px 0;
    }

    .choice {
        padding: 16px;
        font-size: 1.05rem;
        line-height: 1.6;
        min-height: 60px;
    }

    .mark {
        margin-right: 12px;
    }

    .explanation-box {
        margin-top: 16px;
        padding: 16px;
    }

    .explanation-box h2 {
        font-size: 1.05rem;
    }

    .explanation-box p {
        font-size: 1rem;
    }

    footer {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
}

/* Custom Added Styles for Antigravity Enhancement */
.welcome-banner {
    background: linear-gradient(135deg, #eff6ff, #f3e8ff);
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid #dbeafe;
}

.welcome-banner h1 {
    margin-bottom: 8px;
    color: #1e3a8a;
    font-size: 1.8rem;
}

.welcome-banner p {
    margin: 0;
    color: #4b5563;
    font-size: 1.05rem;
    line-height: 1.6;
}

.section {
    margin: 24px 0;
}

.section-title {
    font-size: 1.3rem;
    color: #1f2937;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.accent-card {
    background: linear-gradient(135deg, #ffffff, #fefefe);
    border-left: 5px solid #3b82f6;
}

.action-area {
    margin-top: 16px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    border: none;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white !important;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(59, 130, 246, 0.4);
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151 !important;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background: #e5e7eb;
    color: #1f2937 !important;
    transform: translateY(-1px);
}

.btn-large {
    padding: 14px 28px;
    font-size: 1.1rem;
}

/* Update History */
.update-history-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.history-item {
    display: flex;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid #f3f4f6;
}

.history-item:last-child {
    border-bottom: none;
}

.history-date {
    font-weight: bold;
    color: #6b7280;
    font-family: monospace;
    font-size: 0.95rem;
    min-width: 90px;
}

.history-note {
    color: #374151;
}

/* Question List & Grid */
.questions-container, .categories-container {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.filter-area {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.random-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin: 12px 0;
}

.random-options label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.9rem;
    color: #374151;
}

.random-options input[type="number"] {
    width: 100px;
}

.select-input {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-size: 0.95rem;
    background: white;
}

.question-grid-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.question-item {
    margin: 0 !important;
}

.question-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
    transition: all 0.2s ease;
    color: #374151 !important;
}

.question-card:hover {
    background: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.08);
    transform: translateX(4px);
    text-decoration: none !important;
}

.question-cat-badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* Tag chips (question.html) and tag-type sections (tags.html) */
.tag-chip-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-chip {
    display: inline-block;
    background: #f3f4f6;
    color: #374151 !important;
    border: 1px solid #d1d5db;
    text-transform: none;
    text-decoration: none !important;
}

.tag-chip:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.tag-type-section {
    margin-top: 24px;
}

.tag-type-section h2 {
    margin-bottom: 8px;
}

.badge-law {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.badge-chem {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.badge-fire {
    background: #fff5f5;
    color: #9b2c2c;
    border: 1px solid #feb2b2;
}

.question-text {
    flex: 1;
    margin: 0 16px;
    font-weight: 500;
}

.related-reason-badge {
    flex-shrink: 0;
    background: #e5e7eb;
    color: #374151;
    border: 1px solid #d1d5db;
    text-transform: none;
    white-space: nowrap;
}

.question-arrow, .category-arrow {
    font-weight: bold;
    color: #9ca3af;
    transition: transform 0.2s ease;
}

.question-card:hover .question-arrow,
.category-card:hover .category-arrow {
    color: #3b82f6;
    transform: translateX(4px);
}

/* Category Grid */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.category-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #f9fafb;
    transition: all 0.2s ease;
    color: #374151 !important;
}

.category-card:hover {
    background: white;
    border-color: #3b82f6;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.1);
    transform: translateY(-2px);
    text-decoration: none !important;
}

.category-card-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.category-icon {
    font-size: 1.4rem;
}

.category-name {
    font-size: 1.1rem;
    font-weight: 600;
}
