/* Use local font stacks only; avoid third-party font fetches. */

/* ============================================
   设计系统 - Design Tokens
   ============================================ */
:root {
    /* 色彩系统：低饱和暖色 + 桌面助理式柔和层级 */
    --color-brand: #C87963;
    --color-brand-dark: #A95845;
    --color-brand-light: rgba(200, 121, 99, 0.13);
    --color-brand-subtle: rgba(200, 121, 99, 0.2);

    --color-bg: #F7F0E9;
    --color-surface: #FFFDFC;
    --color-surface-alt: #F7EFE8;
    --color-surface-elevated: #FFFFFF;
    --color-surface-tint: rgba(255, 253, 250, 0.86);
    --color-text-primary: #241F1C;
    --color-text-secondary: #5A504A;
    --color-text-tertiary: #82746A;
    --color-text-muted: #A99B91;
    --color-border: rgba(137, 111, 94, 0.18);
    --color-border-soft: rgba(137, 111, 94, 0.13);
    --color-border-strong: rgba(137, 111, 94, 0.34);

    --color-success: #4B8B6A;
    --color-error: #C44536;

    --bg-warm-gradient:
        radial-gradient(circle at 14% 8%, rgba(255, 219, 196, 0.5) 0%, rgba(255, 219, 196, 0) 32%),
        radial-gradient(circle at 88% 0%, rgba(252, 239, 207, 0.58) 0%, rgba(252, 239, 207, 0) 30%),
        linear-gradient(135deg, #FFF8F1 0%, #F7F0E9 46%, #F1E8DF 100%);

    --color-bg-topbar-strong: rgba(255, 248, 241, 0.96);
    --color-bg-topbar-soft: rgba(255, 248, 241, 0.86);
    --color-bg-topbar-clear: rgba(255, 248, 241, 0);

    /* 字体系统 */
    --font-family-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-family-display: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-family-mono: 'JetBrainsMono Nerd Font Mono', 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
    --font-family: var(--font-family-body);

    --font-size-display: 52px;
    --font-size-title: 18px;
    --font-size-large: 20px;
    --font-size-body: 15px;
    --font-size-secondary: 13px;
    --font-size-caption: 11px;

    --font-weight-display: 600;
    --font-weight-primary: 600;
    --font-weight-title: 600;
    --font-weight-body: 400;
    --font-weight-secondary: 500;
    --font-weight-caption: 500;

    --line-height-tight: 1.12;
    --line-height-normal: 1.5;

    /* 间距系统 */
    --spacing-xs: 8px;
    --spacing-sm: 16px;
    --spacing-md: 24px;
    --spacing-lg: 40px;
    --spacing-xl: 64px;

    /* 圆角系统 */
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-full: 50px;

    /* 阴影系统 - 柔和桌面浮层 */
    --shadow-subtle: 0 1px 2px rgba(60, 47, 38, 0.05);
    --shadow-card: 0 12px 30px rgba(92, 68, 52, 0.08);
    --shadow-card-hover: 0 18px 44px rgba(92, 68, 52, 0.14);
    --shadow-float: 0 22px 56px rgba(70, 51, 39, 0.18);
    --shadow-raised: 0 14px 30px rgba(92, 68, 52, 0.14);
    --shadow-modal:
        0 16px 42px rgba(70, 51, 39, 0.16),
        0 34px 84px rgba(70, 51, 39, 0.16);
    --shadow-input-focus:
        0 0 0 3px var(--color-brand-light),
        0 1px 2px rgba(60, 47, 38, 0.06);

    /* 动画 - 更细腻的曲线 */
    --transition-instant: 100ms;
    --transition-fast: 120ms;
    --transition-normal: 200ms;
    --transition-slow: 300ms;
    --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring-soft: cubic-bezier(0.25, 1, 0.5, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
}

/* ============================================
   手机桌面 UA 兜底：触控设备强制紧凑排版
   ============================================ */
body.force-compact {
    --font-size-title: 20px;
    --font-size-body: 16px;
    --font-size-secondary: 14px;
    --font-size-caption: 12px;
}

body.force-compact .provider-fast-switch {
    position: sticky;
    top: 8px;
    z-index: 16;
}

body.force-compact .provider-fast-switch-select {
    min-height: 44px;
    font-size: 16px;
}

@media (max-width: 720px) {
    body.force-compact .app-shell {
        grid-template-columns: 1fr;
        gap: 12px;
        height: auto;
        min-height: auto;
        overflow: visible;
    }

    body.force-compact .main-panel {
        position: relative;
        top: auto;
        align-self: stretch;
        width: 100%;
        height: auto;
        overflow-y: visible;
        padding: 14px 12px;
    }

    body.force-compact .side-rail,
    body.force-compact .status-inspector {
        display: none;
    }

    body.force-compact .top-tabs {
        display: flex !important;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    body.force-compact .top-tabs::-webkit-scrollbar {
        display: none;
    }

    body.force-compact .main-panel-topbar {
        position: static;
        margin: 0 0 10px;
        padding: 0;
        background: transparent;
        backdrop-filter: none;
    }

    body.force-compact .card {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        padding: 12px;
        gap: 8px;
    }

    body.force-compact .card-leading {
        align-items: flex-start;
        width: 100%;
    }

    body.force-compact .card-content {
        width: 100%;
    }

    body.force-compact .card-title,
    body.force-compact .card-title > span:first-child {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        overflow-wrap: anywhere;
    }

    body.force-compact .card-subtitle {
        white-space: normal;
        overflow: hidden;
        text-overflow: clip;
        overflow-wrap: anywhere;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    body.force-compact .card-trailing {
        width: 100%;
        margin-top: 0;
        grid-auto-flow: row;
        grid-auto-columns: 1fr;
        justify-content: stretch;
        justify-items: end;
    }

    body.force-compact .card-trailing .card-actions {
        width: 100%;
        justify-content: flex-end;
        justify-self: stretch;
        flex-wrap: wrap;
    }

    body.force-compact .card-actions {
        opacity: 1;
        transform: none;
    }

    body.force-compact .card-trailing .pill,
    body.force-compact .card-trailing .latency {
        justify-self: end;
    }
}

body.force-compact .btn-add,
body.force-compact .btn-tool,
body.force-compact .card-action-btn {
    min-height: 44px;
}

/* ============================================
   基础重置
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 仅屏幕阅读器可见 */
.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;
}

body {
    font-family: var(--font-family-body);
    background-color: var(--color-bg);
    background: var(--bg-warm-gradient);
    color: var(--color-text-primary);
    display: flex;
    justify-content: stretch;
    align-items: stretch;
    min-height: 100vh;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0) 26%),
        radial-gradient(circle at 86% 18%, rgba(255, 232, 206, 0.36), rgba(255, 232, 206, 0) 30%);
    z-index: 0;
}
