/* theme.css — 两个页面共用的设计令牌与基础控件。
 *
 * 简约风格：中性灰 + 一个强调色（钴蓝），只用在主按钮、链接、焦点与"自己发的"消息上。
 * 层次靠留白与字重，不靠边框、渐变与阴影。
 *
 * 主题：默认跟随系统（prefers-color-scheme）；用户手动选的浅色 / 深色由 theme.js 写到
 * <html data-theme>。三种状态都在令牌层处理，组件只引用令牌，不写死任何颜色。
 */

:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eceef2;      /* 输入框、对方的消息 */
  --text: #15171c;
  --muted: #5d6470;          /* 次要文字：在 --bg 上对比度约 5.7:1 */
  --border: #dde0e6;
  --accent: #2d5bd7;
  --accent-hover: #244cb8;
  --on-accent: #ffffff;
  --sent-bg: #e3eafb;        /* 自己发的消息 */
  --focus: rgba(45, 91, 215, 0.35);
  --danger: #b8332a;
  --danger-bg: #fbe9e7;
  --warn: #8a5a00;
  --warn-bg: #fdf1dc;
  --ok: #1d7446;
  --ok-bg: #e2f3e9;
  --overlay: rgba(15, 16, 18, 0.45);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: "SF Mono", Menlo, Consolas, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1012;
    --surface: #17191c;
    --surface-2: #202328;
    --text: #e7e9ec;
    --muted: #9aa1ab;
    --border: #2a2e34;
    --accent: #7b9ef5;
    --accent-hover: #93b0f7;
    --on-accent: #0f1012;
    --sent-bg: #1c2740;
    --focus: rgba(123, 158, 245, 0.4);
    --danger: #f08a80;
    --danger-bg: #3a1d1b;
    --warn: #e0a94a;
    --warn-bg: #362812;
    --ok: #6fcf97;
    --ok-bg: #16301f;
    --overlay: rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1012;
  --surface: #17191c;
  --surface-2: #202328;
  --text: #e7e9ec;
  --muted: #9aa1ab;
  --border: #2a2e34;
  --accent: #7b9ef5;
  --accent-hover: #93b0f7;
  --on-accent: #0f1012;
  --sent-bg: #1c2740;
  --focus: rgba(123, 158, 245, 0.4);
  --danger: #f08a80;
  --danger-bg: #3a1d1b;
  --warn: #e0a94a;
  --warn-bg: #362812;
  --ok: #6fcf97;
  --ok-bg: #16301f;
  --overlay: rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 线条图标（icons.js 填充）：跟随文字颜色 */
.i { display: inline-flex; width: 20px; height: 20px; flex-shrink: 0; }
.i svg { width: 100%; height: 100%; }

.btn-primary {
  width: 100%;
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  transition: background 0.15s;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

/* 只有图标的按钮：40×40 的点击区域 */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.field {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.field::placeholder { color: var(--muted); }

/* 标签在左、下拉在右的一行设置 */
.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: left;
}
.setting select {
  flex-shrink: 0;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.notice { padding: 0.7rem 0.85rem; border-radius: var(--radius); font-size: 0.88rem; }
.notice.error { background: var(--danger-bg); color: var(--danger); }
.notice.success { background: var(--ok-bg); color: var(--ok); }

/* 主题切换：显示当前偏好对应的图标（theme.js 写 data-theme-pref） */
.theme-btn .i { display: none; }
:root:not([data-theme-pref]) .theme-btn .i-auto,
:root[data-theme-pref="auto"] .theme-btn .i-auto,
:root[data-theme-pref="light"] .theme-btn .i-light,
:root[data-theme-pref="dark"] .theme-btn .i-dark { display: inline-flex; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
