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

:root {
  --bg: #d4d0c8;
  --panel: #ece9d8;
  --border: #808080;
  --title-a: #0a246a;
  --title-b: #a6caf0;
  --text: #1a1a1a;
  --chat-bg: #ffffff;
}

body {
  font-family: Tahoma, "Segoe UI", Verdana, sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#topbar {
  background: linear-gradient(to right, var(--title-a), var(--title-b));
  color: #fff;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}
.logo { font-weight: bold; font-size: 15px; }
.status { font-size: 11px; opacity: .9; }
.model { font-size: 11px; margin-left: auto; opacity: .8; font-family: Consolas, monospace; }

#layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ---- canvas ---- */
#canvasWrap {
  flex: 1;
  position: relative;
  background: #555;
  overflow: hidden;
  cursor: grab;
}
#canvasWrap.dragging { cursor: grabbing; }
#board {
  position: absolute;
  image-rendering: pixelated;
  background: #fff;
  box-shadow: 0 0 20px rgba(0,0,0,.5);
}
#hoverInfo {
  position: absolute;
  background: #ffffe1;
  border: 1px solid #000;
  padding: 3px 6px;
  font-size: 11px;
  pointer-events: none;
  z-index: 5;
  white-space: nowrap;
}
#zoomHint {
  position: absolute;
  bottom: 8px;
  left: 8px;
  color: #ccc;
  font-size: 11px;
  z-index: 4;
}

/* ---- sidebar ---- */
#sidebar {
  flex: 0 0 320px;
  display: flex;
  flex-direction: column;
  border-left: 2px solid var(--border);
  background: var(--panel);
  min-height: 0;
}
.panel {
  display: flex;
  flex-direction: column;
  border-bottom: 2px solid var(--border);
  min-height: 0;
}
.panel.grow { flex: 1; }
.panel-title {
  background: linear-gradient(to right, var(--title-a), var(--title-b));
  color: #fff;
  font-weight: bold;
  font-size: 12px;
  padding: 4px 8px;
  flex: 0 0 auto;
}

/* buddy list */
#buddyPanel { flex: 0 0 auto; max-height: 42%; }
#buddyList {
  list-style: none;
  overflow-y: auto;
  background: var(--chat-bg);
}
#buddyList li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-bottom: 1px solid #eee;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #2bb52b; flex: 0 0 auto; }
.dot.thinking { background: #e5a000; animation: pulse 1s infinite; }
.dot.error { background: #cc2222; }
@keyframes pulse { 50% { opacity: .3; } }
.swatch { width: 10px; height: 10px; border: 1px solid #666; flex: 0 0 auto; }
.bname { font-weight: bold; }
.cooldown { margin-left: auto; font-size: 10px; color: #777; font-family: Consolas, monospace; }
.hbadge { font-size: 10px; background: #d8e4f8; border: 1px solid #9ab; border-radius: 3px; padding: 0 3px; color: #345; }

/* huddles */
#huddlePanel { flex: 0 0 auto; max-height: 25%; }
#huddleList { list-style: none; overflow-y: auto; background: var(--chat-bg); }
#huddleList li {
  padding: 4px 8px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}
#huddleList li:hover { background: #d8e4f8; }
#huddleList .hname { font-weight: bold; }
#huddleList .hmembers { font-size: 10px; color: #666; }
#huddleList .empty { color: #999; cursor: default; font-style: italic; }

/* chat */
#chatLog {
  flex: 1;
  overflow-y: auto;
  background: var(--chat-bg);
  padding: 4px 6px;
  font-size: 12px;
  line-height: 1.45;
}
.msg .from { font-weight: bold; }
.msg.system { color: #888; font-size: 11px; font-style: italic; }
.msg .time { color: #aaa; font-size: 10px; margin-right: 4px; }

/* huddle modal */
#huddleModal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.hidden { display: none !important; }
.modal-box {
  width: 440px;
  max-height: 70vh;
  background: var(--panel);
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 4px 0 rgba(0,0,0,.3);
}
.modal-head {
  background: linear-gradient(to right, var(--title-a), var(--title-b));
  color: #fff;
  font-weight: bold;
  padding: 5px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-head button {
  background: var(--panel);
  border: 1px solid #444;
  cursor: pointer;
  font-size: 11px;
  padding: 0 5px;
}
.modal-members { padding: 4px 8px; font-size: 11px; color: #555; border-bottom: 1px solid #ccc; }
#huddleModalLog {
  overflow-y: auto;
  background: var(--chat-bg);
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.5;
  min-height: 120px;
}
