/* ============================================================
   Betty CSS - Material Design 3 Inspired
   ============================================================
   
   Table of Contents:
   1. Design Tokens (CSS Variables)
   2. Reset & Base
   3. Layout (Container, Grid, Columns)
   4. Typography
   5. Common Components (Buttons, Cards, Inputs, Modals)
   6. Feature Components (Header, Sidebar, ThreadList, PostList)
   7. Feature: Board Browser & Japan Map
   8. Feature: Help Overlay & Welcome
   9. Utilities
   10. Animations (@keyframes)
   11. Responsive (@media queries)
   
   ============================================================ */

/* ============================================================
   1. Design Tokens (CSS Variables)
   ============================================================ */

* {
    box-sizing: border-box;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
    /* Spacing Scale (8dp grid) */
    --space-xs: 0.25rem;
    /* 4px */
    --space-sm: 0.5rem;
    /* 8px */
    --space-md: 1rem;
    /* 16px */
    --space-lg: 1.5rem;
    /* 24px */
    --space-xl: 2rem;
    /* 32px */
    --space-2xl: 3rem;
    /* 48px */

    /* Font Size Scale */
    --text-xs: 0.75rem;
    /* 12px */
    --text-sm: 0.875rem;
    /* 14px */
    --text-base: 1rem;
    /* 16px */
    --text-lg: 1.25rem;
    /* 20px */
    --text-xl: 1.5rem;
    /* 24px */

    /* Baseline M3 Color System (Neutral/Blue Tonal) */
    --md-sys-color-primary: #3f51b5;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #e8eaf6;
    --md-sys-color-on-primary-container: #1a237e;

    --md-sys-color-secondary: #5c5e71;
    --md-sys-color-on-secondary: #ffffff;
    --md-sys-color-secondary-container: #e1e2f6;

    --md-sys-color-surface: #fdfbff;
    --md-sys-color-on-surface: #1b1b1f;
    --md-sys-color-surface-variant: #e2e2ec;
    --md-sys-color-on-surface-variant: #45464f;
    --md-sys-color-outline: #757780;

    --md-sys-color-error: #ba1a1a;
    --md-sys-color-on-error: #ffffff;

    /* M3 Surface Containers (Opaque) */
    --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;

    /* Shapes */
    --md-sys-shape-corner-extra-small: 4px;
    --md-sys-shape-corner-small: 8px;
    --md-sys-shape-corner-medium: 12px;
    --md-sys-shape-corner-large: 16px;
    --md-sys-shape-corner-extra-large: 28px;
    --md-sys-shape-corner-full: 9999px;

    /* Elevation */
    --md-sys-elevation-1: 0 1px 2px 0 rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-2: 0 1px 2px 0 rgba(0, 0, 0, 0.3), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-3: 0 4px 8px 3px rgba(0, 0, 0, 0.15), 0 1px 3px 0 rgba(0, 0, 0, 0.3);

    --header-height: 48px;

    /* ===== Breakpoints =====
       Mobile:  < 768px
       Tablet:  768px - 1024px
       Desktop: > 1024px
       
       Usage:
       - @media (max-width: 768px)  -- Mobile only
       - @media (max-width: 1024px) -- Mobile + Tablet
       - @media (min-width: 769px)  -- Tablet + Desktop
       - @media (min-width: 1025px) -- Desktop only
    */
}

/* ============================================================
   2. Reset & Base
   ============================================================ */

body {
    margin: 0;
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    letter-spacing: 0.01em;
    width: 100%;
    overflow-x: hidden;
    /* Global robust fix */
}

#root {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow-x: hidden;
    padding-top: var(--header-height);
}

.premium-header {
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-primary);
    padding: var(--space-xs) var(--space-md);
    height: var(--header-height);

    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--md-sys-color-outline);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.premium-header .brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.premium-header h1 {
    margin: 0;
    font-size: 1.375rem;
    /* Title Large */
    font-weight: 700;
    letter-spacing: 0;
}

.premium-header .actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md);
    width: 100%;
    box-sizing: border-box;
    flex: 1;
}

.nav-item {
    padding: 0.75rem var(--space-md);
    margin: var(--space-xs) 0.75rem;
    /* M3 sidebar/drawer item spacing */
    border-radius: var(--md-sys-shape-corner-full);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--md-sys-color-on-surface-variant);
}

.nav-item:hover {
    background: var(--md-sys-color-surface-variant);
}

.nav-item.active {
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.card {
    background: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 1.25rem;
    box-shadow: var(--md-sys-elevation-1);
    border: 1px solid var(--md-sys-color-outline);
    transition: box-shadow 0.2s, transform 0.2s;
}

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

.card h2 {
    margin-top: 0;
    font-size: var(--text-lg);
    /* Title Medium/Large */
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    margin-bottom: var(--space-md);
    letter-spacing: 0;
}

/* List Items */
.list-unstyled {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Inputs & Buttons */
.input-group {
    display: flex;
    gap: 0.75rem;
    margin-bottom: var(--space-md);
}

.search-input-container {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

.modal-content.drawer .input-group {
    flex-direction: column;
    margin-bottom: var(--space-xl);
    padding: 0 var(--space-lg);
}

input[type="text"] {
    padding: 12px var(--space-md);
    border-radius: 9999px;
    /* Pill shape */
    border: 1px solid var(--md-sys-color-outline);
    font-size: var(--text-base);
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    transition: all 0.2s;
    font-family: inherit;
    box-sizing: border-box;
}

/* Add padding for right-aligned clear button */
.search-input-container input[type="text"] {
    padding-right: 2.5rem;
}

.modal-content.drawer input[type="text"] {
    width: 100%;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 2px var(--md-sys-color-primary-container);
}

.btn {
    padding: 0.75rem var(--space-lg);
    border-radius: var(--md-sys-shape-corner-full);
    border: none;
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    font-size: var(--text-sm);
    font-family: inherit;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    white-space: nowrap;
    /* Prevent wrapping which causes circular buttons */
    flex-shrink: 0;
    /* Prevent buttons from being squashed in flex containers */
}

.modal-content.drawer .btn {
    width: 100%;
}

.btn:hover {
    background: var(--md-sys-color-primary);
    box-shadow: var(--md-sys-elevation-1);
}

.btn::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--md-sys-color-on-primary);
    opacity: 0;
    transition: opacity 0.2s;
}

.btn:hover::after {
    opacity: 0.08;
}

.btn:active::after {
    opacity: 0.12;
}

.btn:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    background: var(--md-sys-color-on-surface);
    color: var(--md-sys-color-surface);
}

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

.btn-danger {
    background: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
}

.btn-danger::after {
    background: var(--md-sys-color-on-error);
}

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

.btn-outline:hover {
    background: var(--md-sys-color-primary-container);
}

.icon-button {
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    width: 40px;
    height: 40px;
    border: none;
    cursor: pointer;
    border-radius: var(--md-sys-shape-corner-full);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.input-clear-btn {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 1.1rem;
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    transition: background 0.2s;
}

.input-clear-btn:hover {
    background: var(--md-sys-color-surface-variant);
}

.icon-button:hover {
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-primary);
}

.icon-button.mobile-only:hover {
    background: rgba(255, 255, 255, 0.2);
}

.fav-active,
.icon-button.fav-active {
    color: #eab308;
}

/* Content Area */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: var(--space-xl);
}

.thread-column {
    min-width: 0;
}

.column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.column-header h3 {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: 700;
}

@media (max-width: 1024px) {
    .column-header .text-truncate {
        flex: 1;
        /* Allow taking available space */
        min-width: 0;
        /* Allow shrinking */
    }
}

/* Thread/Post Items */
.thread-item.card {
    margin-bottom: var(--space-sm);
    /* 8dp */
    cursor: pointer;
    padding: var(--space-md);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-medium);
    transition: all 0.2s ease;
    background: var(--md-sys-color-surface);
}

.thread-item:hover {
    background: var(--md-sys-color-surface-variant);
    border-color: var(--md-sys-color-primary);
}

.thread-item.selected {
    background: var(--md-sys-color-primary-container);
    border-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary-container);
}

.post-item {
    margin-bottom: var(--space-md);
    padding: var(--space-md);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-large);
    background: var(--md-sys-color-surface);
    transition: all 0.2s;
}

.post-item:hover {
    box-shadow: var(--md-sys-elevation-1);
    transform: translateY(-1px);
}

.post-header {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: var(--space-sm);
    flex-wrap: wrap;
}

.post-number {
    font-size: 0.9rem;
    color: var(--md-sys-color-primary);
    font-weight: 500;
}

.post-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
}

.post-date {
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
}

.post-content {
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-all;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    /* M3 Scrim */
    backdrop-filter: blur(4px);
    /* Slightly stronger blur for premium feel */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
    /* High enough to over everything */
}

.modal-overlay.drawer {
    justify-content: flex-end;
    background: rgba(0, 0, 0, 0.4);
    /* Pure scrim */
    backdrop-filter: blur(4px);
    z-index: 5000;
}

.modal-overlay .modal-content {
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    background: var(--md-sys-color-surface-container);
    /* Explicit opaque background */
    border-radius: var(--md-sys-shape-corner-extra-large);
    box-shadow: var(--md-sys-elevation-3);
    border: none;
    animation: modalFadeIn 0.3s cubic-bezier(0, 0, 0.2, 1);
}

.modal-content.drawer {
    width: 100%;
    max-width: 360px;
    height: 100%;
    border-radius: 28px 0 0 28px;
    /* M3 Standard Drawer shape */
    margin-left: auto;
    animation: drawerSlideIn 0.3s cubic-bezier(0, 0, 0.2, 1);
    background: var(--md-sys-color-surface-container-low);
    box-shadow: var(--md-sys-elevation-3);
    border: none;
    overflow-y: auto;
    /* Required for long menus */
    max-height: 100vh;
}

/* ============================================================
   10. Animations (@keyframes)
   ============================================================
   - modalFadeIn:    Modal fade/scale in
   - drawerSlideIn:  Drawer slide from right
   - popupScaleIn:   Anchor popup scale in
   - pulse:          Loading pulse
   - highlight-fade: Post highlight fade
   - fadeIn:         Generic fade in
   - spin:           Loading spinner
   ============================================================ */

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes drawerSlideIn {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

.modal-header {
    padding: var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--md-sys-color-surface-container);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 var(--space-lg) var(--space-lg) var(--space-lg);
}

/* Animations */
/* Anchor Popup Overlay - Invisible but blocks interaction and allows closing by clicking outside */
/* Anchor Popup Styles */
.anchor-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2500;
    background: rgba(0, 0, 0, 0.2);
    /* Slightly darker scrim */
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    /* Default center for mobile */
    justify-content: center;
}

.anchor-popup-overlay .anchor-popup {
    /* Base styles (Mobile First / Shared) */
    background: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-extra-large);
    box-shadow: var(--md-sys-elevation-3);
    border: 1px solid var(--md-sys-color-outline-variant);
    padding: 0;
    /* Managed by inner layout */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: popupScaleIn 0.25s cubic-bezier(0.2, 0, 0, 1);

    /* Mobile specific defaults */
    width: 90%;
    max-width: 400px;
    max-height: 70vh;
    position: relative;
    /* Centered by flex container overlay */
}

/* Desktop styles: absolute positioning near click */
@media (min-width: 769px) {
    .anchor-popup-overlay {
        background: transparent;
        /* No scrim on desktop, just click catcher */
        backdrop-filter: none;
        display: block;
        /* Allow absolute positioning inside */
    }

    .anchor-popup {
        position: absolute;
        width: 400px;
        max-width: 90vw;
        max-height: 400px;
        /* Limit height on desktop */

        /* Coordinate magic via CSS variables set in Rust */
        left: var(--popup-left);
        top: var(--popup-top);

        /* Prevent overflow off right screen edge implies simpler logic here, 
           but robust solution needs JS calc. For now, we rely on Rust logic 
           or simple transform shift if needed. */
        transform: translateY(10px);
        /* Just a little offset below click usually */
    }
}

@keyframes popupScaleIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Popup Internals */
.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    /* Increased padding */
    background: var(--md-sys-color-surface-container);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    flex-shrink: 0;
}

.popup-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--md-sys-color-primary);
}

.popup-header .close-btn {
    width: 32px;
    height: 32px;
    color: var(--md-sys-color-on-surface-variant);
}

.popup-header .close-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.popup-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    overscroll-behavior: contain;
}

.popup-meta {
    display: flex;
    gap: var(--space-sm);
    align-items: baseline;
    margin-bottom: var(--space-sm);
    flex-wrap: wrap;
    font-size: 0.85rem;
}

.meta-number {
    color: var(--md-sys-color-primary);
    font-weight: 500;
}

.meta-name {
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
}

.meta-date {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.8rem;
}

.popup-text {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--md-sys-color-on-surface);
}

.popup-loading-placeholder {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-on-surface-variant);
}

.popup-loading-placeholder::after {
    content: "読み込み中...";
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

.post-item.highlight-post {
    animation: highlight-fade 3s ease-in-out forwards;
    border-left: 8px solid var(--md-sys-color-primary);
}

@keyframes highlight-fade {
    0% {
        background-color: #fef08a;
    }

    100% {
        background-color: var(--md-sys-color-surface);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Breadcrumbs */
.breadcrumbs {
    padding: var(--space-sm) 0;
    margin-bottom: var(--space-md);
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.breadcrumb-list {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    align-items: center;
    font-size: var(--text-xs);
}

.breadcrumb-item {
    display: flex;
    align-items: center;
}

.breadcrumb-link {
    color: var(--md-sys-color-primary);
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
}

.breadcrumb-link:hover {
    text-decoration: underline;
}

.breadcrumb-text {
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 400;
}

.breadcrumb-separator {
    margin: 0 var(--space-xs);
    color: var(--md-sys-color-outline);
    font-size: 0.8em;
}

/* Spinner */
.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--md-sys-color-secondary-container);
    border-top: 4px solid var(--md-sys-color-primary);
    border-radius: var(--md-sys-shape-corner-full);
    animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    margin: var(--space-xl) auto;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--md-sys-color-surface-container-high) 25%,
        var(--md-sys-color-surface-container-highest) 50%,
        var(--md-sys-color-surface-container-high) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite linear;
    border-radius: var(--md-sys-shape-corner-small);
}

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

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-title {
    height: 1.25rem;
    width: 80%;
    margin-bottom: 0.75rem;
}

.skeleton-meta {
    height: 0.75rem;
    width: 40%;
}

.skeleton-thread-item {
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-medium);
    background: var(--md-sys-color-surface);
}

.skeleton-post-item {
    margin-bottom: var(--space-md);
    padding: var(--space-md);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-large);
    background: var(--md-sys-color-surface);
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Board Browser Specifics */
.category-title {
    background: transparent;
    padding: var(--space-md) 0 var(--space-sm) 0;
    border: none;
    margin-bottom: var(--space-sm);
    font-weight: 500;
    font-size: var(--text-sm);
    color: var(--md-sys-color-primary);
    letter-spacing: 0.1px;
}

.board-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: var(--space-sm);
}

.board-item-btn {
    padding: 0.75rem var(--space-md);
    border: 1px solid var(--md-sys-color-outline);
    background: var(--md-sys-color-surface);
    cursor: pointer;
    border-radius: var(--md-sys-shape-corner-small);
    font-size: var(--text-sm);
    text-align: center;
    transition: all 0.2s;
    font-family: inherit;
    color: var(--md-sys-color-on-surface);
}

.board-item-btn:hover {
    background: var(--md-sys-color-surface-variant);
    border-color: var(--md-sys-color-primary);
}

/* Japan Map SVG */
.japan-map-container {
    display: flex;
    justify-content: center;
    padding: var(--space-md);
    background: var(--md-sys-color-surface-container-low);
    border-radius: var(--md-sys-shape-corner-large);
    overflow-x: auto;
}

.japan-map-svg {
    width: 100%;
    max-width: 600px;
    height: auto;
    max-height: 60vh;
}


/* Mobile Responsive */
.mobile-only {
    display: none;
}

@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .premium-header {
        padding: var(--space-md);
    }

    .premium-header h1 {
        font-size: 1.4rem;
    }

    .container {
        padding: var(--space-md) var(--space-sm);
    }

    .card {
        padding: var(--space-md);
    }
}

/* Pagination Improvements */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-lg);
    margin-top: var(--space-lg);
    padding: var(--space-sm);
}

.pagination-btn {
    min-width: 100px;
    padding: var(--space-sm) var(--space-md);
    border-radius: 20px;
    /* Fully rounded capsule */
    justify-content: center;
    /* Center text */
    font-weight: 500;
}

.pagination-info {
    font-size: 0.9rem;
    color: var(--md-sys-color-on-surface-variant);
    font-family: inherit;
    font-weight: 500;
}

/* Utility */
.text-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Welcome View */
.welcome-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: var(--space-xl);
    color: var(--md-sys-color-on-surface);
    background: radial-gradient(circle at center, var(--md-sys-color-surface-container-low) 0%, var(--md-sys-color-surface) 100%);
    border-radius: var(--md-sys-shape-corner-medium);
}

.welcome-content {
    max-width: 500px;
    animation: fadeIn 0.6s ease-out;
}

.app-logo-large {
    width: 80px;
    height: 80px;
    margin-bottom: var(--space-xl);
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.welcome-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--space-md);
    color: var(--md-sys-color-primary);
    letter-spacing: -0.02em;
}

.welcome-subtitle {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--md-sys-color-on-surface-variant);
}

.welcome-decoration {
    margin-top: var(--space-2xl);
    height: 4px;
    width: 60px;
    background: var(--md-sys-color-primary);
    margin-left: auto;
    margin-right: auto;
    border-radius: 2px;
}

/* Help Overlay */
.help-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 6000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-card {
    background: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-extra-large);
    width: 90%;
    max-width: 480px;
    padding: var(--space-xl);
    box-shadow: var(--md-sys-elevation-3);
    border: 1px solid var(--md-sys-color-outline);
    animation: modalFadeIn 0.3s cubic-bezier(0, 0, 0.2, 1);
}

.help-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.help-header h3 {
    margin: 0;
    font-size: var(--text-xl);
    color: var(--md-sys-color-primary);
}

/* Load Previous Button */
.load-prev-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin: var(--space-lg) auto var(--space-md) auto;
    padding: 0.75rem var(--space-xl);
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-primary);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-full);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    width: fit-content;
    min-width: 200px;
}

.load-prev-btn:hover {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-color: var(--md-sys-color-primary);
    box-shadow: var(--md-sys-elevation-1);
    transform: translateY(-1px);
}

.load-prev-btn:active {
    transform: translateY(0);
}

.load-prev-btn span {
    font-size: 1.2rem;
}

.help-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.help-step {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
}

.step-icon {
    font-size: 2rem;
    color: var(--md-sys-color-secondary);
    background: var(--md-sys-color-secondary-container);
    padding: var(--space-sm);
    border-radius: 50%;
}

.help-step strong {
    display: block;
    margin-bottom: var(--space-xs);
    font-size: 1.1rem;
    color: var(--md-sys-color-on-surface);
}

.help-step p {
    margin: 0;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.95rem;
}

.help-actions {
    display: flex;
    justify-content: center;
}

.help-actions .btn {
    min-width: 140px;
    font-size: 1.1rem;
    padding: 0.875rem var(--space-xl);
}

/* Floating Action Button (FAB) */
.fab-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
}

.fab-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    /* MD3 Standard FAB shape */
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    box-shadow: var(--md-sys-elevation-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fab-btn:hover {
    box-shadow: 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12), 0 3px 5px -1px rgba(0, 0, 0, 0.2);
    transform: scale(1.05);
}

.fab-btn:active {
    transform: scale(0.95);
    box-shadow: var(--md-sys-elevation-1);
}

/* Material Icons font size for FAB */
.fab-btn .material-symbols-outlined {
    font-size: var(--text-xl);
}

@media (max-width: 768px) {
    .fab-container {
        bottom: 1.5rem;
        right: 1.5rem;
    }
}

/* Sticky Header Styles */
.sticky-header {
    display: contents;
    /* Default for Desktop: allow grid items to place naturally */
}

/* Default Desktop Layout explicit placement */
@media (min-width: 1025px) {
    .thread-column {
        grid-column: 1;
    }

    .post-list-header-container {
        grid-column: 2;
    }

    .post-column-body {
        grid-column: 2;
    }
}

@media (max-width: 1024px) {
    .sticky-header {
        display: block;
        position: sticky;
        top: var(--header-height);
        z-index: 900;
        background: var(--md-sys-color-surface);
        transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);

        width: 100%;
        min-width: 0;
        /* Fix Grid blowout */
    }

    .sticky-header.header-hidden {
        transform: translateY(-120%);
    }

    .post-list-header-container {
        border-bottom: 1px solid var(--md-sys-color-outline-variant);
    }

    .thread-column {
        /* border-bottom: 1px solid var(--md-sys-color-outline-variant); */
        /* padding-bottom: 0.5rem; */
        margin-bottom: 0;
    }

    .thread-column-body,
    .post-column-body {
        min-width: 0;
        width: 100%;
    }
}

/* Update Thread Layout for sticky header compatibility */
@media (min-width: 1025px) {

    /* PC Layout: Standard Grid */
    .thread-column-body {
        grid-column: 1;
    }
}

@media (max-width: 1024px) {
    /* Mobile Layout: Stacked */
    /* Sticky Header Logic handled by previous block */


    .thread-list-container .thread-list-header {
        border-bottom: none;
    }
}

/* --- Refactored Components Styles --- */

/* Board Browser */
.browser-content {
    max-height: 400px;
    overflow-y: auto;
}

.browser-header-actions {
    margin-bottom: var(--space-md);
}

.category-group {
    margin-bottom: var(--space-md);
}

.category-header {
    background: var(--md-sys-color-surface-container-highest);
    padding: var(--space-xs) var(--space-sm);
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.8rem;
    margin-bottom: var(--space-sm);
    color: var(--md-sys-color-on-surface-variant);
}

.board-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.board-nav-item {
    padding: 6px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: var(--md-sys-shape-corner-medium);
    transition: background-color 0.2s;
}

.board-nav-item:hover {
    background-color: var(--md-sys-color-surface-variant);
}

.macro-region-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.macro-region-title {
    margin: 0;
    font-size: 1.1rem;
    color: var(--md-sys-color-primary);
    font-weight: 700;
}

.sub-region-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.sub-region-btn {
    height: 48px;
    font-size: 0.95rem;
    font-weight: bold;
    box-shadow: var(--md-sys-elevation-1);
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-medium);
}

.sub-region-btn:hover {
    box-shadow: var(--md-sys-elevation-2);
}

.map-instruction {
    text-align: center;
    margin-bottom: var(--space-sm);
    font-size: 0.9rem;
    color: var(--md-sys-color-secondary);
}

/* Japan Map */
.map-region {
    fill: var(--md-sys-color-surface);
    stroke: var(--md-sys-color-outline);
    stroke-width: 1.5;
    transition: all 0.2s;
    cursor: pointer;
    filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.1));
}

.map-region:hover,
.map-region.active {
    fill: var(--md-sys-color-primary-container);
    stroke: var(--md-sys-color-primary);
    filter: drop-shadow(3px 3px 4px rgba(0, 0, 0, 0.15));
    transform: translateY(-2px);
}

.map-text {
    font-size: 14px;
    font-weight: bold;
    fill: var(--md-sys-color-on-surface);
    pointer-events: none;
    dominant-baseline: middle;
    text-anchor: middle;
}

.map-text.large {
    font-size: 16px;
}

/* Region Colors */
.region-hokkaido {
    fill: #e3f2fd;
}

.region-tohoku {
    fill: #e8eaf6;
}

.region-kanto {
    fill: #fff8e1;
}

.region-chubu {
    fill: #f3e5f5;
}

.region-kinki {
    fill: #e8f5e9;
}

.region-chugoku {
    fill: #fce4ec;
}

.region-shikoku {
    fill: #fff3e0;
}

.region-kyushu {
    fill: #ffebee;
}

.region-okinawa {
    fill: #e1f5fe;
}

.region-overseas {
    fill: #eceff1;
}


/* Sidebar Refactor */
.sidebar-title {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: 700;
}

.sidebar-body {
    padding-top: var(--space-md);
}

.sidebar-section {
    margin-bottom: var(--space-xl);
}

.sidebar-section-title {
    margin-bottom: 0.75rem;
    color: var(--md-sys-color-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.sidebar-icon {
    font-size: 1.2rem;
    margin-right: var(--space-sm);
    color: var(--md-sys-color-primary);
}

.sidebar-footer {
    margin-top: var(--space-2xl);
    padding: var(--space-md) 0;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-on-surface-variant);
    /* text-muted replacement */
    font-size: var(--text-xs);
    text-align: center;
}

.empty-state-text {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.9rem;
    padding: var(--space-sm);
}

.btn-full-width {
    width: 100%;
    justify-content: flex-start;
}

.mb-2 {
    margin-bottom: var(--space-sm);
}

/* Post List Extras */
.post-list-empty {
    padding: var(--space-md);
    color: var(--md-sys-color-on-surface-variant);
    text-align: center;
}

.loading-spinner-container {
    display: flex;
    justify-content: center;
    padding: var(--space-xl);
}