﻿:root {
  --bg: #0f1218;
  --panel: #171c26;
  --panel-2: #1e2532;
  --line: #2a3344;
  --text: #e8edf6;
  --muted: #93a0b5;
  --accent: #4f8cff;
  --accent-2: #35d0a5;
  --danger: #ff6b6b;
  --warn: #ffb454;
  --ok: #35d0a5;
  --radius: 14px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #17233c 0%, var(--bg) 55%);
  color: var(--text);
  font: 15px/1.5 -apple-system, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
code { background: #0c1017; padding: 1px 6px; border-radius: 6px; font-size: 12.5px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: rgba(15, 18, 24, .72); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 10px; }
.logo-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 0 4px rgba(53, 208, 165, .15); }
.tag { font-size: 11px; font-weight: 500; color: var(--muted); border: 1px solid var(--line); padding: 1px 8px; border-radius: 999px; }
.topbar-right { display: flex; gap: 10px; align-items: center; }

main { padding: 22px; max-width: 1760px; margin: 0 auto; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.card.narrow { max-width: 420px; margin: 7vh auto; }
.card h1 { margin: 0 0 6px; font-size: 22px; }
.card h2, .card h3 { margin: 0; }

label { display: block; margin: 14px 0 0; font-size: 13px; color: var(--muted); }
input, select, textarea {
  width: 100%; margin-top: 6px; background: #0e131c; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,140,255,.15); }
textarea { resize: vertical; min-height: 64px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

button {
  font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); padding: 9px 14px;
}
button:hover { border-color: #3a4760; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; }
button.danger { border-color: rgba(255,107,107,.5); color: var(--danger); background: rgba(255,107,107,.08); }
button:disabled { opacity: .5; cursor: default; }
.wide { width: 100%; margin-top: 18px; padding: 11px; }

.error { color: var(--danger); min-height: 20px; margin: 10px 0 0; font-size: 13px; }

.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: stretch; }

.sidebar {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 10px; }
.sidebar-head h2 { font-size: 15px; }
.device-list { display: flex; flex-direction: column; gap: 8px; }
.device-card {
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel-2); cursor: pointer; transition: border-color .15s, transform .15s;
}
.device-card:hover { border-color: #3a4760; }
.device-card.active { border-color: var(--accent); background: rgba(79,140,255,.08); }
.device-card .name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.device-card .sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; display: flex; justify-content: space-between; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #55607a; flex: 0 0 auto; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(53,208,165,.15); }
.dot.released { background: var(--warn); }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.fingerprint { display: block; margin-top: 4px; word-break: break-all; color: var(--muted); }

.detail { min-height: 60vh; }
.detail-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.detail-title { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; }
.badge { font-size: 11px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.ok { color: var(--ok); border-color: rgba(53,208,165,.4); }
.badge.warn { color: var(--warn); border-color: rgba(255,180,84,.4); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 14px; }
.tabs button { padding: 7px 13px; font-size: 13.5px; }
.tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.grid { display: grid; gap: 12px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.tile { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.tile .k { color: var(--muted); font-size: 12.5px; }
.tile .v { font-size: 20px; font-weight: 700; margin-top: 4px; }
.tile .v.small { font-size: 15px; }

.section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-top: 14px; }
.section h3 { font-size: 15px; margin-bottom: 10px; }
.section .hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 0 0 auto; }
.row input, .row select { margin-top: 0; width: auto; }
.row .grow { flex: 1 1 120px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
td.mono, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.events { max-height: 520px; overflow: auto; }
.ev { padding: 8px 2px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; }
.ev .t { color: var(--muted); font-size: 12px; flex: 0 0 132px; }
.ev .ty { font-weight: 600; font-size: 13px; flex: 0 0 120px; }
.ev .pl { color: var(--muted); font-size: 12.5px; word-break: break-word; }

.day-windows { display: flex; flex-direction: column; gap: 6px; }
.day-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.day-row .day { width: 44px; color: var(--muted); font-size: 13px; }
.day-row input { width: 110px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #202a3a; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 16px; font-size: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.4); z-index: 99;
  max-width: 90vw;
}

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 20px; max-width: 520px; width: calc(100vw - 32px); }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog h3 { margin: 0 0 8px; }
dialog label { margin-top: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.empty { color: var(--muted); text-align: center; padding: 36px 10px; }
.warnbox { border: 1px solid rgba(255,180,84,.35); background: rgba(255,180,84,.07); border-radius: 12px; padding: 12px 14px; font-size: 13px; color: #ffd9a3; margin-top: 12px; }
.dangerbox { border: 1px solid rgba(255,107,107,.35); background: rgba(255,107,107,.06); border-radius: 12px; padding: 12px 14px; font-size: 13px; color: #ffc4c4; margin-top: 12px; }
.smallbtn { padding: 5px 10px; font-size: 12.5px; }

@media (max-width: 860px) {
  main { padding: 12px; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .device-list { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .device-card { min-width: 210px; }
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; }
  .ev { flex-wrap: wrap; }
  .ev .t, .ev .ty { flex: 1 1 auto; }
}

.media-thumb { max-width: 180px; max-height: 180px; border-radius: 8px; border: 1px solid var(--line); object-fit: cover; }
.submission { margin-bottom: 10px; }
.submission audio { max-width: 100%; }
.quote { margin-top: 8px; padding: 10px 12px; background: var(--bg); border-left: 3px solid var(--accent); border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; max-height: 320px; overflow-y: auto; font-size: 13px; color: var(--text); }
/* chat bubbles */
.chat-list { display:flex; flex-direction:column; gap:8px; margin:8px 0 10px; max-height:25vh; overflow-y:auto; padding-right:6px; }
.chat-row { display:flex; flex-direction:column; max-width:78%; }
.chat-row.in { align-self:flex-start; }
.chat-row.out { align-self:flex-end; align-items:flex-end; }
.chat-meta { font-size:12px; color:var(--muted); margin:0 6px 4px; }
.chat-bubble { background:#1e2635; border:1px solid #2c3648; color:#e8edf6; padding:10px 12px; border-radius:10px; }
.chat-row.out .chat-bubble { background:#2a4a86; border-color:#34589c; }
.ai-badge { display:inline-block; padding:0 5px; border-radius:4px; background:#3a3160; color:#c9b8ff; font-size:11px; }


.chat-section { display:flex; flex-direction:column; height:calc(100vh - 215px); min-height:460px; }
.chat-section .chat-list { flex:1 1 auto; max-height:none; }
.chat-spacer { flex:1 1 auto; min-height:0; }
.chat-section > label, .chat-section > .row { flex:0 0 auto; }

.sidebar-extra { margin-top:16px; border-top:1px solid var(--line); padding-top:12px; display:flex; flex-direction:column; gap:8px; font-size:13px; }
.side-stat { display:flex; justify-content:space-between; color:var(--muted); }
.side-stat b { color:var(--text); font-weight:600; }
.side-actions { display:flex; flex-wrap:wrap; gap:6px; margin-top:4px; }
.side-actions button { flex:1 1 30%; }
