/* 猫猫上班 · 配色参考 Clowder AI：暖米色底 + 暖金强调 + 每猫一 hue */

:root {
  --bg: #fdf8f3;
  --card: #ffffff;
  --ink: #3a332c;
  --ink-soft: #7a7066;
  --ink-faint: #a89e93;
  --line: #eee3d6;
  --gold: #c9a227;
  --gold-soft: #f3e6c3;
  --green: #2e9e5b;
  --green-soft: #e2f3e9;
  --amber: #c9932e;
  --amber-soft: #f7ecd8;
  --red: #b04848;
  --red-soft: #f6e3e3;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(90, 70, 40, .05), 0 8px 24px -12px rgba(90, 70, 40, .14);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  background:
    radial-gradient(1100px 400px at 85% -60px, rgba(201, 162, 39, .10), transparent 60%),
    radial-gradient(900px 380px at -10% 0, rgba(155, 126, 189, .10), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding-bottom: 60px;
}

/* ── 顶栏 ── */
.topbar {
  background: rgba(253, 248, 243, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo {
  width: 52px; height: 52px;
  background: var(--gold-soft);
  border-radius: 16px;
  padding: 6px;
  box-shadow: var(--shadow);
}
.brand-text h1 {
  font-size: 24px;
  letter-spacing: .5px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.brand-sub { font-size: 14px; color: var(--ink-soft); font-weight: 500; }
.brand-tagline { font-size: 13px; color: var(--ink-faint); margin-top: 2px; }
.topbar-right { text-align: right; }
.clock { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 1px; color: var(--gold); }
.updated { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.updated.stale { color: var(--red); }

/* ── 统计条 ── */
.container { max-width: 1180px; margin: 0 auto; padding: 24px 20px; }
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow);
}
.stat-num { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--ink-soft); }
.stat-hot .stat-num { color: var(--green); }
.stat-chill .stat-num { color: var(--amber); }
.stat-mute .stat-num { color: var(--red); }

/* ── 部门 ── */
.device {
  margin-bottom: 30px;
}
.device-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.device-avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--breed);
  background: var(--breed-soft, #f0ece6);
}
.device-name { font-size: 18px; font-weight: 700; }
.device-breed {
  font-size: 12px;
  color: var(--breed);
  background: var(--breed-soft, #f6f1ea);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.device-status { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-faint); }
.dot.on { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.dot.off { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }

/* ── 猫工卡片 ── */
.sessions { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.cat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 14px;
  transition: transform .15s ease, box-shadow .15s ease;
  position: relative;
  overflow: hidden;
}
.cat { cursor: pointer; }
.cat:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(90, 70, 40, .08), 0 14px 32px -14px rgba(90, 70, 40, .2); }
.cat:focus-visible { outline: 2px solid var(--breed); outline-offset: 2px; }
.tag-main {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--breed);
  background: var(--breed-soft, #f6f1ea);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: middle;
}
.cat-cwd { font-size: 11px; color: var(--ink-faint); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-count { font-size: 12px; color: var(--ink-faint); margin-left: 4px; }
.device-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.filter-row { display: flex; gap: 6px; margin: 0 0 12px; flex-wrap: wrap; }
.filter-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.filter-btn.on { background: var(--breed-soft, #f6f1ea); color: var(--breed); border-color: transparent; }
.cat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--breed);
  opacity: .55;
}
.cat.running::after {
  content: "🐾";
  position: absolute;
  right: 12px;
  bottom: 10px;
  font-size: 22px;
  opacity: .35;
  animation: paw .9s ease-in-out infinite alternate;
}
@keyframes paw {
  from { transform: translateY(2px) rotate(-8deg); }
  to   { transform: translateY(-2px) rotate(6deg); }
}
.cat-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  border: 2.5px solid var(--breed);
}
.cat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.cat-title { font-size: 14.5px; font-weight: 650; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cat-meta { font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.cat-id { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 11.5px; color: var(--ink-faint); }
.cat-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; gap: 8px; }
.badge {
  font-size: 12.5px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.badge.running { background: var(--green-soft); color: var(--green); }
.badge.running::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .25; } }
.badge.idle { background: var(--amber-soft); color: var(--amber); }
.badge.other { background: #f0ece6; color: var(--ink-soft); }
.cat-time { font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.cat-idle .cat-title { color: var(--ink-soft); }
.cat-idle .cat-avatar { filter: saturate(.7) brightness(.97); }

.empty {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 15px;
}
.hidden { display: none; }

.footer {
  max-width: 1180px;
  margin: 10px auto 0;
  padding: 0 20px;
  font-size: 12px;
  color: var(--ink-faint);
  text-align: center;
}
.footer a { color: var(--gold); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

.desk {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(58, 51, 44, .28);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  padding: 18px 12px;
}
.desk.hidden { display: none; }
.desk-panel {
  width: min(860px, 100%);
  height: min(92vh, 920px);
  background: var(--card);
  border-radius: 22px;
  box-shadow: 0 20px 60px -20px rgba(58, 51, 44, .45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
}
.desk-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fffaf4;
}
.desk-back {
  border: 0;
  background: var(--gold-soft);
  color: #7a6110;
  font-weight: 700;
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
}
.desk-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--breed, var(--gold)); }
.desk-titles { flex: 1; min-width: 0; }
.desk-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.desk-sub { font-size: 12px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.desk-log {
  flex: 1;
  overflow: auto;
  padding: 16px 18px 20px;
  background:
    linear-gradient(#fff, #fff),
    repeating-linear-gradient(-12deg, transparent, transparent 18px, rgba(201,162,39,.035) 18px, rgba(201,162,39,.035) 19px);
  font-size: 13.5px;
  line-height: 1.55;
}
.bubble {
  max-width: 86%;
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.sys { background: #f4efe8; color: var(--ink-soft); font-size: 12.5px; max-width: 100%; }
.bubble.user { background: #efe6ff; margin-left: auto; }
.bubble.agent { background: #eef6ef; }
.bubble.tool { background: #f7f1e4; color: #6d5c3a; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
.bubble.err { background: var(--red-soft); color: var(--red); }
.bubble .who { display: block; font-size: 11px; font-weight: 700; margin-bottom: 4px; opacity: .7; }
.desk-compose {
  border-top: 1px solid var(--line);
  padding: 10px 14px 14px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.desk-gate { display: flex; gap: 8px; }
.desk-gate.ready { display: none; }
.desk-token, #desk-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  background: #fffdf9;
  color: var(--ink);
  resize: none;
}
.desk-unlock, .desk-send {
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  background: var(--gold);
  color: #fff;
  white-space: nowrap;
}
.desk-send:disabled, .desk-unlock:disabled { opacity: .45; cursor: not-allowed; }
.desk-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.desk-hint { font-size: 12px; color: var(--ink-faint); }

@media (max-width: 640px) {
  .brand-text h1 { font-size: 20px; }
  .clock { font-size: 21px; }
  .topbar-right { text-align: left; }
  .sessions { grid-template-columns: 1fr; }
  .desk { padding: 0; }
  .desk-panel { height: 100vh; border-radius: 0; }
}
