/* 综合数据看板 —— 小组件设计参照 Apple HIG Widgets：
   方形网格单元（小 1×1 / 中 2×1 / 大 2×2 / 通栏 4×2）、11–16px 边距、白底卡片、
   每类数据只用一个低饱和强调色，颜色只做点缀不抢内容。 */
:root {
  --bg: #F2F2F7;
  --surface: #FFFFFF;
  --ink: #1D1D1F;
  --ink-2: #3A3A3C;
  --muted: #6E6E73;
  --line: #E5E5EA;
  --soft: #F2F2F7;
  --power: #C98A3D;   --power-ink: #94590F;  --power-bg: #F7EFE4;
  --study: #8474C9;   --study-ink: #5B48B0;  --study-bg: #EFECF8;
  --drive: #5B86C9;   --drive-ink: #2F62B8;  --drive-bg: #EAF0F9;
  --ok: #4E9A6B;      --ok-ink: #2B7A4B;     --ok-bg: #EAF4EE;
  --warn-ink: #8F5A12; --warn-bg: #F8F0E3;
  --bad: #C8574D;     --bad-ink: #A8332A;    --bad-bg: #F9ECEA;
  --shadow: 0 0 0 .5px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.04);
  --radius: 18px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Inter", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--drive-ink); text-decoration: none; }
a:hover { color: var(--ink); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* —— 按钮与表单 —— */
.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 14px; font-weight: 500; white-space: nowrap; }
.btn:hover { background: #F7F8FA; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #2E333A; }
.btn.danger { color: var(--bad-ink); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #E4E7EB; }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); }
.icon-btn:hover { background: #E4E7EB; }
.icon-btn svg, .btn svg { width: 18px; height: 18px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); color: var(--ink); font-size: 14px; }
.input:focus { outline: 2px solid #BFD3FB; border-color: var(--drive); }
.checks { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow: auto; padding: 4px 2px; }
.checks label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); cursor: pointer; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 10px; border-radius: 12px; background: var(--soft); color: var(--ink-2); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok-ink); }
.chip.bad { background: var(--bad-bg); color: var(--bad-ink); }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); }
.chip.off { background: var(--soft); color: var(--muted); }

/* —— 顶栏 —— */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(242,243,245,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1440px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; white-space: nowrap; color: var(--ink); }
.logo { width: 24px; height: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; flex: none; }
.logo i { border-radius: 50%; background: #C7C7CC; }
.logo i:last-child { background: var(--ink); }
.tabs { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 20px; border: 0; background: transparent;
  font-size: 14px; font-weight: 500; color: var(--ink-2); cursor: pointer; white-space: nowrap; min-height: 36px; }
.tab:hover { background: #E4E7EB; }
.tab.active { background: var(--ink); color: #fff; }
.tab.dead { color: var(--muted); text-decoration: line-through; }
.tab .star { width: 14px; height: 14px; color: #C9A227; }
.tab.dragging { opacity: .4; }
.tab-add { color: var(--muted); }
.userbox { display: flex; align-items: center; gap: 6px; position: relative; }
.menu { position: absolute; right: 0; top: 44px; background: var(--surface); border-radius: 12px; box-shadow: 0 8px 30px rgba(16,24,40,.14);
  padding: 6px; min-width: 180px; z-index: 30; }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 8px; padding: 9px 12px; border: 0; background: none;
  border-radius: 8px; font-size: 14px; color: var(--ink); cursor: pointer; text-align: left; }
.menu button:hover, .menu a:hover { background: var(--soft); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.menu .danger { color: var(--bad-ink); }

/* —— 主体 —— */
.page { max-width: 1440px; margin: 0 auto; padding: 16px 20px 40px; }
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.dash-head h1 { margin: 0; font-size: 24px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.dash-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.banner { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; padding: 10px 14px; border-radius: 12px;
  background: var(--warn-bg); color: var(--warn-ink); font-size: 14px; margin-bottom: 14px; }
.editing-bar { background: var(--drive-bg); color: var(--drive-ink); }


/* —— 网格：列数和尺寸由 JS 按宽度与"卡片大小"计算（见 layout.js gridMetrics）—— */
.grid-wrap { margin: calc(var(--gs-gap, 12px) / -2); --w-pad: 14px; --w-radius: 20px; }
.grid-stack { min-height: 160px; }
.grid-stack > .grid-stack-item > .grid-stack-item-content { background: var(--surface); border-radius: var(--w-radius); box-shadow: var(--shadow); overflow: hidden; }
.editing .grid-stack > .grid-stack-item > .grid-stack-item-content { outline: 2px dashed #C7D3E8; outline-offset: -2px; cursor: move; }
.grid-stack-placeholder > .placeholder-content { background: rgba(91,134,201,.08) !important; border: 2px dashed #C7D3E8; border-radius: var(--w-radius); }
.empty-dash { text-align: center; padding: 60px 20px; color: var(--muted); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.dead-dash { text-align: center; padding: 80px 20px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.dead-dash h2 { margin: 0 0 8px; }

/* 编辑模式工具 */
.w-tools { position: absolute; top: 6px; right: 6px; display: none; gap: 4px; z-index: 5; }
.editing .w-tools { display: flex; }
.w-tools button { width: 36px; height: 36px; border-radius: 10px; border: 0; background: rgba(255,255,255,.96); box-shadow: 0 1px 4px rgba(0,0,0,.14); cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--ink-2); }
.w-tools button:hover { color: var(--ink); }
.w-tools svg { width: 16px; height: 16px; }
.editing .widget-open { visibility: hidden; }
/* 编辑模式：每张卡片底部的尺寸切换（小/中/大/通栏） */
.w-sizes { display: none; position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); z-index: 6; gap: 2px; padding: 2px; border-radius: 10px; background: rgba(255,255,255,.96); box-shadow: 0 1px 4px rgba(0,0,0,.16); }
.editing .w-sizes { display: flex; }
.w-sizes button { border: 0; background: transparent; min-width: 30px; height: 28px; padding: 0 8px; border-radius: 8px; font-size: 12px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.w-sizes button.on { background: var(--ink); color: #fff; font-weight: 600; }
.w-sizes button:focus-visible { outline: 2px solid var(--drive-ink); outline-offset: 1px; }
.editing .widget-body { opacity: .55; }
.editing .widget-body { pointer-events: none; }

/* —— 通用：组件内部元素 —— */
.w { position: absolute; inset: 0; padding: var(--w-pad, 14px); display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.w-head { display: flex; align-items: center; gap: 6px; min-width: 0; flex-shrink: 0; }
.w-head > div[style] { display: flex; flex-direction: column; gap: 1px; }
.w-title { font-weight: 600; font-size: 13px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-sub { font-size: 12px; line-height: 1.35; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ic { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: none; }
.ic svg { width: 18px; height: 18px; }
.ic.power { background: var(--power-bg); color: var(--power-ink); }
.ic.study { background: var(--study-bg); color: var(--study-ink); }
.ic.drive { background: var(--drive-bg); color: var(--drive-ink); }
.ic.sys, .ic.note { background: var(--soft); color: var(--ink-2); }
.big { font-family: ui-rounded, "SF Pro Rounded", -apple-system, "PingFang SC", system-ui, sans-serif; font-size: 32px; font-weight: 700; letter-spacing: -.02em; line-height: 1.05; font-variant-numeric: tabular-nums; white-space: nowrap; }
.big small { font-family: -apple-system, "PingFang SC", system-ui, sans-serif; font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.w-chart { flex: 1; min-height: 0; }
.w-empty { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); font-size: 12px; padding: 4px; }
.w-err { color: var(--bad-ink); }
.ch-list { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.ch { display: grid; grid-template-columns: minmax(0, 1fr) minmax(24px, 72px) 36px 40px; gap: 8px; align-items: center; font-size: 12px; padding: 5px 0; border-bottom: .5px solid var(--line); }
.ch:last-child { border-bottom: 0; }
.ch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ch-bar { height: 6px; border-radius: 3px; background: #ECECF0; overflow: hidden; }
.ch-bar > span { display: block; height: 100%; background: var(--study); }
.ch-bar.weak > span { background: var(--power); }
.ch-acc { text-align: right; font-variant-numeric: tabular-nums; }
.ch-acc.weak { color: var(--warn-ink); font-weight: 600; }
.ch-n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.trip-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; row-gap: 1px; font-size: 12px; line-height: 1.4; padding: 6px 0; border-bottom: .5px solid var(--line); }
.trip-row:last-child { border-bottom: 0; }
.src-list { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.src { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 0; }
.src .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--ok); }
.src .dot.bad { background: var(--bad); }
.src .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-state { font-size: 12px; white-space: nowrap; color: var(--muted); }
.note-body { white-space: pre-wrap; color: var(--ink-2); overflow: hidden; min-height: 0; line-height: 1.55; font-size: 13px; }
.chip { line-height: 1.4; }
.ebike-level { display: flex; align-items: center; gap: 12px; min-height: 0; }
.ebike-meter { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.meter { height: 6px; border-radius: 3px; background: #ECECF0; overflow: hidden; }
.meter > span { display: block; height: 100%; }
.ebike-meter b { color: var(--ink); }
.ebike-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.study-day-count { display: flex; align-items: baseline; gap: 8px; }
.study-day-times { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.study-day-times > div { display: flex; flex-direction: column; gap: 2px; padding: 8px; border-radius: calc(var(--w-radius) - var(--w-pad) + 2px); background: var(--soft); min-width: 0; }
.study-day-times > div > span { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.study-day-times strong { font-size: 18px; font-variant-numeric: tabular-nums; line-height: 1.25; white-space: nowrap; }
.study-day-times small { font-size: 11px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.study-day-note { margin: auto 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.route-widget { gap: 6px; }
.route-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }
.route-toolbar strong { margin-right: auto; font-size: 13px; }
.route-toolbar .input { width: auto; max-width: 100%; }
.route-trip { flex: 1; min-width: 140px; }
.route-canvas { flex: 1; min-height: 60px; position: relative; isolation: isolate; }
.route-summary { white-space: normal; line-height: 1.4; }

/* —— 摘要卡片（看板里的小组件）—— */
.widget-host { position: absolute; inset: 0; container-type: size; --accent: #8E8E93; --accent-ink: var(--ink-2); }
[data-theme="power"] { --accent: var(--power); --accent-ink: var(--power-ink); }
[data-theme="study"] { --accent: var(--study); --accent-ink: var(--study-ink); }
[data-theme="drive"] { --accent: var(--drive); --accent-ink: var(--drive-ink); }
.widget-body { overflow: hidden; }
.widget-body.has-detail { cursor: pointer; }
.widget-body.has-detail > .w-head { padding-right: 18px; }
/* 标题行：小图标 + 强调色标题（类似 Apple 日历/天气小组件左上角的标签） */
.widget-body .w-head .ic { width: auto; height: auto; background: none; border-radius: 0; color: var(--accent); }
.widget-body .w-head .ic svg { width: 14px; height: 14px; }
.widget-body .w-title { color: var(--accent-ink); font-size: 13px; }
.widget-body .big { font-size: clamp(24px, 13cqw, 48px); }
.widget-body .w-sub { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.widget-body .chip { background: var(--soft); color: var(--ink-2); font-size: 11px; padding: 2px 8px; border-radius: 8px; }
.widget-body .chip.ok { background: var(--ok-bg); color: var(--ok-ink); }
.widget-body .src .muted, .widget-body .study-day-note { display: none; }
.widget-body .w-chart, .kpi-trend { min-height: 48px; }
.kpi-trend { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.kpi-trend > .w-head { display: none !important; }
/* 右上角的小箭头：可见的"可点开"提示 + 键盘焦点；整张卡片本身也可点 */
.widget-open { position: absolute; top: calc(var(--w-pad) - 5px); right: calc(var(--w-pad) - 8px); width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #AEAEB2; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 2; }
.widget-open svg { width: 14px; height: 14px; }
.widget-open:hover { color: var(--ink-2); background: var(--soft); }
.widget-open:focus-visible, .btn:focus-visible, .seg-mini button:focus-visible { outline: 2px solid var(--drive-ink); outline-offset: 1px; }
.widget-freshness { margin-top: auto; font-size: 11px; line-height: 1.3; color: var(--muted); flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.widget-freshness.is-stale { color: var(--warn-ink); font-weight: 600; }
.widget-freshness.is-stale::before { content: "⚠ "; }
.widget-refresh-error { position: absolute; inset: auto 8px 8px; background: var(--warn-bg); color: var(--warn-ink); font-size: 12px; line-height: 1.4; padding: 6px 8px; border-radius: 10px; z-index: 3; }
.widget-loading { padding: var(--w-pad, 14px); color: var(--muted); font-size: 12px; }
.widget-host[aria-busy="true"] .widget-loading::before { content: ""; display: block; width: 45%; height: 10px; border-radius: 5px; background: var(--soft); margin-bottom: 10px; }

/* 小（1×1）：一条信息。左上标签，数字和说明压在底部 */
[data-family="small"] .widget-body .big { margin-top: auto; font-size: clamp(22px, 21cqw, 46px); }
[data-family="small"] .widget-body .big small { font-size: clamp(11px, 8cqw, 13px); }
[data-family="small"] .widget-body .w-sub { font-size: 11px; }
[data-family="small"] .widget-body .w-empty { font-size: 11px; }
[data-family="small"] .widget-body .note-body { -webkit-line-clamp: 5; display: -webkit-box; -webkit-box-orient: vertical; font-size: 12px; }
[data-family="small"] .widget-body .widget-freshness { display: none; }

/* 中（2×1）：左侧数字，右侧迷你趋势 */
[data-family="medium"] .widget-body.kpi { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); grid-template-rows: auto 1fr auto; column-gap: 14px; row-gap: 4px; }
[data-family="medium"] .widget-body.kpi > .w-head { grid-column: 1; grid-row: 1; }
[data-family="medium"] .widget-body.kpi > .big { grid-column: 1; grid-row: 2; align-self: end; font-size: clamp(22px, 10.5cqw, 46px); }
[data-family="medium"] .widget-body.kpi > .w-sub { grid-column: 1; grid-row: 3; font-size: 11px; }
[data-family="medium"] .widget-body.kpi > .kpi-trend { grid-column: 2; grid-row: 1 / 4; min-height: 0; padding-top: 18px; }
[data-family="medium"] .widget-body.kpi > .widget-freshness { display: none; }
[data-family="medium"] .widget-body .note-body { -webkit-line-clamp: 4; display: -webkit-box; -webkit-box-orient: vertical; }
[data-family="medium"][data-kind="source_status"] .widget-body > .w-head .w-sub { display: none; }
@container (max-height: 135px) {
  [data-family="small"] .widget-body .note-body { -webkit-line-clamp: 3; }
}
[data-family="medium"][data-kind="ebike_status"] .widget-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); grid-template-rows: auto 1fr auto; column-gap: 14px; row-gap: 4px; }
[data-family="medium"][data-kind="ebike_status"] .w-head { grid-column: 1; grid-row: 1; }
[data-family="medium"][data-kind="ebike_status"] .ebike-chips { grid-column: 1; grid-row: 3; }
[data-family="medium"][data-kind="ebike_status"] .ebike-level { grid-column: 2; grid-row: 1 / 4; flex-direction: column; align-items: stretch; justify-content: center; gap: 6px; padding-right: 8px; }
[data-family="medium"][data-kind="ebike_status"] .ebike-level .big { font-size: clamp(26px, 11cqw, 44px); }
[data-family="medium"][data-kind="ebike_status"] .widget-freshness { display: none; }

/* 大（2×2）/ 通栏（4×2）：主数字 + 一层细节（趋势、列表） */
[data-family="large"] .widget-body .big, [data-family="wide"] .widget-body .big { font-size: clamp(26px, 12cqw, 52px); }
[data-family="wide"] .widget-body .big { font-size: clamp(26px, 7cqw, 52px); }
.source-overview { font-size: clamp(16px, 7cqw, 22px); line-height: 1.2; font-weight: 700; }
[data-kind="source_status"] .widget-body > .w-head .w-sub { display: none; }
.widget-body .route-summary { font-size: 11px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); }
.widget-body .route-canvas { border-radius: max(6px, calc(var(--w-radius) - var(--w-pad))); overflow: hidden; }
.widget-body .route-canvas::after { content: ""; position: absolute; inset: 0; z-index: 600; background: transparent; }
.widget-body .w-map { border-radius: max(6px, calc(var(--w-radius) - var(--w-pad))); }

/* 学习数据刷新小组件 */
.refresh-widget .refresh-age { font-size: clamp(20px, 15cqw, 34px) !important; }
.refresh-widget .w-sub.is-bad { color: var(--bad-ink); }
.refresh-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; align-self: flex-start; min-height: 30px; padding: 0 12px; border: 0; border-radius: 15px; background: var(--study-bg); color: var(--study-ink); font-size: 13px; font-weight: 600; cursor: pointer; flex-shrink: 0; margin-top: 2px; }
.refresh-btn svg { width: 14px; height: 14px; }
.refresh-btn:hover { background: #E4DFF5; }
.refresh-btn:disabled { opacity: .6; cursor: default; }
[data-family="medium"] .refresh-widget { display: grid; grid-template-columns: minmax(0,1fr) auto; grid-template-rows: auto 1fr auto; column-gap: 12px; }
[data-family="medium"] .refresh-widget > .w-head { grid-column: 1 / 3; }
[data-family="medium"] .refresh-widget > .big { grid-column: 1; grid-row: 2; align-self: end; }
[data-family="medium"] .refresh-widget > .w-sub { grid-column: 1; grid-row: 3; }
[data-family="medium"] .refresh-widget > .refresh-btn { grid-column: 2; grid-row: 3; align-self: end; }

/* 问候 + AI 摘要：小=一句话，中=两句，大/通栏=概括+要点 */
.widget-body.greeting { gap: 4px; }
.greet-cap { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.ai-tag { font-size: 10px; font-weight: 600; letter-spacing: .04em; color: var(--muted); border: .5px solid #C7C7CC; border-radius: 4px; padding: 0 4px; line-height: 15px; }
.greet-hello { margin: 0; font-size: clamp(20px, 7cqw, 28px); font-weight: 700; line-height: 1.2; }
.ai-headline { margin: 0; color: var(--ink); font-weight: 600; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; }
.greeting-small .ai-headline { margin-top: auto; font-size: clamp(14px, 10cqw, 19px); -webkit-line-clamp: 4; }
.greeting-medium .ai-headline { font-size: clamp(14px, 4.4cqw, 18px); -webkit-line-clamp: 3; }
.greeting-large .ai-headline, .greeting-wide .ai-headline { font-size: 15px; -webkit-line-clamp: 2; }
.ai-points { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; flex: 0 1 auto; min-height: 0; overflow: hidden; }
.ai-points li { font-size: 13px; line-height: 1.45; color: var(--ink-2); padding: 6px 0; border-top: .5px solid var(--line); }
.ai-foot { margin-top: auto; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
@container (max-height: 135px) { .greeting-medium .ai-headline { -webkit-line-clamp: 2; } .greeting-medium .ai-foot { display: none; } }
.widget-detail-body.greeting .ai-headline { -webkit-line-clamp: unset; }

/* 卡片放大时（"大"档或大屏），字号随卡片宽度自然变大，无需额外规则 */

/* —— 详情弹层 —— */
.widget-dialog { width: min(92vw, 1000px); height: 88dvh; max-height: 94dvh; border: 0; border-radius: 22px; padding: 0; box-shadow: 0 24px 80px rgba(0,0,0,.22); color: var(--ink); background: var(--bg); }
.widget-dialog[open] { display: flex; flex-direction: column; }
.widget-dialog::backdrop { background: rgba(0,0,0,.32); backdrop-filter: blur(4px); }
.widget-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--surface); flex-shrink: 0; border-bottom: .5px solid var(--line); }
.widget-dialog-head h2 { font-size: 17px; margin: 0; }
.widget-detail-region { position: relative; flex: 1; min-height: 0; overflow: auto; }
.widget-detail-body.w { position: relative; inset: auto; min-height: 100%; padding: 16px; gap: 12px; --w-pad: 16px; --w-radius: 18px; --accent: #8E8E93; --accent-ink: var(--ink-2); }
.widget-detail-body .w-head .ic { width: 28px; height: 28px; }
.widget-detail-body .w-title { font-size: 16px; }
.widget-detail-body .w-sub { font-size: 13px; white-space: normal; }
.widget-detail-body .big { font-size: 44px; }
.widget-detail-body .ch-list, .widget-detail-body .src-list, .widget-detail-body .note-body { overflow: visible; flex: none; }
.widget-detail-body .ch, .widget-detail-body .trip-row, .widget-detail-body .src { font-size: 13px; }
.widget-detail-body .w-chart { height: 320px; flex: none; min-height: 240px; }
.widget-detail-body.route-widget { height: 100%; }
.widget-detail-body .route-canvas { flex: 1; min-height: 220px; border-radius: 12px; overflow: hidden; }
.widget-detail-body .route-toolbar select, .widget-detail-body .route-toolbar button { min-height: 40px; font-size: 14px; }
.widget-detail-body .route-toolbar label { min-height: 40px; display: flex; align-items: center; gap: 8px; }
.widget-detail-body .widget-freshness { margin-top: 0; white-space: normal; }
.widget-detail-body .study-day-times strong { font-size: 24px; }
.widget-related { background: var(--surface); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.widget-detail-body .widget-refresh-error { position: static; }

/* —— 路线大图弹窗（旧入口）—— */
.route-dialog { width: 92vw; height: 90vh; max-width: 1600px; max-height: 95vh; border: 0; border-radius: 16px; padding: 16px; background: var(--surface); color: var(--ink); }
.route-dialog::backdrop { background: rgba(0,0,0,.4); }
.route-dialog[open] { display: flex; flex-direction: column; gap: 12px; }
.route-dialog-head { display: flex; align-items: center; justify-content: space-between; flex: none; }
.route-dialog-body.w { position: relative; inset: auto; flex: 1; min-height: 0; padding: 0; }

/* —— 大屏模式（挂墙平板）—— */
body.kiosk { background: var(--bg); cursor: default; }
.kiosk-bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: rgba(242,242,247,.9); }
.kiosk-title { font-size: 22px; font-weight: 700; flex: 1; }
.kiosk-clock { font-size: 22px; font-weight: 600; color: var(--ink-2); }
.kiosk-page { max-width: none; padding: 4px 14px 20px; }
.kiosk .w-tools { display: none !important; }

@media (max-width: 720px) {
  .topbar-in { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .brand > span:not(.logo) { display: none; }
  .tabs { order: 3; flex-basis: 100%; }
  .page { padding: 12px 12px 32px; }
  .dash-head { align-items: center; gap: 8px; margin: 2px 0 12px; }
  .dash-head h1 { font-size: 22px; flex-basis: 100%; }
  .dash-actions { gap: 6px; }
  .dash-actions .btn { min-height: 36px; padding: 0 10px; font-size: 13px; }
  .dash-actions > .editing-bar { flex: 1 1 100% !important; font-size: 12px; padding: 8px 10px; }
  .widget-dialog, .route-dialog { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; border-radius: 0; }
  .route-dialog { padding: 12px; }
  .route-toolbar { gap: 4px; }
  .route-toolbar .input { font-size: 12px; }
  .widget-detail-body .w-chart { height: 260px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* —— 弹窗 —— */
dialog.modal { border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 20px 60px rgba(16,24,40,.25); color: var(--ink); }
dialog.modal.wide { width: min(880px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(16,24,40,.35); }
.modal-in { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-body { padding: 10px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
.modal-sec { display: flex; flex-direction: column; gap: 10px; }
.modal-sec h4 { margin: 4px 0 0; font-size: 14px; color: var(--ink-2); }
.err-text { color: var(--bad-ink); font-size: 13px; min-height: 18px; }
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.pick { display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.pick:hover { border-color: #BFD3FB; background: #F7FAFF; }
.pick b { display: block; font-size: 14px; }
.pick span { font-size: 12px; color: var(--muted); }
.group-title { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .04em; margin: 4px 0 -4px; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--soft); font-size: 14px; flex-wrap: wrap; }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 160px; }
.link-text { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--ink-2); word-break: break-all; }

/* —— 用户管理页 —— */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.admin-grid { display: grid; gap: 16px; }
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl td { padding: 10px; border-bottom: 1px solid var(--soft); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }

/* —— 登录 / 失效 —— */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: min(380px, 100%); background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 100; box-shadow: 0 8px 30px rgba(16,24,40,.25); }

/* —— 电动车 / 地图 —— */
.w-map { flex: 1; min-height: 0; border-radius: 12px; overflow: hidden; position: relative; background: #F3F1EC; }
.w-map .leaflet-container { font: inherit; }
.map-note { position: absolute; left: 10px; bottom: 10px; z-index: 500; font-size: 12px; background: rgba(255,255,255,.95); padding: 4px 10px; border-radius: 10px; color: var(--warn-ink); }
.input.sm { min-height: 32px; padding: 4px 8px; font-size: 13px; width: auto; max-width: 200px; }
.seg-mini { display: inline-flex; gap: 2px; background: #E4E7EB; padding: 2px; border-radius: 8px; }
.seg-mini button { border: 0; background: transparent; padding: 5px 10px; border-radius: 6px; font-size: 12px; cursor: pointer; color: var(--ink-2); min-height: 28px; }
.seg-mini button.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(16,24,40,.08); }

/* —— 管理页：设置 / 系统状态 —— */
.set-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.set-src { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.set-src .set-title { font-weight: 600; }
.set-fields { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.map-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; margin-top: 6px; }
.sys-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.sys-grid > div { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }

