@media print {
    .nav-drawer, .top-app-bar, .editor-toolbar, .editor-status-bar,
    .md3-fab, .bottom-nav, .properties-panel, .slash-menu, .mention-menu,
    button:not(.print-visible) { display: none !important; }
    .editor-scroll { padding: 0 !important; overflow: visible !important; }
    .editor-content a::after { content: " (" attr(href) ")"; font-size: 0.75em; color: #666; }
    body { color: #000 !important; background: #fff !important; }
}

.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--md-sys-color-inverse-surface);
    color: var(--md-sys-color-inverse-on-surface);
    padding: 6px 10px;
    border-radius: var(--md-sys-shape-corner-extra-small);
    font-size: 0.75rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--md-sys-motion-duration-short3);
    z-index: 99;
    font-family: var(--font-ui);
}

.tooltip:hover::after { opacity: 1; }

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8125rem;
    color: var(--md-sys-color-on-surface-variant);
    flex-wrap: wrap;
    padding: 8px 0;
}

.breadcrumb-item {
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    border-radius: var(--md-sys-shape-corner-extra-small);
    padding: 2px 6px;
    transition: background-color var(--md-sys-motion-duration-short3);
}

.breadcrumb-item:hover { background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent); color: var(--md-sys-color-on-surface); }
.breadcrumb-item.current { color: var(--md-sys-color-on-surface); font-weight: 500; }
.breadcrumb-sep { color: var(--md-sys-color-on-surface-variant); opacity: 0.5; user-select: none; }

.storage-bar {
    padding: 12px 16px;
}

.storage-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 6px;
}

*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--md-sys-color-outline-variant); border-radius: 3px; }
*::-webkit-scrollbar-thumb:hover { background: var(--md-sys-color-outline); }

.drag-over {
    outline: 2px dashed var(--md-sys-color-primary);
    outline-offset: -2px;
    background-color: color-mix(in srgb, var(--md-sys-color-primary) 8%, transparent);
}

.dragging { opacity: 0.5; }

.view-transition-animate {
    animation: view-fade var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-standard);
}

@keyframes view-fade {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.stagger-in > * {
    animation: view-fade var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-standard) both;
}

.stagger-in > *:nth-child(1) { animation-delay: 0ms; }
.stagger-in > *:nth-child(2) { animation-delay: 50ms; }
.stagger-in > *:nth-child(3) { animation-delay: 100ms; }
.stagger-in > *:nth-child(4) { animation-delay: 150ms; }
.stagger-in > *:nth-child(5) { animation-delay: 200ms; }
.stagger-in > *:nth-child(n+6) { animation-delay: 250ms; }

.user-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background-color: var(--md-sys-color-surface-container-high);
    border-radius: var(--md-sys-shape-corner-medium);
    box-shadow: var(--md-sys-elevation-level3);
    min-width: 240px;
    padding: 8px 0;
    z-index: 50;
    animation: dialog-in var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}

.user-menu-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    margin-bottom: 8px;
}

.user-menu-name { font-weight: 600; color: var(--md-sys-color-on-surface); font-size: 0.9375rem; }
.user-menu-email { font-size: 0.8125rem; color: var(--md-sys-color-on-surface-variant); }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 24px;
    text-align: center;
    color: var(--md-sys-color-on-surface-variant);
}

.empty-state .material-symbols-rounded { font-size: 48px; opacity: 0.5; }
.empty-state h3 { font-size: 1.125rem; font-weight: 500; color: var(--md-sys-color-on-surface); }
.empty-state p { font-size: 0.875rem; max-width: 280px; }

.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: color-mix(in srgb, var(--md-sys-color-surface) 80%, transparent);
    z-index: 40;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--md-sys-color-outline-variant);
    border-top-color: var(--md-sys-color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.tools-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 380px;
    background-color: var(--md-sys-color-surface-container-low);
    border-left: 1px solid var(--md-sys-color-outline-variant);
    z-index: 25;
    display: flex;
    flex-direction: column;
    box-shadow: var(--md-sys-elevation-level4);
    animation: slide-in-right var(--md-sys-motion-duration-medium3) var(--md-sys-motion-easing-emphasized);
}

@keyframes slide-in-right {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.tools-tabs {
    display: flex;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    overflow-x: auto;
    flex-shrink: 0;
}

.tools-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 8px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.6875rem;
    font-weight: 500;
    transition: color var(--md-sys-motion-duration-short3), border-color var(--md-sys-motion-duration-short3);
    white-space: nowrap;
    border: none;
    background: none;
    font-family: var(--font-ui);
}

.tools-tab:hover { color: var(--md-sys-color-on-surface); }
.tools-tab.active { color: var(--md-sys-color-primary); border-bottom: 2px solid var(--md-sys-color-primary); }

.tools-content { flex: 1; overflow-y: auto; padding: 16px; }

.calc-display {
    background-color: var(--md-sys-color-surface-container-highest);
    border-radius: var(--md-sys-shape-corner-medium);
    padding: 20px;
    text-align: right;
    margin-bottom: 12px;
}

.calc-expression { font-size: 0.875rem; color: var(--md-sys-color-on-surface-variant); min-height: 20px; }
.calc-result { font-size: 2rem; font-weight: 300; color: var(--md-sys-color-on-surface); line-height: 1.2; }

.calc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.calc-btn {
    height: 56px;
    border-radius: var(--md-sys-shape-corner-medium);
    border: none;
    font-family: var(--font-ui);
    font-size: 1rem;
    cursor: pointer;
    transition: background-color var(--md-sys-motion-duration-short3), transform var(--md-sys-motion-duration-short2);
    background-color: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    display: flex;
    align-items: center;
    justify-content: center;
}

.calc-btn:hover { background-color: var(--md-sys-color-surface-container-high); }
.calc-btn:active { transform: scale(0.95); }
.calc-btn.operator { background-color: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.calc-btn.equals { background-color: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }
.calc-btn.clear { background-color: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }
.calc-btn.span2 { grid-column: span 2; }

.history-panel {
    background-color: var(--md-sys-color-surface-container);
    border-radius: var(--md-sys-shape-corner-medium);
    padding: 12px;
    margin-top: 12px;
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    font-size: 0.8125rem;
}

.history-item:last-child { border: none; }
.history-expr { color: var(--md-sys-color-on-surface-variant); }
.history-res { font-weight: 600; color: var(--md-sys-color-on-surface); cursor: pointer; }
.history-res:hover { color: var(--md-sys-color-primary); }

.conv-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.conv-row input { border-radius: var(--md-sys-shape-corner-extra-small); text-align: right; }
.conv-swap { cursor: pointer; color: var(--md-sys-color-primary); }

@media (max-width: 599px) {
    .tools-panel { width: 100%; left: 0; border-left: none; border-top: 1px solid var(--md-sys-color-outline-variant); top: auto; height: 70dvh; border-radius: var(--md-sys-shape-corner-extra-large) var(--md-sys-shape-corner-extra-large) 0 0; animation: sheet-up var(--md-sys-motion-duration-medium3) var(--md-sys-motion-easing-emphasized); }
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.settings-card {
    background-color: var(--md-sys-color-surface-container);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 20px;
}

.settings-card-title { font-weight: 600; font-size: 0.9375rem; color: var(--md-sys-color-on-surface); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

.switch {
    position: relative;
    width: 52px;
    height: 32px;
    flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch-track {
    position: absolute;
    inset: 0;
    background-color: var(--md-sys-color-surface-container-highest);
    border-radius: var(--md-sys-shape-corner-full);
    border: 2px solid var(--md-sys-color-outline);
    cursor: pointer;
    transition: background-color var(--md-sys-motion-duration-medium1), border-color var(--md-sys-motion-duration-medium1);
}

.switch input:checked + .switch-track {
    background-color: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}

.switch-track::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background-color: var(--md-sys-color-outline);
    border-radius: 50%;
    top: 50%;
    left: 4px;
    transform: translateY(-50%);
    transition: transform var(--md-sys-motion-duration-medium1), background-color var(--md-sys-motion-duration-medium1), width var(--md-sys-motion-duration-short3);
}

.switch input:checked + .switch-track::after {
    transform: translateY(-50%) translateX(20px);
    background-color: var(--md-sys-color-on-primary);
    width: 24px;
}
