/* Portal base, shell, and layout primitives. */

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--page-bg);
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
    /* 固定页面缩放，避免双指/双击放大（原生 APP 式体验）。
       局部需要手势的区域（如签名 canvas）用更高特异性的
       touch-action 规则覆盖，不受影响。 */
    touch-action: manipulation;
    -ms-touch-action: manipulation;
}

body {
    margin: 0;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    background: var(--page-bg);
    color: var(--ink);
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 15px;
    line-height: 1.55;
    letter-spacing: 0;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
    /* 阻止整页橡皮筋弹性滚动，行为更接近原生 APP。
       局部滚动容器可单独设 overscroll-behavior: contain。 */
    overscroll-behavior: none;
}

.material-symbols-outlined {
    display: inline-block;
    direction: ltr;
    font-family: "Material Symbols Outlined";
    font-feature-settings: "liga";
    font-size: 24px;
    font-style: normal;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1;
    overflow: hidden;
    text-rendering: optimizeLegibility;
    text-transform: none;
    white-space: nowrap;
    word-wrap: normal;
    -webkit-font-feature-settings: "liga";
    -webkit-font-smoothing: antialiased;
}

/* Hide icon text until Material Symbols font is loaded */
.no-icon-font .material-symbols-outlined {
    visibility: hidden;
}

.skip-link {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 8px);
    left: 12px;
    z-index: 1000;
    transform: translateY(-140%);
    padding: 8px 12px;
    border-radius: var(--radius-control);
    background: var(--ink);
    color: var(--surface-raised);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: transform 0.16s ease;
}

.skip-link:focus {
    transform: translateY(0);
}

body::before {
    content: none;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    touch-action: manipulation;
}

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    color: var(--ink);
    background: var(--surface-raised);
    border-bottom: 1px solid var(--line);
    box-shadow: none;
    backdrop-filter: none;
}

.header-row {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    min-height: calc(50px + env(safe-area-inset-top));
    max-width: 480px;
    margin: 0 auto;
    padding: env(safe-area-inset-top) 14px 0;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    min-width: 0;
}

.header-left {
    justify-content: flex-start;
}

.header-right {
    justify-content: flex-end;
    gap: var(--space-xs);
}

.header h1 {
    justify-self: center;
    margin: 0;
    min-width: 0;
    max-width: min(220px, calc(100vw - 156px));
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0;
    color: var(--ink);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-back,
.header-placeholder {
    display: inline-grid;
    width: 44px;
    height: 44px;
    place-items: center;
}

.nav-back {
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    transition: background 0.16s ease, transform 0.1s ease;
}

.nav-back svg {
    width: 24px;
    height: 24px;
}

.nav-back:active {
    transform: scale(0.94);
    background: color-mix(in oklch, var(--brand-soft), white 36%);
}

.header-action,
.channel-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    max-width: 72px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--brand-strong);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.container {
    width: min(100%, 480px);
    margin: 0 auto;
    padding: 14px 16px calc(104px + env(safe-area-inset-bottom));
    display: grid;
    gap: var(--space-md);
    flex: 1;
    align-content: start;
    overflow-x: hidden;
}

.no-tabbar .container {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.app-main {
    animation: page-in 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.is-navigating .app-main {
    opacity: 0.68;
    transform: translateY(2px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

@keyframes page-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

