/* GambitLab 移动端 Web 框架 */

:root {
    --color-bg: #0f0f12;
    --color-surface: #1a1a20;
    --color-border: #2a2a32;
    --color-text: #ffffff;
    --color-text-muted: #b8b8c0;
    --color-primary: #c9a227;
    --header-height: 56px;
    --tabbar-height: 66px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --tap-min: 48px;
    --line-body: 1.55;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overflow-x: hidden;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 17px;
    line-height: var(--line-body);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.app {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 480px;
    height: 100%;
    margin: 0 auto;
    background: var(--color-bg);
}

.app-header {
    flex-shrink: 0;
    height: var(--header-height);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: relative;
    z-index: 10;
}

.app-back[hidden] {
    display: none !important;
}

.app-header:not(.app-header--sub) .app-back {
    display: none !important;
}

.app-back {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--color-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.app-back svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.app-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.5px;
    max-width: calc(100% - 96px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-main {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.tab-page {
    display: none;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    padding-bottom: calc(16px + var(--safe-bottom));
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.tab-page::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.tab-page.active {
    display: block;
}

.page-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    color: var(--color-text-muted);
    text-align: center;
    gap: 8px;
}

.page-placeholder-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 8px;
}

.page-placeholder-text {
    font-size: 17px;
}

.app-tabbar {
    flex-shrink: 0;
    display: flex;
    height: calc(var(--tabbar-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: #000000;
    border-top: 1px solid var(--color-border);
    z-index: 10;
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: color 0.2s;
    cursor: pointer;
    user-select: none;
    min-height: var(--tap-min);
}

.tab-item.active {
    color: var(--color-text);
}

.tab-item-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-item-icon svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
}

.tab-item.active .tab-item-icon {
    color: var(--color-primary);
}

/* —— AppUI 自定义弹层 / Toast —— */
body.app-dialog-open {
    overflow: hidden;
}

.app-dialog-root {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 20px calc(24px + var(--safe-bottom));
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.app-dialog-root[hidden] {
    display: none !important;
}

.app-dialog-root.is-open {
    opacity: 1;
    pointer-events: auto;
}

.app-dialog-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.app-dialog {
    position: relative;
    width: 100%;
    max-width: 320px;
    padding: 22px 20px 16px;
    border-radius: 18px;
    background: linear-gradient(165deg, #22222a 0%, #16161c 100%);
    border: 1px solid rgba(201, 162, 39, 0.28);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
    transform: translateY(12px) scale(0.96);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
    overflow: hidden;
}

.app-dialog-root.is-open .app-dialog {
    transform: translateY(0) scale(1);
}

.app-dialog-glow {
    position: absolute;
    top: -40%;
    left: 50%;
    width: 180px;
    height: 180px;
    transform: translateX(-50%);
    background: radial-gradient(circle, rgba(201, 162, 39, 0.22) 0%, transparent 70%);
    pointer-events: none;
}

.app-dialog-title {
    position: relative;
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-align: center;
    color: var(--color-text);
}

.app-dialog-message {
    position: relative;
    margin: 0;
    font-size: 17px;
    line-height: 1.55;
    color: var(--color-text-muted);
    text-align: center;
    white-space: pre-wrap;
    word-break: break-word;
}

.app-dialog-message[hidden] {
    display: none !important;
}

.app-dialog-field {
    position: relative;
    margin-top: 16px;
}

.app-dialog-field[hidden] {
    display: none !important;
}

.app-dialog-input {
    width: 100%;
    height: 52px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    background: #0f0f12;
    color: var(--color-text);
    font-size: 19px;
    outline: none;
    transition: border-color 0.2s;
}

.app-dialog-input:focus {
    border-color: rgba(201, 162, 39, 0.7);
}

.app-dialog-actions {
    position: relative;
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.app-dialog-btn {
    flex: 1;
    height: 52px;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s, background 0.15s, opacity 0.15s;
}

.app-dialog-btn:active {
    transform: scale(0.97);
}

.app-dialog-btn-ghost {
    background: rgba(255, 255, 255, 0.06);
    color: var(--color-text-muted);
}

.app-dialog-btn-primary {
    background: linear-gradient(135deg, #d4b03a 0%, #a8841c 100%);
    color: #1a1408;
}

.app-toast-host {
    position: fixed;
    left: 50%;
    top: calc(12px + env(safe-area-inset-top, 0px));
    transform: translateX(-50%);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: min(88%, 340px);
    pointer-events: none;
}

.app-toast {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 17px;
    line-height: 1.5;
    text-align: center;
    color: #fff;
    background: rgba(26, 26, 32, 0.94);
    border: 1px solid var(--color-border);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.app-toast.is-show {
    opacity: 1;
    transform: translateY(0);
}

.app-toast--success {
    border-color: rgba(201, 162, 39, 0.45);
}

.app-toast--error {
    border-color: rgba(220, 80, 80, 0.55);
    background: rgba(40, 18, 18, 0.96);
}

.app-toast--info {
    border-color: rgba(255, 255, 255, 0.12);
}

.app-avatar-fallback {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(145deg, #2a2a32, #1a1a20);
}
