/* 梦·工作站 骨架样式：低调、克制。浅色为主，跟随系统深色。 */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1a1c20;
  --muted: #6b7280;
  --line: #e4e6ea;
  --accent: #4a5bd6;
  --ok: #2f9e5f;
  --warn: #c98a12;
  --err: #c0392b;
  --radius: 14px;
  --tabbar-h: calc(58px + env(safe-area-inset-bottom));
}

/* 深色取值：系统深色（未手动指定时）或手动指定深色，两处共用同一组值 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --surface: #1c1f25;
    --text: #e8eaed;
    --muted: #9aa1ab;
    --line: #2a2e36;
    --accent: #8b9bff;
    --ok: #4cc38a;
    --warn: #e0b341;
    --err: #e06c5e;
  }
}

:root[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1c1f25;
  --text: #e8eaed;
  --muted: #9aa1ab;
  --line: #2a2e36;
  --accent: #8b9bff;
  --ok: #4cc38a;
  --warn: #e0b341;
  --err: #e06c5e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100dvh; }

.muted { color: var(--muted); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar #page-title { font-size: 17px; font-weight: 600; }
.spacer { flex: 1; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:active { background: var(--line); }

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
}
.dot.ok   { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.err  { background: var(--err); }

/* ---------- 内容区 ---------- */
#view {
  padding: 16px 16px calc(var(--tabbar-h) + 24px);
  max-width: 720px;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}
.row:first-of-type { border-top: 0; }
.row .k { color: var(--muted); }
.row .v { font-variant-numeric: tabular-nums; }

/* ---------- 模块网格 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
}
.tile:active { background: var(--line); }
.tile svg { color: var(--accent); }

/* ---------- 底部标签栏 ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 10;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.tab.active { color: var(--accent); }
.tab svg { color: inherit; }

/* ---------- 表单 ---------- */
input[type=password], input[type=text] {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
input:focus { border-color: var(--accent); }

button.primary {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  font-size: 16px;
  font-family: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

button.ghost {
  width: 100%;
  margin-top: 8px;
  padding: 11px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

/* ---------- 首次连接 ---------- */
.setup {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  z-index: 50;
}
.setup-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px 20px;
}
.setup-card h1 { margin: 0 0 6px; font-size: 19px; }
.setup-card .muted { margin: 0 0 16px; font-size: 14px; }
.msg { min-height: 22px; margin: 10px 0 0; font-size: 14px; }
.msg.err { color: var(--err); }
.msg.ok { color: var(--ok); }

[hidden] { display: none !important; }
