/* ============================================================
   theme.css —— Material Design 3（深色）基础层
   只包含颜色角色 / 形状 / 字体 / 通用组件，无任何外部依赖，
   不使用外部字体（国内访问 Google Fonts 常被阻断，会拖慢首屏）。
   ============================================================ */

:root {
    color-scheme: dark;

    /* 颜色角色 */
    --surface: #101014;
    --surface-1: #17171c;
    --surface-2: #1f1f25;
    --surface-3: #26262d;
    --on-surface: #e6e1e5;
    --on-surface-variant: #a9a4ad;
    --outline: #49454f;
    --outline-variant: #2b2b33;
    --primary: #e6e1e5;
    --on-primary: #1c1b1f;
    --success: #8fd9ab;
    --danger: #ffb4ab;

    /* 形状 */
    --shape-xs: 4px;
    --shape-sm: 8px;
    --shape-md: 12px;
    --shape-lg: 16px;
    --shape-full: 999px;

    /* 字体：Android 系统默认 Roboto，中文回落到 Noto Sans SC */
    --font: Roboto, "Noto Sans SC", "Noto Sans CJK SC", system-ui, -apple-system, "Microsoft YaHei", sans-serif;
    --mono: ui-monospace, "Roboto Mono", SFMono-Regular, Menlo, Consolas, monospace;

    --ease: cubic-bezier(0.2, 0, 0, 1);
    --min-touch: 48px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

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

body {
    background: var(--surface);
    color: var(--on-surface);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: contain;
}

a {
    color: inherit;
}

code {
    font-family: var(--mono);
}

::selection {
    background: rgba(230, 225, 229, 0.24);
}

/* ---------------- 按钮（触控高度 ≥ 48dp） ---------------- */
.btn {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: var(--min-touch);
    padding: 0 24px;
    border: 0;
    border-radius: var(--shape-full);
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: background 0.2s var(--ease), transform 0.12s var(--ease);
}

.btn:active {
    transform: scale(0.985);
}

.btn svg {
    flex: 0 0 auto;
}

.btn-filled {
    background: var(--primary);
    color: var(--on-primary);
}

.btn-filled:active {
    background: #f1ecf1;
}

.btn-tonal {
    background: var(--surface-2);
    color: var(--on-surface);
}

.btn-tonal:active {
    background: var(--surface-3);
}

.btn-block {
    display: flex;
    width: 100%;
}

/* 涟漪（MD3 状态层） */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.22;
    transform: scale(0);
    pointer-events: none;
    animation: ripple-out 0.55s var(--ease) forwards;
}

@keyframes ripple-out {
    to {
        transform: scale(2.6);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ripple {
        display: none;
    }

    .btn {
        transition: none;
    }
}

/* ---------------- 分段按钮（语言切换） ---------------- */
.segmented {
    display: inline-flex;
    border: 1px solid var(--outline);
    border-radius: var(--shape-full);
    overflow: hidden;
}

.segmented button {
    min-width: 34px;
    min-height: 32px;
    padding: 0 8px;
    border: 0;
    background: transparent;
    color: var(--on-surface-variant);
    font-family: inherit;
    font-size: 12.5px;
    cursor: pointer;
    transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.segmented button+button {
    border-left: 1px solid var(--outline);
}

.segmented button[aria-pressed="true"] {
    background: var(--primary);
    color: var(--on-primary);
    font-weight: 500;
}

/* ---------------- 卡片 ---------------- */
.card {
    background: var(--surface-1);
    border-radius: var(--shape-lg);
    padding: 18px;
}

.card-title {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.card-hint {
    margin-top: 6px;
    font-size: 13px;
    color: var(--on-surface-variant);
}

/* ---------------- 二维码（白底保证可扫） ---------------- */
.qr {
    display: inline-block;
    padding: 12px;
    border-radius: var(--shape-md);
    background: #fff;
    line-height: 0;
}

.qr img {
    display: block;
    width: 148px;
    height: 148px;
    image-rendering: pixelated;
}

/* ---------------- 输入框 ---------------- */
.field {
    display: block;
    margin-top: 14px;
}

.field-label {
    display: block;
    margin-bottom: 6px;
    font-size: 12.5px;
    color: var(--on-surface-variant);
}

.field input {
    width: 100%;
    min-height: var(--min-touch);
    padding: 10px 14px;
    background: var(--surface-2);
    color: var(--on-surface);
    border: 1px solid var(--outline-variant);
    border-radius: var(--shape-md);
    font-family: var(--mono);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.field input::placeholder {
    color: #6f6b74;
    font-family: var(--font);
    font-size: 13px;
}

.field input:focus {
    border-color: var(--primary);
    background: var(--surface-3);
}

/* ---------------- 提示条 ---------------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom));
    transform: translate(-50%, 10px);
    padding: 10px 18px;
    border-radius: var(--shape-sm);
    background: var(--primary);
    color: var(--on-primary);
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
    z-index: 50;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ---------------- 按钮：文字按钮 ---------------- */
.btn-text {
    background: transparent;
    color: var(--primary);
}

.btn-text:active {
    background: var(--surface-3);
}

/* ---------------- 对话框（Material 3，28dp 圆角） ---------------- */
.dialog {
    width: min(100% - 32px, 420px);
    max-height: calc(100dvh - 96px);
    margin: auto;
    padding: 0;
    border: 0;
    border-radius: 28px;
    background: var(--surface-2);
    color: var(--on-surface);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
}

.dialog-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 24px;
}

.dialog-title {
    font-size: 18px;
    font-weight: 500;
    line-height: 1.4;
}

.dialog-lead {
    font-size: 13px;
    color: var(--on-surface-variant);
}

.dialog-body {
    overflow-y: auto;
    max-height: min(46dvh, 320px);
    margin: 4px -4px 0;
    padding: 0 4px;
}

.dialog-body .legal-list {
    margin-top: 0;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.dialog-actions .btn {
    min-height: 44px;
    padding: 0 20px;
    font-size: 14px;
}
