:root {
    --math-record-bg: #f5f7fb;
    --math-record-card: rgba(255, 255, 255, 0.9);
    --math-record-ink: #172033;
    --math-record-muted: #64748b;
    --math-record-line: #dbe6f3;
    --math-record-primary: #2563eb;
    --math-record-good: #059669;
    --math-record-bad: #dc2626;
    --math-record-shadow: 0 18px 38px rgba(36, 68, 112, 0.14);
}

* {
    box-sizing: border-box;
}

body.math-record-page {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(20, 184, 166, 0.16), transparent 34rem),
        linear-gradient(135deg, var(--math-record-bg), #fff8ec);
    color: var(--math-record-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Pretendard, "Noto Sans KR", sans-serif;
}

.math-record-header {
    max-width: 1120px;
    margin: 0 auto;
    padding: 24px 18px 12px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
}

.math-record-header h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 44px);
    line-height: 1.05;
    font-weight: 950;
}

.math-record-header p {
    margin: 6px 0 0;
    color: var(--math-record-muted);
    font-size: 15px;
    font-weight: 800;
}

.math-record-home,
.math-record-user {
    min-height: 44px;
    border: 1px solid var(--math-record-line);
    border-radius: 999px;
    background: #fff;
    color: #334155;
    padding: 0 16px;
    font: inherit;
    font-weight: 900;
    box-shadow: 0 10px 22px rgba(36, 68, 112, 0.08);
}

.math-record-home {
    cursor: pointer;
}

.math-record-user {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 180px;
}

.math-record-shell {
    width: min(1120px, calc(100% - 36px));
    margin: 10px auto 0;
    display: grid;
    grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.math-record-shell--history {
    width: min(920px, calc(100% - 36px));
    grid-template-columns: minmax(0, 1fr);
}

.math-record-card {
    border: 1px solid rgba(219, 230, 243, 0.92);
    border-radius: 24px;
    background: var(--math-record-card);
    box-shadow: var(--math-record-shadow);
    backdrop-filter: blur(14px);
    padding: 20px;
}

.math-record-toolbar {
    display: flex;
    justify-content: flex-end;
    margin: -4px 0 16px;
}

.math-record-card--form {
    position: sticky;
    top: 16px;
}

.math-record-card-head {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.math-record-card-head span {
    color: var(--math-record-primary);
    font-size: 14px;
    font-weight: 950;
}

.math-record-card-head strong {
    color: #334155;
    font-size: 14px;
    font-weight: 900;
}

.math-record-form {
    display: grid;
    gap: 14px;
}

.math-record-field {
    display: grid;
    gap: 7px;
}

.math-record-field span {
    color: #334155;
    font-size: 13px;
    font-weight: 900;
}

.math-record-field input,
.math-record-field textarea {
    width: 100%;
    border: 1px solid #cfdbea;
    border-radius: 14px;
    background: #fff;
    color: var(--math-record-ink);
    padding: 13px 14px;
    font: inherit;
    font-size: 16px;
    font-weight: 700;
}

.math-record-field textarea {
    resize: vertical;
    min-height: 108px;
    line-height: 1.5;
}

.math-record-field input:focus,
.math-record-field textarea:focus {
    border-color: var(--math-record-primary);
    outline: 3px solid rgba(37, 99, 235, 0.16);
}

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

.math-record-btn {
    min-height: 48px;
    border: 0;
    border-radius: 14px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    text-decoration: none;
    font: inherit;
    font-size: 15px;
    font-weight: 950;
    cursor: pointer;
}

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

.math-record-btn.primary {
    background: linear-gradient(135deg, var(--math-record-primary), #14b8a6);
    color: #fff;
}

.math-record-btn.secondary {
    border: 1px solid #cbd9eb;
    background: #fff;
    color: #1e3a8a;
}

.math-record-status {
    margin: 14px 0 0;
    min-height: 42px;
    border-radius: 14px;
    background: #f8fbff;
    color: var(--math-record-muted);
    padding: 12px 13px;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.4;
}

.math-record-status[data-tone="success"] {
    background: #ecfdf5;
    color: var(--math-record-good);
}

.math-record-status[data-tone="error"] {
    background: #fef2f2;
    color: var(--math-record-bad);
}

.math-record-history {
    display: grid;
    gap: 12px;
}

.math-record-item {
    border: 1px solid #e3ecf6;
    border-radius: 18px;
    background: #fff;
    padding: 16px;
}

.math-record-item.is-pending {
    border-color: #bfdbfe;
    background: #f8fbff;
}

.math-record-item-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.math-record-item-top > div {
    min-width: 0;
}

.math-record-date {
    display: block;
    margin-bottom: 4px;
    color: var(--math-record-primary);
    font-size: 12px;
    font-weight: 900;
}

.math-record-item strong {
    display: block;
    color: var(--math-record-ink);
    line-height: 1.35;
    word-break: keep-all;
}

.math-record-score {
    flex: 0 0 auto;
    align-self: flex-start;
    border-radius: 999px;
    background: #eaf3ff;
    color: #1d4ed8;
    padding: 7px 12px;
    font-size: 14px;
}

.math-record-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 12px;
}

.math-record-badge {
    min-height: 28px;
    border: 1px solid #cfe0f4;
    border-radius: 999px;
    background: #f8fbff;
    color: #334155;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    font-weight: 900;
}

.math-record-badge.is-complete {
    border-color: #bbf7d0;
    background: #ecfdf5;
    color: #047857;
}

.math-record-badge.is-pending {
    border-color: #fde68a;
    background: #fffbeb;
    color: #92400e;
}

.math-record-item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.math-record-comment,
.math-record-muted {
    margin: 10px 0 0;
    color: var(--math-record-muted);
    font-size: 13px;
    font-weight: 800;
    line-height: 1.45;
}

.math-record-comment {
    border-left: 3px solid #14b8a6;
    background: #f0fdfa;
    border-radius: 10px;
    padding: 9px 10px;
}

.math-record-link {
    min-height: 38px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f8fbff;
    color: #1d4ed8;
    padding: 0 13px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 950;
}

.math-record-link.is-primary {
    background: var(--math-record-primary);
    color: #fff;
}

.math-record-empty,
.math-record-more {
    padding: 24px 8px;
    color: var(--math-record-muted);
    text-align: center;
    font-weight: 850;
}

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

#loadingOverlay.hidden {
    display: none;
}

@media (max-width: 820px) {
    .math-record-header {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .math-record-home,
    .math-record-user {
        justify-content: center;
        width: 100%;
    }

    .math-record-shell {
        grid-template-columns: 1fr;
        width: min(100% - 20px, 620px);
    }

    .math-record-card--form {
        position: static;
    }

    .math-record-actions {
        grid-template-columns: 1fr;
    }
}
