:root {
    --surface: #ffffff;
    --surface-muted: #f7f6f3;
    --surface-panel: #ffffff;
    --surface-card: #ffffff;
    --border: rgba(15, 23, 42, 0.08);
    --text: #2f3033;
    --muted: #8b8f9b;
    --accent-blue: #4f7dbd;
    --accent-blue-soft: rgba(79, 125, 189, 0.18);
    --accent-blue-strong: linear-gradient(135deg, #4f7dbd, #6f9de0);
    --accent-red: #d46b6b;
    --accent-red-soft: rgba(212, 107, 107, 0.18);
    --accent-red-strong: linear-gradient(135deg, #d46b6b, #f28f8f);
    --accent-green: #37a46a;
    --shadow: 0 18px 32px rgba(15, 23, 42, 0.08);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Sarabun', Tahoma, Geneva, Verdana, sans-serif;
    background: radial-gradient(circle at top, #f9f8f5 0%, #f2f1ec 60%);
    color: var(--text);
    min-height: 100vh;
    padding: 16px;
}

.page {
    width: min(960px, 100%);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.workspace {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel {
    background: var(--surface-card);
    border-radius: 18px;
    border: 1px solid rgba(15, 23, 42, 0.05);
    padding: 22px 24px;
    box-shadow: var(--shadow);
}

.hidden {
    display: none !important;
}

.x-row{flex-direction: row !important;}
.x-row #size{width: auto;}
.x-row #btn-random{width: auto;}

.controls-panel {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.controls-panel .control-grid {
    background: rgba(255, 255, 255, 0.85);
    border-radius: 14px;
    padding: 12px 16px;
    border: 1px solid rgba(15, 23, 42, 0.05);
}

.controls-panel .control-grid label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.panel-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
}

.panel-head h1 {
    margin: 6px 0;
    font-size: clamp(22px, 4vw, 32px);
}

.panel-head h2 {
    font-size: 22px;
}

.panel-head p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}


.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 11px;
    color: var(--accent-blue);
    margin: 0;
}

.muted {
    color: var(--muted);
}

.muted.small {
    font-size: 14px;
}

.stat-badge {
    min-width: 120px;
    text-align: right;
}

.stat-badge strong {
    display: block;
    font-size: 28px;
}

.control-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-inline {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.control-inline input {
    flex: 1;
}

.button-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.align-center {
    align-items: center;
}

input[type="number"] {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 16px;
    background: var(--surface-panel);
    color: var(--text);
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(79, 125, 189, 0.2);
}

select {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 15px;
    background: var(--surface-panel);
    color: var(--text);
}

select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(79, 125, 189, 0.2);
}

input[type="range"] {
    -webkit-appearance: none;
    height: 6px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.12);
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
}

.btn {
    border: none;
    border-radius: 14px;
    padding: 12px 18px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn.primary {
    background: var(--accent-blue-strong);
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(79, 125, 189, 0.25);
}

.btn.secondary {
    background: transparent;
    color: var(--accent-blue);
    border: 1px solid var(--accent-blue);
}

.btn.text-btn {
    background: transparent;
    color: var(--muted);
    border: none;
    padding: 0;
    box-shadow: none;
    font-size: 14px;
}

.btn:hover {
    transform: translateY(-1px);
}

.prompt-status {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 12px;
    min-height: 24px;
}

#question-order{margin-right:24px;}

.prompt {
    font-size: clamp(26px, 4vw, 36px);
}

.empty-state {
    margin-top: 18px;
    color: var(--muted);
}

.quiz-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.quiz-panel{border:none;padding:0px;}

.prompt-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.prompt-body {
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 16px;
    padding: 18px 20px;
    background: #fcfcfa;
}

.prompt-label {
    margin: 0 0 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--muted);
}

.prompt-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.prompt-row .prompt {
    flex: 1;
}

.prompt-body .prompt {
    margin: 0;
    color: var(--text);
    font-family: 'Inter', 'Sarabun', 'Segoe UI', Arial, sans-serif;
    letter-spacing: 0.02em;
}

#topic{font-family: 'Georgia';}


#btn-save-current {
    white-space: nowrap;
}

#btn-save-current:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.choices-box {
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    padding-top: 12px;
    margin-top: 18px;
}

.focus-modal,
.result-modal {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.55);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 16px;
    z-index: 1000;
}

.focus-modal-content,
.result-modal-content {
    width: min(560px, 100%);
    background: var(--surface-card);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 24px;
    border: 1px solid var(--border);
    max-height: 80vh;
    overflow-y: auto;
}

.result-modal-content {
    text-align: center;
}

.result-text {
    margin: 14px 0 24px;
    font-size: 16px;
    color: var(--text);
}

.focus-panel-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.focus-panel-actions {
    display: flex;
    gap: 8px;
}

.focus-list-wrapper {
    margin-top: 16px;
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 16px;
    background: #fbfbf9;
    padding: 14px 16px;
}

.focus-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

#focus-list {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.focus-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 12px;
    padding: 10px 12px;
    gap: 12px;
}

.focus-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.focus-term {
    font-weight: 600;
    color: var(--text);
}

.focus-meaning {
    font-size: 14px;
    color: var(--muted);
}

.focus-empty {
    margin-top: 12px;
    color: var(--muted);
    font-size: 14px;
}

.remove-focus {
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    border-radius: 50%;
    transition: background 0.2s ease, color 0.2s ease;
}

.remove-focus:hover {
    background: var(--accent-blue-soft);
    color: var(--accent-blue);
}

.choice-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.choice-list li {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    background: #ffffff;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.choice-list li:hover {
    border-color: var(--accent-blue);
    transform: translateX(4px);
    box-shadow: 0 6px 18px rgba(79, 125, 189, 0.18);
}

.choice-list li.active {
    border-color: var(--accent-red);
    box-shadow: 0 8px 20px rgba(212, 107, 107, 0.25);
}

.choice-list li.correct {
    border-color: var(--accent-green);
    box-shadow: 0 8px 20px rgba(55, 164, 106, 0.25);
}

.choice-list li.incorrect {
    border-color: var(--accent-red);
    box-shadow: 0 8px 20px rgba(212, 107, 107, 0.25);
}

.choice-prefix {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(79, 125, 189, 0.12);
    border: 1px solid rgba(79, 125, 189, 0.2);
    text-align: center;
    line-height: 30px;
    font-weight: 700;
    color: var(--accent-blue);
}

.choice-text {
    flex: 1;
}

@media (max-width: 720px) {
    .panel-head {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    .control-inline {
        flex-direction: column;
    }

    .button-stack {
        width: 100%;
    }

    .prompt-meta {
        flex-direction: column;
        align-items: stretch;
    }

    .prompt-row {
        flex-direction: row;
        align-items: center;
    }
}

@media (max-width: 600px) {
    .panel-head h2{margin:0px;}
    .panel-head h1{font-size:16px;}
    .panel-head .muted{font-size:14px;}
    .font-adjust{display: none;}
    .controls-panel {
        padding: 18px 18px 20px;
        gap: 14px;
    }

    .controls-panel .control-grid {
        padding: 10px 12px;
        border-radius: 12px;
    }

    .controls-panel .control-inline input,
    .controls-panel .control-inline button,
    .controls-panel .control-inline select {
        width: 100%;
    }
}
