@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Fira+Code:wght@400;500&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap');

:root {
    --md-sys-color-primary: #6750A4;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #EADDFF;
    --md-sys-color-on-primary-container: #21005D;
    --md-sys-color-secondary: #625B71;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #E8DEF8;
    --md-sys-color-on-secondary-container: #1D192B;
    --md-sys-color-tertiary: #7D5260;
    --md-sys-color-on-tertiary: #FFFFFF;
    --md-sys-color-tertiary-container: #FFD8E4;
    --md-sys-color-on-tertiary-container: #31111D;
    --md-sys-color-error: #B3261E;
    --md-sys-color-on-error: #FFFFFF;
    --md-sys-color-error-container: #F9DEDC;
    --md-sys-color-on-error-container: #410E0B;
    --md-sys-color-background: #FFFBFE;
    --md-sys-color-on-background: #1C1B1F;
    --md-sys-color-surface: #FFFBFE;
    --md-sys-color-on-surface: #1C1B1F;
    --md-sys-color-surface-variant: #E7E0EC;
    --md-sys-color-on-surface-variant: #49454F;
    --md-sys-color-surface-container-lowest: #FFFFFF;
    --md-sys-color-surface-container-low: #F7F2FA;
    --md-sys-color-surface-container: #F3EDF7;
    --md-sys-color-surface-container-high: #ECE6F0;
    --md-sys-color-surface-container-highest: #E6E0E9;
    --md-sys-color-outline: #79747E;
    --md-sys-color-outline-variant: #CAC4D0;
    --md-sys-color-inverse-surface: #313033;
    --md-sys-color-inverse-on-surface: #F4EFF4;
    --md-sys-color-inverse-primary: #D0BCFF;
    --md-sys-color-scrim: #000000;
    --md-sys-color-shadow: #000000;

    --md-sys-shape-corner-none: 0px;
    --md-sys-shape-corner-extra-small: 4px;
    --md-sys-shape-corner-small: 8px;
    --md-sys-shape-corner-medium: 12px;
    --md-sys-shape-corner-large: 16px;
    --md-sys-shape-corner-extra-large: 28px;
    --md-sys-shape-corner-full: 9999px;

    --md-sys-elevation-level0: none;
    --md-sys-elevation-level1: 0px 1px 2px rgba(0,0,0,.3), 0px 1px 3px 1px rgba(0,0,0,.15);
    --md-sys-elevation-level2: 0px 1px 2px rgba(0,0,0,.3), 0px 2px 6px 2px rgba(0,0,0,.15);
    --md-sys-elevation-level3: 0px 4px 8px 3px rgba(0,0,0,.15), 0px 1px 3px rgba(0,0,0,.3);
    --md-sys-elevation-level4: 0px 6px 10px 4px rgba(0,0,0,.15), 0px 2px 3px rgba(0,0,0,.3);
    --md-sys-elevation-level5: 0px 8px 12px 6px rgba(0,0,0,.15), 0px 4px 4px rgba(0,0,0,.3);

    --md-sys-motion-duration-short1: 50ms;
    --md-sys-motion-duration-short2: 100ms;
    --md-sys-motion-duration-short3: 150ms;
    --md-sys-motion-duration-short4: 200ms;
    --md-sys-motion-duration-medium1: 250ms;
    --md-sys-motion-duration-medium2: 300ms;
    --md-sys-motion-duration-medium3: 350ms;
    --md-sys-motion-duration-medium4: 400ms;
    --md-sys-motion-duration-long1: 450ms;
    --md-sys-motion-duration-long2: 500ms;
    --md-sys-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);
    --md-sys-motion-easing-standard-decelerate: cubic-bezier(0, 0, 0, 1);
    --md-sys-motion-easing-standard-accelerate: cubic-bezier(0.3, 0, 1, 1);
    --md-sys-motion-easing-emphasized: cubic-bezier(0.2, 0, 0, 1);

    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-code: 'Fira Code', 'Cascadia Code', monospace;
    --sidebar-width: 280px;
}

[data-theme="dark"] {
    --md-sys-color-primary: #D0BCFF;
    --md-sys-color-on-primary: #381E72;
    --md-sys-color-primary-container: #4F378B;
    --md-sys-color-on-primary-container: #EADDFF;
    --md-sys-color-secondary: #CCC2DC;
    --md-sys-color-on-secondary: #332D41;
    --md-sys-color-secondary-container: #4A4458;
    --md-sys-color-on-secondary-container: #E8DEF8;
    --md-sys-color-tertiary: #EFB8C8;
    --md-sys-color-on-tertiary: #492532;
    --md-sys-color-tertiary-container: #633B48;
    --md-sys-color-on-tertiary-container: #FFD8E4;
    --md-sys-color-error: #F2B8B5;
    --md-sys-color-on-error: #601410;
    --md-sys-color-error-container: #8C1D18;
    --md-sys-color-on-error-container: #F9DEDC;
    --md-sys-color-background: #141218;
    --md-sys-color-on-background: #E6E0E9;
    --md-sys-color-surface: #141218;
    --md-sys-color-on-surface: #E6E0E9;
    --md-sys-color-surface-variant: #49454F;
    --md-sys-color-on-surface-variant: #CAC4D0;
    --md-sys-color-surface-container-lowest: #0F0D13;
    --md-sys-color-surface-container-low: #1D1B20;
    --md-sys-color-surface-container: #211F26;
    --md-sys-color-surface-container-high: #2B2930;
    --md-sys-color-surface-container-highest: #36343B;
    --md-sys-color-outline: #938F99;
    --md-sys-color-outline-variant: #49454F;
    --md-sys-color-inverse-surface: #E6E0E9;
    --md-sys-color-inverse-on-surface: #322F35;
    --md-sys-color-inverse-primary: #6750A4;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-ui);
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    line-height: 1.5;
    min-height: 100dvh;
    transition: background-color var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-standard),
                color var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-standard);
}

.material-symbols-rounded {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    user-select: none;
    pointer-events: none;
}

.material-symbols-rounded.filled {
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

a { color: var(--md-sys-color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
    outline: 3px solid var(--md-sys-color-primary);
    outline-offset: 2px;
    border-radius: var(--md-sys-shape-corner-extra-small);
}

.md3-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 24px;
    border-radius: var(--md-sys-shape-corner-full);
    font-family: var(--font-ui);
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.00625em;
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: box-shadow var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
                background-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.md3-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background-color: currentColor;
    opacity: 0;
    transition: opacity var(--md-sys-motion-duration-short4);
}

.md3-btn:hover::before { opacity: 0.08; }
.md3-btn:active::before { opacity: 0.12; }

.md3-btn-filled {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    box-shadow: var(--md-sys-elevation-level0);
}
.md3-btn-filled:hover { box-shadow: var(--md-sys-elevation-level1); }

.md3-btn-tonal {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.md3-btn-outlined {
    background-color: transparent;
    color: var(--md-sys-color-primary);
    border: 1px solid var(--md-sys-color-outline);
    padding: 0 23px;
}

.md3-btn-text {
    background-color: transparent;
    color: var(--md-sys-color-primary);
    padding: 0 12px;
}

.md3-btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--md-sys-shape-corner-full);
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    transition: background-color var(--md-sys-motion-duration-short3);
}

.md3-btn-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background-color: currentColor;
    opacity: 0;
    transition: opacity var(--md-sys-motion-duration-short4);
}

.md3-btn-icon:hover { background-color: color-mix(in srgb, var(--md-sys-color-on-surface-variant) 8%, transparent); }
.md3-btn-icon:active { background-color: color-mix(in srgb, var(--md-sys-color-on-surface-variant) 12%, transparent); }

.md3-fab {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: var(--md-sys-shape-corner-large);
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--md-sys-elevation-level3);
    transition: box-shadow var(--md-sys-motion-duration-short4), transform var(--md-sys-motion-duration-short4);
    z-index: 6;
    -webkit-tap-highlight-color: transparent;
}

.md3-fab:hover { box-shadow: var(--md-sys-elevation-level4); transform: scale(1.04); }
.md3-fab:active { box-shadow: var(--md-sys-elevation-level3); transform: scale(0.98); }

.md3-fab-extended {
    width: auto;
    padding: 0 20px;
    gap: 12px;
    font-family: var(--font-ui);
    font-size: 0.875rem;
    font-weight: 500;
}

.md3-card {
    background-color: var(--md-sys-color-surface-container);
    border-radius: var(--md-sys-shape-corner-medium);
    padding: 16px;
    transition: box-shadow var(--md-sys-motion-duration-short4);
}

.md3-card-elevated {
    background-color: var(--md-sys-color-surface-container-low);
    box-shadow: var(--md-sys-elevation-level1);
}

.md3-card-elevated:hover { box-shadow: var(--md-sys-elevation-level2); }

.md3-card-filled { background-color: var(--md-sys-color-surface-container-highest); }

.md3-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 16px;
    border-radius: var(--md-sys-shape-corner-small);
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--md-sys-color-outline);
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    transition: background-color var(--md-sys-motion-duration-short3), border-color var(--md-sys-motion-duration-short3);
    white-space: nowrap;
}

.md3-chip:hover { background-color: color-mix(in srgb, var(--md-sys-color-on-surface-variant) 8%, transparent); }
.md3-chip.selected {
    background-color: var(--md-sys-color-secondary-container);
    border-color: transparent;
    color: var(--md-sys-color-on-secondary-container);
}

.md3-chip.tag-chip {
    background-color: color-mix(in srgb, var(--tag-color, var(--md-sys-color-primary)) 15%, transparent);
    border-color: var(--tag-color, var(--md-sys-color-primary));
    color: var(--tag-color, var(--md-sys-color-primary));
}

.md3-dialog-scrim {
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: scrim-in var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-standard);
}

@keyframes scrim-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.md3-dialog {
    background-color: var(--md-sys-color-surface-container-high);
    border-radius: var(--md-sys-shape-corner-extra-large);
    padding: 24px;
    min-width: 280px;
    max-width: 560px;
    width: 100%;
    box-shadow: var(--md-sys-elevation-level3);
    animation: dialog-in var(--md-sys-motion-duration-medium3) var(--md-sys-motion-easing-emphasized);
}

@keyframes dialog-in {
    from { opacity: 0; transform: scale(0.9) translateY(16px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.md3-dialog-title {
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 16px;
}

.md3-dialog-content { color: var(--md-sys-color-on-surface-variant); margin-bottom: 24px; }

.md3-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.md3-input {
    position: relative;
    margin-bottom: 16px;
}

.md3-input input,
.md3-input textarea,
.md3-input select {
    width: 100%;
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-extra-small) var(--md-sys-shape-corner-extra-small) 0 0;
    padding: 16px;
    font-family: var(--font-ui);
    font-size: 1rem;
    transition: border-color var(--md-sys-motion-duration-short4);
    outline: none;
}

.md3-input input:focus,
.md3-input textarea:focus { border-color: var(--md-sys-color-primary); border-width: 2px; }

/* md3-input used directly on an element (not as wrapper) */
input.md3-input, textarea.md3-input, select.md3-input {
    width: 100%;
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-extra-small);
    padding: 10px 14px;
    font-family: var(--font-ui);
    font-size: .9375rem;
    transition: border-color var(--md-sys-motion-duration-short4);
    outline: none;
    box-sizing: border-box;
}
input.md3-input:focus, textarea.md3-input:focus, select.md3-input:focus {
    border-color: var(--md-sys-color-primary);
    border-width: 2px;
}
textarea.md3-input { resize: vertical; min-height: 80px; }

.md3-input label {
    position: absolute;
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    color: var(--md-sys-color-on-surface-variant);
    pointer-events: none;
    transition: all var(--md-sys-motion-duration-short4);
    font-size: 1rem;
}

.md3-input input:focus ~ label,
.md3-input input:not(:placeholder-shown) ~ label {
    top: 8px;
    font-size: 0.75rem;
    color: var(--md-sys-color-primary);
    transform: none;
}

.md3-snackbar-container {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.md3-snackbar {
    background-color: var(--md-sys-color-inverse-surface);
    color: var(--md-sys-color-inverse-on-surface);
    padding: 14px 16px;
    border-radius: var(--md-sys-shape-corner-extra-small);
    font-size: 0.875rem;
    box-shadow: var(--md-sys-elevation-level3);
    min-width: 288px;
    max-width: 568px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    pointer-events: all;
    animation: snackbar-in var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-standard-decelerate);
}

@keyframes snackbar-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.md3-snackbar.dismissing { animation: snackbar-out var(--md-sys-motion-duration-medium1) var(--md-sys-motion-easing-standard-accelerate) forwards; }

@keyframes snackbar-out {
    to { opacity: 0; transform: translateY(20px); }
}

.md3-snackbar .snack-action {
    color: var(--md-sys-color-inverse-primary);
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: none;
    font-family: var(--font-ui);
    font-size: 0.875rem;
    padding: 4px 8px;
    border-radius: var(--md-sys-shape-corner-extra-small);
}

.md3-progress-linear {
    height: 4px;
    background-color: var(--md-sys-color-surface-container-highest);
    border-radius: var(--md-sys-shape-corner-full);
    overflow: hidden;
}

.md3-progress-linear-bar {
    height: 100%;
    background-color: var(--md-sys-color-primary);
    border-radius: inherit;
    transition: width var(--md-sys-motion-duration-medium4) var(--md-sys-motion-easing-standard);
}

.md3-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background-color: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
    border-radius: var(--md-sys-shape-corner-full);
    font-size: 0.6875rem;
    font-weight: 500;
}

.ripple-host { position: relative; overflow: hidden; }
.ripple { position: absolute; border-radius: 50%; background: currentColor; opacity: 0.12; pointer-events: none; transform: scale(0); animation: ripple-anim 400ms var(--md-sys-motion-easing-standard) forwards; }

@keyframes ripple-anim {
    to { transform: scale(4); opacity: 0; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.skeleton {
    background: linear-gradient(90deg, var(--md-sys-color-surface-container) 25%, var(--md-sys-color-surface-container-high) 50%, var(--md-sys-color-surface-container) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: var(--md-sys-shape-corner-small);
}

@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@media (max-width: 599px) {
    .md3-fab { bottom: 80px; }
}
