/* 몬드리안 웹 — Modern Minimal */
:root {
  --red: #E8384F;
  --blue: #2D7FF9;
  --yellow: #FCB400;
  --black: #1B1B1B;
  --white: #FFFFFF;
  --bg: #FAFAFA;
  --gray-50: #F7F7F7;
  --gray-100: #EFEFEF;
  --gray-200: #E0E0E0;
  --gray-300: #C4C4C4;
  --gray-400: #999;
  --gray-600: #666;
  --border: 1px solid var(--gray-200);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --transition: 0.15s ease;
  --font-size: 14px; /* 기본 폰트 사이즈 */
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--black);
  overflow: hidden;
  font-size: var(--font-size);
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.container {
  display: flex;
  height: 100vh;
}

/* ── 몬드리안 악센트 ── */
.accent-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  display: flex;
  z-index: 100;
}
.accent-bar .r { flex: 4; background: var(--red); }
.accent-bar .b { flex: 3; background: var(--blue); }
.accent-bar .y { flex: 2; background: var(--yellow); }
.accent-bar .k { flex: 1; background: var(--black); }

/* ── Sidebar ── */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--white);
  border-right: var(--border);
  display: flex;
  flex-direction: column;
  padding-top: 3px; /* accent bar */
}

.sidebar-header {
  padding: 20px;
  display: block;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header h1 {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-400);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.mondrian-logo {
  display: flex;
  gap: 2px;
}
.mondrian-logo span {
  width: 8px;
  height: 8px;
  border-radius: 1px;
}

.workspace-switcher {
  margin-top: 14px;
}

.workspace-switcher label {
  display: block;
  margin-bottom: 5px;
  color: var(--gray-400);
  font-size: 10px;
  font-weight: 600;
}

.workspace-switcher select {
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: var(--border);
  border-radius: 4px;
  background: var(--gray-50);
  color: var(--black);
  font: inherit;
  font-size: 12px;
  outline: none;
}

.workspace-switcher select:focus {
  border-color: var(--blue);
  background: var(--white);
}

/* ── Sidebar Tabs ── */
.sidebar-tabs {
  display: flex;
  border-bottom: var(--border);
  padding: 0 12px;
  gap: 0;
}

.sidebar-tab {
  flex: 1;
  padding: 8px 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-400);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.sidebar-tab:hover {
  color: var(--gray-600);
}

.sidebar-tab.active {
  color: var(--black);
  border-bottom-color: var(--black);
}

.sidebar-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.sidebar-panel.active {
  display: flex;
  flex-direction: column;
}

.agent-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 12px;
}

/* ── File Browser (Jupyter-style) ── */
.file-panel {
  flex-direction: column;
}

.fb-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: var(--border);
  flex-shrink: 0;
}

.fb-tool-btn {
  width: 34px;
  height: 34px;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--gray-600);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.fb-tool-btn svg {
  display: block;
}

.fb-tool-btn:hover:not(:disabled) {
  background: var(--gray-100);
  color: var(--black);
}

.fb-tool-btn:active:not(:disabled) {
  background: var(--gray-200);
}

.fb-tool-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.fb-filter {
  padding: 6px 10px;
  border-bottom: var(--border);
  flex-shrink: 0;
}

.fb-filter input {
  width: 100%;
  height: 28px;
  padding: 0 10px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 12px;
  color: var(--black);
  font-family: var(--font);
  outline: none;
}

.fb-filter input:focus {
  border-color: var(--blue);
  background: var(--white);
}

.fb-filter input::placeholder {
  color: var(--gray-300);
}

.fb-breadcrumb {
  padding: 6px 10px;
  font-size: 12px;
  color: var(--gray-400);
  border-bottom: var(--border);
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.fb-crumb {
  cursor: pointer;
  color: var(--blue);
  transition: color var(--transition);
}

.fb-crumb:hover {
  color: var(--black);
  text-decoration: underline;
}

.fb-crumb-sep {
  color: var(--gray-300);
  margin: 0 1px;
}

.fb-table-header {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-600);
  border-bottom: var(--border);
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
}

.fb-col-name {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
}

.fb-col-modified {
  width: 100px;
  text-align: right;
  flex-shrink: 0;
}

.fb-sort-icon {
  font-size: 9px;
  color: var(--gray-400);
}

.fb-file-list {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.fb-empty {
  padding: 40px 20px;
  color: var(--gray-400);
  font-size: 12px;
  text-align: center;
}

.fb-item {
  display: flex;
  align-items: center;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
  color: var(--black);
  transition: background var(--transition);
  border-bottom: 1px solid var(--gray-50);
  gap: 8px;
}

.fb-item:hover {
  background: var(--gray-50);
}

.fb-item.selected {
  background: rgba(45, 127, 249, 0.1);
}

.fb-item-icon {
  font-size: 14px;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
  color: var(--gray-400);
}

.fb-item.dir .fb-item-icon {
  color: var(--blue);
}

.fb-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fb-item.dir .fb-item-name {
  color: var(--blue);
  font-weight: 600;
}

.fb-item-modified {
  width: 100px;
  text-align: right;
  font-size: 11px;
  color: var(--gray-400);
  flex-shrink: 0;
}

/* 체크박스 */
.fb-item-check {
  width: 14px;
  height: 14px;
  border: 1px solid var(--gray-300);
  border-radius: 3px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: transparent;
  transition: all var(--transition);
}

.fb-item.selected .fb-item-check {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--white);
}

/* 컨텍스트 메뉴 */
.fb-context-menu {
  position: fixed;
  z-index: 1000;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 4px;
  min-width: 180px;
  animation: ctxIn 0.1s ease;
}

@keyframes ctxIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.fb-ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--black);
  cursor: pointer;
  border-radius: 6px;
  transition: background var(--transition);
}

.fb-ctx-item:hover {
  background: var(--gray-50);
}

.fb-ctx-icon {
  font-size: 13px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.fb-ctx-separator {
  height: 1px;
  background: var(--gray-100);
  margin: 4px 8px;
}

/* 드래그 오버 */
.file-panel.drag-over {
  outline: 2px dashed var(--blue);
  outline-offset: -2px;
}

.file-panel.drag-over .fb-file-list {
  background: rgba(45, 127, 249, 0.03);
}

.agent-item {
  padding: 10px 12px;
  cursor: pointer;
  background: transparent;
  transition: all var(--transition);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius);
  margin-bottom: 2px;
  color: var(--gray-600);
}

.agent-item:hover {
  background: var(--gray-50);
  color: var(--black);
}

.agent-item.active {
  background: var(--black);
  color: var(--white);
}

.agent-item.active .agent-avatar {
  border-color: rgba(255,255,255,0.3);
}

.agent-avatar {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 11px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  background: var(--gray-100);
}

.agent-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.backend-header {
  padding: 8px 12px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-400);
  margin-top: 8px;
}

.backend-header:first-child {
  margin-top: 0;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-left: auto;
  flex-shrink: 0;
}

.status-dot.online {
  background: #34C759;
}

.status-dot.offline {
  background: var(--gray-300);
}

.loading {
  padding: 20px;
  color: var(--gray-400);
  font-size: 12px;
}

/* ── Chat Area ── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-width: 0;
  padding-top: 3px; /* accent bar */
}

.chat-workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

/* ── Weekly Planner ── */
.planner-view {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  background: var(--bg);
}

.planner-view[hidden], .chat-workspace[hidden] {
  display: none;
}

.planner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 12px 22px;
  border-bottom: var(--border);
  background: var(--white);
}

.planner-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.planner-title-row h2 {
  font-size: 15px;
}

.planner-title-row span {
  display: block;
  margin-top: 3px;
  color: var(--gray-400);
  font-size: 11px;
}

.planner-week-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.planner-week-controls button {
  min-width: 32px;
  height: 32px;
  padding: 0 9px;
  border: var(--border);
  border-radius: 4px;
  background: var(--white);
  color: var(--black);
  cursor: pointer;
  font-weight: 600;
}

.planner-week-controls button:hover {
  background: var(--gray-100);
}

.planner-quick-form {
  display: grid;
  grid-template-columns: 56px 132px minmax(240px, 1fr) 64px;
  align-items: start;
  gap: 7px;
  padding: 10px 16px;
  border-bottom: var(--border);
  background: var(--white);
}

.planner-quick-form input,
.planner-quick-form textarea,
.planner-quick-form select {
  width: 100%;
  height: 34px;
  padding: 0 8px;
  border: var(--border);
  border-radius: 4px;
  background: var(--gray-50);
  color: var(--black);
  font: inherit;
  font-size: 12px;
}

.planner-quick-form textarea {
  height: 76px;
  min-height: 76px;
  max-height: 150px;
  padding: 8px;
  resize: vertical;
  line-height: 1.45;
}

.planner-quick-form button {
  height: 34px;
  border: 0;
  border-radius: 4px;
  background: var(--yellow);
  color: var(--black);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.planner-progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: var(--border);
  background: var(--gray-50);
  color: var(--gray-600);
  font-size: 11px;
}

.planner-progress-track {
  width: 140px;
  height: 3px;
  background: var(--gray-200);
}

#plannerProgressFill {
  width: 0;
  height: 100%;
  background: var(--blue);
  transition: width var(--transition);
}

.planner-week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(156px, 1fr));
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--gray-200);
  gap: 1px;
}

.planner-day {
  min-width: 156px;
  min-height: 100%;
  background: var(--white);
}

.planner-day.is-today {
  box-shadow: inset 0 3px 0 var(--yellow);
}

.planner-day.is-weekend .planner-day-name {
  color: var(--red);
}

.planner-day-header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 11px 9px;
  border-bottom: var(--border);
  background: var(--white);
}

.planner-day-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-600);
}

.planner-day-number {
  margin-top: 2px;
  font-size: 22px;
  font-weight: 600;
}

.planner-day-count {
  float: right;
  margin-top: 5px;
  color: var(--gray-400);
  font-size: 10px;
  font-weight: 400;
}

.planner-day-items {
  min-height: 180px;
  padding: 7px;
}

.planner-item {
  display: grid;
  grid-template-columns: 20px 32px minmax(0, 1fr) 24px;
  align-items: start;
  gap: 4px;
  padding: 7px 3px;
  border-bottom: 1px solid var(--gray-100);
  cursor: grab;
}

.planner-item.dragging {
  opacity: 0.45;
}

.planner-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin-top: 2px;
}

.planner-priority {
  display: inline-flex;
  width: 30px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
}

.priority-a { background: var(--red); }
.priority-b { background: var(--blue); }
.priority-c { background: var(--gray-400); }

.planner-item-main {
  min-width: 0;
}

.planner-item-title {
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.35;
}

.planner-item.done .planner-item-title {
  color: var(--gray-400);
  text-decoration: line-through;
}

.planner-item-meta {
  margin-top: 3px;
  color: var(--gray-400);
  font-size: 9px;
}

.planner-item-edit {
  width: 23px;
  height: 23px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 15px;
}

.planner-item-edit:hover {
  background: var(--gray-100);
  color: var(--black);
}

.planner-day.drag-over {
  background: #EDF4FF;
}

.planner-day-empty {
  padding: 14px 5px;
  color: var(--gray-300);
  font-size: 10px;
  text-align: center;
}

.planner-sidebar {
  padding: 12px;
}

.planner-sidebar-section {
  padding: 8px 2px 14px;
  border-bottom: var(--border);
}

.planner-sidebar-section strong {
  display: block;
  margin-bottom: 10px;
  font-size: 11px;
}

.planner-sidebar-section p {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 7px 0;
  color: var(--gray-600);
  font-size: 10px;
}

.planner-sidebar-summary {
  padding: 13px 2px;
  color: var(--gray-400);
  font-size: 11px;
  line-height: 1.6;
}

.chat-header {
  padding: 16px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--white);
  border-bottom: var(--border);
}

.chat-header h2 {
  font-size: 14px;
  font-weight: 600;
}

.status {
  font-size: 11px;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gray-300);
}

.status.connected::before {
  background: #34C759;
}

/* ── Font Size Controls ── */
.font-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 16px;
}

.font-btn {
  width: 28px;
  height: 28px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.font-btn:hover {
  background: var(--gray-200);
  color: var(--black);
}

.font-btn:active {
  transform: scale(0.95);
}

.font-size-display {
  font-size: 11px;
  color: var(--gray-400);
  min-width: 32px;
  text-align: center;
}

/* ── Agent Tabs ── */
.agent-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 20px;
  background: var(--white);
  border-bottom: var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  min-height: 0;
}

.agent-tabs::-webkit-scrollbar { display: none; }

.agent-tabs:empty { display: none; }

/* 분할 종료 버튼 */
.exit-split-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 20px;
  padding: 5px 14px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  transition: all var(--transition);
  align-self: center;
}

.exit-split-btn:hover {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}

.agent-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-400);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  position: relative;
  flex-shrink: 0;
}

.agent-tab:hover {
  color: var(--gray-600);
  background: var(--gray-50);
}

.agent-tab.active {
  color: var(--black);
  border-bottom-color: var(--black);
}

.agent-tab .tab-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
}

.agent-tab .tab-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.agent-tab .tab-close {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--gray-300);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: all var(--transition);
}

.agent-tab:hover .tab-close {
  opacity: 1;
}

.agent-tab .tab-close:hover {
  background: var(--gray-200);
  color: var(--gray-600);
}

.agent-tab .tab-unread {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  flex-shrink: 0;
}

/* ── Messages ── */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  max-width: 72%;
  line-height: 1.65;
  font-size: var(--font-size);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
}

.message.assistant {
  align-self: flex-start;
}

.message-content {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message.user .message-content {
  background: var(--black);
  color: var(--white);
  padding: 10px 16px;
  border-radius: 16px 16px 4px 16px;
}

.message.assistant .message-content {
  background: var(--white);
  padding: 14px 18px;
  border-radius: 4px 16px 16px 16px;
  border: var(--border);
  box-shadow: var(--shadow-sm);
}

.message.streaming .message-content {
  border-color: var(--blue);
  border-left: 2px solid var(--blue);
}

/* ── Message Content Typography ── */
.message-content p {
  margin-bottom: 8px;
}
.message-content p:last-child {
  margin-bottom: 0;
}

.message-content pre {
  background: var(--gray-50);
  padding: 12px 14px;
  overflow-x: auto;
  border: 1px solid var(--gray-100);
  margin: 10px 0;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
}

.message-content code {
  font-family: var(--font-mono);
  font-size: 12px;
}

.message-content :not(pre) > code {
  background: var(--gray-50);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--red);
}

.message.user .message-content :not(pre) > code {
  background: rgba(255,255,255,0.15);
  color: var(--white);
}

.message-content ul, .message-content ol {
  margin-left: 18px;
  margin-bottom: 8px;
}

.message-content li {
  margin-bottom: 3px;
}

.message-content strong {
  font-weight: 600;
}

.message-content a {
  color: var(--blue);
  text-decoration: none;
}
.message-content a:hover {
  text-decoration: underline;
}

.message.user .message-content a {
  color: var(--yellow);
}

.message-content h1, .message-content h2, .message-content h3 {
  font-size: calc(var(--font-size) + 1px);
  font-weight: 600;
  margin: 10px 0 4px;
}

.message-content blockquote {
  border-left: 2px solid var(--gray-200);
  padding-left: 12px;
  color: var(--gray-600);
  margin: 8px 0;
}

.message-content table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 12px;
  width: 100%;
}

.message-content th, .message-content td {
  border: 1px solid var(--gray-200);
  padding: 6px 10px;
  text-align: left;
}

.message-content th {
  background: var(--gray-50);
  font-weight: 600;
}

.message-content hr {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: 12px 0;
}

.message-content img {
  max-width: 100%;
  border-radius: 6px;
}

/* Message Meta */
.message-meta {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
  padding: 0 2px;
}

.message.user .message-meta {
  text-align: right;
}

.typing-indicator {
  color: var(--blue);
  font-weight: 500;
}

.done-indicator {
  color: #34C759;
}

/* Cursor */
.cursor {
  display: inline-block;
  width: 2px;
  height: 14px;
  background: var(--blue);
  margin-left: 1px;
  vertical-align: text-bottom;
  animation: blink 0.8s infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* ── Input Area ── */
.input-area {
  padding: 16px 28px 20px;
  background: var(--bg);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.input-wrapper {
  flex: 1;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: 12px;
  display: flex;
  align-items: flex-end;
  padding: 4px;
  transition: border-color var(--transition);
  box-shadow: var(--shadow-sm);
}

.input-wrapper:focus-within {
  border-color: var(--black);
  box-shadow: var(--shadow-md);
}

#messageInput,
.chat-panel textarea {
  flex: 1;
  padding: 8px 12px;
  border: none;
  font-size: var(--font-size);
  font-family: var(--font);
  resize: none;
  background: transparent;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
  color: var(--black);
}

#messageInput:focus,
.chat-panel textarea:focus {
  outline: none;
}

#messageInput::placeholder,
.chat-panel textarea::placeholder {
  color: var(--gray-300);
}

#sendBtn,
.chat-panel .input-area > button {
  width: 36px;
  height: 36px;
  background: var(--black);
  color: var(--white);
  border: none;
  font-size: 16px;
  cursor: pointer;
  transition: all var(--transition);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#sendBtn:hover:not(:disabled),
.chat-panel .input-area > button:hover:not(:disabled) {
  background: var(--blue);
  transform: scale(1.05);
}

#sendBtn:disabled,
.chat-panel .input-area > button:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-300); }

/* ── Unread Badge ── */
.unread-badge {
  margin-left: auto;
  margin-right: 4px;
  background: var(--red);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  animation: badge-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.agent-item.active .unread-badge {
  background: var(--white);
  color: var(--black);
}
@keyframes badge-pop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

/* ── Loading Overlay ── */
.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(27, 27, 27, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10;
  animation: overlayIn 0.15s ease;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loading-spinner .mondrian-blocks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  width: 40px;
  height: 40px;
}

.loading-spinner .mondrian-blocks span {
  border-radius: 2px;
  animation: blockPulse 1.2s ease-in-out infinite;
}

.loading-spinner .mondrian-blocks span:nth-child(1) {
  background: var(--red);
  animation-delay: 0s;
}
.loading-spinner .mondrian-blocks span:nth-child(2) {
  background: var(--blue);
  animation-delay: 0.15s;
}
.loading-spinner .mondrian-blocks span:nth-child(3) {
  background: var(--yellow);
  animation-delay: 0.3s;
}
.loading-spinner .mondrian-blocks span:nth-child(4) {
  background: var(--black);
  animation-delay: 0.45s;
}

@keyframes blockPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

.loading-spinner .loading-text {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: 0.5px;
}

/* ── Load More Trigger ── */
.load-more-trigger {
  text-align: center;
  padding: 12px;
  color: var(--gray-400);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.load-more-trigger:hover {
  color: var(--blue);
}

/* ── Subtask Items ── */
.subtask-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 28px;
  font-size: 12px;
  color: var(--gray-500);
  flex-wrap: wrap;
}
.subtask-icon {
  font-size: 10px;
}
.subtask-label {
  font-weight: 600;
  color: var(--gray-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.subtask-meta {
  font-size: 11px;
  color: var(--gray-400);
  white-space: nowrap;
}
.subtask-bar {
  flex: 1;
  min-width: 40px;
  height: 3px;
  background: var(--gray-200);
  border-radius: 2px;
  overflow: hidden;
}
.subtask-bar-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 2px;
  transition: width 0.3s;
}

/* ===== 첨부 이미지 ===== */
.attachment-preview {
  display: flex;
  gap: 8px;
  padding: 8px 12px 0;
  flex-wrap: wrap;
}
.attachment-thumb {
  position: relative;
  width: 80px;
  height: 80px;
  border: 2px solid var(--black);
  overflow: hidden;
}
.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.attachment-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  background: var(--red);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 12px;
  line-height: 20px;
  padding: 0;
}
.attachment-remove:hover {
  background: #c00;
}

.attach-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.attach-btn:hover {
  opacity: 1;
}

/* 메시지 내 이미지 */
.message-images {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.message-image {
  max-width: 200px;
  max-height: 200px;
  object-fit: contain;
  border: 1px solid var(--gray-200);
  cursor: pointer;
}
.message-image:hover {
  opacity: 0.9;
}

/* 드래그 오버 */
.chat-area.drag-over {
  outline: 3px dashed var(--blue);
  outline-offset: -3px;
}

/* ===== Split View (분할 뷰) ===== */
.split-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.split-row, .split-col {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.split-row {
  flex-direction: row;
}

.split-col {
  flex-direction: column;
}

.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--bg);
  position: relative;
}

.chat-panel-header {
  padding: 8px 16px;
  background: var(--white);
  border-bottom: var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  transition: all var(--transition);
}

/* 활성 패널 */
.chat-panel.panel-active .chat-panel-header {
  background: var(--black);
  color: var(--white);
  border-bottom-color: var(--black);
}

.chat-panel.panel-active .chat-panel-close {
  color: rgba(255,255,255,0.5);
}

.chat-panel.panel-active .chat-panel-close:hover {
  background: rgba(255,255,255,0.15);
  color: var(--white);
}

/* 비활성 패널 */
.chat-panel.panel-inactive {
  opacity: 0.85;
}

.chat-panel.panel-inactive .chat-panel-header {
  background: var(--gray-50);
  color: var(--gray-600);
}

.panel-title-sub {
  font-weight: 400;
  opacity: 0.6;
  font-size: 11px;
}

.chat-panel-close {
  width: 20px;
  height: 20px;
  background: transparent;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.chat-panel-close:hover {
  background: var(--gray-100);
  color: var(--gray-600);
}

.resizer {
  background: var(--black);
  z-index: 10;
  position: relative;
}

.resizer-horizontal {
  width: 2px;
  cursor: col-resize;
  min-width: 2px;
}

.resizer-vertical {
  height: 2px;
  cursor: row-resize;
  min-height: 2px;
}

.resizer:hover {
  background: var(--blue);
}

.resizer.resizing {
  background: var(--blue);
}

/* 드롭 존 */
.drop-zone {
  position: absolute;
  background: rgba(45, 127, 249, 0.15);
  border: 2px dashed var(--blue);
  z-index: 100;
  pointer-events: none;
  transition: opacity 0.15s;
}

.drop-zone.active {
  background: rgba(45, 127, 249, 0.25);
}

/* 탭 드래그 */
.agent-tab.dragging {
  opacity: 0.5;
}

/* 분할 드롭 가이드 */
.split-drop-guide {
  position: absolute;
  z-index: 50;
  pointer-events: none;
  background: rgba(45, 127, 249, 0.12);
  border: 2px dashed var(--blue);
  border-radius: 4px;
  transition: opacity 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.split-drop-guide::after {
  content: attr(data-label);
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  background: rgba(255,255,255,0.9);
  padding: 4px 12px;
  border-radius: 4px;
}

.split-drop-guide.active {
  background: rgba(45, 127, 249, 0.25);
}

/* 전체 드롭 오버레이 (단일 패널일 때 중앙) */
.split-drop-center {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(45, 127, 249, 0.08);
  border: 2px dashed var(--blue);
  border-radius: 4px;
}

.split-drop-center::after {
  content: '여기에 놓아서 분할';
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
  background: rgba(255,255,255,0.95);
  padding: 8px 20px;
  border-radius: 6px;
  box-shadow: var(--shadow-md);
}

/* 서브태스크 상태 */
.subtask-idle { opacity: 0.5; }
.subtask-done { opacity: 0.4; }

/* 토큰 증가 중 — 펄스 애니메이션 */
.subtask-pulse {
  animation: subtaskPulse 1.5s ease-in-out infinite;
}

@keyframes subtaskPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; color: var(--red); }
}

/* ── Panel-Integrated Dashboard ── */
.panel-with-dashboard {
  display: flex;
  flex: 1;
  min-height: 0;
}

.panel-chat-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.panel-dashboard-column {
  width: 300px;
  min-width: 260px;
  background: var(--white);
  border-right: var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
}

.panel-dashboard-column.hidden {
  display: none;
}

.dashboard-header {
  padding: 12px 16px;
  border-bottom: 3px solid var(--black);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--black);
  color: var(--white);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 5;
}

.dashboard-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.dashboard-updated {
  font-size: 9px;
  color: rgba(255,255,255,0.5);
}

.dash-toggle-inline {
  width: 28px;
  height: 28px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.dash-toggle-inline:hover {
  background: var(--gray-200);
}

.dash-toggle-inline.active {
  background: var(--black);
  border-color: var(--black);
}

.dashboard-content {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  flex: 1;
}

.dashboard-empty {
  color: var(--gray-400);
  font-size: 12px;
  text-align: center;
  padding: 60px 20px;
  font-style: italic;
}

/* ── Dashboard Widgets ── */
.dash-widget {
  background: var(--white);
  border-bottom: 3px solid var(--black);
  padding: 0;
  overflow: hidden;
  position: relative;
}

.dash-widget:last-child {
  border-bottom: none;
}

.dash-widget-header {
  padding: 10px 16px;
  color: var(--white);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  position: relative;
}

.dash-widget-body {
  padding: 14px 16px;
}

/* Widget: text */
.dash-text {
  font-size: 13px;
  line-height: 1.7;
  color: var(--black);
}

/* Widget: kv */
.dash-kv {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.dash-kv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
}

.dash-kv-row:last-child {
  border-bottom: none;
}

.dash-kv-key {
  color: var(--gray-600);
  font-weight: 500;
  font-size: 11px;
}

.dash-kv-value {
  color: var(--black);
  font-weight: 700;
  text-align: right;
  font-size: 12px;
}

/* Widget: progress */
.dash-progress-bar {
  height: 10px;
  background: var(--gray-100);
  border-radius: 0;
  overflow: hidden;
  margin-top: 8px;
  border: 2px solid var(--black);
}

.dash-progress-fill {
  height: 100%;
  background: var(--blue);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.dash-progress-label {
  font-size: 28px;
  font-weight: 900;
  color: var(--black);
  display: block;
  margin-bottom: 2px;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}

/* Widget: list */
.dash-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dash-list li {
  padding: 7px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.5;
}

.dash-list li:last-child {
  border-bottom: none;
}

.dash-list li::before {
  content: '';
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  margin-top: 4px;
}

/* 리스트 아이템 색상 순환: 빨 → 파 → 노 */
.dash-list li:nth-child(3n+1)::before { background: var(--red); }
.dash-list li:nth-child(3n+2)::before { background: var(--blue); }
.dash-list li:nth-child(3n+3)::before { background: var(--yellow); }

.dash-list.ordered li::before {
  content: none;
  display: none;
}

.dash-list.ordered {
  list-style: decimal;
  padding-left: 20px;
}

.dash-list.ordered li {
  padding-left: 4px;
}

/* Widget: table */
.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.dash-table th {
  background: var(--black);
  color: var(--white);
  padding: 8px 10px;
  text-align: left;
  font-weight: 700;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dash-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--gray-100);
}

.dash-table tr:hover td {
  background: var(--gray-50);
}

/* Widget: chart (bar) */
.dash-chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 100px;
  padding-top: 8px;
}

.dash-chart-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
}

.dash-chart-bar-fill {
  width: 100%;
  min-height: 2px;
  transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px solid var(--black);
}

.dash-chart-bar:nth-child(3n+1) .dash-chart-bar-fill { background: var(--red); }
.dash-chart-bar:nth-child(3n+2) .dash-chart-bar-fill { background: var(--blue); }
.dash-chart-bar:nth-child(3n+3) .dash-chart-bar-fill { background: var(--yellow); }

.dash-chart-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--gray-600);
  text-align: center;
}

.dash-chart-value {
  font-size: 10px;
  font-weight: 800;
  color: var(--black);
}

/* 몬드리안 위젯 헤더 색상 패턴 — 비대칭 균형 */
.dash-widget:nth-child(4n+1) .dash-widget-header { background: var(--red); }
.dash-widget:nth-child(4n+2) .dash-widget-header { background: var(--black); }
.dash-widget:nth-child(4n+3) .dash-widget-header { background: var(--blue); }
.dash-widget:nth-child(4n+4) .dash-widget-header { background: var(--yellow); color: var(--black); }

/* 스크롤바 (대시보드) */
.panel-dashboard-column::-webkit-scrollbar { width: 4px; }
.panel-dashboard-column::-webkit-scrollbar-track { background: transparent; }
.panel-dashboard-column::-webkit-scrollbar-thumb { background: var(--gray-200); }
.panel-dashboard-column::-webkit-scrollbar-thumb:hover { background: var(--gray-300); }

/* 토큰 변화량 표시 */
.token-delta {
  color: var(--red);
  font-weight: bold;
  margin-left: 4px;
  animation: deltaFlash 0.5s ease-out;
}

@keyframes deltaFlash {
  0% { opacity: 0; transform: translateY(-4px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════
   모바일 반응형
   ══════════════════════════════════════════ */

/* 햄버거 버튼 (데스크탑에선 숨김) */
.menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--black);
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background var(--transition);
}

.menu-toggle:hover {
  background: var(--gray-100);
}

/* 사이드바 오버레이 배경 */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 199;
  -webkit-tap-highlight-color: transparent;
}

/* ── 태블릿 (≤900px): 사이드바 좁히기 + 패딩 줄이기 ── */
@media (max-width: 900px) {
  .sidebar {
    width: 220px;
    min-width: 220px;
  }

  .messages {
    padding: 16px 20px;
  }

  .input-area {
    padding: 12px 16px 16px;
  }

  .chat-header {
    padding: 12px 16px;
  }

  .message {
    max-width: 85%;
  }

  /* 대시보드 패널 좁히기 */
  .panel-dashboard-column {
    width: 240px;
    min-width: 200px;
  }
}

/* ── 모바일 (≤768px): 사이드바 오버레이 전환 ── */
@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    min-width: 280px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  }

  .sidebar-overlay.visible {
    display: block;
  }

  /* 핵심: 모바일 레이아웃 높이 보장 */
  body {
    height: 100vh;
    height: 100dvh; /* iOS Safari 동적 뷰포트 */
  }

  .container {
    height: 100vh;
    height: 100dvh;
  }

  .chat-area {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .planner-header {
    min-height: 58px;
    padding: 10px 12px;
  }

  .planner-quick-form {
    grid-template-columns: 48px 1fr 56px;
    padding: 8px;
  }

  .planner-quick-form #plannerDate {
    display: none;
  }

  .planner-week-grid {
    grid-template-columns: repeat(7, minmax(220px, 85vw));
    scroll-snap-type: x proximity;
  }

  .planner-day {
    scroll-snap-align: start;
  }

  .split-container {
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  .panel-with-dashboard {
    height: 100%;
  }

  .panel-chat-column {
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .chat-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 12px;
    gap: 12px;
  }

  .input-area {
    flex-shrink: 0;
    padding: 8px 10px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
    background: var(--bg);
    border-top: var(--border);
  }

  .message {
    max-width: 92%;
  }

  .message.user .message-content {
    padding: 8px 12px;
  }

  .message.assistant .message-content {
    padding: 10px 14px;
  }

  .chat-header {
    flex-shrink: 0;
    padding: 10px 14px;
    gap: 8px;
  }

  .chat-header h2 {
    font-size: 13px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* 폰트 컨트롤 숨기기 (모바일에서 공간 절약) */
  .font-controls {
    display: none;
  }

  /* 대시보드 패널: 모바일에서는 숨기기 */
  .panel-dashboard-column {
    display: none !important;
  }

  /* 에이전트 탭 스크롤 */
  .agent-tabs {
    flex-shrink: 0;
    padding: 0 10px;
  }

  .agent-tab {
    padding: 6px 10px;
    font-size: 11px;
  }

  /* 분할 뷰 비활성화 — 모바일에서 한 패널만 */
  .split-row {
    flex-direction: column;
  }

  .resizer-horizontal {
    display: none;
  }
}

/* ── 작은 모바일 (≤480px) ── */
@media (max-width: 480px) {
  .message {
    max-width: 96%;
  }

  .messages {
    padding: 10px 8px;
    gap: 10px;
  }

  .input-area {
    padding: 6px 8px 10px;
  }

  .chat-header {
    padding: 8px 10px;
  }

  .message-content pre {
    font-size: 11px;
    padding: 8px 10px;
  }

  .agent-tab .tab-avatar {
    display: none;
  }
}

/* Hermes per-session controls */
.stop-btn { background: var(--red); color: var(--white); border: 3px solid var(--black); cursor: pointer; min-width: 44px; }
.stop-btn[hidden] { display: none; }
.chat-progress { font-size: 12px; color: var(--blue); padding: 0 12px; min-height: 18px; }
textarea:disabled { opacity: .7; }
