/* ==========================================================================
   8W通行证 —— 界面样式表（NES 像素风）
   --------------------------------------------------------------------------
   与社区主站（css/style.css + index.html）保持同一套视觉语言：
     · ZPix 像素字体（/fonts/zpix.woff2）
     · NES 调色板（蓝 #209cee / 红 #e76e55 / 绿 #92cc41 / 黄 #f7d51d /
       深 #212529 / 白 #fff / 灰 #adafbc / 黑 #000）
     · 4px（容器）/ 2px（控件）实线深色描边
     · 无模糊的硬阴影（2px 2px 0 / 4px 4px 0 / 6px 6px 0）
     · 一律直角、像素化渲染、导航与标签大写
   仅重绘样式：不改动任何 w8-* 类名，也不依赖深色模式（主站为纯浅色）。

   组织方式：
     1. 像素字体       2. 设计令牌       3. 基础重置       4. 布局
     5. 顶栏           6. 卡片           7. 表单           8. 按钮
     9. 徽章与状态     10. 提示与吐司    11. 绑定列表      12. 标签页
     13. 键值表        14. 授权页        15. 骨架与空状态  16. 工具类
     17. 响应式        18. 动效与无障碍
   ========================================================================== */

/* ==========================================================================
   1. 像素字体
   ========================================================================== */

@font-face {
    font-family: 'ZPix';
    src: url('/fonts/zpix.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ==========================================================================
   2. 设计令牌
   ========================================================================== */

:root {
    /* NES 调色板（与主站一致） */
    --nes-blue:   #209cee;
    --nes-red:    #e76e55;
    --nes-green:  #92cc41;
    --nes-yellow: #f7d51d;
    --nes-dark:   #212529;
    --nes-white:  #ffffff;
    --nes-gray:   #adafbc;
    --nes-black:  #000000;

    /* 语义映射（保留 w8-* 变量名：index.php 内联样式引用 --w8-line） */
    --w8-bg:            #f0f0f0;
    --w8-bg-elevated:   var(--nes-white);
    --w8-bg-subtle:     #e8e8e8;
    --w8-ink:           var(--nes-dark);
    --w8-ink-soft:      #3a3f47;
    --w8-ink-muted:     #6b6b6b;
    --w8-line:          var(--nes-dark);
    --w8-line-strong:   var(--nes-black);
    --w8-brand:         var(--nes-blue);
    --w8-brand-strong:  #1673b8;
    --w8-brand-soft:    #e8f4fc;

    /* 语义色（徽章 / 提示 / 状态） */
    --w8-success: var(--nes-green);
    --w8-warn:    var(--nes-yellow);
    --w8-danger:  var(--nes-red);
    --w8-info:    var(--nes-blue);

    /* 硬阴影：一律无模糊 */
    --w8-shadow-sm: 2px 2px 0 var(--nes-dark);
    --w8-shadow-md: 4px 4px 0 var(--nes-dark);
    --w8-shadow-lg: 6px 6px 0 var(--nes-dark);

    /* 间距（4px 基准） */
    --w8-space-1: 4px;
    --w8-space-2: 8px;
    --w8-space-3: 12px;
    --w8-space-4: 16px;
    --w8-space-5: 20px;
    --w8-space-6: 24px;
    --w8-space-8: 32px;
    --w8-space-10: 40px;
    --w8-space-12: 48px;

    /* 字体 */
    --w8-font: "ZPix", "Press Start 2P", "Noto Sans SC", cursive, sans-serif;
    --w8-font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
                    "Liberation Mono", monospace;

    /* 动效：短促、线性，贴近像素机的手感 */
    --w8-ease: linear;
    --w8-dur-fast: 100ms;
    --w8-dur: 160ms;
    --w8-dur-slow: 240ms;

    /* 尺寸 */
    --w8-header-h: 64px;
    --w8-content-max: 960px;
    --w8-narrow-max: 460px;

    color-scheme: light;
}

/* ==========================================================================
   3. 基础重置
   ========================================================================== */

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body.w8-passport {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--w8-bg);
    color: var(--w8-ink);
    font-family: var(--w8-font);
    font-size: 15px;
    line-height: 1.8;
    image-rendering: pixelated;
}

h1, h2, h3, h4 {
    margin: 0;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 1px;
}

p { margin: 0; }

a {
    color: var(--w8-brand-strong);
    text-decoration: none;
    transition: color var(--w8-dur-fast) var(--w8-ease);
}

a:hover { text-decoration: underline; }

code, .w8-mono {
    font-family: var(--w8-font-mono);
    font-size: 0.88em;
    background: var(--w8-bg-subtle);
    padding: 1px 6px;
    border: 2px solid var(--w8-line);
}

::selection {
    background: var(--nes-blue);
    color: var(--nes-white);
}

/* 统一的焦点可见样式 —— 键盘用户必须看得见焦点在哪 */
:focus-visible {
    outline: 3px solid var(--nes-blue);
    outline-offset: 2px;
}

/* 深色底上的焦点改用黄色，保证对比度 */
.w8-topbar :focus-visible,
.w8-nav :focus-visible { outline-color: var(--nes-yellow); }

/* NES 滚动条 */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: #e0e0e0; border: 2px solid var(--nes-dark); }
::-webkit-scrollbar-thumb { background: var(--nes-blue); border: 2px solid var(--nes-dark); }
::-webkit-scrollbar-thumb:hover { background: var(--nes-red); }

/* ==========================================================================
   4. 布局
   ========================================================================== */

.w8-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.w8-main {
    flex: 1 1 auto;
    width: 100%;
    max-width: var(--w8-content-max);
    margin: 0 auto;
    padding: var(--w8-space-8) var(--w8-space-5) var(--w8-space-12);
}

.w8-main--narrow { max-width: var(--w8-narrow-max); }

/* 仪表盘：宽屏左导航 + 右内容 */
.w8-dashboard {
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
    gap: var(--w8-space-6);
    align-items: start;
}

.w8-stack {
    display: flex;
    flex-direction: column;
    gap: var(--w8-space-5);
}

.w8-stack--tight { gap: var(--w8-space-3); }

.w8-cluster {
    display: flex;
    align-items: center;
    gap: var(--w8-space-3);
    flex-wrap: wrap;
}

.w8-cluster--end { justify-content: flex-end; }
.w8-cluster--between { justify-content: space-between; }

/* ==========================================================================
   5. 顶栏
   ========================================================================== */

.w8-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--nes-blue);
    color: var(--nes-white);
    border-bottom: 4px solid var(--nes-dark);
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
}

.w8-topbar__inner {
    max-width: var(--w8-content-max);
    margin: 0 auto;
    padding: 0 var(--w8-space-5);
    height: var(--w8-header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--w8-space-4);
}

.w8-brand {
    display: inline-flex;
    align-items: center;
    gap: var(--w8-space-3);
    color: var(--nes-white);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-decoration: none;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.w8-brand:hover { text-decoration: none; }

.w8-brand__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex: none;
    background: var(--nes-white);
    color: var(--nes-dark);
    border: 2px solid var(--nes-dark);
    box-shadow: 2px 2px 0 var(--nes-dark);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 1px;
}

.w8-brand__sub {
    display: block;
    font-size: 11px;
    font-weight: normal;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 1px;
    line-height: 1.3;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2);
}

/* 用户胶囊 */
.w8-userchip {
    display: inline-flex;
    align-items: center;
    gap: var(--w8-space-2);
    padding: 4px 4px 4px 10px;
    background: var(--nes-white);
    color: var(--nes-dark);
    border: 2px solid var(--nes-dark);
    box-shadow: 2px 2px 0 var(--nes-dark);
}

.w8-userchip__name {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    max-width: 15ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 头像（首字母）—— NES 方块 */
.w8-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex: none;
    background: var(--nes-blue);
    color: var(--nes-white);
    border: 2px solid var(--nes-dark);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.w8-avatar--sm { width: 28px; height: 28px; font-size: 12px; }
.w8-avatar--lg { width: 52px; height: 52px; font-size: 20px; }

/* ==========================================================================
   6. 卡片
   ========================================================================== */

.w8-card {
    background: var(--w8-bg-elevated);
    border: 4px solid var(--nes-dark);
    box-shadow: var(--w8-shadow-md);
}

.w8-card__head {
    padding: var(--w8-space-4) var(--w8-space-5);
    background: var(--w8-bg-subtle);
    border-bottom: 4px solid var(--nes-dark);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--w8-space-4);
}

.w8-card__title {
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: var(--w8-space-2);
}

.w8-card__sub {
    margin-top: 4px;
    font-size: 12.5px;
    color: var(--w8-ink-muted);
    line-height: 1.7;
}

.w8-card__body { padding: var(--w8-space-5); }

.w8-card__foot {
    padding: var(--w8-space-4) var(--w8-space-5);
    border-top: 4px solid var(--nes-dark);
    background: var(--w8-bg-subtle);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--w8-space-3);
    flex-wrap: wrap;
}

/* 强调卡片（用于登录/注册主面板） */
.w8-card--hero { box-shadow: var(--w8-shadow-lg); }

/* 侧边导航 —— 深色 NES 菜单条 */
.w8-nav {
    position: sticky;
    top: calc(var(--w8-header-h) + var(--w8-space-5));
    display: flex;
    flex-direction: column;
    padding: var(--w8-space-2);
    background: var(--nes-dark);
    border: 4px solid var(--nes-black);
    box-shadow: var(--w8-shadow-md);
}

.w8-nav__item {
    display: flex;
    align-items: center;
    gap: var(--w8-space-2);
    padding: 10px 12px;
    color: var(--nes-white);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-decoration: none;
    border-bottom: 2px solid var(--nes-black);
    transition: background var(--w8-dur-fast) var(--w8-ease),
                color var(--w8-dur-fast) var(--w8-ease);
}

.w8-nav__item:last-child { border-bottom: none; }

.w8-nav__item:hover {
    background: var(--nes-blue);
    color: var(--nes-white);
    text-decoration: none;
}

.w8-nav__item--active {
    background: var(--nes-blue);
    color: var(--nes-white);
}

.w8-nav__icon {
    width: 18px;
    text-align: center;
    flex: none;
}

/* ==========================================================================
   7. 表单
   ========================================================================== */

.w8-field { margin-bottom: var(--w8-space-5); }
.w8-field:last-child { margin-bottom: 0; }

.w8-label {
    display: block;
    margin-bottom: 6px;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--w8-ink);
}

.w8-label__optional {
    margin-left: 6px;
    font-size: 10.5px;
    font-weight: normal;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--w8-ink-muted);
    padding: 1px 6px;
    background: var(--w8-bg-subtle);
    border: 2px solid var(--w8-line);
}

.w8-input,
.w8-select,
.w8-textarea {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--nes-dark);
    background: var(--nes-white);
    color: var(--w8-ink);
    font-family: var(--w8-font);
    font-size: 15px;
    line-height: 1.5;
    box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.06);
    transition: border-color var(--w8-dur-fast) var(--w8-ease),
                box-shadow var(--w8-dur-fast) var(--w8-ease),
                background var(--w8-dur-fast) var(--w8-ease);
    -webkit-appearance: none;
    appearance: none;
}

.w8-textarea { min-height: 74px; resize: vertical; }

.w8-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23212529' d='M1.4 0 6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    padding-right: 36px;
}

.w8-input::placeholder,
.w8-textarea::placeholder { color: var(--w8-ink-muted); opacity: 0.75; }

.w8-input:hover:not(:disabled),
.w8-select:hover:not(:disabled),
.w8-textarea:hover:not(:disabled) { border-color: var(--nes-black); }

.w8-input:focus,
.w8-select:focus,
.w8-textarea:focus {
    outline: none;
    border-color: var(--nes-blue);
    box-shadow: 3px 3px 0 var(--nes-blue);
}

.w8-input:disabled,
.w8-select:disabled,
.w8-textarea:disabled {
    background: var(--w8-bg-subtle);
    color: var(--w8-ink-muted);
    cursor: not-allowed;
}

/* 校验失败 */
.w8-input--invalid,
.w8-input[aria-invalid="true"] {
    border-color: var(--nes-red);
    box-shadow: 3px 3px 0 var(--nes-red);
}

.w8-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--w8-ink-muted);
    line-height: 1.7;
}

.w8-error {
    display: none;
    margin-top: 6px;
    font-size: 12px;
    color: var(--nes-red);
    font-weight: 700;
}

.w8-error--show { display: block; }

/* 输入 + 按钮同行 */
.w8-inputgroup {
    display: flex;
    gap: var(--w8-space-2);
    align-items: stretch;
}

.w8-inputgroup .w8-input { flex: 1 1 auto; min-width: 0; }
.w8-inputgroup .w8-btn { flex: none; white-space: nowrap; }

/* 密码框：带显示/隐藏 */
.w8-password { position: relative; }

.w8-password .w8-input { padding-right: 46px; }

.w8-password__toggle {
    position: absolute;
    top: 50%;
    right: 5px;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--w8-ink-muted);
    cursor: pointer;
    font-size: 15px;
    transition: background var(--w8-dur-fast) var(--w8-ease);
}

.w8-password__toggle:hover { background: var(--w8-bg-subtle); color: var(--w8-ink); }

/* 密码强度条 —— 方头色块 */
.w8-meter {
    margin-top: 8px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.w8-meter__bar {
    flex: 1 1 auto;
    height: 8px;
    background: var(--w8-bg-subtle);
    border: 2px solid var(--nes-dark);
    transition: background var(--w8-dur) var(--w8-ease);
}

.w8-meter__bar--on-1 { background: var(--nes-red); }
.w8-meter__bar--on-2 { background: var(--nes-yellow); }
.w8-meter__bar--on-3 { background: var(--nes-blue); }
.w8-meter__bar--on-4 { background: var(--nes-green); }

.w8-meter__text {
    flex: none;
    font-size: 11px;
    color: var(--w8-ink-muted);
    min-width: 4em;
    text-align: right;
    text-transform: uppercase;
}

/* 复选框行 */
.w8-check {
    display: flex;
    align-items: flex-start;
    gap: var(--w8-space-3);
    padding: 11px 13px;
    border: 2px solid var(--nes-dark);
    background: var(--nes-white);
    box-shadow: 2px 2px 0 var(--nes-dark);
    cursor: pointer;
    transition: background var(--w8-dur-fast) var(--w8-ease),
                box-shadow var(--w8-dur-fast) var(--w8-ease);
}

.w8-check:hover { background: var(--w8-bg-subtle); }

.w8-check:has(input:checked) {
    background: var(--w8-brand-soft);
    border-color: var(--nes-blue);
    box-shadow: 2px 2px 0 var(--nes-blue);
}

.w8-check input[type="checkbox"] {
    flex: none;
    width: 18px;
    height: 18px;
    margin: 3px 0 0;
    accent-color: var(--nes-blue);
    cursor: pointer;
}

.w8-check__text { font-size: 13px; line-height: 1.7; }
.w8-check__text strong { display: block; font-size: 13.5px; text-transform: uppercase; letter-spacing: 1px; }
.w8-check__text span { color: var(--w8-ink-muted); }

/* ==========================================================================
   8. 按钮 —— NES 硬阴影按钮
   ========================================================================== */

.w8-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border: 2px solid var(--nes-dark);
    background: var(--nes-blue);
    color: var(--nes-white);
    font-family: var(--w8-font);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 2px 2px 0 var(--nes-dark);
    transition: transform var(--w8-dur-fast) var(--w8-ease),
                box-shadow var(--w8-dur-fast) var(--w8-ease),
                background var(--w8-dur-fast) var(--w8-ease),
                color var(--w8-dur-fast) var(--w8-ease),
                border-color var(--w8-dur-fast) var(--w8-ease);
}

.w8-btn:hover {
    background: #1a86d0;
    text-decoration: none;
    transform: translate(-2px, -2px);
    box-shadow: 4px 4px 0 var(--nes-dark);
}

.w8-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 0 0 0 var(--nes-dark);
}

.w8-btn:disabled,
.w8-btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: 2px 2px 0 var(--nes-dark);
}

.w8-btn--ghost {
    background: var(--nes-white);
    border-color: var(--nes-dark);
    color: var(--nes-dark);
}

.w8-btn--ghost:hover { background: var(--nes-blue); color: var(--nes-white); }

.w8-btn--subtle {
    background: var(--nes-gray);
    border-color: var(--nes-dark);
    color: var(--nes-dark);
}

.w8-btn--subtle:hover { background: var(--nes-white); color: var(--nes-dark); }

.w8-btn--danger {
    background: var(--nes-red);
    border-color: var(--nes-dark);
    color: var(--nes-white);
}

.w8-btn--danger:hover { background: #d05a42; }

.w8-btn--danger-ghost {
    background: var(--nes-white);
    border-color: var(--nes-red);
    color: var(--nes-red);
    box-shadow: 2px 2px 0 var(--nes-red);
}

.w8-btn--danger-ghost:hover {
    background: var(--nes-red);
    color: var(--nes-white);
    box-shadow: 4px 4px 0 var(--nes-red);
}

.w8-btn--block { width: 100%; }
.w8-btn--lg { min-height: 50px; font-size: 14px; padding: 0 22px; }
.w8-btn--sm { min-height: 34px; font-size: 11.5px; padding: 0 12px; gap: 5px; }

/* 加载态：文字淡出，中间转圈（方块描边，无模糊） */
.w8-btn--loading { color: transparent !important; pointer-events: none; }

.w8-btn--loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-top-color: var(--nes-white);
    animation: w8-spin 0.6s steps(8, end) infinite;
}

.w8-btn--ghost.w8-btn--loading::after,
.w8-btn--subtle.w8-btn--loading::after {
    border-color: rgba(33, 37, 41, 0.25);
    border-top-color: var(--nes-dark);
}

.w8-btn--danger-ghost.w8-btn--loading::after {
    border-color: rgba(231, 110, 85, 0.3);
    border-top-color: var(--nes-red);
}

@keyframes w8-spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   9. 徽章与状态 —— NES 色块
   ========================================================================== */

.w8-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border: 2px solid var(--nes-dark);
    background: var(--nes-gray);
    color: var(--nes-dark);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.6;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
}

.w8-badge--ok {
    background: var(--nes-green);
    color: var(--nes-dark);
}

.w8-badge--todo {
    background: var(--nes-yellow);
    color: var(--nes-dark);
}

.w8-badge--off {
    background: var(--nes-gray);
    color: var(--nes-dark);
}

.w8-badge--info {
    background: var(--nes-blue);
    color: var(--nes-white);
}

.w8-badge--required {
    background: var(--nes-red);
    color: var(--nes-white);
}

.w8-dot {
    width: 8px;
    height: 8px;
    background: currentColor;
    flex: none;
}

/* ==========================================================================
   10. 提示与吐司
   ========================================================================== */

.w8-alert {
    display: flex;
    gap: var(--w8-space-3);
    padding: 12px 14px;
    background: var(--w8-bg-subtle);
    border: 4px solid var(--nes-dark);
    box-shadow: 4px 4px 0 var(--nes-dark);
    color: var(--w8-ink);
    font-size: 13px;
    line-height: 1.7;
}

.w8-alert[hidden] { display: none; }

.w8-alert__icon { flex: none; font-size: 14px; font-weight: 700; line-height: 1.6; }
.w8-alert__body { flex: 1 1 auto; min-width: 0; }

.w8-alert--error   { background: #ffe6e6; }
.w8-alert--error   .w8-alert__icon { color: var(--nes-red); }
.w8-alert--success { background: #e6ffe6; }
.w8-alert--success .w8-alert__icon { color: #3f7a15; }
.w8-alert--warn    { background: #fff6cc; }
.w8-alert--warn    .w8-alert__icon { color: #b38f00; }
.w8-alert--info    { background: var(--w8-brand-soft); }
.w8-alert--info    .w8-alert__icon { color: var(--nes-blue); }

.w8-alert code {
    background: rgba(0, 0, 0, 0.07);
    padding: 1px 6px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    font-size: 12px;
    word-break: break-all;
}

/* 吐司 */
.w8-toasts {
    position: fixed;
    left: 50%;
    bottom: calc(var(--w8-space-6) + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: var(--w8-space-2);
    width: min(420px, calc(100vw - 32px));
    pointer-events: none;
}

.w8-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: var(--w8-space-3);
    padding: 12px 14px;
    background: var(--nes-dark);
    color: var(--nes-white);
    border: 4px solid var(--nes-black);
    box-shadow: 4px 4px 0 var(--nes-black);
    font-size: 13px;
    line-height: 1.6;
    animation: w8-toast-in var(--w8-dur-slow) var(--w8-ease);
}

.w8-toast--success {
    background: var(--nes-green);
    color: var(--nes-dark);
    border-color: var(--nes-dark);
    box-shadow: 4px 4px 0 var(--nes-dark);
}

.w8-toast--error {
    background: var(--nes-red);
    color: var(--nes-white);
}

.w8-toast--leaving { animation: w8-toast-out var(--w8-dur) var(--w8-ease) forwards; }

@keyframes w8-toast-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}

@keyframes w8-toast-out {
    to { opacity: 0; transform: translateY(8px); }
}

/* ==========================================================================
   11. 绑定列表
   ========================================================================== */

.w8-bindings {
    display: flex;
    flex-direction: column;
    gap: var(--w8-space-3);
}

.w8-binding {
    display: flex;
    align-items: center;
    gap: var(--w8-space-4);
    padding: var(--w8-space-4);
    background: var(--nes-white);
    border: 2px solid var(--nes-dark);
    box-shadow: 2px 2px 0 var(--nes-dark);
    transition: transform var(--w8-dur-fast) var(--w8-ease),
                box-shadow var(--w8-dur-fast) var(--w8-ease);
}

.w8-binding:hover { transform: translate(-2px, -2px); box-shadow: 4px 4px 0 var(--nes-dark); }

.w8-binding--bound {
    border-color: var(--nes-blue);
    box-shadow: 2px 2px 0 var(--nes-blue);
}

.w8-binding__icon {
    flex: none;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--w8-bg-subtle);
    border: 2px solid var(--nes-dark);
    font-size: 18px;
    line-height: 1;
}

.w8-binding--bound .w8-binding__icon {
    background: var(--w8-brand-soft);
    border-color: var(--nes-blue);
}

.w8-binding__main { flex: 1 1 auto; min-width: 0; }

.w8-binding__name {
    display: flex;
    align-items: center;
    gap: var(--w8-space-2);
    flex-wrap: wrap;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.w8-binding__value {
    margin-top: 2px;
    font-size: 13px;
    color: var(--w8-ink-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.w8-binding__actions {
    flex: none;
    display: flex;
    gap: var(--w8-space-2);
    align-items: center;
}

/* ==========================================================================
   12. 标签页
   ========================================================================== */

.w8-tabs {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 0;
    padding: 0;
    background: var(--w8-bg-subtle);
    border: 2px solid var(--nes-dark);
    margin-bottom: var(--w8-space-6);
}

.w8-tab {
    padding: 10px 14px;
    border: none;
    border-right: 2px solid var(--nes-dark);
    background: transparent;
    color: var(--w8-ink-muted);
    font-family: var(--w8-font);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background var(--w8-dur-fast) var(--w8-ease),
                color var(--w8-dur-fast) var(--w8-ease);
}

.w8-tab:last-child { border-right: none; }

.w8-tab:hover { background: var(--nes-gray); color: var(--nes-dark); }

.w8-tab--active {
    background: var(--nes-blue);
    color: var(--nes-white);
}

.w8-panel[hidden] { display: none; }

/* ==========================================================================
   13. 键值表
   ========================================================================== */

.w8-kv {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.w8-kv th,
.w8-kv td {
    text-align: left;
    padding: 10px 0;
    border-bottom: 2px dashed var(--nes-gray);
    vertical-align: top;
}

.w8-kv tr:last-child th,
.w8-kv tr:last-child td { border-bottom: none; }

.w8-kv th {
    width: 128px;
    padding-right: var(--w8-space-4);
    color: var(--w8-ink-muted);
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.w8-kv td { color: var(--w8-ink); word-break: break-word; }

.w8-kv code {
    background: var(--w8-bg-subtle);
    padding: 2px 6px;
    border: 2px solid var(--w8-line);
    font-size: 12px;
    word-break: break-all;
}

/* ==========================================================================
   14. 授权页
   ========================================================================== */

.w8-consent__app {
    display: flex;
    align-items: center;
    gap: var(--w8-space-4);
    padding: var(--w8-space-4);
    background: var(--w8-brand-soft);
    border: 4px solid var(--nes-dark);
    box-shadow: 4px 4px 0 var(--nes-dark);
    margin-bottom: var(--w8-space-5);
}

.w8-consent__logo {
    flex: none;
    width: 48px;
    height: 48px;
    background: var(--nes-blue);
    color: var(--nes-white);
    border: 2px solid var(--nes-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    font-weight: 700;
    overflow: hidden;
}

.w8-consent__logo img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }

.w8-consent__name { font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.w8-consent__meta { font-size: 12px; color: var(--w8-ink-muted); word-break: break-all; }

.w8-scopes {
    margin: 0;
    padding: 0;
    list-style: none;
    border: 2px solid var(--nes-dark);
}

.w8-scopes li {
    display: flex;
    gap: var(--w8-space-3);
    padding: 10px 14px;
    background: var(--nes-white);
    border-bottom: 2px solid var(--nes-dark);
    font-size: 13px;
}

.w8-scopes li:last-child { border-bottom: none; }

.w8-scopes__check {
    flex: none;
    color: #3f7a15;
    font-weight: 700;
    line-height: 1.7;
}

.w8-scopes__body { flex: 1 1 auto; min-width: 0; }

.w8-scopes__name {
    display: block;
    font-family: var(--w8-font-mono);
    font-size: 12px;
    font-weight: 700;
    color: var(--w8-brand-strong);
    text-transform: uppercase;
}

.w8-scopes__desc { color: var(--w8-ink-muted); }

.w8-consent__footnote {
    margin-top: var(--w8-space-4);
    font-size: 12px;
    color: var(--w8-ink-muted);
    text-align: center;
    line-height: 1.7;
}

/* ==========================================================================
   15. 骨架与空状态
   ========================================================================== */

.w8-skeleton {
    height: 14px;
    background: linear-gradient(90deg, var(--w8-bg-subtle) 25%, #d8d8d8 37%, var(--w8-bg-subtle) 63%);
    background-size: 400% 100%;
    border: 2px solid var(--nes-gray);
    animation: w8-shimmer 1.2s linear infinite;
}

@keyframes w8-shimmer {
    from { background-position: 100% 50%; }
    to   { background-position: 0 50%; }
}

.w8-empty {
    padding: var(--w8-space-8) var(--w8-space-5);
    text-align: center;
    color: var(--w8-ink-muted);
    font-size: 13px;
}

.w8-empty__icon { font-size: 28px; opacity: 0.5; display: block; margin-bottom: var(--w8-space-3); }

/* ==========================================================================
   16. 工具类
   ========================================================================== */

.w8-muted { color: var(--w8-ink-muted); font-size: 13px; }
.w8-soft  { color: var(--w8-ink-soft); }
.w8-small { font-size: 12px; }
.w8-strong { font-weight: 700; }
.w8-break { word-break: break-all; }
.w8-mt-0 { margin-top: 0; }
.w8-mt-3 { margin-top: var(--w8-space-3); }
.w8-mt-4 { margin-top: var(--w8-space-4); }
.w8-mt-5 { margin-top: var(--w8-space-5); }
.w8-mt-6 { margin-top: var(--w8-space-6); }
.w8-mb-0 { margin-bottom: 0; }
.w8-mb-4 { margin-bottom: var(--w8-space-4); }
.w8-hidden { display: none !important; }
.w8-sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* 页脚 */
.w8-footer {
    margin-top: var(--w8-space-8);
    padding-top: var(--w8-space-5);
    border-top: 2px solid var(--nes-dark);
    text-align: center;
    font-size: 12px;
    color: var(--w8-ink-muted);
    line-height: 1.9;
}

.w8-footer a { color: var(--w8-brand-strong); }

/* ==========================================================================
   17. 响应式
   ========================================================================== */

/* 平板：侧导航收成顶部横向滚动条 */
@media (max-width: 900px) {
    .w8-dashboard {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--w8-space-4);
    }

    .w8-nav {
        position: static;
        flex-direction: row;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 4px;
    }

    .w8-nav::-webkit-scrollbar { display: none; }

    .w8-nav__item {
        flex: none;
        padding: 8px 13px;
        border-bottom: none;
        border-right: 2px solid var(--nes-black);
    }

    .w8-nav__item:last-child { border-right: none; }

    .w8-nav__icon { display: none; }
}

@media (max-width: 640px) {
    :root { --w8-header-h: 56px; }

    .w8-main {
        padding: var(--w8-space-5) var(--w8-space-4) var(--w8-space-10);
    }

    .w8-topbar__inner { padding: 0 var(--w8-space-4); }
    .w8-brand { font-size: 15px; }
    .w8-brand__mark { width: 30px; height: 30px; font-size: 12px; }
    .w8-brand__sub { display: none; }
    .w8-userchip { padding: 4px; gap: 0; border: none; background: transparent; box-shadow: none; }
    .w8-userchip__name { display: none; }

    .w8-card__head,
    .w8-card__body { padding: var(--w8-space-4); }

    .w8-card__foot { padding: var(--w8-space-3) var(--w8-space-4); }

    /* 绑定行改上下布局，操作按钮占满整行 */
    .w8-binding {
        flex-wrap: wrap;
        gap: var(--w8-space-3);
        padding: var(--w8-space-3);
    }

    .w8-binding__actions {
        width: 100%;
        justify-content: flex-end;
    }

    .w8-binding__actions .w8-btn { flex: 1 1 auto; }

    /* 输入 + 按钮同行在窄屏会挤，改成上下 */
    .w8-inputgroup { flex-direction: column; }
    .w8-inputgroup .w8-btn { width: 100%; }

    /* 表单控件最小 16px，避免 iOS 聚焦时自动放大 */
    .w8-input,
    .w8-select,
    .w8-textarea { font-size: 16px; }

    .w8-kv th { width: 96px; }

    .w8-footer { margin-top: var(--w8-space-6); }
}

@media (max-width: 380px) {
    .w8-brand span:not(.w8-brand__mark) { font-size: 14px; }
    .w8-btn { padding: 0 14px; }
}

/* 横屏手机：压扁留白 */
@media (max-height: 480px) and (orientation: landscape) {
    .w8-main { padding-top: var(--w8-space-4); }
}

/* 触屏设备：把点击目标撑到 44px */
@media (hover: none) and (pointer: coarse) {
    .w8-btn { min-height: 46px; }
    .w8-btn--sm { min-height: 40px; }
    .w8-nav__item { min-height: 44px; }
    .w8-password__toggle { width: 40px; height: 40px; }
}

/* 安全区（刘海屏 / 手势条） */
@supports (padding: env(safe-area-inset-bottom)) {
    .w8-main {
        padding-left: max(var(--w8-space-5), env(safe-area-inset-left));
        padding-right: max(var(--w8-space-5), env(safe-area-inset-right));
    }
    .w8-footer { padding-bottom: env(safe-area-inset-bottom); }
}

/* ==========================================================================
   18. 动效与无障碍
   ========================================================================== */

/* 尊重"减少动态效果"的系统设置 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* 高对比度模式：加深描边与次要文字 */
@media (prefers-contrast: more) {
    :root {
        --w8-ink-muted: #333333;
        --nes-gray: #7c8091;
    }
}

/* 打印：去掉所有装饰，只留内容 */
@media print {
    .w8-topbar,
    .w8-nav,
    .w8-toasts,
    .w8-footer { display: none !important; }

    body.w8-passport { background: #fff; }
    .w8-card,
    .w8-alert,
    .w8-binding,
    .w8-check { box-shadow: none; }
    .w8-main { max-width: none; padding: 0; }
}
