/* ==========================================================================
   Theme tokens - shared CSS variables with dark/light switching.
   Applied at :root; individual pages include chat.css / admin.css on top.
   ========================================================================== */

/* Site is light-only ("no black background"). The legacy dark palette is
   intentionally mapped to the same warm light tokens so that a stale stored
   theme preference (data-theme="dark") can never render a black page. */
:root,
[data-theme="dark"],
[data-theme="light"] {
  --bg: #fbfbfa;
  --bg2: #f5f2ec;
  --surface: #ffffff;
  --surface2: #f0ece4;
  --surface3: #e6dfd2;
  --border: #e2d9c7;
  --border2: #cdc2ad;
  --text: #1b1b1b;
  --text2: #5c5c5c;
  --text3: #8a8a8a;
  --accent: #ad7a2f;
  --accent2: #c58b3d;
  --accent-bg: rgba(173, 122, 47, 0.08);
  --accent-border: rgba(173, 122, 47, 0.35);
  --green: #2ea043;
  --red: #cf222e;
  --blue: #0969da;
  --sidebar-w: 280px;
  --chat-max: 760px;
  --radius: 10px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 15px;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "LXGW WenKai", "Noto Serif SC", "PingFang SC", serif;
  height: 100%;
  overflow: hidden;
  display: flex;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
textarea,
select {
  font-family: inherit;
  color: inherit;
}

::selection {
  background: var(--accent-bg);
  color: var(--accent);
}

/* Shared primitives used by multiple pages */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}
.btn:hover {
  border-color: var(--border2);
  background: var(--surface);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover {
  filter: brightness(1.1);
}
.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: rgba(248, 81, 73, 0.3);
}
.btn-danger:hover {
  background: rgba(248, 81, 73, 0.1);
}
.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: none;
}
.btn-ghost:hover {
  background: var(--surface2);
  color: var(--text);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-green {
  background: rgba(63, 185, 80, 0.15);
  color: var(--green);
}
.badge-red {
  background: rgba(248, 81, 73, 0.15);
  color: var(--red);
}
.badge-blue {
  background: rgba(88, 166, 255, 0.15);
  color: var(--blue);
}
.badge-gray {
  background: var(--surface3);
  color: var(--text3);
}

/* Visible keyboard-focus ring for accessibility (pointer clicks stay clean). */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
