:root {
    --brand: #c8102e;
    --brand-dark: #a30d25;
    --text: #1f2329;
    --muted: #6b7280;
    --border: #e5e7eb;
    --bg: #f5f6f8;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
    padding: 32px 28px;
}

.card.wide { max-width: 720px; }

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

h1 { font-size: 20px; margin: 12px 0 4px; }

.subtitle { color: var(--muted); font-size: 13px; margin-bottom: 22px; }

.tabs { display: flex; gap: 8px; margin-bottom: 18px; }

.tab {
    flex: 1;
    text-align: center;
    padding: 8px 0;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
    color: var(--muted);
}

.tab.active { border-color: var(--brand); color: var(--brand); font-weight: 600; }

label { display: block; font-size: 13px; margin: 14px 0 6px; color: #374151; }

input {
    width: 100%;
    padding: 11px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: border-color .15s;
}

input:focus { border-color: var(--brand); }

.row { display: flex; gap: 8px; }
.row input { flex: 1; }

.phone-field { display: flex; gap: 8px; }
.phone-field select {
    width: 168px;
    flex: none;
    padding: 11px 8px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
}
.phone-field select:focus { border-color: var(--brand); outline: none; }
.phone-field input { flex: 1; min-width: 0; }
.phone-field.email-mode select { display: none; }

.code-button {
    white-space: nowrap;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid var(--brand);
    background: #fff;
    color: var(--brand);
    font-size: 13px;
    cursor: pointer;
}

.code-button:disabled { border-color: var(--border); color: var(--muted); cursor: default; }

.primary {
    width: 100%;
    margin-top: 22px;
    padding: 12px 0;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    background: var(--brand);
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.primary:hover { background: var(--brand-dark); }
.primary:disabled { background: #d1d5db; cursor: default; }

.links { display: flex; justify-content: space-between; margin-top: 16px; font-size: 13px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.message {
    margin-top: 14px;
    font-size: 13px;
    padding: 10px 12px;
    border-radius: 8px;
    display: none;
}

.message.show { display: block; }
.message.error { background: #fef2f2; color: #b91c1c; }
.message.success { background: #f0fdf4; color: #15803d; }

.kv { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.kv span:first-child { color: var(--muted); }

.footer-note { margin-top: 18px; font-size: 12px; color: var(--muted); line-height: 1.6; }

.binding { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-top: 10px; font-size: 13px; }
.binding b { color: var(--brand); }

.actions { display: flex; gap: 10px; margin-top: 22px; }
.actions .primary { margin-top: 0; }

.account-toast {
    position: fixed;
    left: 50%;
    top: 28px;
    transform: translateX(-50%) translateY(-8px);
    z-index: 30;
    max-width: calc(100% - 32px);
    padding: 12px 18px;
    border-radius: 999px;
    background: #111827;
    color: #fff;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
    opacity: 1;
    pointer-events: none;
}

.account-toast:not(.show) {
    display: none;
}

.account-toast.success { background: #047857; }
.account-toast.error { background: #b91c1c; }

.ghost {
    flex: 1;
    padding: 12px 0;
    font-size: 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
    color: var(--text);
}

/* 商城 App 内嵌登录（?embed=full）：整屏白底，去掉独立卡片和阴影 */
html.embed-full body {
    background: #ffffff;
    align-items: flex-start;
    padding: 64px 20px 40px;
}

html.embed-full .card {
    width: 100%;
    max-width: none;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
}

/* App 内嵌时的左上角返回键（网页端不显示） */
.kinliu-back {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    background: transparent;
    color: #30414c;
    font-size: 28px;
    line-height: 40px;
    text-align: center;
    cursor: pointer;
    z-index: 10;
}

html.embed-full .kinliu-back {
    display: block;
}

/* 普通弹窗及旧商城仍由外层提供关闭入口。 */
html.in-frame .kinliu-back {
    display: none;
}

/* 網頁端彈窗（iframe，非 App 整屏）：整頁就是登錄卡片本身。
   去掉卡片外的灰底、外層留白與卡片投影，彈窗只剩表單這一塊。 */
html.in-frame:not(.embed-full) body {
    background: #ffffff;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 0;
}

html.in-frame:not(.embed-full) .card,
html.in-frame:not(.embed-full) .card.wide {
    width: 100%;
    max-width: none;
    min-height: 0;
    padding: 32px 28px 36px;
    background: #ffffff;
    border-radius: 0;
    box-shadow: none;
}

/* App 全屏 iframe 内返回键和表单共用文档滚动，避免覆盖上移的内容。 */
html.embed-full.in-frame.has-embedded-navigation body {
    flex-direction: column;
    justify-content: flex-start;
    padding: 10px 20px 40px;
}

html.embed-full.in-frame.has-embedded-navigation .kinliu-back {
    display: flex;
    position: static;
    flex: 0 0 40px;
    align-items: center;
    justify-content: center;
    margin: 0 0 14px -10px;
    line-height: 1;
}
