/* 片刻月小女仆 · Web 面板样式 —— 小女仆的房间主题
 *
 * 设计语言：奶油色房间 + 双色波点墙纸，可可色墙壁（侧栏），
 * 草莓粉点缀，蕾丝花边分隔，圆角蝴蝶结按钮。
 * 所有类名与页面逻辑解耦，改主题只需要动这一个文件。
 */

:root {
  --accent: #e57a8d;            /* 草莓粉 */
  --accent-strong: #cf5a72;
  --accent-soft: #fdeff1;
  --bg: #fbf5ee;                /* 奶油底色 */
  --surface: #fffcf8;
  --border: #f0e2d6;
  --text: #5b4636;              /* 可可色文字 */
  --text-dim: #99816f;
  --danger: #dd6a6a;
  --danger-soft: #fceeee;
  --ok: #7cae66;                /* 抹茶绿 */
  --ok-soft: #eef6e8;
  --warn: #dda14b;              /* 蜂蜜黄 */
  --warn-soft: #fbf3e2;
  --lavender: #b3a1d6;
  --sidebar-bg: #46362e;        /* 可可色墙壁 */
  --sidebar-text: #e9d9c8;
  --radius: 16px;
  --shadow: 0 2px 6px rgba(122, 84, 60, 0.07), 0 10px 26px rgba(122, 84, 60, 0.06);
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--text);
  font: 14px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Yuanti SC", "YouYuan", sans-serif;
  background-color: var(--bg);
  /* 双色波点墙纸：草莓粉 + 薰衣草，错位排布 */
  background-image:
    radial-gradient(rgba(229, 122, 141, 0.08) 1.5px, transparent 1.6px),
    radial-gradient(rgba(179, 161, 214, 0.07) 1.5px, transparent 1.6px);
  background-size: 26px 26px;
  background-position: 0 0, 13px 13px;
  background-attachment: fixed;
}

.app-loading {
  display: grid; place-items: center; height: 100vh;
  color: var(--text-dim); background: var(--bg);
}

button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* 柔和滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #ecd8c6; border-radius: 999px; border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: #e3c7ae; }

/* ---------- 登录 / 初始化 / 锁定 ---------- */
.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 22px;
  box-shadow: var(--shadow); padding: 30px 30px 26px; text-align: center;
}
/* 门顶的蝴蝶结 */
.login-card::before {
  content: "🎀";
  display: block; font-size: 36px; line-height: 1; margin-bottom: 10px;
}
.login-card h1 { margin: 0 0 4px; font-size: 21px; letter-spacing: 0.02em; }
.login-card .sub { color: var(--text-dim); margin: 0 0 18px; font-size: 13px; }
.login-card .field { margin-bottom: 14px; text-align: left; }
.login-error { color: var(--danger); font-size: 13px; min-height: 20px; margin: 6px 0; }
.login-card .btn.primary { width: 100%; padding: 9px 12px; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 212px; flex: none; color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  background: linear-gradient(180deg, #4d3a30, #3d2d25);
  /* 墙壁上的暗纹波点 */
  background-image:
    radial-gradient(rgba(255, 236, 214, 0.06) 1.5px, transparent 1.6px),
    linear-gradient(180deg, #4d3a30, #3d2d25);
  background-size: 22px 22px, auto;
}
.brand { padding: 18px 16px 12px; border-bottom: 1px solid rgba(255, 240, 220, 0.1); }
.brand .name { color: #fff6ec; font-weight: 650; font-size: 15px; }
.brand .name::before { content: "🎀 "; }
.brand .bot { font-size: 12px; opacity: 0.72; word-break: break-all; }
.greet {
  margin: 12px 12px 0; padding: 9px 12px;
  background: rgba(255, 240, 220, 0.09); border-radius: 12px;
  font-size: 12.5px; color: #f6e7d4;
}
.nav { padding: 10px 8px; overflow-y: auto; flex: 1; }
.nav .group {
  font-size: 11px; letter-spacing: 0.1em; opacity: 0.5;
  padding: 12px 10px 4px;
}
.nav .group::before { content: "♡ "; }
.nav a {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin-bottom: 2px;
  border-radius: 12px; color: var(--sidebar-text); text-decoration: none; font-size: 13.5px;
  transition: background 0.15s;
}
.nav a:hover { background: rgba(255, 240, 220, 0.08); }
.nav a.active {
  background: linear-gradient(135deg, #ef8ea1, #e57a8d);
  color: #fff; font-weight: 600;
  box-shadow: 0 3px 10px rgba(229, 122, 141, 0.35);
}
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255, 240, 220, 0.1); }
.sidebar-foot button {
  width: 100%; background: transparent; color: var(--sidebar-text);
  border: 1px solid rgba(255, 240, 220, 0.22); border-radius: 999px; padding: 6px 10px;
}
.sidebar-foot button:hover { background: rgba(255, 240, 220, 0.1); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 22px; background: var(--surface);
  border-bottom: 2px solid #f3ddc9;
  position: sticky; top: 0; z-index: 20;
}
/* 顶栏下的蕾丝花边 */
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 9px;
  background: radial-gradient(circle at 9px -3px, var(--surface) 8px, transparent 8.6px);
  background-size: 18px 12px; background-repeat: repeat-x;
  filter: drop-shadow(0 1px 0 #f3ddc9);
  pointer-events: none;
}
.topbar { position: sticky; }
.topbar > * { position: relative; }
.topbar h2 { margin: 0; font-size: 16px; }
.topbar h2::before { content: "❀ "; color: var(--accent); font-size: 13px; }
.topbar .hint { color: var(--text-dim); font-size: 12.5px; }
.content { padding: 22px 22px 44px; }

/* ---------- 组件 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; margin-bottom: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 14.5px; }
.card h3 .sub { color: var(--text-dim); font-weight: 400; font-size: 12px; margin-left: 6px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h3 { margin: 0; }
.muted { color: var(--text-dim); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 6px 14px; font-size: 13px;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.btn:hover { background: #fbf1e6; }
.btn.primary {
  background: linear-gradient(135deg, #f18ea0, #e57a8d);
  border-color: transparent; color: #fff;
  box-shadow: 0 3px 10px rgba(229, 122, 141, 0.3);
}
.btn.primary:hover { background: linear-gradient(135deg, #ee8398, #e06d83); }
.btn.danger { background: var(--danger-soft); border-color: #f4cfcf; color: #c25555; }
.btn.danger:hover { background: #f9e2e2; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent-strong); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.sm { padding: 3px 11px; font-size: 12px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }

.input, select.input, textarea.input {
  width: 100%; border: 1.5px solid var(--border); border-radius: 12px;
  padding: 7px 11px; background: #fffdf9; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(229, 122, 141, 0.14); }
textarea.input { resize: vertical; min-height: 72px; }
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 4px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .grow { flex: 1; min-width: 160px; }

.badge {
  display: inline-block; padding: 1.5px 9px; border-radius: 999px; font-size: 11.5px;
  background: #f6ecdf; color: #8a6f57; vertical-align: middle;
}
.badge.ok { background: var(--ok-soft); color: #5c8f47; }
.badge.danger { background: var(--danger-soft); color: #c25555; }
.badge.warn { background: var(--warn-soft); color: #b57a24; }
.badge.accent { background: var(--accent-soft); color: var(--accent-strong); }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: #e6d3c2; border-radius: 999px;
  transition: background 0.15s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform 0.15s;
  box-shadow: 0 1px 3px rgba(122, 84, 60, 0.25);
}
.switch input:checked + .slider {
  background: linear-gradient(135deg, #f18ea0, #e57a8d);
}
.switch input:checked + .slider::before { transform: translateX(16px); }
.switch input:disabled + .slider { opacity: 0.5; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; color: var(--text-dim); font-size: 12px;
  padding: 7px 8px; border-bottom: 1.5px solid var(--border); white-space: nowrap;
  background: #fdf6ec;
}
.table th:first-child { border-radius: 10px 0 0 10px; }
.table th:last-child { border-radius: 0 10px 10px 0; }
.table td { padding: 8px; border-bottom: 1px dashed #f2e4d4; vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fdf3ec; }
.table .actions { white-space: nowrap; text-align: right; }
.table-wrap { overflow-x: auto; }

.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 10px; font-size: 12.5px; color: var(--text-dim); }

/* 统计小卡：顶部彩带轮换（草莓 / 抹茶 / 蜂蜜） */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px 12px; box-shadow: var(--shadow);
}
.stat::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, #f18ea0, #f6c1cb);
}
.stat:nth-child(3n + 2)::before { background: linear-gradient(90deg, #9fc483, #cfe0b8); }
.stat:nth-child(3n)::before { background: linear-gradient(90deg, #e6c077, #f2dda8); }
.stat .num { font-size: 24px; font-weight: 700; line-height: 1.25; }
.stat .label { color: var(--text-dim); font-size: 12.5px; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  border: none; background: transparent; padding: 8px 12px; color: var(--text-dim);
  border-bottom: 2.5px solid transparent; font-size: 13.5px; margin-bottom: -2px;
  border-radius: 10px 10px 0 0; transition: color 0.15s;
}
.tabs button:hover { color: var(--accent-strong); }
.tabs button.active { color: var(--accent-strong); border-bottom-color: var(--accent); font-weight: 650; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft); color: var(--accent-strong);
  border-radius: 999px; padding: 2px 6px 2px 11px; font-size: 12px; margin: 0 6px 6px 0;
}
.chip button { border: none; background: transparent; color: inherit; padding: 0 2px; font-size: 13px; }
.chip button:hover { color: #a13c53; }

.toast-wrap { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-left: 4px solid var(--accent); border-radius: 14px;
  padding: 10px 14px; font-size: 13px; max-width: 380px;
  box-shadow: var(--shadow); animation: toast-in 0.18s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

.modal-mask {
  position: fixed; inset: 0; background: rgba(88, 62, 48, 0.4);
  display: grid; place-items: center; z-index: 100; padding: 20px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: var(--shadow);
  width: 100%; max-width: 460px; max-height: 86vh; display: flex; flex-direction: column;
  overflow: hidden;
}
.modal.wide { max-width: 640px; }
.modal header {
  padding: 13px 18px; border-bottom: 1.5px dashed var(--border);
  font-weight: 650;
}
.modal header::before { content: "❀ "; color: var(--accent); font-size: 13px; }
.modal .body { padding: 16px 18px; overflow-y: auto; }
.modal footer {
  padding: 12px 18px; border-top: 1.5px dashed var(--border);
  display: flex; justify-content: flex-end; gap: 8px; background: #fdf8f1;
}

pre.result {
  background: #3c2f27; color: #f3e7d8; border-radius: 14px; padding: 13px 15px;
  overflow: auto; font-family: var(--mono); font-size: 12px; line-height: 1.6; margin: 0;
  white-space: pre-wrap; word-break: break-word;
}

/* ---------- 会话 ---------- */
.chat-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; height: calc(100vh - 110px); min-height: 480px; }
.conv-list {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow);
}
.conv-search { padding: 10px; border-bottom: 1.5px dashed var(--border); }
.conv-items { flex: 1; overflow-y: auto; }
.conv-item { padding: 10px 12px; border-bottom: 1px dashed #f2e4d4; cursor: pointer; transition: background 0.12s; }
.conv-item:hover { background: #fdf3ec; }
.conv-item.unread { background: #fff9fa; }
.conv-item.unread .who { color: var(--accent-strong); }
.conv-item.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.conv-item .line1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.conv-item .who { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .when { color: var(--text-dim); font-size: 11.5px; flex: none; }
.conv-item .preview { color: var(--text-dim); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .conv-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.conv-item .conv-badges:empty { display: none; }

.chat-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow);
}
.chat-head { padding: 10px 14px; border-bottom: 1.5px dashed var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chat-head .who { font-weight: 650; }
.chat-body {
  flex: 1; overflow-y: auto; padding: 14px; background: #fdf4ec;
  /* 淡淡的斜纹桌布 */
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(229, 122, 141, 0.03) 0 10px,
    transparent 10px 20px
  );
}
.msg { display: flex; margin-bottom: 10px; }
.msg .bubble {
  max-width: 72%; padding: 8px 12px; border-radius: 14px;
  white-space: pre-wrap; word-break: break-word;
  background: #fff; border: 1.5px solid var(--border); font-size: 13.5px;
  box-shadow: 0 1px 3px rgba(122, 84, 60, 0.08);
}
.msg .meta { font-size: 11px; color: var(--text-dim); margin-top: 3px; }
.msg.out { justify-content: flex-end; }
.msg.out .bubble {
  background: linear-gradient(135deg, #ef8ea1, #e57a8d);
  border-color: transparent; color: #fff;
}
.msg.out .meta { text-align: right; }
.msg img, .msg video { max-width: 100%; border-radius: 10px; display: block; }
.msg audio { width: 240px; }
.chat-input { border-top: 1.5px dashed var(--border); padding: 10px; display: flex; gap: 8px; align-items: flex-end; background: var(--surface); }
.chat-input textarea { min-height: 40px; max-height: 140px; }
.chat-empty { display: grid; place-items: center; height: 100%; color: var(--text-dim); }

/* ---------- 配置中心 ---------- */
.config-item { border-bottom: 1px dashed #f2e4d4; padding: 11px 0; }
.config-item:last-child { border-bottom: none; }
.config-item .top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.config-item .label { font-weight: 600; font-size: 13.5px; }
.config-item .hint { color: var(--text-dim); font-size: 12.5px; margin: 2px 0 6px; }
.config-item .controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.config-item .controls .input { max-width: 380px; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 30;
    box-shadow: 0 2px 10px rgba(61, 45, 37, 0.18);
  }
  .brand {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
  }
  .nav {
    display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 4px;
    padding: 6px 10px; scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; margin-bottom: 0; padding: 6px 10px; font-size: 13px; }
  .nav .group, .greet, .sidebar-foot { display: none; }
  .topbar { position: static; padding: 12px 16px; }
  .content { padding: 16px 14px 32px; }
  .chat-layout { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .conv-list { max-height: 260px; }
  .chat-panel { height: 68vh; min-height: 420px; }
}
