:root {
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 1rem;
    --space-5: 20px;
    --bg: oklch(0.97 0.008 240);
    --bg-elevated: oklch(0.992 0.004 240);
    --panel: rgba(255, 255, 255, 0.8);
    --panel-strong: rgba(255, 255, 255, 0.94);
    --line: oklch(0.88 0.014 240);
    --line-strong: oklch(0.78 0.018 240);
    --text: oklch(0.26 0.02 255);
    --muted: oklch(0.54 0.016 250);
    --soft: oklch(0.67 0.014 248);
    --accent: oklch(0.54 0.08 235);
    --accent-strong: oklch(0.45 0.09 235);
    --accent-soft: oklch(0.94 0.03 235);
    --success: oklch(0.62 0.11 160);
    --danger: oklch(0.61 0.14 24);
    --shadow: 0 18px 48px rgba(27, 43, 65, 0.08);
    --radius-xl: 20px;
    --radius-lg: 1rem;
    --radius-md: 12px;
    --radius-sm: 8px;
    --control-height: 42px;
    --control-height-sm: 36px;
}


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


body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #fcfcfc;
    color: var(--text);
    transition: background-color 0.25s ease, color 0.25s ease;
}


body.dark-mode {
    --bg: #14161a;
    --bg-elevated: #1e2126;
    --panel: #1a1d21;
    --panel-strong: #23272d;
    --line: #2a3036;
    --line-strong: #3f4750;
    --text: #d8dee4;
    --muted: #8b949e;
    --soft: #a1abc1;
    --accent: #537599;
    --accent-strong: #7ba2c9;
    --accent-soft: rgba(83, 117, 153, 0.15);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    background: #14161a;
}


.app-shell {
    max-width: 1440px;
    margin: 0 auto;
    padding: clamp(18px, 3vw, 40px);
}


.app-bar,
.surface {
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
    border-radius: 8px;
}


.app-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 16px 20px;
    margin-bottom: 1.5rem;
}


.app-bar-copy h1,
.surface h2,
.account-card h3,
.pane-head h3 {
    margin: 0;
    font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
    letter-spacing: -0.01em;
    font-weight: bold;
    color: var(--text);
}


.app-bar-copy h1 {
    font-size: clamp(1.6rem, 2.2vw, 2.15rem);
    line-height: 1.15;
}


.app-bar-tools {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
}


.top-userbar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}


.top-status {
    min-width: 128px;
    justify-content: center;
    flex-shrink: 0;
}


.user-chip {
    display: inline-flex;
    align-items: center;
    min-height: var(--control-height);
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg-elevated);
    font-weight: 600;
}


.toggle-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--control-height);
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}


.toggle-chip:hover,
.toggle-chip:focus-within {
    background: var(--bg-elevated);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}


.icon-btn,
.icon-toggle {
    display: inline-flex;
    align-items: center;
    width: var(--control-height);
    height: var(--control-height);
    min-width: var(--control-height);
    padding-inline: 0;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: transparent;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}


.icon-btn:hover,
.icon-toggle:hover {
    border-color: var(--accent);
    background: var(--bg-elevated);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}


.icon-btn i,
.icon-toggle i {
    font-size: 1rem;
}


.icon-toggle {
    gap: 0;
}


.icon-toggle input {
    pointer-events: none;
}


.icon-toggle:has(input:checked) {
    background: #e2e8f0;
    color: #1a202c;
    border-color: #cbd5e0;
}


body.dark-mode .icon-toggle:has(input:checked) {
    background: #2d3748;
    color: #f7fafc;
    border-color: #4a5568;
}


.workspace-grid {
    display: flex;
    flex-direction: column;
    gap: 32px;
}


.workspace-primary {
    display: flex;
    flex-direction: column;
    gap: 32px;
}


.workspace-side {
    border-top: 2px solid var(--line);
    padding-top: 1.5rem;
}


.upload-surface {
    padding: 0;
    border: none;
    background: transparent;
    margin-bottom: 8px;
}


.workbench-surface {
    padding: 0;
    border: none;
    background: transparent;
}


.surface {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    border-radius: 8px;
    padding: var(--space-4);
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
}


.surface-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}


.surface-head-compact {
    margin-bottom: 12px;
}


.surface h2 {
    font-size: clamp(1.25rem, 1.6vw, 1.6rem);
}


.status-pill {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 14px;
    min-height: var(--control-height);
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    white-space: normal;
    background: var(--bg-elevated);
    color: var(--text);
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}


.status-loading::after {
    content: "";
    width: 8px;
    height: 8px;
    margin-left: var(--space-2);
    border-radius: 50%;
    background: currentColor;
    opacity: 0.35;
    animation: status-pulse 1s ease-in-out infinite;
}


.upload-grid {
    display: grid;
    grid-template-columns: minmax(clamp(140px, 26vw, 240px), 0.4fr) minmax(0, 0.6fr);
    gap: 14px;
    align-items: stretch;
}


.upload-file-block {
    margin: 0;
    display: flex;
    cursor: pointer;
    position: relative;
}


.upload-file-block input[type="file"]::file-selector-button {
    display: none;
}


.upload-file-block .form-control {
    min-height: 140px;
    height: 100%;
    border-radius: 8px;
    border: 1px dashed var(--line-strong);
    background: transparent;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}


.upload-file-block:hover .form-control {
    background: var(--bg-elevated);
    border-color: var(--accent);
}


.upload-file-block::after {
    content: "未选择文件\A点击以选择文件";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 0.88rem;
    pointer-events: none;
    padding: 0 1rem;
    text-align: center;
    white-space: pre;
    line-height: 1.6;
}


.upload-file-block.is-filled::after,
.upload-file-block:focus-within::after {
    display: none;
}


.workbench-grid {
    display: grid;
    grid-template-columns: minmax(clamp(200px, 38vw, 480px), 0.5fr) minmax(clamp(140px, 24vw, 300px), 0.5fr);
    gap: 1.5rem;
    align-items: stretch;
}


.preview-column,
.editor-column {
    min-width: 0;
    display: flex;
    flex-direction: column;
}


.pane-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    min-height: var(--control-height-sm);
}


.pane-head h3 {
    font-size: 1.05rem;
    line-height: 1.2;
}


.latex-editor-container {
    flex: 1 1 auto;
    display: flex;
}


#formulaDisplay {
    min-height: 320px;
    flex: 1 1 auto;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    overflow: auto;
    transition: border-color 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.015);
}


#formulaDisplay.flash-success {
    animation: formula-flash 1s ease-out forwards;
}


@keyframes formula-flash {
    0% {
        border-color: color-mix(in srgb, var(--success) 80%, transparent);
        box-shadow: 0 0 0 6px color-mix(in srgb, var(--success) 22%, transparent),
                    inset 0 0 24px color-mix(in srgb, var(--success) 8%, transparent);
    }


    35% {
        border-color: color-mix(in srgb, var(--success) 55%, transparent);
        box-shadow: 0 0 0 5px color-mix(in srgb, var(--success) 14%, transparent),
                    inset 0 0 16px color-mix(in srgb, var(--success) 5%, transparent);
    }


    100% {
        border-color: var(--line);
        box-shadow: none;
        inset 0 0 0 transparent;
    }


}


#mathOutput {
    max-width: 100%;
    font-size: clamp(1.05rem, 1.6vw, 1.45rem);
    color: var(--soft);
    text-align: center;
    word-break: break-word;
}


#formulaDisplay .MathJax_Display,
#formulaDisplay .mjx-chtml,
#formulaDisplay .mjx-container {
    font-size: inherit !important;
    text-align: center !important;
    margin: 0 auto !important;
}


#latexEditor {
    min-height: 320px;
    height: 100%;
    resize: vertical;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 1.1rem;
    line-height: 1.8;
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.015);
}


.stack-actions {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}


.action-dropdown .btn {
    min-width: 140px;
    padding-inline: 1rem;
}


.history-surface {
    height: 100%;
}


.history-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}


.history-limit-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}


.history-limit-wrap .form-label {
    margin: 0;
    white-space: nowrap;
}


.history-limit-select {
    min-width: 78px;
    min-height: var(--control-height-sm);
    padding-block: 0.35rem;
    padding-inline: 0.7rem 2rem;
}


#historyList {
    min-height: 260px;
    flex: 1 1 auto;
    max-height: min(560px, 62vh);
    overflow: auto;
    display: grid;
    gap: 12px;
    padding-right: 4px;
}


.history-item {
    appearance: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    padding: 16px 18px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--line);
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}


.history-item:hover,
.history-item:focus-visible {
    border-color: var(--accent);
    background: var(--bg-elevated);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}


.history-item:focus-visible {
    outline: none;
    box-shadow: 0 0 0 0.25rem color-mix(in srgb, var(--accent-soft) 72%, transparent);
}


.history-formula {
    max-width: 100%;
    display: block;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg-elevated);
    color: var(--text);
    overflow-wrap: anywhere;
    white-space: normal;
}


.history-meta small {
    color: var(--muted);
}


.history-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}


.history-item .d-flex {
    align-items: flex-start !important;
    gap: 10px;
}


.history-item .mjx-container,
.history-item .mjx-chtml,
.history-item .mjx-svg {
    color: inherit !important;
    font-size: 1em !important;
    vertical-align: middle !important;
    display: block !important;
    margin: 0 !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
}


.history-item svg path,
.history-item svg text {
    fill: currentColor !important;
    stroke: none;
}


.badge-confidence {
    border-radius: 6px;
    padding: 0.52em 0.72em;
    min-width: 64px;
    font-weight: 700;
    border: 1px solid var(--line);
    font-size: 0.8rem;
}


.badge-conf-high {
    background: transparent !important;
    color: var(--text) !important;
}


.badge-conf-medium {
    background: transparent !important;
    color: var(--text) !important;
}


.badge-conf-low {
    background: transparent !important;
    color: var(--muted) !important;
}


.field-block {
    display: grid;
    gap: var(--space-2);
    margin-bottom: 14px;
}


.field-inline {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 12px;
}


.field-inline > * {
    min-width: 0;
}


.form-label {
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 600;
}


.form-control,
.form-select {
    min-height: 46px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--text);
    padding: 0.75rem 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, background-color 0.2s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.015);
}


.upload-file-block .form-control::file-selector-button {
    min-height: calc(var(--control-height) - 4px);
    margin-right: var(--space-3);
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font-weight: 600;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}


.upload-file-block .form-control:hover::file-selector-button,
.upload-file-block .form-control:focus::file-selector-button {
    border-color: color-mix(in srgb, var(--accent) 55%, var(--line-strong));
    background: color-mix(in srgb, var(--accent-soft) 55%, transparent);
}


.form-control:focus,
.form-select:focus {
    border-color: var(--text);
    box-shadow: 0 0 0 1px var(--text);
    background: var(--bg-elevated);
    color: var(--text);
    outline: none;
}


.btn {
    border-radius: 6px;
    min-height: var(--control-height);
    font-weight: 600;
    padding-inline: 1rem;
    letter-spacing: 0.01em;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}


.btn-sm {
    min-height: var(--control-height-sm);
    font-size: 0.85rem;
}


.btn:hover,
.btn:focus {
    outline: none;
}


.btn:focus-visible,
.dropdown-toggle:focus-visible,
.btn-close:focus-visible {
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
    outline: none;
}


.btn-primary {
    background: #2a2f35;
    border: 1px solid #2a2f35;
    color: #fcfdfc;
    box-shadow: none;
}


.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background: #3e444b;
    border-color: #3e444b;
    color: #fcfdfc;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(42, 47, 53, 0.2);
}


body.dark-mode .btn-primary {
    background: #e2e8f0;
    border-color: #e2e8f0;
    color: #1a202c;
    box-shadow: none;
}


body.dark-mode .btn-primary:hover {
    background: #fcfdfc;
    border-color: #fcfdfc;
    color: #1a202c;
    box-shadow: none;
}


.btn-outline-secondary {
    color: var(--text);
    border: 1px solid var(--line-strong);
    background: transparent;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.015);
}


.btn-outline-secondary:hover,
.btn-outline-secondary:focus,
.btn-outline-secondary:active {
    color: var(--text);
    background: var(--bg-elevated);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}


.btn-link {
    color: var(--accent-strong);
    text-decoration: none;
}


.btn-link:hover,
.btn-link:focus {
    color: var(--accent);
}


.paste-panel {
    position: relative;
    display: flex;
    align-items: stretch;
    min-height: 140px;
    padding: 0;
    text-align: left;
    border: 1px dashed var(--accent-strong);
    border-radius: 8px;
    background: color-mix(in srgb, var(--accent-soft) 30%, transparent);
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}


.paste-panel:hover,
.paste-panel:focus {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent-soft) 50%, transparent);
    outline: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}


.paste-panel i {
    font-size: 1.2rem;
    color: var(--accent-strong);
}


.paste-panel-copy {
    display: grid;
    align-content: center;
    gap: 6px;
    width: 100%;
    padding: 18px;
}


.paste-panel span {
    color: var(--muted);
    line-height: 1.65;
}


.clipboard-preview-container {
    position: absolute;
    inset: 0;
    margin-top: 0;
    padding: 10px;
    border-radius: inherit;
    border: 0;
    background: color-mix(in srgb, var(--panel-strong) 76%, transparent);
}


.clipboard-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    border-radius: 12px;
}


.clipboard-clear-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--panel-strong);
}


.form-check-input {
    width: 42px;
    height: 1.5rem;
    cursor: pointer;
}


.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}


.dropdown-menu {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    padding: 4px 0;
}


.dropdown-item {
    padding: 10px 1rem;
    color: var(--text);
    border-bottom: none;
    transition: background-color 0.2s ease;
}


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


.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--bg-elevated);
    color: var(--text);
}


.modal-content {
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--text);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
}


.modal-header,
.modal-footer {
    border-color: var(--line);
}


.btn-close {
    border-radius: 6px;
}


.auth-modal .modal-dialog {
    max-width: 480px;
}


.auth-modal .modal-content {
    box-shadow: none;
}


.auth-modal .modal-body {
    padding: var(--space-5);
}


.verify-field-inline {
    margin-bottom: 0;
}


.modal-backdrop.show {
    opacity: 1;
    background: rgba(12, 18, 28, 0.3);
}


.modal-header,
.modal-footer {
    border-color: var(--line);
}


.alert-info {
    color: #2b6cb0;
    background: #ebf8ff;
    border-color: #bee3f8;
    border-left: 4px solid #3182ce;
}


body.dark-mode .alert-info {
    color: #90cdf4;
    background: rgba(49, 130, 206, 0.12);
    border-color: rgba(49, 130, 206, 0.25);
    border-left: 4px solid #4299e1;
}


.alert-success {
    color: #276749;
    background: #f0fff4;
    border-color: #c6f6d5;
    border-left: 4px solid #38a169;
}


body.dark-mode .alert-success {
    color: #9ae6b4;
    background: rgba(56, 161, 105, 0.12);
    border-color: rgba(56, 161, 105, 0.25);
    border-left: 4px solid #48bb78;
}


.alert-warning {
    color: #975a16;
    background: #fffff0;
    border-color: #fef08a;
    border-left: 4px solid #ecc94b;
}


body.dark-mode .alert-warning {
    color: #f6e05e;
    background: rgba(214, 158, 46, 0.12);
    border-color: rgba(214, 158, 46, 0.25);
    border-left: 4px solid #ecc94b;
}


.alert-danger {
    color: #9b2c2c;
    background: #fff5f5;
    border-color: #fed7d7;
    border-left: 4px solid #e53e3e;
}


body.dark-mode .alert-danger {
    color: #fc8181;
    background: rgba(229, 62, 62, 0.12);
    border-color: rgba(229, 62, 62, 0.25);
    border-left: 4px solid #f56565;
}


body.dark-mode .alert-warning {
    color: #ffd68a;
    background: rgba(131, 94, 23, 0.36);
}


body.dark-mode .alert-success,
body.dark-mode .alert-danger,
body.dark-mode .alert-info {
    border-color: transparent;
}


@media (max-width: 1120px) {
    .app-shell {
        padding: 1rem;
    }


    .app-bar {
        align-items: flex-start;
    }


    .app-bar-tools {
        justify-content: flex-start;
    }


    .workspace-grid,
    .upload-grid {
        grid-template-columns: 1fr;
    }


    .workbench-grid {
        grid-template-columns: 1fr;
    }


    .history-surface {
        height: auto;
    }


    #historyList {
        max-height: min(460px, 55vh);
    }


}


@media (max-width: 900px) {
    .app-bar {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
        padding: 14px;
    }


    .app-bar-copy,
    .app-bar-tools {
        width: 100%;
        min-width: 0;
    }


    .app-bar-tools {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
    }


    .top-status {
        min-width: 0;
        width: 100%;
        justify-content: flex-start;
        order: -1;
    }


    .top-userbar {
        display: contents;
    }


    .user-chip {
        justify-self: start;
        min-width: 0;
        max-width: 100%;
    }


    #adminBtn,
    #logoutBtn,
    #authOpenBtn,
    .icon-toggle {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }


    .upload-grid {
        grid-template-columns: 1fr;
    }


    .upload-file-block .form-control,
    .paste-panel {
        min-height: 104px;
    }


    .surface {
        padding: 14px;
    }


    .history-actions {
        width: 100%;
        justify-content: space-between;
    }


    .history-limit-wrap {
        flex: 1 1 auto;
    }


    .history-limit-select {
        min-width: 88px;
        min-height: 40px;
    }


    .auth-modal .modal-dialog {
        max-width: min(100vw - 24px, 560px);
        margin: 12px auto;
    }


}


@media (max-width: 760px) {
    .surface-head,
    .pane-head,
    .history-actions,
    .history-limit-wrap {
        flex-direction: column;
        align-items: stretch;
    }


    .app-shell {
        padding: 12px;
    }


    .top-status,
    .user-chip {
        grid-column: 1 / -1;
    }


    .field-inline {
        grid-template-columns: 1fr;
    }


    .pane-head {
        gap: 10px;
    }


    .action-dropdown,
    .action-dropdown .btn,
    .dropdown-menu-end {
        width: 100%;
    }


    .action-dropdown .btn {
        min-width: 0;
    }


    .history-actions {
        gap: 8px;
    }


    #clearHistoryBtn {
        width: 100%;
    }


    .auth-modal .modal-dialog {
        max-width: none;
        margin: 8px;
    }


    .auth-modal .modal-content {
        min-height: calc(100vh - 16px);
    }


    .modal-header,
    .modal-footer {
        padding: 14px;
    }


    .auth-modal .modal-body {
        padding: 14px;
    }


    #formulaDisplay,
    #latexEditor,
    #historyList {
        min-height: 220px;
    }


    .clipboard-clear-btn {
        width: 40px;
        height: 40px;
    }


    #historyList {
        max-height: 320px;
    }


    .paste-panel-copy span {
        display: none;
    }


    .paste-panel-copy {
        text-align: center;
        justify-items: center;
    }


}


@media (max-width: 420px) {
    .app-bar-copy h1 {
        font-size: 1.4rem;
    }


    .paste-panel-copy strong,
    .surface h2,
    .pane-head h3 {
        font-size: 1rem;
    }


    .paste-panel span,
    .history-meta small,
    .form-label {
        font-size: 0.88rem;
    }


    #formulaDisplay,
    #latexEditor {
        min-height: 200px;
    }


}


@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }


}


@keyframes status-pulse {
    0%,
    100% {
        opacity: 0.35;
        transform: scale(0.9);
    }


    50% {
        opacity: 0.85;
        transform: scale(1);
    }


}


.toast {
    border-radius: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    color: var(--text);
}


h1 {
    font-size: clamp(2.5rem, 4vw + 1rem, 4.5rem);
    line-height: 1.1;
    letter-spacing: -0.03em;
}
h2 {
    font-size: clamp(1.75rem, 3vw + 0.5rem, 2.5rem);
    line-height: 1.2;
    letter-spacing: -0.02em;
}
h3 {
    font-size: clamp(1.25rem, 2vw + 0.5rem, 1.75rem);
    line-height: 1.3;
}
