/* =============================================
   Unit Converter — Styles v1.3
   Dark-first, mobile-first design
   UI/UX Polish & Dark Mode refinements
   ============================================= */

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #1a1a3e;
    --text-primary: #e8e8ff;
    --text-secondary: #8888aa;
    --text-muted: #555577;
    --accent: #6c63ff;
    --accent-hover: #5a52e0;
    --accent-glow: rgba(108, 99, 255, 0.2);
    --accent-subtle: rgba(108, 99, 255, 0.08);
    --success: #4ecca3;
    --success-glow: rgba(78, 204, 163, 0.15);
    --danger: #ff6b6b;
    --warning: #ffd93d;
    --border: #2a2a4a;
    --border-hover: #3a3a5e;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-accent: 0 4px 15px rgba(108, 99, 255, 0.4);
    --nav-height: 64px;
    --header-height: 56px;
    --transition: 0.2s ease;
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light mode */
.light-mode {
    --bg-primary: #f0f2f8;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f5f6fa;
    --text-primary: #1a1a2e;
    --text-secondary: #5a5a7a;
    --text-muted: #8a8aaa;
    --accent: #5b54e6;
    --accent-hover: #4a44d0;
    --accent-glow: rgba(91, 84, 230, 0.12);
    --accent-subtle: rgba(91, 84, 230, 0.05);
    --success: #2db88a;
    --success-glow: rgba(45, 184, 138, 0.1);
    --border: #e2e4f0;
    --border-hover: #d0d2e2;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-accent: 0 4px 15px rgba(91, 84, 230, 0.2);
}

/* ============ Smooth Theme Transition ============ */
body.theme-transitioning,
body.theme-transitioning *,
body.theme-transitioning *::before,
body.theme-transitioning *::after {
    transition: background-color 0.4s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* ============ Reset & Base ============ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport for mobile browsers */
    max-width: 480px;
    margin: 0 auto;
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Remove default focus for mouse users */
:focus:not(:focus-visible) {
    outline: none;
}

/* ============ Header ============ */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.app-header h1 {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.01em;
}

.offline-badge {
    font-size: 0.6rem;
    padding: 3px 8px;
    background: var(--success-glow);
    color: var(--success);
    border-radius: 20px;
    border: 1px solid rgba(78, 204, 163, 0.3);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: pulse-badge 3s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ============ Main Content ============ */
main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 16px 16px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .tab-content.active,
    .converter-panel.visible,
    .quick-convert-result,
    .comparison-table,
    .common-list {
        animation: none !important;
    }

    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* ============ Category Grid ============ */
.category-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    margin-bottom: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 2px 0 6px;
    scroll-snap-type: x proximity;
}

.category-grid::-webkit-scrollbar {
    display: none;
}

/* Scroll fade indicators */
.category-grid-wrapper {
    position: relative;
}

.category-grid-wrapper::before,
.category-grid-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 6px;
    width: 20px;
    z-index: 2;
    pointer-events: none;
    transition: opacity var(--transition);
}

.category-grid-wrapper::before {
    left: 0;
    background: linear-gradient(to right, var(--bg-primary), transparent);
    opacity: 0;
}

.category-grid-wrapper::after {
    right: 0;
    background: linear-gradient(to left, var(--bg-primary), transparent);
}

.category-grid-wrapper.scrolled-start::before {
    opacity: 1;
}

.category-grid-wrapper.scrolled-end::after {
    opacity: 0;
}

.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 6px 6px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
    min-width: 64px;
    flex-shrink: 0;
    scroll-snap-align: start;
    box-shadow: var(--shadow-sm);
}

.category-card:active {
    transform: scale(0.93);
}

.category-card.active {
    border-color: var(--cat-color, var(--accent));
    background: color-mix(in srgb, var(--cat-color, var(--accent)) 12%, var(--bg-card));
    box-shadow: 0 0 16px color-mix(in srgb, var(--cat-color, var(--accent)) 30%, transparent);
    transform: translateY(-1px);
}

.category-icon {
    font-size: 1.25rem;
    line-height: 1;
    transition: transform var(--transition);
}

.category-card.active .category-icon {
    transform: scale(1.1);
}

.category-name {
    font-size: 0.58rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    text-align: center;
    line-height: 1.2;
    white-space: nowrap;
}

.category-card.active .category-name {
    color: var(--cat-color, var(--accent));
    font-weight: 700;
}

/* ============ Converter Panel ============ */
.converter-panel {
    display: none;
    flex-direction: column;
    gap: 8px;
}

.converter-panel.visible {
    display: flex;
    animation: fadeSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.converter-row {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 12px;
    border: 1px solid var(--border);
    transition: border-color var(--transition), box-shadow var(--transition);
    box-shadow: var(--shadow-sm);
}

.converter-row:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.converter-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.input-group {
    display: flex;
    gap: 8px;
}

.converter-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    min-width: 0;
}

.converter-input:focus {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.converter-input.result {
    color: var(--success);
    font-weight: 700;
}

/* Result glow animation */
.converter-input.result.flash {
    animation: resultFlash 0.4s ease;
}

@keyframes resultFlash {
    0% { box-shadow: inset 0 0 0 1px var(--success), 0 0 12px var(--success-glow); }
    100% { box-shadow: none; }
}

.converter-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

/* Remove number input spinners */
.converter-input[type="number"]::-webkit-inner-spin-button,
.converter-input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.converter-input[type="number"] {
    -moz-appearance: textfield;
}

.unit-select {
    width: 110px;
    flex-shrink: 0;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238888aa' viewBox='0 0 16 16'%3E%3Cpath d='M8 12L2 6h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
    transition: border-color var(--transition);
}

.unit-select:focus {
    border-color: var(--accent);
}

/* ============ Swap Row ============ */
.swap-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: -4px 0;
    z-index: 1;
}

.swap-button {
    width: 44px;
    height: 44px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    box-shadow: var(--shadow-accent);
    position: relative;
    overflow: hidden;
}

.swap-button::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    opacity: 0;
    transition: opacity var(--transition);
}

.swap-button:active::after {
    opacity: 1;
}

.swap-button:active {
    transform: scale(0.9) rotate(180deg);
}

.swap-button:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 20px rgba(108, 99, 255, 0.5);
}

/* ============ Star Button (Converter) ============ */
.star-converter-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    line-height: 1;
}

.star-converter-btn:active {
    transform: scale(1.2);
}

.star-converter-btn.starred {
    background: rgba(255, 215, 0, 0.15);
    border-color: rgba(255, 215, 0, 0.4);
    animation: starPop 0.3s ease;
}

@keyframes starPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* ============ Copy Button ============ */
.copy-button {
    align-self: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: var(--shadow-sm);
}

.copy-button:active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: scale(0.96);
}

.copy-button.copied {
    background: var(--success);
    color: white;
    border-color: var(--success);
    box-shadow: 0 0 12px var(--success-glow);
}

/* ============ Formula Display ============ */
.formula-display {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 8px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

/* ============ Favorites & History ============ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
    filter: grayscale(30%);
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
}

.empty-hint {
    color: var(--text-muted) !important;
    font-size: 0.85rem !important;
    font-weight: 400 !important;
    margin-top: 4px;
}

.favorites-list, .history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item, .favorite-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

.history-item:active, .favorite-item:active {
    background: var(--accent-glow);
    transform: scale(0.98);
}

/* Staggered entry animation for list items */
.history-item, .favorite-item {
    animation: listItemIn 0.2s ease backwards;
}

.history-item:nth-child(1), .favorite-item:nth-child(1) { animation-delay: 0ms; }
.history-item:nth-child(2), .favorite-item:nth-child(2) { animation-delay: 30ms; }
.history-item:nth-child(3), .favorite-item:nth-child(3) { animation-delay: 60ms; }
.history-item:nth-child(4), .favorite-item:nth-child(4) { animation-delay: 90ms; }
.history-item:nth-child(5), .favorite-item:nth-child(5) { animation-delay: 120ms; }
.history-item:nth-child(n+6), .favorite-item:nth-child(n+6) { animation-delay: 150ms; }

@keyframes listItemIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

.conversion-text {
    flex: 1;
    min-width: 0;
}

.conversion-text .value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversion-text .category-tag {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.conversion-text .time-ago {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.item-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
    margin-left: 8px;
}

.star-btn, .delete-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    opacity: 0.5;
    transition: all var(--transition);
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.star-btn:active, .delete-btn:active {
    transform: scale(1.2);
}

.star-btn.starred {
    opacity: 1;
}

.delete-btn:active {
    opacity: 1;
    color: var(--danger);
}

/* ============ Settings ============ */
.settings-group {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
}

.settings-group h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    min-height: 44px; /* Touch target size */
}

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

.setting-item span {
    font-weight: 500;
    color: var(--text-primary);
}

.settings-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    min-height: 36px;
}

.settings-button {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 8px;
    min-height: 44px; /* Touch target */
}

.settings-button:last-child {
    margin-bottom: 0;
}

.settings-button.danger {
    border-color: rgba(255, 107, 107, 0.3);
    color: var(--danger);
}

.settings-button.danger:active {
    background: var(--danger);
    color: white;
    transform: scale(0.98);
}

.about p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.6;
}

.about .muted {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ============ Toggle Switch ============ */
.toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border);
    border-radius: 26px;
    transition: var(--transition-slow);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    bottom: 3px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: var(--transition-slow);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(22px);
    background: white;
}

/* ============ Bottom Navigation ============ */
.bottom-nav {
    display: flex;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    height: var(--nav-height);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    /* iOS safe area */
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    padding: 8px 0;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    min-height: 44px; /* Touch target */
}

.nav-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 32px;
    height: 3px;
    background: var(--accent);
    border-radius: 0 0 3px 3px;
    transition: transform var(--transition-slow);
}

.nav-btn.active::before {
    transform: translateX(-50%) scaleX(1);
}

.nav-btn.active {
    color: var(--accent);
}

.nav-btn:active {
    transform: scale(0.92);
}

.nav-icon {
    font-size: 1.3rem;
    transition: transform var(--transition);
}

.nav-btn.active .nav-icon {
    transform: scale(1.1);
}

.nav-label {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============ Quick Convert Bar ============ */
.quick-convert-bar {
    margin-bottom: 12px;
}

.quick-convert-input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 0.95rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    box-shadow: var(--shadow-sm);
}

.quick-convert-input::placeholder {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.quick-convert-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.quick-convert-result {
    margin-top: 8px;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 12px 14px;
    animation: fadeSlideIn 0.25s ease;
    box-shadow: 0 0 16px var(--accent-glow);
}

.qc-answer {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.qc-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.qc-equals {
    font-size: 1rem;
    color: var(--text-muted);
}

.qc-result {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--success);
}

.qc-use-btn {
    margin-top: 8px;
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
    text-decoration: underline;
    text-underline-offset: 2px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
}

.qc-use-btn:active {
    opacity: 0.7;
}

/* ============ Comparison Table ============ */
.compare-toggle-btn {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

.compare-toggle-btn:active {
    background: var(--accent-glow);
    border-color: var(--accent);
    transform: scale(0.98);
}

.comparison-table {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    animation: fadeSlideIn 0.25s ease;
    box-shadow: var(--shadow-sm);
}

.compare-row {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    gap: 10px;
    transition: background-color var(--transition);
}

.compare-row:last-child {
    border-bottom: none;
}

.compare-row.compare-self {
    background: var(--accent-glow);
    border-left: 3px solid var(--accent);
}

.compare-abbr {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent);
    width: 55px;
    flex-shrink: 0;
}

.compare-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.compare-name {
    font-size: 0.7rem;
    color: var(--text-muted);
    width: 90px;
    flex-shrink: 0;
    text-align: right;
}

/* ============ Common Conversions Reference ============ */
.common-conversions {
    margin-top: 16px;
}

.common-toggle-btn {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

.common-toggle-btn:active {
    background: var(--accent-glow);
    transform: scale(0.98);
}

.toggle-arrow {
    margin-left: auto;
    font-size: 0.9rem;
    transition: transform var(--transition-slow);
}

.toggle-arrow.open {
    transform: rotate(90deg);
}

.common-list {
    margin-top: 8px;
    animation: fadeSlideIn 0.25s ease;
}

.common-group {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.common-group-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    padding: 8px 12px;
    background: var(--accent-subtle);
    border-bottom: 1px solid var(--border);
}

.common-item {
    padding: 6px 12px;
    font-size: 0.82rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}

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

/* ============ Responsive ============ */
@media (min-width: 481px) {
    #app {
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
        box-shadow: var(--shadow);
    }
}

@media (max-width: 360px) {
    .category-card {
        min-width: 56px;
    }

    .unit-select {
        width: 90px;
    }

    .converter-input {
        font-size: 1rem;
        padding: 10px;
    }
}

@media (max-width: 320px) {
    .category-card {
        min-width: 52px;
    }

    .converter-input {
        font-size: 0.95rem;
    }
}

/* ============ System dark mode (for initial load before JS) ============ */
@media (prefers-color-scheme: light) {
    body:not(.dark-mode-override) {
        /* Only apply if no explicit preference saved */
    }
}
