/* ============================================================
   nibango Layout System (Standard & Robust)
   ============================================================ */

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--sp-md);
    width: 100%;
}

.main-content {
    /* `100dvh` keeps the bottom of the page in view when iOS Safari
       and Android Chrome collapse their address bars. `100vh` is the
       fallback for browsers without dvh support (pre-2023). Pages
       that need full-bleed (chat detail) override both via their own
       block — see chat_detail.html. */
    min-height: calc(100vh - 120px);
    min-height: calc(100dvh - 120px);
    padding: var(--sp-lg) 0 var(--sp-3xl) 0;
    /* Extra padding on bottom for mobile tab bar */
}

/* Header */
.app-header {
    background-color: var(--glass-bg);
    backdrop-filter: blur(var(--blur-intensity));
    -webkit-backdrop-filter: blur(var(--blur-intensity));
    border-bottom: 1px solid var(--separator);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.app-header__inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.app-header__logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    font-size: 24px;
}

.app-header__logo-link:hover {
    text-decoration: none;
}

.header-nav--desktop {
    display: flex;
    align-items: center;
    gap: var(--sp-xs);
    margin-right: var(--sp-sm);
}

/* Menu as chips: grey on hover, brand tint when it is the current page,
   a small press like an iOS button. */
.header-nav__link {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 36px;
    padding: 0 14px;
    border-radius: 18px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    transition: background-color var(--t-fast), color var(--t-fast), transform 0.12s ease-out;
}

.header-nav__link:hover {
    /* iOS secondary fill: visible on the near-white header */
    background-color: rgba(120, 120, 128, 0.12);
    color: var(--text-primary);
    text-decoration: none;
}

.header-nav__link.active:hover {
    color: var(--b-primary-text-aa);
}

.header-nav__link:active {
    transform: scale(0.95);
}

.header-nav__link.active {
    background-color: rgba(0, 98, 204, 0.1);
    color: var(--b-primary-text-aa);
    font-weight: 600;
}

.header-nav__link--sell {
    background-color: var(--b-primary-fill-aa);
    color: #fff;
    font-weight: 600;
}

.header-nav__link--sell:hover,
.header-nav__link--sell.active {
    background-color: var(--b-primary-hover);
    color: #fff;
}

.header-nav__link .tab-badge {
    top: -4px;
    right: -4px;
}

.header-nav__divider {
    width: 1px;
    height: 24px;
    background-color: var(--separator);
    margin: 0 var(--sp-sm);
}

.app-header__actions {
    display: flex;
    align-items: center;
}

.header-nav__icon {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    transition: transform 0.12s ease-out;
}

/* iOS app-icon tile (squircle). It sits on a layer of its own so the
   unread badge, which overhangs the corner, is not clipped by the mask. */
.header-nav__icon::before,
.header-nav__avatar {
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M100.00 50.00 L99.96 66.80 L99.83 72.14 L99.61 76.01 L99.31 79.12 L98.92 81.75 L98.44 84.05 L97.87 86.08 L97.20 87.89 L96.44 89.52 L95.58 91.00 L94.61 92.33 L93.53 93.53 L92.33 94.61 L91.00 95.58 L89.52 96.44 L87.89 97.20 L86.08 97.87 L84.05 98.44 L81.75 98.92 L79.12 99.31 L76.01 99.61 L72.14 99.83 L66.80 99.96 L50.00 100.00 L33.20 99.96 L27.86 99.83 L23.99 99.61 L20.88 99.31 L18.25 98.92 L15.95 98.44 L13.92 97.87 L12.11 97.20 L10.48 96.44 L9.00 95.58 L7.67 94.61 L6.47 93.53 L5.39 92.33 L4.42 91.00 L3.56 89.52 L2.80 87.89 L2.13 86.08 L1.56 84.05 L1.08 81.75 L0.69 79.12 L0.39 76.01 L0.17 72.14 L0.04 66.80 L0.00 50.00 L0.04 33.20 L0.17 27.86 L0.39 23.99 L0.69 20.88 L1.08 18.25 L1.56 15.95 L2.13 13.92 L2.80 12.11 L3.56 10.48 L4.42 9.00 L5.39 7.67 L6.47 6.47 L7.67 5.39 L9.00 4.42 L10.48 3.56 L12.11 2.80 L13.92 2.13 L15.95 1.56 L18.25 1.08 L20.88 0.69 L23.99 0.39 L27.86 0.17 L33.20 0.04 L50.00 0.00 L66.80 0.04 L72.14 0.17 L76.01 0.39 L79.12 0.69 L81.75 1.08 L84.05 1.56 L86.08 2.13 L87.89 2.80 L89.52 3.56 L91.00 4.42 L92.33 5.39 L93.53 6.47 L94.61 7.67 L95.58 9.00 L96.44 10.48 L97.20 12.11 L97.87 13.92 L98.44 15.95 L98.92 18.25 L99.31 20.88 L99.61 23.99 L99.83 27.86 L99.96 33.20Z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M100.00 50.00 L99.96 66.80 L99.83 72.14 L99.61 76.01 L99.31 79.12 L98.92 81.75 L98.44 84.05 L97.87 86.08 L97.20 87.89 L96.44 89.52 L95.58 91.00 L94.61 92.33 L93.53 93.53 L92.33 94.61 L91.00 95.58 L89.52 96.44 L87.89 97.20 L86.08 97.87 L84.05 98.44 L81.75 98.92 L79.12 99.31 L76.01 99.61 L72.14 99.83 L66.80 99.96 L50.00 100.00 L33.20 99.96 L27.86 99.83 L23.99 99.61 L20.88 99.31 L18.25 98.92 L15.95 98.44 L13.92 97.87 L12.11 97.20 L10.48 96.44 L9.00 95.58 L7.67 94.61 L6.47 93.53 L5.39 92.33 L4.42 91.00 L3.56 89.52 L2.80 87.89 L2.13 86.08 L1.56 84.05 L1.08 81.75 L0.69 79.12 L0.39 76.01 L0.17 72.14 L0.04 66.80 L0.00 50.00 L0.04 33.20 L0.17 27.86 L0.39 23.99 L0.69 20.88 L1.08 18.25 L1.56 15.95 L2.13 13.92 L2.80 12.11 L3.56 10.48 L4.42 9.00 L5.39 7.67 L6.47 6.47 L7.67 5.39 L9.00 4.42 L10.48 3.56 L12.11 2.80 L13.92 2.13 L15.95 1.56 L18.25 1.08 L20.88 0.69 L23.99 0.39 L27.86 0.17 L33.20 0.04 L50.00 0.00 L66.80 0.04 L72.14 0.17 L76.01 0.39 L79.12 0.69 L81.75 1.08 L84.05 1.56 L86.08 2.13 L87.89 2.80 L89.52 3.56 L91.00 4.42 L92.33 5.39 L93.53 6.47 L94.61 7.67 L95.58 9.00 L96.44 10.48 L97.20 12.11 L97.87 13.92 L98.44 15.95 L98.92 18.25 L99.31 20.88 L99.61 23.99 L99.83 27.86 L99.96 33.20Z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

.header-nav__icon::before {
    content: "";
    position: absolute;
    inset: 4px;
    background-color: rgba(120, 120, 128, 0.12);
    transition: background-color var(--t-fast);
    z-index: 0;
}

.header-nav__icon > svg {
    position: relative;
}

.header-nav__icon:hover::before {
    background-color: rgba(120, 120, 128, 0.2);
}

.header-nav__icon:active,
.header-nav__avatar:active {
    transform: scale(0.92);
}

.header-nav__icon .tab-badge {
    top: 0;
    right: 0;
    z-index: 1;
}

.header-nav__avatar {
    width: 36px;
    height: 36px;
    margin-left: var(--sp-xs);
    overflow: hidden;
    background-color: var(--b-primary-fill-aa);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.12s ease-out, opacity var(--t-fast);
}

.header-nav__avatar:hover {
    opacity: 0.85;
    text-decoration: none;
}

.header-nav__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

@media (prefers-reduced-motion: reduce) {
    .header-nav__link,
    .header-nav__icon,
    .header-nav__avatar {
        transition: none;
    }
    .header-nav__link:active,
    .header-nav__icon:active,
    .header-nav__avatar:active {
        transform: none;
    }
}

/* Mobile Tab Bar */
/* Site Footer */
.site-footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--separator);
    padding: var(--sp-2xl) 0 var(--sp-lg);
    margin-top: var(--sp-3xl);
}

.site-footer__inner {
    display: flex;
    flex-direction: column;
    gap: var(--sp-xl);
}

.site-footer__top {
    display: flex;
    justify-content: space-between;
    gap: var(--sp-2xl);
}

.site-footer__brand {
    flex-shrink: 0;
}

.site-footer__logo {
    display: inline-flex;
    text-decoration: none;
    font-size: 22px;
}

.site-footer__tagline {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: var(--sp-sm);
}

.site-footer__links {
    display: flex;
    gap: var(--sp-3xl);
}

.site-footer__col {
    display: flex;
    flex-direction: column;
    gap: var(--sp-sm);
}

.site-footer__heading {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--sp-xs);
}

.site-footer__col a {
    color: var(--text-secondary);
    font-size: 14px;
    text-decoration: none;
    transition: color var(--t-fast);
}

.site-footer__col a:hover {
    color: var(--text-primary);
}

.site-footer__bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: var(--sp-lg);
    border-top: 1px solid var(--separator);
}

.site-footer__copy {
    color: var(--text-tertiary);
    font-size: 13px;
}

.site-footer__lang select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--separator);
    border-radius: 8px;
    padding: 6px 28px 6px 10px;
    font-size: 13px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.site-footer__social {
    display: flex;
    gap: var(--sp-md);
}

.site-footer__social a {
    color: var(--text-secondary);
    transition: color var(--t-fast);
    display: flex;
    align-items: center;
}

.site-footer__social a:hover {
    color: var(--text-primary);
}

@media (max-width: 767px) {
    .site-footer {
        padding-bottom: 100px; /* clear mobile tab bar */
    }

    .site-footer__top {
        flex-direction: column;
        gap: var(--sp-lg);
    }

    .site-footer__links {
        gap: var(--sp-xl);
    }
}

@media (max-width: 480px) {
    .site-footer__links {
        flex-direction: column;
        gap: var(--sp-lg);
    }

    .site-footer__bottom {
        flex-direction: column;
        gap: var(--sp-sm);
        text-align: center;
    }
}

.mobile-tab-bar {
    display: none !important;
}

/* Responsive Overrides */
@media (max-width: 767px) {

    /* Hide desktop nav items on mobile */
    .header-nav {
        display: none;
    }

    .mobile-tab-bar {
        display: flex !important;
        justify-content: space-around;
        align-items: center;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 83px;
        /* iOS standard includes safe area */
        padding-bottom: env(safe-area-inset-bottom, 20px);
        background-color: var(--glass-bg);
        backdrop-filter: blur(var(--blur-intensity));
        -webkit-backdrop-filter: blur(var(--blur-intensity));
        border-top: 1px solid var(--glass-border);
        z-index: 1000;
    }

    .mobile-tab-bar__item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: var(--text-secondary);
        font-size: 10px;
        font-weight: 500;
        gap: 2px;
        flex: 1;
        padding-top: 8px;
        text-decoration: none;
        transition: color 0.2s ease;
    }

    .mobile-tab-bar__item.active {
        color: var(--b-primary-text-aa);
    }

    .mobile-tab-bar__item:hover {
        text-decoration: none;
    }

    /* Center add button — no label, slightly raised */
    .mobile-tab-bar__item--add {
        position: relative;
        top: -4px;
    }

    .mobile-tab-bar__item--add span {
        display: none;
    }

    .main-content {
        padding-bottom: 100px;
        /* Ensure content clears tab bar */
    }
}