/* ==========================================================================
   Materia M3 — Components
   The full M3 component library. Naming follows .m3-{component}--{variant}.
   Components use the system tokens defined in tokens.css and the type scale
   from typography.css.
   ========================================================================== */

/* ==========================================================================
   STATE LAYERS
   The M3 state-layer pattern: an absolutely positioned ::before pseudo
   element with the component's "on-" colour + variable opacity. Applied
   on hover / focus / active / dragged.
   ========================================================================== */
.m3-state-layer {
    position: relative;
    isolation: isolate;
    overflow: hidden;
}
.m3-state-layer::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: currentColor;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--md-sys-motion-duration-short3)
                var(--md-sys-motion-easing-standard);
    z-index: 0;
}
/* Real children (icons, labels, etc.) need `position: relative` to sit
 * above the `::before` state layer (z-index: 0). The JS-injected ripple
 * span has its OWN absolute positioning to track the click point; we
 * must NOT promote it to a flex/relative child or it will displace the
 * other children. Hence the `:not(.m3-ripple__circle)` exclusion on every
 * `> *` rule throughout this file. */
.m3-state-layer > *:not(.m3-ripple__circle) {
    position: relative;
    z-index: 1;
}
.m3-state-layer:hover::before    { opacity: var(--md-sys-state-hover-state-layer-opacity); }
.m3-state-layer:focus-visible::before { opacity: var(--md-sys-state-focus-state-layer-opacity); }
.m3-state-layer:active::before   { opacity: var(--md-sys-state-pressed-state-layer-opacity); }
.m3-state-layer[aria-disabled="true"]::before,
.m3-state-layer:disabled::before { opacity: 0 !important; }

/* ==========================================================================
   RIPPLE
   The JS in ripple.js inserts a span.m3-ripple__circle into a positioned
   .m3-ripple element on press. The animation expands and fades out.
   ========================================================================== */
.m3-ripple {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}
.m3-ripple__circle {
    position: absolute;
    border-radius: 50%;
    background-color: currentColor;
    opacity: var(--md-sys-state-pressed-state-layer-opacity);
    pointer-events: none;
    transform: scale(0);
    animation: m3-ripple-expand
        var(--md-sys-motion-duration-long2)
        var(--md-sys-motion-easing-standard) forwards;
    z-index: 0;
}

/* ==========================================================================
   ICONS — Material Symbols Outlined
   ========================================================================== */
.material-symbols-outlined,
.m3-icon {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    user-select: none;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}
.m3-icon--filled  { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.m3-icon--small   { font-size: 20px; }
.m3-icon--medium  { font-size: 24px; }
.m3-icon--large   { font-size: 40px; font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 40; }
.m3-icon--xl      { font-size: 48px; font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 48; }

/* ==========================================================================
   BUTTONS
   M3 has 5 common buttons + FAB + Icon Button.
   ========================================================================== */

/* shared base */
.m3-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 24px;
    border: 0;
    border-radius: var(--md-sys-shape-corner-full);
    font-family: var(--md-sys-typescale-font-plain);
    font-size: 14px;
    line-height: 20px;
    font-weight: 500;
    letter-spacing: 0.1px;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    position: relative;
    isolation: isolate;
    overflow: hidden;
    transition:
        background-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
        box-shadow       var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
        color            var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
    white-space: nowrap;
}
.m3-button:disabled,
.m3-button[aria-disabled="true"] {
    cursor: not-allowed;
    pointer-events: none;
}
.m3-button .m3-icon { font-size: 18px; }
/* No `:first-child` / `:last-child` negative margin tweaks here. Text
 * nodes don't count toward those pseudo-classes, so a single icon with
 * a text label adjacent to it matches BOTH — and worse, when ripple.js
 * appends a `.m3-ripple__circle` as a sibling, `:last-child` stops
 * matching, the icon's `margin-right` resets, and `justify-content:
 * center` shifts the whole label leftwards on click. We drop the
 * adjustment entirely; the standard 24px padding + 8px gap looks fine.
 * For an icon-only button use the dedicated `.m3-icon-button` class. */

/* Buttons are anchors (.m3-button is often an `<a>`), so the
 * `a:hover { text-decoration: underline }` rule in typography.css
 * applies. The underline doesn't align under text + Material Symbols
 * icons because they sit on different baselines. Buttons already have
 * a hover state layer (the `::before` pseudo) — turn the underline off. */
.m3-button,
.m3-button:hover,
.m3-button:focus,
.m3-button:focus-visible,
.m3-button:active {
    text-decoration: none;
}

.m3-button::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: currentColor;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
    z-index: 0;
}
.m3-button:hover::before          { opacity: var(--md-sys-state-hover-state-layer-opacity); }
.m3-button:focus-visible::before  { opacity: var(--md-sys-state-focus-state-layer-opacity); }
.m3-button:active::before         { opacity: var(--md-sys-state-pressed-state-layer-opacity); }
.m3-button > *:not(.m3-ripple__circle) { position: relative; z-index: 1; }

/* ----- Filled (default emphasis) ----- */
.m3-button--filled {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}
.m3-button--filled:disabled {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent);
    color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);
}

/* ----- Tonal (medium-low emphasis) ----- */
.m3-button--tonal {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}
.m3-button--tonal:disabled {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent);
    color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);
}

/* ----- Elevated (low emphasis but elevated) ----- */
.m3-button--elevated {
    background-color: var(--md-sys-color-surface-container-low);
    color: var(--md-sys-color-primary);
    box-shadow: var(--md-sys-elevation-1);
}
.m3-button--elevated:hover  { box-shadow: var(--md-sys-elevation-2); }
.m3-button--elevated:disabled {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent);
    color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);
    box-shadow: var(--md-sys-elevation-0);
}

/* ----- Outlined (low emphasis) ----- */
.m3-button--outlined {
    background-color: transparent;
    color: var(--md-sys-color-primary);
    border: 1px solid var(--md-sys-color-outline);
}
.m3-button--outlined:focus-visible { border-color: var(--md-sys-color-primary); }
.m3-button--outlined:disabled {
    color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);
    border-color: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent);
}

/* ----- Text (lowest emphasis) ----- */
.m3-button--text {
    background-color: transparent;
    color: var(--md-sys-color-primary);
    padding: 0 12px;
}
.m3-button--text:disabled {
    color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);
}

/* ----- Floating Action Button ----- */
.m3-fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: var(--md-sys-shape-corner-large);
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    box-shadow: var(--md-sys-elevation-3);
    cursor: pointer;
    overflow: hidden;
    isolation: isolate;
    position: relative;
    transition:
        box-shadow var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
        background-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.m3-fab::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: currentColor;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
    z-index: 0;
}
.m3-fab:hover::before { opacity: var(--md-sys-state-hover-state-layer-opacity); }
.m3-fab:hover { box-shadow: var(--md-sys-elevation-4); }
.m3-fab:active::before { opacity: var(--md-sys-state-pressed-state-layer-opacity); }
.m3-fab > *:not(.m3-ripple__circle) { position: relative; z-index: 1; }
.m3-fab .m3-icon { font-size: 24px; }

.m3-fab--small  { width: 40px; height: 40px; border-radius: var(--md-sys-shape-corner-medium); }
.m3-fab--small  .m3-icon { font-size: 24px; }
.m3-fab--large  { width: 96px; height: 96px; border-radius: var(--md-sys-shape-corner-extra-large); }
.m3-fab--large  .m3-icon { font-size: 36px; }
.m3-fab--extended {
    width: auto;
    height: 56px;
    padding: 0 16px 0 16px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
}
.m3-fab--surface   { background-color: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-primary); }
.m3-fab--secondary { background-color: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.m3-fab--tertiary  { background-color: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }

/* ----- Icon Button ----- */
.m3-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: var(--md-sys-shape-corner-full);
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    position: relative;
    isolation: isolate;
    overflow: hidden;
    transition:
        background-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
        color            var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.m3-icon-button::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: currentColor;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
    z-index: 0;
}
.m3-icon-button:hover::before  { opacity: var(--md-sys-state-hover-state-layer-opacity); }
.m3-icon-button:focus-visible::before { opacity: var(--md-sys-state-focus-state-layer-opacity); }
.m3-icon-button:active::before { opacity: var(--md-sys-state-pressed-state-layer-opacity); }
.m3-icon-button > *:not(.m3-ripple__circle) { position: relative; z-index: 1; }
.m3-icon-button--filled {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}
.m3-icon-button--tonal {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}
.m3-icon-button--outlined {
    border: 1px solid var(--md-sys-color-outline);
    color: var(--md-sys-color-on-surface-variant);
}
.m3-icon-button[aria-pressed="true"]:not(.m3-icon-button--filled):not(.m3-icon-button--tonal) {
    color: var(--md-sys-color-primary);
}

/* ==========================================================================
   CARDS
   M3 has 3 card variants: elevated, filled, outlined.
   ========================================================================== */
.m3-card {
    display: flex;
    flex-direction: column;
    border-radius: var(--md-sys-shape-corner-medium);
    overflow: hidden;
    position: relative;
    isolation: isolate;
    transition:
        box-shadow       var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
        background-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.m3-card--elevated {
    background-color: var(--md-sys-color-surface-container-low);
    color: var(--md-sys-color-on-surface);
    box-shadow: var(--md-sys-elevation-1);
}
.m3-card--elevated:hover { box-shadow: var(--md-sys-elevation-2); }
.m3-card--filled {
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
}
.m3-card--outlined {
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
}
.m3-card--clickable { cursor: pointer; }
.m3-card--clickable::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: var(--md-sys-color-on-surface);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
    z-index: 1;
}
.m3-card--clickable:hover::before  { opacity: var(--md-sys-state-hover-state-layer-opacity); }
.m3-card--clickable:focus-visible::before { opacity: var(--md-sys-state-focus-state-layer-opacity); }
.m3-card--clickable:active::before { opacity: var(--md-sys-state-pressed-state-layer-opacity); }

.m3-card__media {
    aspect-ratio: 16/9;
    background-color: var(--md-sys-color-surface-container-high);
    position: relative;
    z-index: 0;
    overflow: hidden;
}
.m3-card__media img,
.m3-card__media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-standard);
}
.m3-card--clickable:hover .m3-card__media img { transform: scale(1.04); }

.m3-card__header {
    padding: 16px 16px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}
.m3-card__avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--md-sys-shape-corner-full);
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.m3-card__avatar img { width: 100%; height: 100%; object-fit: cover; }
.m3-card__title-block { flex: 1; min-width: 0; }
.m3-card__title {
    font-family: var(--md-sys-typescale-font-brand);
    font-size: 16px;
    font-weight: 500;
    line-height: 24px;
    letter-spacing: 0.15px;
    color: var(--md-sys-color-on-surface);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.m3-card__subtitle {
    font-size: 14px;
    line-height: 20px;
    color: var(--md-sys-color-on-surface-variant);
    margin: 2px 0 0;
}
.m3-card__body {
    padding: 16px;
    color: var(--md-sys-color-on-surface-variant);
    flex: 1;
}
.m3-card__body p:last-child { margin-bottom: 0; }
.m3-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 16px 16px;
    align-items: center;
}
.m3-card__actions--end { justify-content: flex-end; }

/* ==========================================================================
   CHIPS
   ========================================================================== */
.m3-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 16px;
    border-radius: var(--md-sys-shape-corner-small);
    border: 1px solid var(--md-sys-color-outline);
    background-color: transparent;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 14px;
    line-height: 20px;
    font-weight: 500;
    letter-spacing: 0.1px;
    cursor: pointer;
    position: relative;
    isolation: isolate;
    overflow: hidden;
    text-decoration: none;
    transition:
        background-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
        color            var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
        border-color     var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.m3-chip::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: currentColor;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
    z-index: 0;
}
.m3-chip:hover::before          { opacity: var(--md-sys-state-hover-state-layer-opacity); }
.m3-chip:focus-visible::before  { opacity: var(--md-sys-state-focus-state-layer-opacity); }
.m3-chip:active::before         { opacity: var(--md-sys-state-pressed-state-layer-opacity); }
.m3-chip > *:not(.m3-ripple__circle) { position: relative; z-index: 1; }
.m3-chip .m3-icon { font-size: 18px; }

.m3-chip--assist { background-color: transparent; }

.m3-chip--filter[aria-pressed="true"],
.m3-chip--filter.is-selected {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    border-color: transparent;
}

.m3-chip--input {
    height: 32px;
    padding-right: 8px;
}
.m3-chip--input .m3-chip__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
}
.m3-chip--input .m3-chip__remove .m3-icon { font-size: 16px; }

.m3-chip--suggestion {
    background-color: transparent;
    border-color: var(--md-sys-color-outline);
}

.m3-chip--elevated {
    border-color: transparent;
    background-color: var(--md-sys-color-surface-container-low);
    box-shadow: var(--md-sys-elevation-1);
}

.m3-chip-set {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ==========================================================================
   TEXT FIELDS
   ========================================================================== */
.m3-text-field {
    display: inline-flex;
    flex-direction: column;
    width: 100%;
    position: relative;
    font-family: var(--md-sys-typescale-font-plain);
}

.m3-text-field__input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 56px;
    border-radius: var(--md-sys-shape-corner-extra-small) var(--md-sys-shape-corner-extra-small) 0 0;
    transition: background-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

/* Filled variant */
.m3-text-field--filled .m3-text-field__input-wrap {
    background-color: var(--md-sys-color-surface-container-highest);
    border-bottom: 1px solid var(--md-sys-color-on-surface-variant);
}
.m3-text-field--filled .m3-text-field__input-wrap:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, var(--md-sys-color-surface-container-highest));
}
.m3-text-field--filled.is-focused .m3-text-field__input-wrap {
    border-bottom: 2px solid var(--md-sys-color-primary);
}

/* Outlined variant */
.m3-text-field--outlined .m3-text-field__input-wrap {
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-extra-small);
    background: transparent;
}
.m3-text-field--outlined.is-focused .m3-text-field__input-wrap {
    border: 2px solid var(--md-sys-color-primary);
}
.m3-text-field--outlined.has-error .m3-text-field__input-wrap {
    border-color: var(--md-sys-color-error);
}

.m3-text-field__input,
.m3-text-field textarea {
    flex: 1;
    width: 100%;
    background: transparent;
    border: 0;
    outline: 0;
    padding: 24px 16px 8px;
    color: var(--md-sys-color-on-surface);
    font-family: inherit;
    font-size: 16px;
    line-height: 24px;
    letter-spacing: 0.5px;
    resize: vertical;
}
.m3-text-field--outlined .m3-text-field__input { padding: 16px; }

.m3-text-field__label {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--md-sys-color-on-surface-variant);
    pointer-events: none;
    font-size: 16px;
    line-height: 24px;
    letter-spacing: 0.5px;
    transition: all var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
    background-color: transparent;
    padding: 0 4px;
}
.m3-text-field.is-focused .m3-text-field__label,
.m3-text-field.has-value .m3-text-field__label {
    top: 0;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--md-sys-color-primary);
}
.m3-text-field--outlined.is-focused .m3-text-field__label,
.m3-text-field--outlined.has-value .m3-text-field__label {
    background-color: var(--md-sys-color-surface);
}
.m3-text-field--filled.is-focused .m3-text-field__label,
.m3-text-field--filled.has-value .m3-text-field__label {
    top: 8px;
    transform: none;
}
.m3-text-field--filled .m3-text-field__input { padding: 24px 16px 8px; }
.m3-text-field--filled .m3-text-field__input:placeholder-shown + .m3-text-field__label {
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
}

.m3-text-field__supporting {
    display: flex;
    justify-content: space-between;
    margin: 4px 16px 0;
    font-size: 12px;
    line-height: 16px;
    color: var(--md-sys-color-on-surface-variant);
}
.m3-text-field.has-error .m3-text-field__supporting { color: var(--md-sys-color-error); }

.m3-text-field__leading,
.m3-text-field__trailing {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-on-surface-variant);
    padding: 0 12px;
}

/* ==========================================================================
   SEARCH BAR (M3 search)
   ========================================================================== */
.m3-search-bar {
    display: flex;
    align-items: center;
    height: 56px;
    padding: 0 16px;
    background-color: var(--md-sys-color-surface-container-high);
    border-radius: var(--md-sys-shape-corner-full);
    color: var(--md-sys-color-on-surface);
    box-shadow: var(--md-sys-elevation-1);
    transition: box-shadow var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.m3-search-bar:focus-within { box-shadow: var(--md-sys-elevation-2); }
.m3-search-bar__icon {
    color: var(--md-sys-color-on-surface-variant);
    margin-right: 16px;
}
.m3-search-bar__input {
    flex: 1;
    background: transparent;
    border: 0;
    outline: 0;
    color: inherit;
    font-size: 16px;
    line-height: 24px;
    letter-spacing: 0.5px;
}
.m3-search-bar__input::placeholder { color: var(--md-sys-color-on-surface-variant); }

/* ==========================================================================
   TOP APP BAR
   M3 has Center-aligned, Small, Medium, Large variants.
   ========================================================================== */
.m3-top-app-bar {
    position: sticky;
    top: 0;
    z-index: var(--md-sys-z-index-app-bar);
    display: flex;
    align-items: center;
    gap: 4px;
    height: var(--md-comp-top-app-bar-height);
    padding: 8px 16px;
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    transition:
        background-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
        box-shadow       var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
.m3-top-app-bar.is-scrolled {
    background-color: var(--md-sys-color-surface-container);
}
.m3-top-app-bar__leading {
    display: flex;
    align-items: center;
    gap: 4px;
}
.m3-top-app-bar__title {
    flex: 1;
    margin: 0 8px;
    font-family: var(--md-sys-typescale-font-brand);
    font-size: 22px;
    font-weight: 400;
    line-height: 28px;
    letter-spacing: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.m3-top-app-bar__trailing {
    display: flex;
    align-items: center;
    gap: 4px;
}
.m3-top-app-bar--center .m3-top-app-bar__title { text-align: center; }
.m3-top-app-bar--medium { height: 112px; align-items: flex-end; padding-bottom: 24px; }
.m3-top-app-bar--medium .m3-top-app-bar__title { font-size: 28px; line-height: 36px; }
.m3-top-app-bar--large  { height: 152px; align-items: flex-end; padding-bottom: 28px; }
.m3-top-app-bar--large  .m3-top-app-bar__title { font-size: 32px; line-height: 40px; }

/* ==========================================================================
   NAVIGATION DRAWER (M3)
   - Modal mode: phone — slides in from left with scrim.
   - Standard mode: tablet+ — persistent left rail (see layout.css media query).
   - Supports nested expandable groups (matches m3.material.io).
   ========================================================================== */
.m3-nav-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--md-comp-nav-drawer-width);
    max-width: 90vw;
    background-color: var(--md-sys-color-surface-container-low);
    color: var(--md-sys-color-on-surface);
    z-index: var(--md-sys-z-index-drawer);
    transform: translateX(-100%);
    transition: transform var(--md-sys-motion-duration-medium2)
                var(--md-sys-motion-easing-emphasized);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-top-right-radius: var(--md-sys-shape-corner-large);
    border-bottom-right-radius: var(--md-sys-shape-corner-large);
}
.m3-nav-drawer.is-open { transform: translateX(0); }

.m3-nav-drawer__header {
    padding: 28px 28px 16px;
    font-family: var(--md-sys-typescale-font-brand);
    font-size: 22px;
    line-height: 28px;
    color: var(--md-sys-color-on-surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.m3-nav-drawer__header .site-title { flex: 1; }

.m3-nav-drawer__list,
.m3-nav-drawer__sublist {
    list-style: none;
    margin: 0;
    padding: 0;
}
.m3-nav-drawer__list  { padding: 8px 12px 24px; }
.m3-nav-drawer__item  { margin: 0; }

/* ----- Plain link (leaf item) ----- */
.m3-nav-drawer__link,
.m3-nav-drawer__group-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    height: 56px;
    padding: 0 24px 0 16px;
    border: 0;
    background: transparent;
    border-radius: var(--md-sys-shape-corner-full);
    color: var(--md-sys-color-on-surface-variant);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    position: relative;
    isolation: isolate;
    overflow: hidden;
    transition:
        background-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
        color            var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.m3-nav-drawer__link::before,
.m3-nav-drawer__group-toggle::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: currentColor;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
    z-index: 0;
}
.m3-nav-drawer__link:hover::before,
.m3-nav-drawer__group-toggle:hover::before          { opacity: var(--md-sys-state-hover-state-layer-opacity); }
.m3-nav-drawer__link:focus-visible::before,
.m3-nav-drawer__group-toggle:focus-visible::before  { opacity: var(--md-sys-state-focus-state-layer-opacity); }
.m3-nav-drawer__link:active::before,
.m3-nav-drawer__group-toggle:active::before         { opacity: var(--md-sys-state-pressed-state-layer-opacity); }
.m3-nav-drawer__link > *:not(.m3-ripple__circle),
.m3-nav-drawer__group-toggle > *:not(.m3-ripple__circle) { position: relative; z-index: 1; }

.m3-nav-drawer__label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Active leaf */
.m3-nav-drawer__link.current-menu-item,
.m3-nav-drawer__link[aria-current="page"],
.m3-nav-drawer__sublink.current-menu-item,
.m3-nav-drawer__sublink[aria-current="page"] {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

/* ----- Expandable group ----- */
.m3-nav-drawer__item--group { display: contents; }

.m3-nav-drawer__group-toggle .m3-nav-drawer__chevron {
    margin-left: auto;
    flex-shrink: 0;
    transition: transform var(--md-sys-motion-duration-medium1)
                var(--md-sys-motion-easing-emphasized);
}
.m3-nav-drawer__item--expanded > .m3-nav-drawer__group-toggle .m3-nav-drawer__chevron,
.m3-nav-drawer__group-toggle[aria-expanded="true"] .m3-nav-drawer__chevron {
    transform: rotate(180deg);
}

.m3-nav-drawer__group-content {
    overflow: hidden;
    max-height: 0;
    transition: max-height var(--md-sys-motion-duration-medium2)
                var(--md-sys-motion-easing-emphasized);
}
.m3-nav-drawer__item--expanded > .m3-nav-drawer__group-content,
.m3-nav-drawer__group-toggle[aria-expanded="true"] + .m3-nav-drawer__group-content {
    max-height: 80vh;
}

/* ----- Sub-link (nested) ----- */
.m3-nav-drawer__sublist {
    padding: 4px 0 8px;
    list-style: none;
}
.m3-nav-drawer__sublink {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 40px;
    padding: 0 16px 0 52px; /* indent past leading-icon column */
    border-radius: var(--md-sys-shape-corner-full);
    color: var(--md-sys-color-on-surface-variant);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    text-decoration: none;
    position: relative;
    isolation: isolate;
    overflow: hidden;
    transition: background-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.m3-nav-drawer__sublink::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: currentColor;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
    z-index: 0;
}
.m3-nav-drawer__sublink:hover::before { opacity: var(--md-sys-state-hover-state-layer-opacity); }
.m3-nav-drawer__sublink:active::before { opacity: var(--md-sys-state-pressed-state-layer-opacity); }
.m3-nav-drawer__sublink > *:not(.m3-ripple__circle) { position: relative; z-index: 1; }

/* Deeper nesting (3+ levels) progressively indents */
.m3-nav-drawer__sublist .m3-nav-drawer__sublist .m3-nav-drawer__sublink { padding-left: 76px; }
.m3-nav-drawer__sublist .m3-nav-drawer__sublist .m3-nav-drawer__sublist .m3-nav-drawer__sublink { padding-left: 100px; }

/* ----- Section heading (uppercase label, not a link) ----- */
.m3-nav-drawer__section-heading {
    padding: 24px 28px 8px;
    font-family: var(--md-sys-typescale-font-plain);
    font-size: 11px;
    line-height: 16px;
    font-weight: 500;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--md-sys-color-on-surface-variant);
    user-select: none;
}
.m3-nav-drawer__section-heading + .m3-nav-drawer__item { margin-top: 0; }

/* ----- Divider ----- */
.m3-nav-drawer__divider {
    height: 1px;
    margin: 16px 28px;
    background-color: var(--md-sys-color-outline-variant);
    border: 0;
    list-style: none;
}

.m3-scrim {
    position: fixed;
    inset: 0;
    background-color: var(--md-sys-color-scrim);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-standard);
    z-index: calc(var(--md-sys-z-index-drawer) - 1);
}
.m3-scrim.is-visible {
    opacity: 0.32;
    pointer-events: auto;
}

/* ==========================================================================
   NAVIGATION RAIL (desktop side rail)
   ========================================================================== */
.m3-nav-rail {
    width: var(--md-comp-nav-rail-width);
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
    gap: 12px;
}
.m3-nav-rail__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 56px;
    padding-top: 12px;
    text-decoration: none;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.5px;
}
.m3-nav-rail__item-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 32px;
    border-radius: var(--md-sys-shape-corner-large);
    transition: background-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.m3-nav-rail__item.is-active .m3-nav-rail__item-indicator,
.m3-nav-rail__item[aria-current="page"] .m3-nav-rail__item-indicator {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}
.m3-nav-rail__item.is-active,
.m3-nav-rail__item[aria-current="page"] {
    color: var(--md-sys-color-on-surface);
}

/* ==========================================================================
   NAVIGATION BAR (mobile bottom bar)
   ========================================================================== */
.m3-nav-bar {
    display: none;
    height: var(--md-comp-bottom-bar-height);
    background-color: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: var(--md-sys-z-index-app-bar);
    align-items: stretch;
    justify-content: space-around;
    padding: 12px 8px;
}
.m3-nav-bar__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.5px;
}
.m3-nav-bar__indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 32px;
    border-radius: var(--md-sys-shape-corner-large);
    transition: background-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.m3-nav-bar__item.is-active .m3-nav-bar__indicator {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

/* ==========================================================================
   LISTS
   ========================================================================== */
.m3-list {
    list-style: none;
    margin: 0;
    padding: 8px 0;
    background-color: transparent;
}
.m3-list__item {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 56px;
    padding: 8px 16px;
    color: var(--md-sys-color-on-surface);
    font-size: 16px;
    line-height: 24px;
    letter-spacing: 0.5px;
    text-decoration: none;
    cursor: pointer;
    position: relative;
    isolation: isolate;
    overflow: hidden;
    transition: background-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.m3-list__item::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: var(--md-sys-color-on-surface);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
    z-index: 0;
}
.m3-list__item:hover::before  { opacity: var(--md-sys-state-hover-state-layer-opacity); }
.m3-list__item:active::before { opacity: var(--md-sys-state-pressed-state-layer-opacity); }
.m3-list__item > *:not(.m3-ripple__circle) { position: relative; z-index: 1; }
.m3-list__item--two-line  { min-height: 72px; }
.m3-list__item--three-line { min-height: 88px; }
.m3-list__leading {
    color: var(--md-sys-color-on-surface-variant);
    width: 24px;
    text-align: center;
}
.m3-list__leading--avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
}
.m3-list__content { flex: 1; min-width: 0; }
.m3-list__headline { font-weight: 400; }
.m3-list__supporting {
    font-size: 14px;
    line-height: 20px;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.m3-list__trailing {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 14px;
}

.m3-list__divider {
    height: 1px;
    background-color: var(--md-sys-color-outline-variant);
    border: 0;
    margin: 8px 0;
}

/* ==========================================================================
   SWITCH
   ========================================================================== */
.m3-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 32px;
}
.m3-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.m3-switch__track {
    position: absolute;
    inset: 0;
    border-radius: var(--md-sys-shape-corner-full);
    background-color: var(--md-sys-color-surface-container-highest);
    border: 2px solid var(--md-sys-color-outline);
    transition:
        background-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-emphasized),
        border-color     var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-emphasized);
}
.m3-switch__thumb {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--md-sys-color-outline);
    transition:
        all var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-emphasized);
}
.m3-switch input:checked ~ .m3-switch__track {
    background-color: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}
.m3-switch input:checked ~ .m3-switch__thumb {
    left: 28px;
    width: 24px;
    height: 24px;
    background-color: var(--md-sys-color-on-primary);
}
.m3-switch input:disabled ~ .m3-switch__track { opacity: 0.38; }

/* ==========================================================================
   CHECKBOX
   ========================================================================== */
.m3-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}
.m3-checkbox input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.m3-checkbox__box {
    width: 18px;
    height: 18px;
    border: 2px solid var(--md-sys-color-on-surface-variant);
    border-radius: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
    color: transparent;
}
.m3-checkbox input:checked ~ .m3-checkbox__box {
    background-color: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}
.m3-checkbox__box::before {
    content: "✓";
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}

/* ==========================================================================
   RADIO
   ========================================================================== */
.m3-radio {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}
.m3-radio input { position: absolute; opacity: 0; width: 0; height: 0; }
.m3-radio__circle {
    width: 20px;
    height: 20px;
    border: 2px solid var(--md-sys-color-on-surface-variant);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.m3-radio__circle::after {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--md-sys-color-primary);
    transform: scale(0);
    transition: transform var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.m3-radio input:checked ~ .m3-radio__circle { border-color: var(--md-sys-color-primary); }
.m3-radio input:checked ~ .m3-radio__circle::after { transform: scale(1); }

/* ==========================================================================
   SLIDER
   ========================================================================== */
.m3-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 16px;
    background: transparent;
    cursor: pointer;
}
.m3-slider::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
    background: var(--md-sys-color-surface-container-highest);
}
.m3-slider::-moz-range-track {
    height: 4px;
    border-radius: 2px;
    background: var(--md-sys-color-surface-container-highest);
}
.m3-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    margin-top: -8px;
    background-color: var(--md-sys-color-primary);
    border-radius: 50%;
    border: 0;
    box-shadow: var(--md-sys-elevation-1);
    transition: box-shadow var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.m3-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background-color: var(--md-sys-color-primary);
    border-radius: 50%;
    border: 0;
    box-shadow: var(--md-sys-elevation-1);
}
.m3-slider:active::-webkit-slider-thumb { box-shadow: var(--md-sys-elevation-3); }

/* ==========================================================================
   PROGRESS INDICATORS
   ========================================================================== */
.m3-progress-linear {
    width: 100%;
    height: 4px;
    overflow: hidden;
    background-color: var(--md-sys-color-surface-container-highest);
    border-radius: 2px;
    position: relative;
}
.m3-progress-linear__bar {
    position: absolute;
    top: 0;
    bottom: 0;
    background-color: var(--md-sys-color-primary);
    border-radius: 2px;
}
.m3-progress-linear--indeterminate .m3-progress-linear__bar {
    animation: m3-progress-linear-indeterminate-1 2.0s
        var(--md-sys-motion-easing-standard) infinite;
}

.m3-progress-circular {
    display: inline-block;
    width: 48px;
    height: 48px;
    animation: m3-progress-circular-rotate 1.4s linear infinite;
}
.m3-progress-circular svg { display: block; width: 100%; height: 100%; }
.m3-progress-circular circle {
    stroke: var(--md-sys-color-primary);
    stroke-linecap: round;
    fill: none;
    stroke-width: 4;
    animation: m3-progress-circular-dash 1.4s ease-in-out infinite;
}

/* ==========================================================================
   DIALOG
   ========================================================================== */
.m3-dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    overflow: visible;
    z-index: var(--md-sys-z-index-modal);
    max-width: 560px;
    max-height: 90vh;
    width: calc(100% - 48px);
}
.m3-dialog::backdrop {
    background-color: var(--md-sys-color-scrim);
    opacity: 0.32;
}
.m3-dialog__surface {
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    border-radius: var(--md-sys-shape-corner-extra-large);
    box-shadow: var(--md-sys-elevation-3);
    padding: 24px;
    overflow: hidden;
    animation: m3-scale-in var(--md-sys-motion-duration-medium2)
        var(--md-sys-motion-easing-emphasized-decelerate) both;
}
.m3-dialog__icon {
    text-align: center;
    color: var(--md-sys-color-secondary);
    font-size: 24px;
    margin-bottom: 16px;
}
.m3-dialog__title {
    font-family: var(--md-sys-typescale-font-brand);
    font-size: 24px;
    line-height: 32px;
    font-weight: 400;
    margin: 0 0 16px;
    color: var(--md-sys-color-on-surface);
}
.m3-dialog__content {
    font-size: 14px;
    line-height: 20px;
    color: var(--md-sys-color-on-surface-variant);
    overflow-y: auto;
    max-height: 60vh;
}
.m3-dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 24px;
    flex-wrap: wrap;
}

/* ==========================================================================
   SNACKBAR
   ========================================================================== */
.m3-snackbar {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    min-width: 288px;
    max-width: 568px;
    padding: 14px 16px;
    background-color: var(--md-sys-color-inverse-surface);
    color: var(--md-sys-color-inverse-on-surface);
    border-radius: var(--md-sys-shape-corner-extra-small);
    box-shadow: var(--md-sys-elevation-3);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: var(--md-sys-z-index-snackbar);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized),
                transform var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized);
}
.m3-snackbar.is-open { opacity: 1; pointer-events: auto; }
.m3-snackbar__message { flex: 1; font-size: 14px; }
.m3-snackbar__action {
    color: var(--md-sys-color-inverse-primary);
    font-weight: 500;
    font-size: 14px;
    text-transform: none;
    background: transparent;
    padding: 6px 12px;
    border-radius: var(--md-sys-shape-corner-extra-small);
    cursor: pointer;
}
.m3-snackbar__action:hover { background-color: rgba(255,255,255,0.08); }

/* ==========================================================================
   TOOLTIPS
   ========================================================================== */
.m3-tooltip {
    position: relative;
    display: inline-block;
}
.m3-tooltip__content {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    background-color: var(--md-sys-color-inverse-surface);
    color: var(--md-sys-color-inverse-on-surface);
    padding: 4px 8px;
    border-radius: var(--md-sys-shape-corner-extra-small);
    font-size: 12px;
    line-height: 16px;
    letter-spacing: 0.4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
    z-index: var(--md-sys-z-index-tooltip);
    margin-bottom: 4px;
}
.m3-tooltip:hover .m3-tooltip__content,
.m3-tooltip:focus-visible .m3-tooltip__content { opacity: 1; }

/* ==========================================================================
   TABS
   ========================================================================== */
.m3-tabs {
    display: flex;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    overflow-x: auto;
    scrollbar-width: none;
}
.m3-tabs::-webkit-scrollbar { display: none; }
.m3-tab {
    display: inline-flex;
    flex: 1 1 auto;
    min-width: 90px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
    padding: 0 16px;
    border: 0;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    cursor: pointer;
    position: relative;
    isolation: isolate;
    overflow: hidden;
    text-decoration: none;
    transition: color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.m3-tab::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: var(--md-sys-color-on-surface);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
    z-index: 0;
}
.m3-tab:hover::before  { opacity: var(--md-sys-state-hover-state-layer-opacity); }
.m3-tab:active::before { opacity: var(--md-sys-state-pressed-state-layer-opacity); }
.m3-tab > *:not(.m3-ripple__circle) { position: relative; z-index: 1; }
.m3-tab[aria-selected="true"],
.m3-tab.is-active {
    color: var(--md-sys-color-primary);
}
.m3-tab[aria-selected="true"]::after,
.m3-tab.is-active::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--md-sys-color-primary);
    border-radius: 3px 3px 0 0;
    z-index: 2;
}

/* ==========================================================================
   MENUS
   ========================================================================== */
.m3-menu {
    background-color: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    border-radius: var(--md-sys-shape-corner-extra-small);
    box-shadow: var(--md-sys-elevation-2);
    min-width: 112px;
    max-width: 280px;
    padding: 8px 0;
    position: absolute;
    z-index: var(--md-sys-z-index-modal);
    animation: m3-scale-in var(--md-sys-motion-duration-short4)
        var(--md-sys-motion-easing-emphasized-decelerate);
    transform-origin: top right;
}
.m3-menu__item {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 48px;
    padding: 0 12px;
    font-size: 14px;
    line-height: 20px;
    letter-spacing: 0.1px;
    color: var(--md-sys-color-on-surface);
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.m3-menu__item:hover { background-color: var(--md-sys-color-surface-container-high); }
.m3-menu__item .m3-icon {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 24px;
}
.m3-menu__divider {
    height: 1px;
    background-color: var(--md-sys-color-outline-variant);
    margin: 8px 0;
    border: 0;
}

/* ==========================================================================
   BADGE
   ========================================================================== */
.m3-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: var(--md-sys-shape-corner-full);
    background-color: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.5px;
}
.m3-badge--small { width: 6px; height: 6px; min-width: 6px; padding: 0; }

/* ==========================================================================
   DIVIDER
   ========================================================================== */
.m3-divider {
    height: 1px;
    background-color: var(--md-sys-color-outline-variant);
    border: 0;
    margin: 1rem 0;
}
.m3-divider--inset { margin-left: 16px; }
.m3-divider--vertical { width: 1px; height: auto; align-self: stretch; }

/* ==========================================================================
   COMMENTS (WordPress-specific)
   ========================================================================== */
.comments-area {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}
.comments-title {
    font-family: var(--md-sys-typescale-font-brand);
    font-size: 24px;
    line-height: 32px;
    margin: 0 0 1.5rem;
}
.comment-list {
    list-style: none;
    margin: 0 0 2rem;
    padding: 0;
}
.comment-list .comment,
.comment-list .pingback {
    margin: 0 0 1rem;
    padding: 1.25rem;
    border-radius: var(--md-sys-shape-corner-medium);
    background-color: var(--md-sys-color-surface-container-low);
}
.comment-list .children {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0 0 0 1.5rem;
    border-left: 2px solid var(--md-sys-color-outline-variant);
}
.comment-author {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0.75rem;
}
.comment-author .avatar {
    border-radius: 50%;
    width: 40px; height: 40px;
}
.comment-author .fn {
    font-weight: 500;
    font-style: normal;
}
.comment-meta {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 0.75rem;
}
.comment-content { margin: 0.5rem 0; }
.reply { margin-top: 0.75rem; }
.reply a {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 16px;
    border-radius: var(--md-sys-shape-corner-full);
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.comment-form {
    display: grid;
    gap: 1rem;
    background-color: var(--md-sys-color-surface-container-low);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 1.5rem;
}
.comment-form label {
    display: block;
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 0.25rem;
}
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
    width: 100%;
    padding: 16px;
    background-color: var(--md-sys-color-surface-container-highest);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-extra-small);
    font-family: inherit;
    font-size: 16px;
    line-height: 24px;
    color: var(--md-sys-color-on-surface);
    transition: border-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.comment-form input:focus,
.comment-form textarea:focus {
    outline: 0;
    border-color: var(--md-sys-color-primary);
    border-width: 2px;
}
.comment-form .form-submit input[type="submit"] {
    display: inline-flex;
    align-items: center;
    height: 40px;
    padding: 0 24px;
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: 0;
    border-radius: var(--md-sys-shape-corner-full);
    font-weight: 500;
    cursor: pointer;
    transition: box-shadow var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.comment-form .form-submit input[type="submit"]:hover { box-shadow: var(--md-sys-elevation-1); }

/* ==========================================================================
   PAGINATION
   ========================================================================== */
.m3-pagination,
.navigation.pagination,
.posts-navigation,
.post-navigation {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 2rem 0;
}
.m3-pagination .page-numbers,
.navigation.pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: var(--md-sys-shape-corner-full);
    color: var(--md-sys-color-on-surface);
    font-weight: 500;
    text-decoration: none;
    background-color: transparent;
    transition: background-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.m3-pagination .page-numbers:hover,
.navigation.pagination .page-numbers:hover {
    background-color: var(--md-sys-color-surface-container);
}
.m3-pagination .page-numbers.current,
.navigation.pagination .page-numbers.current {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.posts-navigation,
.post-navigation {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.posts-navigation .nav-previous,
.post-navigation .nav-previous { text-align: left; }
.posts-navigation .nav-next,
.post-navigation .nav-next { text-align: right; }
.posts-navigation a,
.post-navigation a {
    display: block;
    padding: 1rem;
    border-radius: var(--md-sys-shape-corner-medium);
    background-color: var(--md-sys-color-surface-container-low);
    color: var(--md-sys-color-on-surface);
    text-decoration: none;
}

/* ==========================================================================
   SEARCH PANEL (toggled from top app bar)
   ========================================================================== */
.m3-search-panel {
    position: sticky;
    top: var(--md-comp-top-app-bar-height);
    z-index: calc(var(--md-sys-z-index-app-bar) - 1);
    background-color: var(--md-sys-color-surface-container);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition:
        max-height var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized),
        opacity    var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized);
}
.m3-search-panel.is-open {
    max-height: 200px;
    opacity: 1;
}

/* ==========================================================================
   BACK-TO-TOP FAB (optional, fixed lower-right)
   ========================================================================== */
.m3-back-to-top {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: var(--md-sys-z-index-fab);
    opacity: 0;
    pointer-events: none;
    transform: translateY(16px);
    transition:
        opacity   var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-emphasized),
        transform var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-emphasized);
}
.m3-back-to-top.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* ==========================================================================
   WP BLOCK LAYOUT TWEAKS
   ========================================================================== */
.wp-block-quote { /* uses blockquote styling */ }
.wp-block-pullquote {
    background-color: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
    padding: 2rem;
    border-radius: var(--md-sys-shape-corner-large);
    text-align: center;
    margin: 2rem 0;
}
.wp-block-pullquote cite {
    display: block;
    margin-top: 1rem;
    font-size: 14px;
    font-style: normal;
}
.wp-block-image figcaption,
.wp-block-gallery figcaption,
.wp-element-caption {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    text-align: center;
    margin-top: 0.5rem;
}
.wp-block-button__link {
    display: inline-flex;
    align-items: center;
    height: 40px;
    padding: 0 24px;
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border-radius: var(--md-sys-shape-corner-full);
    font-weight: 500;
    text-decoration: none;
}
.is-style-outline > .wp-block-button__link {
    background-color: transparent;
    color: var(--md-sys-color-primary);
    border: 1px solid var(--md-sys-color-outline);
}
.wp-block-separator { border-color: var(--md-sys-color-outline-variant); }

.wp-block-table table {
    border-collapse: collapse;
}
.wp-block-code {
    background-color: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    padding: 1rem;
    border-radius: var(--md-sys-shape-corner-medium);
}

.wp-block-cover {
    border-radius: var(--md-sys-shape-corner-large);
    overflow: hidden;
}

/* ==========================================================================
   WIDGETS
   ========================================================================== */
.widget {
    padding: 1.25rem;
    margin-bottom: 1rem;
    border-radius: var(--md-sys-shape-corner-large);
}
.widget-title {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-family: var(--md-sys-typescale-font-brand);
    color: var(--md-sys-color-on-surface);
}
.widget ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.widget ul li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.widget ul li:last-child { border-bottom: 0; }
.widget a {
    color: var(--md-sys-color-on-surface);
    text-decoration: none;
}
.widget a:hover {
    color: var(--md-sys-color-primary);
    text-decoration: underline;
}
