/* ==========================================================================
   GOOGLE MATERIAL YOU (MATERIAL 3) DESIGN SYSTEM
   Mobile-First Homework Hub
   ========================================================================== */

/* 1. TOKENS & COLOR SYSTEM */
:root {
    /* Google Fonts */
    --font-brand: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    --font-body: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Base Dimensions & Shapes */
    --radius-xs: 4px;
    --radius-s: 8px;
    --radius-m: 12px;
    --radius-l: 18px;
    --radius-xl: 24px;
    --radius-sheet: 28px;
    --radius-full: 9999px;

    /* Elevation Shadows */
    --elevation-1: 0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30);
    --elevation-2: 0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30);
    --elevation-3: 0px 4px 8px 3px rgba(0, 0, 0, 0.15), 0px 1px 3px 0px rgba(0, 0, 0, 0.30);
    --elevation-fab: 0px 6px 14px 4px rgba(0, 0, 0, 0.25);

    /* Google Material 3 Motion Curves & Timings */
    --m3-easing-emphasized: cubic-bezier(0.2, 0.0, 0.0, 1.0);
    --m3-easing-emphasized-decelerate: cubic-bezier(0.05, 0.7, 0.1, 1.0);
    --m3-easing-emphasized-accelerate: cubic-bezier(0.3, 0.0, 0.8, 0.15);
    --m3-easing-standard: cubic-bezier(0.2, 0.0, 0.0, 1.0);
    --m3-easing-spring: cubic-bezier(0.175, 0.885, 0.32, 1.15);

    --motion-fast: 160ms var(--m3-easing-standard);
    --motion-normal: 280ms var(--m3-easing-emphasized);
    --motion-sheet: 400ms var(--m3-easing-emphasized-decelerate);
    --motion-spring: 350ms var(--m3-easing-spring);
}

/* 2. DARK THEME (M3 AMOLED / Charcoal) */
[data-theme="dark"] {
    color-scheme: dark;
    --md-sys-color-primary: #a8c7fa;
    --md-sys-color-on-primary: #062e6f;
    --md-sys-color-primary-container: #0842a0;
    --md-sys-color-on-primary-container: #d3e3fd;

    --md-sys-color-surface: #111318;
    --md-sys-color-surface-dim: #111318;
    --md-sys-color-surface-container-lowest: #0c0e12;
    --md-sys-color-surface-container-low: #191c20;
    --md-sys-color-surface-container: #1d2024;
    --md-sys-color-surface-container-high: #272a2f;
    --md-sys-color-surface-container-highest: #32353a;

    --md-sys-color-on-surface: #e2e2e9;
    --md-sys-color-on-surface-variant: #c4c6d0;
    --md-sys-color-outline: #8e9099;
    --md-sys-color-outline-variant: #44474f;

    --md-sys-color-error: #ffb4ab;
    --md-sys-color-error-container: #93000a;
    --md-sys-color-on-error: #690005;
    --md-sys-color-on-error-container: #ffdad6;

    --md-sys-color-tertiary-container: #334460;
    --md-sys-color-on-tertiary-container: #d4e3ff;

    --sheet-backdrop: rgba(0, 0, 0, 0.65);

    /* M3 Scrollbar Tokens */
    --scrollbar-thumb: rgba(226, 226, 233, 0.28);
    --scrollbar-thumb-hover: rgba(168, 199, 250, 0.6);
    --scrollbar-thumb-active: #a8c7fa;
}

/* 3. LIGHT THEME (M3 Google Day Light) */
[data-theme="light"] {
    color-scheme: light;
    --md-sys-color-primary: #0b57d0;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #d3e3fd;
    --md-sys-color-on-primary-container: #041e49;

    --md-sys-color-surface: #fdfcff;
    --md-sys-color-surface-dim: #ded8e1;
    --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-on-surface: #1a1c1e;
    --md-sys-color-on-surface-variant: #44474f;
    --md-sys-color-outline: #74777f;
    --md-sys-color-outline-variant: #c4c6d0;

    --md-sys-color-error: #ba1a1a;
    --md-sys-color-error-container: #ffdad6;
    --md-sys-color-on-error: #ffffff;
    --md-sys-color-on-error-container: #410002;

    --md-sys-color-tertiary-container: #d4e3ff;
    --md-sys-color-on-tertiary-container: #001c3b;

    --sheet-backdrop: rgba(0, 0, 0, 0.4);

    /* M3 Scrollbar Tokens */
    --scrollbar-thumb: rgba(26, 28, 30, 0.28);
    --scrollbar-thumb-hover: rgba(11, 87, 208, 0.55);
    --scrollbar-thumb-active: #0b57d0;
}

/* 4. RESET & GLOBAL STYLES */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

html {
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

/* Google Material You (M3) Floating Capsule Scrollbars */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border-radius: var(--radius-full);
    border: 3px solid transparent;
    background-clip: padding-box;
    transition: background-color var(--motion-fast), border-width var(--motion-fast);
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--scrollbar-thumb-hover);
    border-width: 2px;
}

::-webkit-scrollbar-thumb:active {
    background-color: var(--scrollbar-thumb-active);
    border-width: 2px;
}

::-webkit-scrollbar-button {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

::-webkit-scrollbar-corner {
    background: transparent;
}

body {
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
    transition: background-color var(--motion-normal), color var(--motion-normal);
}

.app-container {
    width: 100%;
    max-width: 640px; /* Optimal mobile-centric width, centered on tablet/desktop */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

/* 5. TOP APP BAR */
.top-app-bar {
    position: sticky;
    top: 0;
    z-index: 40;
    background-color: var(--md-sys-color-surface);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    backdrop-filter: blur(12px);
    transition: background-color var(--motion-normal), border-color var(--motion-normal);
    padding-top: env(safe-area-inset-top);
}

.app-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    font-size: 28px;
    color: var(--md-sys-color-primary);
}

.brand-title {
    font-family: var(--font-brand);
    font-size: 22px;
    font-weight: 500;
    letter-spacing: -0.02em;
    color: var(--md-sys-color-on-surface);
}

.app-bar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-full);
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color var(--motion-fast), color var(--motion-fast);
}

.icon-btn:hover {
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
}

.icon-btn:active {
    background-color: var(--md-sys-color-surface-container-highest);
}

.icon-btn.active-lock {
    color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-primary-container);
}

/* 6. CHIPS CAROUSEL (M3 Filter Chips) */
.chips-scroll-container {
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 6px 16px 8px 16px;
}

.chips-scroll-container::-webkit-scrollbar {
    display: none;
}

.chips-carousel {
    display: flex;
    gap: 8px;
    width: max-content;
}

.filter-chip {
    height: 36px;
    padding: 0 16px;
    border-radius: var(--radius-s);
    border: 1px solid var(--md-sys-color-outline-variant);
    background-color: transparent;
    color: var(--md-sys-color-on-surface-variant);
    font-family: var(--font-brand);
    font-size: 13.5px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--motion-fast);
}

.filter-chip .chip-check {
    font-size: 18px;
    display: none;
}

.filter-chip:hover {
    background-color: var(--md-sys-color-surface-container-high);
}

.filter-chip.active {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-color: transparent;
}

.filter-chip.active .chip-check {
    display: inline-block;
}

/* 7. SEGMENTED CONTROL */
.segmented-control-container {
    padding: 0 16px 12px 16px;
}

.segmented-control {
    display: flex;
    background-color: var(--md-sys-color-surface-container-low);
    border-radius: var(--radius-full);
    border: 1px solid var(--md-sys-color-outline-variant);
    padding: 3px;
    gap: 2px;
}

.segment-btn {
    flex: 1;
    height: 34px;
    border-radius: var(--radius-full);
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    font-family: var(--font-brand);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--motion-fast);
}

.segment-btn.active {
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
    font-weight: 700;
    box-shadow: var(--elevation-1);
}

/* 8. MAIN FEED & CARDS */
.feed-main {
    flex: 1;
    padding: 16px;
}

.author-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    padding: 10px 16px;
    border-radius: var(--radius-m);
    margin-bottom: 16px;
    font-size: 13.5px;
    font-family: var(--font-brand);
}

.author-banner-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.text-btn {
    background: none;
    border: none;
    color: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
    font-size: 13px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface-variant);
    font-size: 12px;
    margin-bottom: 12px;
}

.status-icon {
    font-size: 16px;
    color: var(--md-sys-color-primary);
}

.feed-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Card Styling (M3 Filled Card) */
.homework-card {
    background-color: var(--md-sys-color-surface-container);
    border-radius: var(--radius-xl);
    padding: 16px;
    border: 1px solid var(--md-sys-color-outline-variant);
    transition: transform var(--motion-fast), box-shadow var(--motion-fast), border-color var(--motion-fast);
    animation: m3CardEnter 360ms var(--m3-easing-emphasized-decelerate) both;
}

@keyframes m3CardEnter {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.homework-card:nth-child(1) { animation-delay: 30ms; }
.homework-card:nth-child(2) { animation-delay: 70ms; }
.homework-card:nth-child(3) { animation-delay: 110ms; }
.homework-card:nth-child(4) { animation-delay: 150ms; }
.homework-card:nth-child(5) { animation-delay: 190ms; }
.homework-card:nth-child(6) { animation-delay: 230ms; }

.homework-card:hover {
    box-shadow: var(--elevation-1);
    border-color: var(--md-sys-color-outline);
}

.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 8px;
}

.subject-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-family: var(--font-brand);
    font-size: 13px;
    font-weight: 700;
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-primary);
}

.due-date-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12.5px;
    color: var(--md-sys-color-on-surface-variant);
    font-family: var(--font-brand);
}

.due-date-badge .material-symbols-outlined {
    font-size: 16px;
}

.due-date-badge.urgent {
    color: var(--md-sys-color-error);
    font-weight: 700;
}

.card-task-text {
    font-size: 15px;
    line-height: 1.55;
    color: var(--md-sys-color-on-surface);
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 12px;
}

/* Material Assist Link Chip */
.card-link-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--radius-s);
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-primary);
    text-decoration: none;
    font-family: var(--font-brand);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 12px;
    transition: background-color var(--motion-fast);
    max-width: 100%;
}

.card-link-chip:hover {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.card-link-chip .material-symbols-outlined {
    font-size: 17px;
}

.card-link-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Card Bottom Actions */
.card-bottom-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 10px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}

.action-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    font-family: var(--font-brand);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--motion-fast);
}

.action-pill-btn:hover {
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
}

.action-pill-btn.report-btn:hover {
    color: var(--md-sys-color-error);
}

.card-author-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.delete-card-btn {
    color: var(--md-sys-color-error);
    width: 36px;
    height: 36px;
}

.delete-card-btn:hover {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

/* 9. COMMENTS ACCORDION */
.comments-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--md-sys-color-outline-variant);
    display: none;
}

.comments-section.open {
    display: block;
    animation: fadeIn var(--motion-fast);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.comment-bubble {
    background-color: var(--md-sys-color-surface-container-high);
    border-radius: var(--radius-m);
    padding: 10px 12px;
    position: relative;
}

.comment-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.comment-author-badge {
    display: flex;
    align-items: center;
    gap: 6px;
}

.comment-avatar {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-full);
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    font-family: var(--font-brand);
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.comment-author-name {
    font-family: var(--font-brand);
    font-size: 12.5px;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
}

.comment-time {
    font-size: 11px;
    color: var(--md-sys-color-outline);
}

.comment-text {
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--md-sys-color-on-surface);
    word-break: break-word;
}

.comment-report-btn {
    background: none;
    border: none;
    color: var(--md-sys-color-outline);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
}

.comment-report-btn:hover {
    color: var(--md-sys-color-error);
}

/* Comment Input Bar */
.comment-input-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-color: var(--md-sys-color-surface-container-lowest);
    border-radius: var(--radius-l);
    padding: 8px 12px;
    border: 1px solid var(--md-sys-color-outline-variant);
}

.comment-name-input {
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface);
    font-family: var(--font-brand);
    font-size: 12px;
    font-weight: 500;
    outline: none;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    padding-bottom: 4px;
}

.comment-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.comment-msg-input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface);
    font-size: 13.5px;
    outline: none;
}

.comment-send-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    border: none;
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform var(--motion-fast);
}

.comment-send-btn:active {
    transform: scale(0.92);
}

/* 10. EMPTY STATE */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
}

.empty-icon-circle {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.empty-icon-circle .material-symbols-outlined {
    font-size: 40px;
}

.empty-title {
    font-family: var(--font-brand);
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 6px;
}

.empty-subtitle {
    font-size: 14px;
    color: var(--md-sys-color-on-surface-variant);
    max-width: 320px;
}

/* 11. SKELETON LOADERS */
.card-skeleton {
    background-color: var(--md-sys-color-surface-container);
    border-radius: var(--radius-xl);
    padding: 16px;
    border: 1px solid var(--md-sys-color-outline-variant);
    animation: pulse 1.5s infinite ease-in-out;
}

.sk-header {
    width: 40%;
    height: 24px;
    border-radius: var(--radius-full);
    background-color: var(--md-sys-color-surface-container-highest);
    margin-bottom: 14px;
}

.sk-body {
    width: 90%;
    height: 48px;
    border-radius: var(--radius-s);
    background-color: var(--md-sys-color-surface-container-highest);
    margin-bottom: 14px;
}

.sk-footer {
    width: 30%;
    height: 20px;
    border-radius: var(--radius-full);
    background-color: var(--md-sys-color-surface-container-highest);
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1.0; }
    100% { opacity: 0.6; }
}

/* 12. FLOATING ACTION BUTTON (M3 Extended FAB) */
.fab {
    position: fixed;
    bottom: calc(24px + env(safe-area-inset-bottom));
    right: 20px;
    z-index: 50;
    height: 56px;
    padding: 0 20px;
    border-radius: var(--radius-xl);
    border: none;
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    box-shadow: var(--elevation-fab);
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-family: var(--font-brand);
    font-size: 14px;
    font-weight: 700;
    transition: all var(--motion-fast);
}

.fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
}

.fab:active {
    transform: scale(0.96);
}

.fab-icon {
    font-size: 24px;
}

/* 13. BOTTOM SHEET MODAL */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background-color: var(--sheet-backdrop);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--motion-normal), visibility var(--motion-normal);
}

.modal-backdrop.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.bottom-sheet {
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    background-color: var(--md-sys-color-surface);
    border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
    padding: 12px 20px calc(24px + env(safe-area-inset-bottom)) 20px;
    box-shadow: var(--elevation-3);
    border-top: 1px solid var(--md-sys-color-outline-variant);
    transform: translateY(100%);
    transition: transform var(--motion-sheet);
    will-change: transform;
}

.modal-backdrop.open .bottom-sheet {
    transform: translateY(0);
}

.sheet-drag-handle {
    width: 36px;
    height: 4px;
    border-radius: var(--radius-full);
    background-color: var(--md-sys-color-outline-variant);
    margin: 0 auto 14px auto;
}

.sheet-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.sheet-heading {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sheet-icon {
    font-size: 26px;
    color: var(--md-sys-color-primary);
}

.sheet-icon.report-color {
    color: var(--md-sys-color-error);
}

.sheet-title {
    font-family: var(--font-brand);
    font-size: 20px;
    font-weight: 500;
}

.sheet-subtitle {
    font-size: 13.5px;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 16px;
}

/* M3 Form Fields */
.sheet-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-family: var(--font-brand);
    font-size: 13px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

.m3-input-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--radius-m);
    padding: 0 14px;
    height: 48px;
    transition: border-color var(--motion-fast);
}

.m3-input-box:focus-within {
    border-color: var(--md-sys-color-primary);
    border-width: 2px;
}

.input-leading-icon {
    font-size: 20px;
    color: var(--md-sys-color-outline);
}

.m3-input-box input,
.m3-input-box select {
    flex: 1;
    height: 100%;
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface);
    font-size: 14.5px;
    outline: none;
}

.m3-input-box select {
    cursor: pointer;
    font-family: inherit;
}

/* Explicit high-contrast styling for dropdown options in all browsers */
select option {
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    padding: 10px 14px;
    font-size: 14.5px;
}

[data-theme="dark"] select option {
    background-color: #272a2f !important;
    color: #ffffff !important;
}

[data-theme="light"] select option {
    background-color: #ffffff !important;
    color: #1a1c1e !important;
}

select option[disabled] {
    color: var(--md-sys-color-outline) !important;
}

select option:checked {
    background-color: var(--md-sys-color-primary) !important;
    color: var(--md-sys-color-on-primary) !important;
}

[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator {
    filter: none;
    cursor: pointer;
}

.m3-input-box.textarea-box {
    height: auto;
    padding: 12px 14px;
    align-items: flex-start;
}

.m3-input-box textarea {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface);
    font-size: 14.5px;
    font-family: inherit;
    line-height: 1.5;
    outline: none;
    resize: vertical;
}

/* Radio Group in Report Modal */
.m3-radio-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.m3-radio-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-m);
    background-color: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    cursor: pointer;
    transition: background-color var(--motion-fast), border-color var(--motion-fast);
}

.m3-radio-item:has(input:checked) {
    background-color: var(--md-sys-color-primary-container);
    border-color: var(--md-sys-color-primary);
}

.m3-radio-item input {
    accent-color: var(--md-sys-color-primary);
    width: 18px;
    height: 18px;
}

.radio-texts {
    display: flex;
    flex-direction: column;
}

.radio-title {
    font-family: var(--font-brand);
    font-size: 14px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

.radio-desc {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
}

.m3-radio-item:has(input:checked) .radio-title {
    color: var(--md-sys-color-on-primary-container);
    font-weight: 700;
}

.m3-radio-item:has(input:checked) .radio-desc {
    color: var(--md-sys-color-on-primary-container);
    opacity: 0.9;
}

/* Sheet Buttons */
.sheet-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.btn {
    height: 44px;
    padding: 0 20px;
    border-radius: var(--radius-full);
    font-family: var(--font-brand);
    font-size: 14px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all var(--motion-fast);
}

.btn-outlined {
    background: transparent;
    border: 1px solid var(--md-sys-color-outline);
    color: var(--md-sys-color-primary);
}

.btn-outlined:hover {
    background-color: var(--md-sys-color-surface-container-high);
}

.btn-filled {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
}

.btn-filled:hover {
    opacity: 0.92;
}

.btn-filled:active {
    transform: scale(0.97);
}

.btn-danger {
    background-color: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
}

/* 14. MATERIAL 3 SNACKBAR */
.m3-snackbar {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: 200;
    background-color: var(--md-sys-color-on-surface);
    color: var(--md-sys-color-surface);
    padding: 12px 22px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--elevation-3);
    font-family: var(--font-brand);
    font-size: 14px;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    transition: all var(--motion-normal);
}

.m3-snackbar.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.m3-snackbar.error {
    background-color: #ba1a1a;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 6px 20px rgba(186, 26, 26, 0.45);
}

.m3-snackbar.error .snackbar-icon {
    color: #ffffff;
    font-weight: 900;
    font-size: 24px;
}

.snackbar-icon {
    font-size: 20px;
    color: var(--md-sys-color-primary);
}

/* 15. BETA BADGE & CLASS BADGES */
.brand-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.beta-badge {
    font-size: 10.5px;
    font-family: var(--font-brand);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    padding: 2px 7px;
    border-radius: var(--radius-full);
    white-space: nowrap;
    border: 1px solid var(--md-sys-color-outline-variant);
}

.class-pill-badge {
    font-size: 11.5px;
    font-family: var(--font-brand);
    font-weight: 700;
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-primary);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    border: 1px solid var(--md-sys-color-outline-variant);
}

.profile-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    border: 1.5px solid var(--md-sys-color-primary);
    background: transparent;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--motion-fast);
}

.profile-btn:active {
    transform: scale(0.92);
}

.profile-avatar {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-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;
    font-family: var(--font-brand);
    font-size: 13.5px;
    font-weight: 700;
}

/* Super Admin Switcher */
.admin-class-switcher {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px 8px 16px;
    background-color: var(--md-sys-color-surface-container-lowest);
    border-bottom: 1px dashed var(--md-sys-color-outline-variant);
    font-size: 12.5px;
    font-family: var(--font-brand);
}

.segmented-control.small {
    width: auto;
}

.segmented-control.small .segment-btn {
    padding: 0 12px;
    height: 28px;
    font-size: 12px;
}

/* Rules Checklist */
.rules-checklist {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
}

.rule-checkbox-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-m);
    background-color: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    cursor: pointer;
    transition: background-color var(--motion-fast), border-color var(--motion-fast);
}

.rule-checkbox-card:has(input:checked) {
    background-color: var(--md-sys-color-surface-container-highest);
    border-color: var(--md-sys-color-primary);
}

.rule-checkbox-card.has-error {
    border-color: var(--md-sys-color-error) !important;
    background-color: rgba(255, 84, 73, 0.12) !important;
    box-shadow: 0 0 0 1px var(--md-sys-color-error);
}

.required-star {
    color: var(--md-sys-color-error);
    font-weight: 700;
    margin-left: 2px;
    font-size: 15px;
}

@keyframes shakeError {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-10px); }
    30% { transform: translateX(10px); }
    45% { transform: translateX(-7px); }
    60% { transform: translateX(7px); }
    75% { transform: translateX(-3px); }
    90% { transform: translateX(3px); }
}

.shake-error {
    animation: shakeError 400ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.m3-checkbox {
    width: 20px;
    height: 20px;
    accent-color: var(--md-sys-color-primary);
    cursor: pointer;
    margin-top: 2px;
    flex-shrink: 0;
}

.rule-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 13.5px;
    line-height: 1.4;
}

.rule-text strong {
    font-family: var(--font-brand);
    color: var(--md-sys-color-on-surface);
    font-size: 13.5px;
}

.rule-text span {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 12px;
}

/* Auth & Profile Sheets */
.auth-tabs {
    margin-bottom: 14px;
}

.full-width {
    width: 100%;
    justify-content: center;
}

.field-hint {
    font-size: 11.5px;
    color: var(--md-sys-color-outline);
    margin-top: 4px;
}

.profile-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background-color: var(--md-sys-color-surface-container-high);
    border-radius: var(--radius-l);
    border: 1px solid var(--md-sys-color-outline-variant);
    margin-bottom: 16px;
}

.profile-avatar-large {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    font-family: var(--font-brand);
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profile-name {
    font-family: var(--font-brand);
    font-size: 18px;
    font-weight: 700;
}

.profile-badges {
    display: flex;
    align-items: center;
    gap: 6px;
}

.profile-class-badge,
.profile-role-badge {
    font-size: 11.5px;
    font-family: var(--font-brand);
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.profile-class-badge {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.profile-role-badge {
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
}

.profile-menu-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-m);
    border: 1px solid var(--md-sys-color-outline-variant);
    background-color: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    font-family: var(--font-brand);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--motion-fast);
}

.profile-menu-item:hover {
    background-color: var(--md-sys-color-surface-container-high);
}

.profile-menu-item.danger-item {
    color: var(--md-sys-color-error);
    border-color: rgba(255, 180, 171, 0.2);
}

/* Super Admin Dashboard */
.current-target-class-pill {
    padding: 8px 14px;
    border-radius: var(--radius-m);
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    font-family: var(--font-brand);
    font-weight: 700;
    font-size: 14px;
    display: inline-flex;
    width: max-content;
}

.admin-tab-content {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.generated-result-card {
    background-color: var(--md-sys-color-surface-container-high);
    border-radius: var(--radius-m);
    padding: 14px;
    margin-top: 14px;
    border: 1.5px solid var(--md-sys-color-primary);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.result-label {
    font-family: var(--font-brand);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

.code-copy-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background-color: var(--md-sys-color-surface);
    border-radius: var(--radius-s);
    padding: 8px 12px;
    border: 1px solid var(--md-sys-color-outline-variant);
}

.code-value {
    font-family: monospace;
    font-size: 17px;
    font-weight: 700;
    color: var(--md-sys-color-primary);
    letter-spacing: 0.06em;
}

.result-hint {
    font-size: 11.5px;
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.4;
}

.codes-list,
.reports-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 50vh;
    overflow-y: auto;
}

.code-item-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--md-sys-color-surface-container-high);
    padding: 10px 14px;
    border-radius: var(--radius-m);
    border: 1px solid var(--md-sys-color-outline-variant);
    font-size: 13px;
}

.code-item-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.code-item-code {
    font-family: monospace;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--md-sys-color-primary);
}

.code-item-info {
    font-size: 11.5px;
    color: var(--md-sys-color-outline);
}

.code-status-pill {
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
}

.code-status-pill.free {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.code-status-pill.used {
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-outline);
}

/* GUEST MODE STYLES & LOCKED COMMENTS */
.guest-mode-section {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 6px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.auth-divider span {
    padding: 0 12px;
    font-size: 11px;
    color: var(--md-sys-color-outline);
    text-transform: uppercase;
    font-family: var(--font-brand);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.guest-hint {
    font-size: 12px;
    color: var(--md-sys-color-outline);
    text-align: center;
    line-height: 1.4;
    margin: 0;
}

.btn-tonal {
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
}

.btn-tonal:hover {
    background-color: var(--md-sys-color-surface-container-high);
}

.banner-action-btn {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    border-radius: var(--radius-full);
    padding: 4px 12px;
    font-family: var(--font-brand);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: transform var(--motion-fast);
}

.banner-action-btn:active {
    transform: scale(0.94);
}

.guest-comment-locked {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background-color: var(--md-sys-color-surface-container-lowest);
    border: 1px dashed var(--md-sys-color-outline-variant);
    border-radius: var(--radius-l);
    padding: 10px 14px;
    margin-top: 4px;
}

.guest-comment-locked .locked-text {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--md-sys-color-on-surface-variant);
}

.guest-comment-locked .locked-btn {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    border-radius: var(--radius-full);
    padding: 5px 12px;
    font-family: var(--font-brand);
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: transform var(--motion-fast);
}

.guest-comment-locked .locked-btn:active {
    transform: scale(0.94);
}

/* Desktop Polish */
@media (min-width: 641px) {
    .app-container {
        border-left: 1px solid var(--md-sys-color-outline-variant);
        border-right: 1px solid var(--md-sys-color-outline-variant);
    }
}

/* 22. PWA INSTALL SHEET */
.pwa-steps-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0 20px 0;
}

.pwa-step-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background-color: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--radius-m);
    padding: 12px 14px;
}

.pwa-step-num {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-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;
    font-family: var(--font-brand);
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.pwa-step-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pwa-step-text strong {
    font-size: 13.5px;
    color: var(--md-sys-color-on-surface);
}

.pwa-step-text span {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.35;
}