/* ===========================================================
   单词蛇 · 学习前台
   共用层：设计变量 / 顶栏 / 卡片 / 表格 / 状态 / 控件
   配色对齐客户端：亮蓝底 + 橙黄按钮（见 --brand / --cta-*）
   =========================================================== */

:root {
    --paper: #eef4ff;
    --paper-2: #e3ecfe;
    --card: #ffffff;
    --ink: #12203a;
    --ink-2: #35476d;
    --muted: #5a6d92;
    --muted-2: #7487a9;
    --line: #dde8fb;
    --line-2: #c9d9f5;

    /* 品牌蓝：取自游戏大厅背景 #3D8EF6 */
    --brand: #2f6fe0;
    --brand-dark: #1d54bc;
    --brand-50: #e9f2ff;
    --brand-100: #d5e6ff;

    /* 旧代码里 --green* 一律指向品牌蓝，避免大面积改选择器；
       真正的“良好/掌握”语义改用 --ok，别再用 --green 表达 */
    --green: var(--brand);
    --green-dark: var(--brand-dark);
    --green-50: var(--brand-50);
    --green-100: var(--brand-100);
    --ok: #0a8055;
    --ok-50: #e8f7f0;
    --ok-100: #cdeede;

    /* 按钮橙黄：取自游戏内按钮 #F6B900 / #F66700 */
    --cta: #ea6000;
    --cta-hi: #ffa91c;
    --cta-dark: #c24a00;
    --cta-line: #e05b00;
    --amber: #a86a00;
    --amber-50: #fff6e2;
    --red: #c8472b;
    --red-50: #fdeee9;
    --blue: #6d5ce0;
    --blue-50: #f0edff;
    --radius: 18px;
    --radius-sm: 11px;
    --shadow-sm: 0 1px 2px rgba(18, 40, 90, .05);
    --shadow: 0 2px 4px rgba(18, 40, 90, .04), 0 20px 38px -32px rgba(18, 46, 110, .55);
    --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 15px/1.62 var(--font);
    -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }

:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
    border-radius: 8px;
}

.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;
}

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* 单元格里两行文字的通用堆叠 */
.stack { display: flex; flex-direction: column; gap: 2px; }
.stack > * { display: block; }
.tiny { font-size: 11.5px; color: var(--muted-2); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 26px; }

/* ---------- 顶栏 ---------- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    background: rgba(255, 255, 255, .9);
    border-bottom: 1px solid var(--line);
    backdrop-filter: saturate(180%) blur(12px);
}
.topbar-inner {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; min-height: 62px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.01em; }
/* 直接用 APK 里那张图标（res/D2.png），不另画 */
.brand-mark {
    width: 32px; height: 32px; border-radius: 10px; flex: 0 0 auto;
    display: block; object-fit: cover;
    box-shadow: 0 0 0 1px rgba(18, 32, 58, .1), 0 2px 6px rgba(18, 46, 110, .18);
}
.brand-sub { color: var(--muted); font-weight: 500; font-size: 13px; }

.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; }
.chip {
    display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
    border-radius: 999px; padding: 4px 11px;
    font-size: 12px; font-weight: 600; line-height: 1.5;
    background: var(--brand-50); color: var(--brand-dark); border: 1px solid #c9defb;
}
.chip::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85;
}
.chip.chip-quiet { background: #f2f6f4; color: var(--muted); border-color: var(--line); }
.chip.chip-quiet::before { display: none; }
.chip.chip-amber { background: var(--amber-50); color: var(--amber); border-color: #efdfc8; }

.who {
    display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2);
    min-width: 0; white-space: nowrap;
}
.who b { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; }

.btn-ghost {
    border: 1px solid var(--line-2); background: #fff; color: var(--ink-2);
    border-radius: 10px; padding: 6px 12px; font-size: 13px;
    transition: background .15s, border-color .15s, color .15s;
}
.btn-ghost:hover { background: var(--brand-50); border-color: #bcd4fb; color: var(--brand-dark); }

/* ---------- 卡片 ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
}
.card + .card { margin-top: 16px; }

.card-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 14px; flex-wrap: wrap; margin-bottom: 16px;
}
.card-head h2 { font-size: 16px; letter-spacing: -.01em; font-weight: 700; }
.card-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

.eyebrow {
    font-size: 11.5px; font-weight: 700; letter-spacing: .13em;
    color: var(--green); text-transform: uppercase;
}

/* ---------- 按钮 / 控件 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border: 1px solid var(--line-2); background: #fff; color: var(--ink);
    border-radius: 11px; padding: 9px 16px; font-size: 14px; font-weight: 500;
    transition: background .15s, border-color .15s, transform .06s, box-shadow .15s;
}
.btn:hover { background: #fbfdfc; border-color: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: linear-gradient(180deg, var(--cta-hi) 0%, var(--cta) 100%);
    border: 1px solid var(--cta-line); color: #fff; font-weight: 700;
    text-shadow: 0 1px 0 rgba(150, 55, 0, .35);
    box-shadow: 0 3px 0 var(--cta-dark), 0 12px 22px -14px rgba(240, 100, 0, .95);
}
.btn-primary:hover { background: linear-gradient(180deg, #ffbe4d 0%, #ff7a14 100%); border-color: #ef6a00; }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--cta-dark), 0 6px 14px -12px rgba(240, 100, 0, .9); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.seg {
    display: inline-flex; background: #e8f0fd; border-radius: 12px; padding: 4px; gap: 2px;
}
.seg button {
    border: 0; background: none; border-radius: 9px; padding: 6px 13px;
    font-size: 13px; color: var(--muted); white-space: nowrap;
    transition: background .15s, color .15s;
}
.seg button:hover { color: var(--ink-2); }
.seg button.on {
    background: #fff; color: var(--ink); font-weight: 600;
    box-shadow: 0 1px 4px rgba(18, 40, 90, .12);
}
.seg-sm button { padding: 5px 10px; font-size: 12.5px; }

.field { position: relative; }
.input, .select {
    border: 1px solid var(--line-2); background: #fff; border-radius: 11px;
    padding: 10px 13px; font-size: 14px; width: 100%;
    transition: border-color .15s, box-shadow .15s;
}
.input:hover, .select:hover { border-color: #b8cff2; }
.input:focus, .select:focus {
    outline: none; border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(47, 111, 224, .16);
}
.select { width: auto; padding-right: 30px; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%236b7f78' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 11px center;
}

/* ---------- 状态 ---------- */
.pill {
    display: inline-flex; align-items: center; gap: 5px;
    border-radius: 999px; padding: 2px 9px;
    font-size: 12px; font-weight: 600; line-height: 1.7;
    background: #f1f5f3; color: var(--muted);
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill { white-space: nowrap; }
.pill.is-active { background: var(--ok-50); color: var(--ok); }
.pill.is-recent { background: var(--blue-50); color: var(--blue); }
.pill.is-stalled { background: var(--amber-50); color: var(--amber); }
.pill.is-idle { background: #f1f4fb; color: #7c8cae; }
.pill.no-dot::before { display: none; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
table.data {
    width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px;
}
table.data th {
    text-align: left; font-weight: 600; font-size: 12px; letter-spacing: .02em;
    color: var(--muted); padding: 0 12px 10px; border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.data td {
    padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr.clickable { cursor: pointer; transition: background .12s; }
table.data tbody tr.clickable:hover { background: #f4f9ff; }
table.data th.right, table.data td.right { text-align: right; }
table.data td.mono { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }

/* ---------- 头像 ---------- */
.avatar {
    width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
    display: grid; place-items: center; font-weight: 700; font-size: 13px;
    background: var(--brand-50); color: var(--brand-dark); border: 1px solid #d3e5fb;
}
.avatar.lg { width: 52px; height: 52px; font-size: 18px; border-radius: 16px; }
.avatar.idle { background: #f2f5f4; color: var(--muted-2); border-color: var(--line); }

.person { display: flex; align-items: center; gap: 11px; min-width: 0; }
.person .name { font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.person .sub { font-size: 12px; color: var(--muted); }

/* ---------- 阶梯小条 ---------- */
.ladder-mini { display: inline-flex; gap: 2px; align-items: center; }
.ladder-mini i {
    width: 5px; height: 12px; border-radius: 2px; background: #e0eafb;
}
.ladder-mini i.on { background: var(--green); }
.ladder-mini i.on.high { background: var(--green-dark); }
.ladder-cell { display: flex; align-items: center; gap: 8px; }
.ladder-cell .val { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- 页头 ---------- */
.page-head { padding: 34px 0 24px; }
.page-head h1 {
    font-size: 30px; line-height: 1.24; letter-spacing: -.025em; margin: 8px 0 10px;
}
.page-head h1 .accent { color: var(--green); }
.page-head .lede { color: var(--ink-2); font-size: 14.5px; max-width: 700px; }

/* ---------- KPI ---------- */
.kpis {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
    margin-bottom: 16px;
}
@media (min-width: 980px) { .kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 721px) and (max-width: 979px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kpi {
    background: var(--card); border: 1px solid var(--line); border-radius: 15px;
    padding: 15px 16px 14px; box-shadow: var(--shadow-sm);
}
.kpi .k { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .v {
    font-size: 27px; font-weight: 700; letter-spacing: -.02em; line-height: 1.3; margin-top: 6px;
    font-variant-numeric: tabular-nums;
}
.kpi .v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.kpi .s { font-size: 12px; color: var(--muted-2); margin-top: 4px; }
.kpi.warn { background: linear-gradient(180deg, #fffdf9, #fff); border-color: #f0e2cd; }
.kpi.warn .v { color: var(--amber); }
.kpi.good .v { color: var(--ok); }

/* ---------- 空态 ---------- */
.empty {
    padding: 34px 20px; text-align: center; color: var(--muted);
    border: 1px dashed var(--line-2); border-radius: var(--radius-sm);
    background: #fbfdff;
}
.empty h3 { font-size: 15px; color: var(--ink-2); margin-bottom: 6px; }
.empty p { font-size: 13px; max-width: 380px; margin: 0 auto; }

/* ---------- 加载骨架 ---------- */
.skeleton {
    background: linear-gradient(90deg, #e9f1fd 25%, #f5f9ff 37%, #e9f1fd 63%);
    background-size: 400% 100%;
    animation: shimmer 1.3s ease infinite;
    border-radius: 10px; color: transparent !important;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- 页脚 ---------- */
.footnote {
    color: var(--muted-2); font-size: 12px; line-height: 1.8;
    padding: 26px 0 40px; max-width: 820px;
}
.footnote b { color: var(--muted); font-weight: 600; }

/* ---------- toast ---------- */
.toast {
    position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 14px);
    background: #12203a; color: #eaf2ff; padding: 10px 18px; border-radius: 999px;
    font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
    z-index: 60; box-shadow: 0 16px 32px -18px rgba(0, 0, 0, .7);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 栅格子项默认 min-width:auto，会被表格的 min-width 撑破容器，这里统一收住 */
.layout > *, .grid-2 > * { min-width: 0; }

@media (max-width: 720px) {
    .wrap { padding: 0 16px; }
    .card { padding: 18px 16px; border-radius: 15px; }
    .topbar-inner { min-height: 56px; gap: 10px; }
    .brand-sub { display: none; }
    .topbar-right .chip { display: none; }
    .topbar-right { gap: 8px; }
    .who .who-phone { display: none; }
    .who { font-size: 12.5px; }
    .btn-ghost { padding: 5px 10px; font-size: 12.5px; }
    .page-head { padding: 22px 0 18px; }
    .page-head h1 { font-size: 23px; }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .kpis .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
    .kpi { padding: 13px 14px 12px; }
    .kpi .v { font-size: 23px; }
}
