/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
    min-height: 100vh;
}

/* ===== Header ===== */
.header {
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: #fff;
    padding: 1.5rem 1rem;
    text-align: center;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.header .subtitle {
    font-size: 0.875rem;
    opacity: 0.85;
    font-weight: 400;
}

/* ===== Main Container ===== */
.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* ===== Section Card ===== */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

.card h2 {
    font-size: 1rem;
    font-weight: 600;
    color: #1e40af;
    margin-bottom: 0.75rem;
}

/* ===== Lesson Select ===== */
.lesson-select-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.lesson-select-wrap label {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

#lessonSelect {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #333;
    cursor: pointer;
}

#lessonSelect:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ===== Description ===== */
.description {
    font-size: 0.95rem;
    color: #555;
    line-height: 1.7;
}

/* ===== Hint Accordion ===== */
.hint-accordion {
    cursor: default;
}

.hint-summary {
    font-size: 1rem;
    font-weight: 600;
    color: #1e40af;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
}

.hint-summary::-webkit-details-marker {
    display: none;
}

.hint-summary::before {
    content: "▶";
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.hint-accordion[open] > .hint-summary::before {
    transform: rotate(90deg);
}

.hint-accordion .rules {
    margin-top: 0.75rem;
}

/* ===== Rules ===== */
.rules {
    font-size: 0.85rem;
    color: #444;
    line-height: 1.8;
    white-space: pre-wrap;
    background: #f8fafc;
    border-left: 3px solid #2563eb;
    padding: 1rem 1.25rem;
    border-radius: 0 6px 6px 0;
}

/* ===== Code Editor ===== */
.editor-wrap {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    overflow: hidden;
}

.cm-editor {
    font-size: 14px;
}

.cm-editor .cm-scroller {
    font-family: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", Menlo, Consolas, monospace;
}

.cm-editor.cm-focused {
    outline: none;
}

/* ===== Button ===== */
.btn-area {
    text-align: center;
    margin: 1.25rem 0;
}

#reviewBtn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #2563eb;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

#reviewBtn:hover:not(:disabled) {
    background: #1d4ed8;
}

#reviewBtn:active:not(:disabled) {
    transform: scale(0.97);
}

#reviewBtn:disabled {
    background: #93c5fd;
    cursor: not-allowed;
}

/* Spinner */
.spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

#reviewBtn.loading .spinner {
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Result ===== */
#resultArea {
    display: none;
}

#resultArea.visible {
    display: block;
}

.result-content {
    font-size: 0.92rem;
    line-height: 1.85;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: #222;
}

.result-content code {
    font-family: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", Menlo, Consolas, monospace;
    font-size: 0.85em;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 0.1em 0.35em;
    color: #0f172a;
}

.result-content .line-ok {
    color: #16a34a;
}

.result-content .line-ng {
    color: #dc2626;
}

.result-content .line-ok code,
.result-content .line-ng code {
    color: #0f172a;
}

.result-content .result-divider {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 0.75rem 0;
}

.result-content .line-score {
    font-weight: 700;
    font-size: 1rem;
    color: #1e40af;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 1.5rem 1rem;
    font-size: 0.75rem;
    color: #9ca3af;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .header h1 {
        font-size: 1.2rem;
    }

    .container {
        padding: 1rem 0.75rem;
    }

    .card {
        padding: 1rem;
    }

    #reviewBtn {
        width: 100%;
        justify-content: center;
    }

    .cm-editor {
        font-size: 13px;
    }
}
