:root {
    --math-bg: #f7fbff;
    --math-bg-warm: #fff7e8;
    --math-ink: #1f2937;
    --math-muted: #64748b;
    --math-primary: #2563eb;
    --math-primary-2: #14b8a6;
    --math-accent: #f59e0b;
    --math-good: #059669;
    --math-bad: #e11d48;
    --math-line: #dbe8f6;
    --math-card: rgba(255, 255, 255, 0.82);
    --math-shadow: 0 18px 38px rgba(36, 68, 112, 0.14);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body.math-daily-page {
    margin: 0;
    color: var(--math-ink);
    background: linear-gradient(135deg, var(--math-bg), var(--math-bg-warm));
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Pretendard, "Noto Sans KR", sans-serif;
}

.math-daily-app {
    min-height: 100vh;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.math-topbar,
.math-panel {
    background: var(--math-card);
    border: 1px solid rgba(219, 232, 246, 0.95);
    border-radius: 24px;
    box-shadow: var(--math-shadow);
    backdrop-filter: blur(14px);
}

.math-topbar {
    min-height: 78px;
    padding: 14px 18px;
    display: grid;
    grid-template-columns: minmax(260px, 360px) minmax(240px, 1fr) auto;
    align-items: center;
    gap: 18px;
}

.math-brand {
    display: flex;
    align-items: center;
    gap: 13px;
}

.math-logo {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--math-primary-2), var(--math-primary));
    color: #fff;
    font-size: 26px;
    font-weight: 900;
}

.math-brand h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.08;
    font-weight: 900;
}

.math-brand p {
    margin: 4px 0 0;
    color: var(--math-muted);
    font-size: 13px;
    font-weight: 700;
}

.math-progress-info {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    color: #526174;
    font-size: 13px;
    font-weight: 800;
}

.math-progress-bar {
    height: 14px;
    overflow: hidden;
    border-radius: 999px;
    background: #e9f2fb;
}

.math-progress-fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--math-primary-2), var(--math-primary));
    transition: width 0.25s ease;
}

.math-user {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 190px;
    font-size: 14px;
    font-weight: 900;
    color: #334155;
}

.math-main {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 14px;
}

@media (min-width: 761px) {
    body.math-daily-page {
        overflow: hidden;
    }

    .math-daily-app {
        height: 100vh;
    }
}

.math-panel {
    min-height: 0;
}

.math-left {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.math-left h2,
.math-control-title h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 900;
}

.math-left p {
    margin: 4px 0 8px;
    color: var(--math-muted);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.45;
}

.math-unit-list {
    display: grid;
    gap: 9px;
}

.math-unit-item {
    border: 1px solid #e4eef9;
    border-radius: 16px;
    background: #fff;
    padding: 11px 12px;
}

.math-unit-item.is-active {
    border-color: #a9d4ff;
    background: linear-gradient(135deg, #edf8ff, #fff8e7);
}

.math-unit-item.is-muted {
    opacity: 0.52;
}

.math-unit-item strong {
    display: block;
    font-size: 13px;
    line-height: 1.3;
}

.math-unit-item span {
    display: block;
    margin-top: 3px;
    color: var(--math-muted);
    font-size: 11px;
    font-weight: 800;
}

.math-tip {
    margin-top: auto;
    border: 1px dashed #bfd2e6;
    border-radius: 18px;
    background: linear-gradient(135deg, #fff9ea, #eefbf8);
    padding: 13px;
    color: #536173;
    font-size: 12.5px;
    font-weight: 800;
    line-height: 1.45;
}

.math-stage {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.math-question-head {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.math-tag,
.math-count {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    border-radius: 999px;
    padding: 0 13px;
    font-size: 13px;
    font-weight: 900;
}

.math-tag {
    background: #eaf6ff;
    border: 1px solid #cfe6ff;
    color: #1d5f9f;
}

.math-count {
    background: #fff;
    border: 1px solid #e5eef8;
    color: var(--math-muted);
}

.math-problem {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 14px;
    position: relative;
    overflow: hidden;
    border: 1px solid #e6eff9;
    border-radius: 26px;
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
}

.math-prompt {
    position: relative;
    margin: 0;
    text-align: center;
    color: #152238;
    font-size: 28px;
    font-weight: 900;
    line-height: 1.45;
}

.math-frac {
    display: inline-grid;
    grid-template-rows: auto auto;
    align-items: center;
    vertical-align: middle;
    min-width: 1.1em;
    margin: 0 0.14em;
    font-weight: 900;
    line-height: 0.95;
    text-align: center;
}

.math-frac span:first-child {
    border-bottom: 2px solid currentColor;
    padding: 0 0.14em 0.08em;
}

.math-frac span:last-child {
    padding: 0.08em 0.14em 0;
}

.math-expression {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.24em;
    white-space: nowrap;
    vertical-align: middle;
}

.math-expression .math-frac {
    vertical-align: middle;
}

.math-symbol,
.math-operator {
    display: inline-grid;
    place-items: center;
    min-width: 1.05em;
    min-height: 1.2em;
    margin: 0 0.08em;
    font-weight: 950;
    line-height: 1;
    vertical-align: middle;
}

.math-symbol {
    font-size: 1.08em;
}

.math-symbol-square {
    min-width: 1.42em;
    min-height: 1.42em;
    border: 2px solid currentColor;
    border-radius: 7px;
    background: #ffffff;
    color: #1d4ed8;
    font-size: 1.18em;
}

.math-expression .math-symbol-square {
    min-width: 1.68em;
    min-height: 1.48em;
    font-size: 1.24em;
}

.math-mixed-whole {
    display: inline-block;
    margin-right: 0.08em;
    font-weight: 900;
}

.math-context {
    display: block;
    margin-top: 8px;
    color: var(--math-muted);
    font-size: 15px;
    font-weight: 800;
}

.math-workspace {
    display: grid;
    place-items: center;
    align-content: start;
    gap: 12px;
    min-height: 0;
    overflow: auto;
    padding: 2px 4px 4px;
}

.math-visual {
    width: min(640px, 100%);
    min-width: 0;
}

.math-polygon-visual {
    width: min(620px, 100%);
}

.math-visual-table {
    width: 100%;
    margin: 0 0 10px;
    border-collapse: collapse;
    overflow: hidden;
    border-radius: 12px;
    background: #fff;
    color: #243044;
    font-size: 13px;
    font-weight: 900;
    box-shadow: inset 0 0 0 1px #dfeaf6;
}

.math-visual-table caption {
    padding: 6px 8px;
    color: #475569;
    text-align: left;
    font-size: 12px;
}

.math-visual-table th,
.math-visual-table td {
    border: 1px solid #dfeaf6;
    padding: 7px 8px;
    text-align: center;
}

.math-visual-table th {
    background: #eef6ff;
    color: #1d4f86;
}

.math-line-graph-svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.math-polygon-svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.math-polygon-bg {
    fill: #ffffff;
    stroke: #dce8f5;
    stroke-width: 2;
}

.math-polygon-shape {
    stroke-width: 4;
    stroke-linejoin: round;
}

.math-polygon-segment {
    stroke-width: 4;
    stroke-linecap: round;
}

.math-polygon-segment.is-dashed {
    stroke-dasharray: 8 7;
}

.math-polygon-grid-shade {
    fill: #dbeafe;
}

.math-polygon-grid-line {
    stroke: #9fb6d8;
    stroke-width: 1.5;
}

.math-polygon-title,
.math-polygon-label {
    fill: #243044;
    font-weight: 950;
}

.math-polygon-title {
    font-size: 18px;
}

.math-polygon-label {
    font-size: 17px;
}

.math-polygon-label.is-note,
.math-polygon-label.is-unit {
    fill: #1d4f86;
    font-size: 15px;
}

.math-polygon-label.is-height {
    fill: #b91c1c;
}

.math-line-graph-bg {
    fill: #ffffff;
    stroke: #dce8f5;
    stroke-width: 2;
}

.math-line-graph-title,
.math-line-graph-y-name,
.math-line-graph-x-label,
.math-line-graph-grid-row text {
    fill: #334155;
    font-weight: 900;
}

.math-line-graph-title {
    font-size: 18px;
}

.math-line-graph-y-name,
.math-line-graph-x-label,
.math-line-graph-grid-row text {
    font-size: 13px;
}

.math-line-graph-grid-row line {
    stroke: #e7eef7;
    stroke-width: 1;
}

.math-line-graph-axis {
    stroke: #64748b;
    stroke-width: 2;
}

.math-line-graph-segment {
    stroke: #2563eb;
    stroke-linecap: round;
    stroke-width: 4;
}

.math-line-graph-segment.is-highlight {
    stroke: #f59e0b;
    stroke-width: 6;
}

.math-line-graph-segment.is-locked {
    stroke: #60a5fa;
    stroke-width: 4;
}

.math-line-graph-point circle {
    fill: #2563eb;
    stroke: #fff;
    stroke-width: 3;
}

.math-line-graph-point text {
    fill: #172033;
    font-size: 13px;
    font-weight: 900;
}

.math-line-graph-point.is-highlight circle {
    fill: #f59e0b;
}

.math-line-graph-point.is-locked circle {
    fill: #dbeafe;
    stroke: #2563eb;
}

.math-line-graph-point.is-locked text {
    fill: #1e3a8a;
}

.math-line-graph-point.is-missing circle {
    fill: #fff7ed;
    stroke: #f59e0b;
    stroke-dasharray: 4 3;
}

.math-line-graph-point.is-missing text,
.math-line-graph-wave {
    fill: #f97316;
    font-size: 24px;
    font-weight: 950;
}

.math-line-graph-candidate circle {
    fill: #fff7ed;
    stroke: #f59e0b;
    stroke-width: 3;
}

.math-line-graph-candidate text {
    fill: #9a3412;
    font-size: 13px;
    font-weight: 950;
}

.math-line-graph-visual.is-draw-input .math-line-graph-svg {
    cursor: crosshair;
    touch-action: manipulation;
}

.math-line-graph-draw-segment {
    stroke: #f97316;
    stroke-width: 5;
    stroke-linecap: round;
}

.math-line-graph-draw-point circle {
    fill: #fff7ed;
    stroke: #ea580c;
    stroke-width: 4;
}

.math-line-graph-draw-point text {
    fill: #9a3412;
    font-size: 13px;
    font-weight: 950;
}

.math-choice .math-visual {
    width: 100%;
    margin-top: 8px;
    pointer-events: none;
}

.math-choice .math-line-graph-title {
    font-size: 16px;
}

.math-choice .math-line-graph-y-name,
.math-choice .math-line-graph-x-label,
.math-choice .math-line-graph-grid-row text {
    font-size: 12px;
}

.math-choice-grid {
    width: min(620px, 100%);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.math-point-option-grid,
.math-symbol-choice-grid,
.math-input-panel {
    width: min(620px, 100%);
}

.math-draw-toolbar {
    width: min(620px, 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 2px solid #fed7aa;
    border-radius: 18px;
    background: #fff7ed;
    padding: 12px 14px;
    color: #7c2d12;
    font-weight: 950;
    box-shadow: 0 8px 18px rgba(154, 52, 18, 0.08);
}

.math-draw-toolbar.is-correct {
    border-color: var(--math-good);
    background: #ecfdf5;
    color: #047857;
}

.math-draw-toolbar.is-wrong {
    border-color: var(--math-bad);
    background: #fff1f2;
    color: #be123c;
}

.math-draw-status {
    font-size: 15px;
}

.math-draw-reset {
    border: 0;
    border-radius: 999px;
    background: #ea580c;
    color: #fff;
    padding: 10px 16px;
    font: inherit;
    font-size: 14px;
    font-weight: 950;
    cursor: pointer;
}

.math-draw-reset:hover {
    background: #c2410c;
}

.math-point-option-grid,
.math-symbol-choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.math-symbol-choice-grid {
    width: min(520px, 100%);
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.math-input-panel {
    border: 2px solid #dbeafe;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.96);
    padding: 16px 18px;
    box-shadow: 0 8px 18px rgba(29, 55, 91, 0.07);
}

.math-input-label {
    display: block;
    margin-bottom: 8px;
    color: #334155;
    font-size: 14px;
    font-weight: 900;
}

.math-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.math-fraction-input-panel {
    display: grid;
    gap: 14px;
    justify-items: center;
}

.math-fraction-answer-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    width: 100%;
}

.math-whole-input-wrap {
    display: grid;
    gap: 6px;
    color: #334155;
    font-size: 13px;
    font-weight: 900;
    text-align: center;
}

.math-fraction-box {
    display: grid;
    grid-template-rows: 58px 4px 58px;
    align-items: center;
    justify-items: center;
    width: min(180px, 48vw);
}

.math-fraction-line {
    width: 100%;
    height: 4px;
    border-radius: 999px;
    background: #172033;
}

.math-fraction-slot {
    width: 100%;
    min-height: 58px;
    padding: 0 10px;
}

.math-input-note {
    margin: 0;
    color: #64748b;
    font-size: 13px;
    font-weight: 800;
    text-align: center;
}

body.math-daily-page .math-direct-input {
    width: 100%;
    min-height: 58px;
    border: 2px solid #dbeafe;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.98);
    background-color: rgba(255, 255, 255, 0.98);
    color: #172033;
    padding: 0 16px;
    font: inherit;
    font-size: 24px;
    font-weight: 950;
    text-align: center;
}

body.math-daily-page .math-direct-input::placeholder {
    color: #64748b;
    opacity: 0.78;
}

.math-fraction-box .math-fraction-slot {
    padding: 0 10px;
}

.math-whole-input-wrap .math-fraction-slot {
    width: 112px;
}

body.math-daily-page .math-direct-input:focus {
    outline: 3px solid rgba(37, 99, 235, 0.18);
    border-color: var(--math-primary);
    background: #fff;
    background-color: #fff;
    color: #172033;
}

body.math-daily-page .math-direct-input.is-correct {
    border-color: var(--math-good);
    background: #ecfdf5;
    background-color: #ecfdf5;
}

body.math-daily-page .math-direct-input.is-wrong {
    border-color: var(--math-bad);
    background: #fff1f2;
    background-color: #fff1f2;
}

.math-floating-keypad {
    position: fixed;
    z-index: 90;
    width: 292px;
    color: #172033;
    touch-action: none;
}

.math-floating-keypad.is-hidden {
    display: none;
}

.math-floating-keypad.is-collapsed {
    width: 62px;
}

.math-keypad-fab {
    width: 62px;
    height: 62px;
    border: 0;
    border-radius: 22px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--math-primary-2), var(--math-primary));
    color: #fff;
    font: inherit;
    font-size: 28px;
    font-weight: 950;
    box-shadow: 0 16px 34px rgba(37, 99, 235, 0.28);
    cursor: grab;
    touch-action: none;
}

.math-keypad-fab:active,
.math-keypad-head {
    cursor: grabbing;
}

.math-keypad-panel {
    margin-top: 8px;
    border: 2px solid #bfdbfe;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.96);
    padding: 12px;
    box-shadow: 0 20px 42px rgba(15, 23, 42, 0.22);
    backdrop-filter: blur(12px);
}

.math-keypad-head {
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: #1e3a8a;
    font-size: 14px;
    font-weight: 950;
    touch-action: none;
}

.math-keypad-head button {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 999px;
    background: #eaf3ff;
    color: #1d4ed8;
    font: inherit;
    font-weight: 950;
    cursor: pointer;
}

.math-keypad-display {
    min-height: 48px;
    margin: 8px 0 10px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: #f8fbff;
    color: #172033;
    font-size: 23px;
    font-weight: 950;
}

.math-keypad-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
}

.math-keypad-key {
    min-height: 50px;
    border: 0;
    border-radius: 14px;
    background: #eaf3ff;
    color: #172033;
    font: inherit;
    font-size: 21px;
    font-weight: 950;
    cursor: pointer;
    box-shadow: inset 0 -2px 0 rgba(37, 99, 235, 0.12);
    touch-action: manipulation;
}

.math-keypad-key:hover,
.math-keypad-key:focus-visible {
    background: #dbeafe;
    outline: 3px solid rgba(37, 99, 235, 0.18);
}

.math-keypad-key.is-action {
    background: #fff7ed;
    color: #9a3412;
}

.math-keypad-key.is-primary {
    background: linear-gradient(135deg, var(--math-primary), var(--math-primary-2));
    color: #fff;
}

.math-keypad-key.is-wide {
    grid-column: span 3;
    min-height: 46px;
    font-size: 16px;
}

.math-floating-scratchpad {
    position: fixed;
    z-index: 88;
    width: var(--math-scratchpad-width, 360px);
    color: #172033;
    touch-action: none;
}

.math-floating-scratchpad.is-hidden {
    display: none;
}

.math-floating-scratchpad.is-collapsed {
    width: 62px;
}

.math-scratchpad-fab {
    width: 62px;
    height: 62px;
    border: 0;
    border-radius: 22px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--math-accent), var(--math-primary-2));
    color: #fff;
    font: inherit;
    font-size: 31px;
    font-weight: 950;
    box-shadow: 0 16px 34px rgba(20, 184, 166, 0.26);
    cursor: grab;
    touch-action: none;
}

.math-scratchpad-fab:active,
.math-scratchpad-head {
    cursor: grabbing;
}

.math-scratchpad-panel {
    position: relative;
    margin-top: 8px;
    border: 2px solid #fed7aa;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.96);
    padding: 12px;
    box-shadow: 0 20px 42px rgba(15, 23, 42, 0.2);
    backdrop-filter: blur(12px);
}

.math-floating-scratchpad.is-resizing .math-scratchpad-panel {
    user-select: none;
}

.math-scratchpad-head {
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: #7c2d12;
    font-size: 14px;
    font-weight: 950;
    touch-action: none;
}

.math-scratchpad-head button {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 999px;
    background: #fff7ed;
    color: #9a3412;
    font: inherit;
    font-weight: 950;
    cursor: pointer;
}

.math-scratchpad-toolbar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 10px 0;
}

.math-scratchpad-tool {
    min-height: 38px;
    border: 1px solid #fed7aa;
    border-radius: 12px;
    background: #fff7ed;
    color: #7c2d12;
    font: inherit;
    font-size: 13px;
    font-weight: 950;
    cursor: pointer;
    touch-action: manipulation;
}

.math-scratchpad-tool:hover,
.math-scratchpad-tool:focus-visible,
.math-scratchpad-tool.is-active {
    border-color: #14b8a6;
    background: #ecfdf5;
    color: #0f766e;
    outline: 3px solid rgba(20, 184, 166, 0.16);
}

.math-scratchpad-canvas {
    display: block;
    width: 100%;
    height: var(--math-scratchpad-canvas-height, 270px);
    border: 1px solid #f2d7b7;
    border-radius: 16px;
    background-color: #fffdf7;
    background-image:
        linear-gradient(rgba(20, 184, 166, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(20, 184, 166, 0.08) 1px, transparent 1px);
    background-size: 24px 24px;
    cursor: crosshair;
    touch-action: none;
}

.math-scratchpad-resize {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 28px;
    height: 28px;
    border: 1px solid #fed7aa;
    border-radius: 10px;
    background: rgba(255, 247, 237, 0.92);
    box-shadow: 0 8px 18px rgba(124, 45, 18, 0.16);
    cursor: nwse-resize;
    touch-action: none;
}

.math-scratchpad-resize::before {
    content: "";
    position: absolute;
    inset: 7px;
    background:
        linear-gradient(135deg, transparent 0 42%, #c2410c 43% 50%, transparent 51%),
        linear-gradient(135deg, transparent 0 62%, #c2410c 63% 70%, transparent 71%);
    opacity: 0.78;
}

.math-scratchpad-resize:hover,
.math-scratchpad-resize:focus-visible {
    border-color: #14b8a6;
    outline: 3px solid rgba(20, 184, 166, 0.16);
}

.math-input-unit {
    min-width: 44px;
    color: #334155;
    font-size: 20px;
    font-weight: 950;
}

.math-choice {
    min-height: 88px;
    border: 2px solid #e0eaf6;
    border-radius: 20px;
    background: #fff;
    color: #172033;
    font-size: 22px;
    font-weight: 900;
    line-height: 1.25;
    text-align: center;
    box-shadow: 0 8px 18px rgba(29, 55, 91, 0.07);
    cursor: pointer;
}

.math-symbol-choice {
    min-height: 96px;
    border-color: #bfdbfe;
    background: #f8fbff;
    color: #1d4ed8;
    font-size: 34px;
    line-height: 1;
}

.math-symbol-choice.is-long-label {
    color: #334155;
    font-size: 17px;
    line-height: 1.18;
    word-break: keep-all;
}

.math-choice:hover,
.math-choice.is-selected {
    border-color: var(--math-primary);
    background: #edf6ff;
}

.math-choice.is-correct {
    border-color: var(--math-good);
    background: #ecfdf5;
}

.math-choice.is-wrong {
    border-color: var(--math-bad);
    background: #fff1f2;
}

.math-feedback {
    min-height: 64px;
    border: 1px solid #e4edf8;
    border-radius: 18px;
    background: #f8fbff;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.math-feedback > div {
    width: 100%;
    min-width: 0;
}

.math-feedback strong {
    font-size: 16px;
}

.math-feedback > div > span {
    display: block;
    margin-top: 3px;
    color: #5d697a;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.35;
    overflow-wrap: break-word;
}

.math-feedback.is-good {
    border-color: #a7f3d0;
    background: #ecfdf5;
}

.math-feedback.is-bad {
    border-color: #fecdd3;
    background: #fff1f2;
}

.math-controls {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.math-control-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.math-control-title small {
    color: var(--math-muted);
    font-weight: 900;
}

.math-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.math-stat {
    border: 1px solid #e6eef8;
    border-radius: 16px;
    background: #fff;
    padding: 12px;
}

.math-stat b {
    display: block;
    font-size: 24px;
}

.math-stat span {
    display: block;
    margin-top: 3px;
    color: var(--math-muted);
    font-size: 12px;
    font-weight: 800;
}

.math-help {
    min-height: 120px;
    overflow: auto;
    border: 1px solid #e6eef8;
    border-radius: 18px;
    background: #fff;
    padding: 12px;
    color: #4f5d70;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.45;
}

.math-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
}

.math-btn {
    min-height: 50px;
    border: 0;
    border-radius: 16px;
    padding: 0 14px;
    font-weight: 900;
    font-size: 15px;
    cursor: pointer;
}

.math-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.math-btn.hint {
    grid-column: 1 / 3;
    background: #fff4db;
    color: #915b00;
}

.math-btn.solve {
    background: #eef6ff;
    color: #2363a8;
}

.math-btn.primary {
    grid-column: 1 / 3;
    color: #fff;
    background: linear-gradient(135deg, var(--math-primary), var(--math-primary-2));
    font-size: 18px;
}

.math-btn.dark {
    grid-column: 1 / 3;
    color: #fff;
    background: #172033;
    font-size: 18px;
}

.math-overlay {
    position: fixed;
    inset: 18px;
    z-index: 20;
    display: grid;
    place-items: start center;
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid rgba(219, 232, 246, 0.95);
    border-radius: 30px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(248, 252, 255, 0.92));
    box-shadow: 0 25px 70px rgba(32, 53, 86, 0.18);
    backdrop-filter: blur(16px);
    padding: 26px;
}

.math-overlay.is-hidden,
.math-hidden {
    display: none !important;
}

.math-start-grid,
.math-result-grid {
    width: min(980px, 100%);
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 28px;
    align-items: center;
    margin: auto 0;
}

.math-wrong-modal {
    inset: 0;
    z-index: 50;
    border: 0;
    border-radius: 0;
    place-items: center;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.48);
    padding: 20px;
}

.math-wrong-modal-card {
    position: relative;
    width: min(560px, 100%);
    max-height: min(680px, calc(100vh - 48px));
    overflow: auto;
    border: 1px solid rgba(219, 232, 246, 0.95);
    border-radius: 26px;
    background: #fff;
    box-shadow: 0 24px 72px rgba(15, 23, 42, 0.28);
    padding: 28px;
}

.math-wrong-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: #eef3f9;
    color: #172033;
    font-size: 28px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
}

.math-wrong-modal-kicker {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    background: #fff4db;
    color: #915b00;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 900;
}

.math-wrong-modal-card h2 {
    margin: 14px 44px 14px 0;
    color: #172033;
    font-size: 30px;
    line-height: 1.18;
}

.math-wrong-modal-body {
    border: 1px solid #e6eef8;
    border-radius: 18px;
    background: #f8fbff;
    color: #263246;
    padding: 18px;
    font-size: 17px;
    font-weight: 800;
    line-height: 1.65;
}

.math-wrong-modal-next {
    width: 100%;
    margin-top: 18px;
    grid-column: auto;
}

.math-hero h2 {
    margin: 0 0 12px;
    font-size: 44px;
    line-height: 1.08;
    font-weight: 900;
}

.math-hero p {
    margin: 0;
    color: #5c6878;
    font-size: 17px;
    font-weight: 800;
    line-height: 1.55;
}

.math-hero-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 22px;
}

.math-hero-card {
    min-height: 118px;
    border: 1px solid #e5edf7;
    border-radius: 20px;
    background: #fff;
    padding: 15px;
}

.math-hero-card b {
    display: block;
    margin: 8px 0 5px;
    font-size: 16px;
}

.math-hero-card span {
    color: var(--math-muted);
    font-size: 13px;
    font-weight: 800;
    line-height: 1.35;
}

.math-analysis-card {
    display: grid;
    gap: 12px;
    margin-top: 16px;
    border: 1px solid #dbeafe;
    border-radius: 20px;
    background: linear-gradient(135deg, #ffffff, #eefbf8);
    padding: 16px;
}

.math-analysis-kicker {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    background: #e0f2fe;
    color: #075985;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 950;
}

.math-analysis-card h3 {
    margin: 8px 0 5px;
    color: #172033;
    font-size: 22px;
    font-weight: 950;
}

.math-analysis-card p {
    margin: 0;
    color: #526174;
    font-size: 14px;
    font-weight: 800;
}

.math-analysis-due-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.math-analysis-due-chip {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    max-width: 100%;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    background: #eff6ff;
    color: #1e3a8a;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 900;
}

.math-review-btn {
    justify-self: start;
    min-height: 44px;
    border: 0;
    border-radius: 16px;
    background: linear-gradient(135deg, #f97316, #f59e0b);
    color: #fff;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 950;
    cursor: pointer;
}

.math-review-btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.math-start-action-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: stretch;
    margin-top: 16px;
}

.math-start-actions {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: stretch;
    gap: 10px;
}

.math-start-action-row .math-start-btn {
    min-width: 160px;
}

.math-completion-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    border: 1px solid #bbf7d0;
    border-radius: 20px;
    background: linear-gradient(135deg, #ecfdf5, #f8fbff);
    padding: 16px;
}

.math-completion-card[hidden] {
    display: none;
}

.math-completion-kicker {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    background: #dcfce7;
    color: #047857;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 950;
}

.math-completion-card h3 {
    margin: 8px 0 5px;
    color: #172033;
    font-size: 22px;
    font-weight: 950;
}

.math-completion-card p {
    margin: 0;
    color: #526174;
    font-size: 14px;
    font-weight: 850;
}

.math-completion-link {
    min-height: 42px;
    border-radius: 14px;
    background: #172033;
    color: #fff;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 14px;
    font-weight: 950;
    white-space: nowrap;
}

.math-mascot {
    min-height: 340px;
    border: 1px solid #deecf7;
    border-radius: 30px;
    background: linear-gradient(180deg, #e8fbf7, #fff5df);
    display: grid;
    place-items: center;
    text-align: center;
    padding: 28px;
}

.math-mascot .mark {
    font-size: 84px;
    font-weight: 900;
    color: var(--math-primary);
}

.math-mascot b {
    display: block;
    margin-top: 8px;
    font-size: 25px;
}

.math-start-btn,
.math-retry-btn,
.math-home-link {
    min-height: 58px;
    border-radius: 20px;
    border: 0;
    padding: 0 24px;
    color: #fff;
    background: linear-gradient(135deg, var(--math-primary), var(--math-primary-2));
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
}

.math-resume-btn {
    margin-top: 10px;
    background: linear-gradient(135deg, var(--math-accent), var(--math-bad));
}

.math-home-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    text-decoration: none;
    background: #172033;
}

.math-result-list {
    height: 300px;
    overflow: auto;
    border: 1px solid #e6eef8;
    border-radius: 20px;
    background: #fff;
    padding: 14px;
}

.math-result-list h3 {
    margin: 0 0 10px;
    font-size: 17px;
}

.math-result-item {
    margin-bottom: 8px;
    border-radius: 14px;
    background: #f8fbff;
    padding: 10px;
    color: #556171;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.4;
}

.math-result-item.is-resolved {
    border: 1px solid rgba(5, 150, 105, 0.22);
    background: #ecfdf5;
    color: #166534;
}

.math-result-item.is-persistent {
    border: 1px solid rgba(225, 29, 72, 0.24);
    background: #fff1f2;
    color: #9f1239;
}

.math-result-learning-link {
    display: grid;
    gap: 8px;
}

.math-result-learning-btn {
    width: fit-content;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    padding: 0 12px;
    color: #fff;
    background: #2563eb;
    text-decoration: none;
    font-size: 12px;
    font-weight: 900;
}

.math-result-growth {
    margin: 14px 0;
    border: 1px solid #dbeafe;
    border-radius: 18px;
    background: #f8fbff;
    padding: 12px 14px;
    color: #334155;
    font-size: 13px;
    font-weight: 850;
    line-height: 1.45;
}

.math-toast {
    position: fixed;
    left: 50%;
    bottom: 22px;
    z-index: 60;
    transform: translateX(-50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, bottom 0.2s ease;
    border-radius: 999px;
    background: #172033;
    color: #fff;
    padding: 12px 18px;
    font-weight: 900;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.math-toast.is-showing {
    opacity: 1;
    bottom: 34px;
}

#loadingOverlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.8);
    color: #172033;
    font-weight: 900;
}

#loadingOverlay.hidden {
    display: none;
}

@media (max-width: 1080px) {
    .math-main {
        grid-template-columns: minmax(0, 1fr) 280px;
    }

    .math-topbar {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .math-user {
        justify-content: flex-start;
    }
}

@media (min-width: 761px) and (max-height: 720px) {
    .math-overlay {
        inset: 10px;
        padding: 18px;
        border-radius: 24px;
    }

    .math-start-grid,
    .math-result-grid {
        gap: 22px;
    }

    .math-hero h2 {
        margin-bottom: 8px;
        font-size: 38px;
    }

    .math-hero p {
        font-size: 15px;
        line-height: 1.42;
    }

    .math-hero-cards {
        gap: 10px;
        margin-top: 16px;
    }

    .math-hero-card {
        min-height: 96px;
        border-radius: 16px;
        padding: 12px;
    }

    .math-hero-card b {
        margin: 5px 0 4px;
        font-size: 15px;
    }

    .math-hero-card span {
        font-size: 12px;
    }

    .math-analysis-card {
        gap: 8px;
        margin-top: 12px;
        padding: 14px;
    }

    .math-analysis-card h3,
    .math-completion-card h3 {
        margin: 6px 0 4px;
        font-size: 20px;
    }

    .math-analysis-card p,
    .math-completion-card p {
        font-size: 13px;
        line-height: 1.45;
    }

    .math-start-action-row {
        margin-top: 12px;
    }

    .math-completion-card {
        border-radius: 18px;
        padding: 14px;
    }

    .math-start-btn,
    .math-retry-btn,
    .math-home-link {
        min-height: 54px;
        border-radius: 18px;
        font-size: 17px;
    }

    .math-mascot {
        min-height: 300px;
        padding: 24px;
    }

    .math-mascot .mark {
        font-size: 72px;
    }
}

@media (max-width: 760px) {
    .math-daily-app {
        padding: 10px;
    }

    .math-main,
    .math-start-grid,
    .math-result-grid {
        grid-template-columns: 1fr;
    }

    .math-controls {
        order: 2;
    }

    .math-hero h2 {
        font-size: 34px;
    }

    .math-choice-grid,
    .math-point-option-grid,
    .math-symbol-choice-grid,
    .math-hero-cards {
        grid-template-columns: 1fr;
    }

    .math-symbol-choice-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .math-completion-card {
        grid-template-columns: 1fr;
    }

    .math-completion-link {
        width: 100%;
    }

    .math-start-action-row {
        grid-template-columns: 1fr;
    }

    .math-start-action-row .math-start-btn {
        width: 100%;
    }

    .math-fraction-answer-row {
        flex-wrap: wrap;
    }

    .math-draw-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .math-floating-scratchpad {
        width: min(var(--math-scratchpad-width, 340px), calc(100vw - 20px));
    }

    .math-floating-scratchpad.is-collapsed {
        width: 56px;
    }

    .math-scratchpad-fab {
        width: 56px;
        height: 56px;
        border-radius: 20px;
        font-size: 28px;
    }

    .math-scratchpad-toolbar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .math-prompt {
        font-size: 23px;
    }

    .math-overlay {
        inset: 10px;
        overflow: auto;
        align-items: start;
    }

    .math-wrong-modal {
        inset: 0;
        align-items: center;
        padding: 14px;
    }

    .math-wrong-modal-card {
        max-height: calc(100vh - 28px);
        border-radius: 22px;
        padding: 22px;
    }

    .math-wrong-modal-card h2 {
        font-size: 25px;
    }
}
