/* ═══════════════════════════════════════════════════════════════════════════
   WBS Creator — Apple-inspired Minimal Theme
   Palette: black · white · grayscale only. No vibrant colors.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────────────
   CSS Variables — Light
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  /* Grayscale only */
  --app-bg:           #f5f5f7;
  --text:             #1d1d1f;
  --text-secondary:   #6e6e73;
  --text-muted:       #aeaeb2;

  /* Black is the accent */
  --accent-primary:       #1d1d1f;
  --accent-primary-hover: #000000;
  --accent-success:       #3a3a3c;
  --accent-warning:       #6e6e73;

  /* Panels */
  --panel-border:       #d2d2d7;
  --panel-shadow:       0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
  --panel-bg:           #ffffff;
  --panel-header-bg:    #ffffff;

  /* Sidebar */
  --sidebar-bg:     #1d1d1f;
  --sidebar-bg-2:   #1d1d1f;
  --sidebar-text:   rgba(255, 255, 255, 0.92);
  --sidebar-muted:  rgba(255, 255, 255, 0.50);
  --sidebar-border: rgba(255, 255, 255, 0.10);

  /* Layout */
  --navbar-height: 52px;

  /* Geometry */
  --border-radius-sm: 6px;
  --border-radius-md: 10px;
  --border-radius-lg: 12px;

  /* Motion */
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition: 0.18s var(--ease);
}

/* ─────────────────────────────────────────────────────────────────────────────
   CSS Variables — Dark
   ───────────────────────────────────────────────────────────────────────────── */
:root[data-theme="dark"],
:root[data-bs-theme="dark"] {
  --app-bg:           #000000;
  --text:             #f5f5f7;
  --text-secondary:   #aeaeb2;
  --text-muted:       #6e6e73;

  --accent-primary:       #f5f5f7;
  --accent-primary-hover: #ffffff;
  --accent-success:       #ebebed;

  --panel-border:       rgba(255, 255, 255, 0.12);
  --panel-shadow:       0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.2);
  --panel-bg:           #1d1d1f;
  --panel-header-bg:    #1d1d1f;

  --sidebar-bg:     #000000;
  --sidebar-bg-2:   #000000;
  --sidebar-text:   rgba(255, 255, 255, 0.92);
  --sidebar-muted:  rgba(255, 255, 255, 0.48);
  --sidebar-border: rgba(255, 255, 255, 0.10);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Base
   ───────────────────────────────────────────────────────────────────────────── */
html, body { height: 100%; margin: 0; }

*, *::before, *::after { box-sizing: border-box; }

body.app-shell {
  overflow: hidden;
  color: var(--text);
  background: var(--app-bg);
  font-family: -apple-system, "SF Pro Text", BlinkMacSystemFont, "Segoe UI",
               system-ui, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Login page
   ───────────────────────────────────────────────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--app-bg);
}

.login-card {
  width: 380px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-lg);
  padding: 40px 36px 36px;
  box-shadow: var(--panel-shadow);
}

.login-card .login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.login-card .login-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--text);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--panel-bg);
  font-size: 16px;
  flex-shrink: 0;
}

.login-card .login-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.2;
}

.login-card .login-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Navbar
   ───────────────────────────────────────────────────────────────────────────── */
.navbar {
  height: var(--navbar-height);
  min-height: var(--navbar-height);
  padding: 0 20px;
  background: var(--panel-bg) !important;
  border-bottom: 1px solid var(--panel-border);
  box-shadow: none;
}

.navbar .container-fluid { height: 100%; padding: 0; }

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text) !important;
  letter-spacing: -0.02em;
}

.brand-badge {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-sm);
  background: var(--text);
  color: var(--panel-bg);
  font-size: 14px;
  flex-shrink: 0;
}

.brand-badge--sm { width: 24px; height: 24px; border-radius: 5px; font-size: 12px; }

.navbar .btn-outline-secondary {
  padding: 4px 10px;
  font-size: 13px;
  border-color: var(--panel-border);
  color: var(--text-secondary);
  background: transparent;
  transition: all var(--transition);
}

.navbar .btn-outline-secondary:hover {
  background: var(--app-bg);
  border-color: var(--panel-border);
  color: var(--text);
}

.navbar .badge {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 9px;
  background: var(--app-bg) !important;
  color: var(--text-secondary) !important;
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-sm);
}

:root[data-theme="dark"] .navbar { background: var(--panel-bg) !important; }

/* Sidebar logo + controls (replaces top navbar) */
.sidebar-header { flex-direction: column; align-items: stretch; padding: 10px 12px 8px; gap: 6px; }
.sidebar-logo-row { display: flex; align-items: center; justify-content: space-between; }
.sidebar-logo { height: 20px; width: auto; opacity: 0.85; max-width: 110px; object-fit: contain; }
.sidebar-projects-row { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
.btn-icon {
  width: 26px; height: 26px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--panel-border); border-radius: var(--border-radius-sm);
  color: var(--text-secondary); background: transparent;
  font-size: 13px; transition: all var(--transition);
}
.btn-icon:hover { background: var(--app-bg); color: var(--text); }
:root[data-theme="dark"] .btn-icon { color: var(--text-secondary); border-color: var(--panel-border); }

/* Collapsed sidebar: hide logo and projects row — keep only toggle icon */
.app-grid.projects-collapsed .sidebar-logo { display: none; }
.app-grid.projects-collapsed .sidebar-logo-row { justify-content: center; }
.app-grid.projects-collapsed .sidebar-projects-row { display: none; }

/* ─────────────────────────────────────────────────────────────────────────────
   App Grid
   ───────────────────────────────────────────────────────────────────────────── */
.app-grid {
  display: grid;
  grid-template-columns: 160px 1fr 6px var(--chat-panel-width, 360px);
  grid-template-rows: minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

.app-grid.projects-collapsed {
  grid-template-columns: 52px 1fr 6px var(--chat-panel-width, 360px);
}

.app-grid.projects-collapsed .panel-left .panel-body { display: none; }
.app-grid.projects-collapsed .panel-left .panel-header {
  padding: 8px 6px;
  align-items: center;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Panel Resizer
   ───────────────────────────────────────────────────────────────────────────── */
.panel-resizer {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: col-resize;
  user-select: none;
  background: transparent;
  transition: background var(--transition);
  border-radius: 3px;
  margin: 0 -3px;
}

.panel-resizer:hover { background: rgba(0, 0, 0, 0.06); }
.panel-resizer.dragging { background: rgba(0, 0, 0, 0.10); }

.panel-resizer-handle {
  width: 3px;
  height: 36px;
  background: var(--panel-border);
  border-radius: 2px;
  transition: all var(--transition);
}

.panel-resizer:hover .panel-resizer-handle,
.panel-resizer.dragging .panel-resizer-handle {
  background: var(--text-secondary);
  height: 56px;
}

:root[data-theme="dark"] .panel-resizer:hover  { background: rgba(255,255,255,0.06); }
:root[data-theme="dark"] .panel-resizer.dragging { background: rgba(255,255,255,0.10); }

body.resizing { cursor: col-resize !important; user-select: none !important; }
body.resizing * { cursor: col-resize !important; user-select: none !important; }

/* ─────────────────────────────────────────────────────────────────────────────
   Panels
   ───────────────────────────────────────────────────────────────────────────── */
.panel {
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-lg);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-header {
  padding: 11px 16px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--panel-header-bg);
  flex: 0 0 auto;
}

.panel-header h2 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin: 0;
}

.panel-body {
  padding: 12px;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Left Panel — Sidebar (light)
   ───────────────────────────────────────────────────────────────────────────── */
.panel-left {
  background: #ffffff;
  border-color: var(--panel-border);
}

.panel-left .panel-header {
  background: #ffffff;
  border-bottom-color: var(--panel-border);
  color: var(--text);
}

.panel-left .panel-header h2 { color: var(--text-secondary); }

.panel-left .panel-header .btn-outline-light {
  --bs-btn-color: var(--text-secondary);
  --bs-btn-border-color: var(--panel-border);
  --bs-btn-hover-bg: var(--app-bg);
  --bs-btn-hover-border-color: var(--panel-border);
  padding: 4px 8px;
  font-size: 13px;
}

.panel-left .panel-body {
  color: var(--text);
  padding: 8px;
}

.panel-left .text-muted,
.panel-left .small,
.panel-left .opacity-75 { color: var(--text-muted) !important; }

/* cards inside sidebar */
.panel-left .card {
  background: var(--app-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-md);
  color: var(--text);
}

.panel-left .card-body { padding: 12px; }
.panel-left .card .fw-semibold { font-size: 12px; letter-spacing: 0.02em; color: var(--text-secondary); }

:root[data-theme="dark"] .panel-left {
  background: var(--panel-bg);
  border-color: var(--panel-border);
}
:root[data-theme="dark"] .panel-left .panel-header { background: var(--panel-bg); }
:root[data-theme="dark"] .panel-left .card { background: rgba(255,255,255,0.05); }

/* ─────────────────────────────────────────────────────────────────────────────
   Project List
   ───────────────────────────────────────────────────────────────────────────── */
.list-group { gap: 2px; display: flex; flex-direction: column; }

.list-group-item {
  border: none;
  border-radius: var(--border-radius-sm) !important;
  padding: 9px 12px;
  transition: background var(--transition);
}

/* sidebar items */
.panel-left .list-group-item {
  background: transparent;
  color: var(--text);
  border-left: 2px solid transparent;
}

.panel-left .list-group-item .small,
.panel-left .list-group-item .opacity-75 { color: var(--text-muted) !important; }

.panel-left .list-group-item:hover {
  background: var(--app-bg);
}

.panel-left .list-group-item.active {
  background: var(--app-bg);
  border-left-color: var(--text);
  color: var(--text);
  font-weight: 600;
}

.list-group-item .fw-semibold { font-size: 13px; font-weight: 500; }
.list-group-item .small { font-size: 11px; }

:root[data-theme="dark"] .list-group-item { background: transparent; color: var(--text); }
:root[data-theme="dark"] .list-group-item:hover { background: rgba(255,255,255,0.05); }
:root[data-theme="dark"] .list-group-item.active { background: rgba(255,255,255,0.08); }

/* ─────────────────────────────────────────────────────────────────────────────
   Center Panel — Tabs
   ───────────────────────────────────────────────────────────────────────────── */
.panel-center .panel-body {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 12px;
  min-height: 0;
}

.panel-center .panel-header { padding: 8px 16px; }

.panel-center .tab-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.nav-tabs {
  border-bottom: 1px solid var(--panel-border);
  padding: 0 16px;
  background: var(--panel-header-bg);
  gap: 0;
}

.nav-tabs .nav-link {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  transition: all var(--transition);
  letter-spacing: -0.01em;
}

.nav-tabs .nav-link:hover { color: var(--text); border-bottom-color: var(--panel-border); }

.nav-tabs .nav-link.active {
  color: var(--text);
  border-bottom-color: var(--text);
  background: transparent;
  font-weight: 600;
}

:root[data-theme="dark"] .nav-tabs { border-bottom-color: var(--panel-border); }
:root[data-theme="dark"] .nav-tabs .nav-link { color: var(--text-muted); }
:root[data-theme="dark"] .nav-tabs .nav-link:hover { color: var(--text); }
:root[data-theme="dark"] .nav-tabs .nav-link.active { color: var(--text); border-bottom-color: var(--text); }

/* Tab Panes */
.tab-pane.tab-pane-flex.active {
  display: flex !important;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.panel-center .tab-pane { min-height: 0; flex: 1 1 auto; }

/* Fix flex chain — estimation panel-body must be flex container */
#estimation-pane > .panel-body { display: flex; flex-direction: column; }

/* ─────────────────────────────────────────────────────────────────────────────
   Data Grid Shell
   ───────────────────────────────────────────────────────────────────────────── */
.table-shell {
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-md);
  overflow: hidden;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.table-shell--fill { flex: 1 1 auto; min-height: 0; }
.grid-host         { flex: 1 1 auto; min-height: 0; }

/* jspreadsheet heights are set via JS resizeGrid() — no CSS override here */

:root[data-theme="dark"] .table-shell {
  border-color: var(--panel-border);
  background: rgba(15, 15, 15, 0.6);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Jspreadsheet Customization
   ───────────────────────────────────────────────────────────────────────────── */
.jexcel, .jspreadsheet, .jss { font-size: 11px; font-family: inherit; }
.jss_container, .jss_content  { font-family: inherit; font-size: 11px; }

/* Force dark text on all cells */
#gridEstimation td, #gridEstimation th,
.jexcel td, .jexcel th,
.jspreadsheet td, .jspreadsheet th,
.jss td, .jss th { color: #1d1d1f !important; }

/* Default cell bg */
#gridEstimation tbody td, #gridEstimation .jss tbody td { background: #ffffff; }

/* Headers */
#gridEstimation thead td, #gridEstimation thead th,
.jexcel thead td, .jexcel thead th,
.jspreadsheet thead td, .jspreadsheet thead th,
.jss thead td, .jss thead th {
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6e6e73 !important;
  background: #f5f5f7 !important;
  border-bottom: 1px solid #d2d2d7 !important;
}

/* Cell padding */
.jexcel td, .jspreadsheet td, .jss td { padding: 4px 8px; vertical-align: middle; font-size: 11px; }

/* Epic row — Apple section header: very subtle gray divider */
#gridEstimation .jss tbody tr.row-epic td,
#gridEstimation .jexcel tbody tr.row-epic td,
tr.row-epic td {
  background-color: #f5f5f7 !important;
  color: #1d1d1f !important;
  font-weight: 700 !important;
  font-size: 11px !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
  border-top: 1px solid #1d1d1f !important;
  border-bottom: 1px solid #d2d2d7 !important;
}

#gridEstimation .jss tbody tr.row-epic:hover td { background-color: #ebebed !important; }

/* Subtotal row */
#gridEstimation .jss tbody tr.row-subtotal td,
#gridEstimation .jexcel tbody tr.row-subtotal td,
tr.row-subtotal td {
  background-color: #ebebed !important;
  color: #1d1d1f !important;
  font-weight: 600 !important;
  border-bottom: 1px solid #d2d2d7 !important;
}

#gridEstimation .jss tbody tr.row-subtotal:hover td { background-color: #e5e5ea !important; }

/* Read-only cells */
.table-shell .cell-readonly,
#gridEstimation .cell-readonly { background: #f5f5f7; color: #6e6e73; }

/* Row numbers */
#gridEstimation .jexcel_row, #gridEstimation .jss_row,
.jexcel_row, .jss_row {
  background: #f5f5f7 !important;
  color: #aeaeb2 !important;
  font-size: 11px; font-weight: 500; text-align: center;
  border-right: 1px solid #d2d2d7 !important;
}

#gridEstimation .jexcel_corner, #gridEstimation .jss_corner,
.jexcel_corner, .jss_corner {
  background: #f5f5f7 !important;
  border-right: 1px solid #d2d2d7 !important;
  border-bottom: 1px solid #d2d2d7 !important;
}

#gridEstimation table { table-layout: fixed; }
#gridEstimation td, #gridEstimation th { min-width: 50px; }

/* Sheet tabs */
.jss_tab, .jexcel_tab {
  font-size: 13px !important; font-weight: 500 !important;
  padding: 8px 16px !important;
  color: #6e6e73 !important;
  background: transparent !important;
  border: none !important;
  border-bottom: 2px solid transparent !important;
}

.jss_tab_selected, .jexcel_tab_selected,
.jss_tab.selected, .jexcel_tab.selected {
  color: #1d1d1f !important;
  border-bottom-color: #1d1d1f !important;
  background: transparent !important;
}

.jss_tabs, .jexcel_tabs {
  background: #ffffff !important;
  border-bottom: 1px solid #d2d2d7 !important;
  padding: 0 8px !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Dark Mode — Jspreadsheet Overrides
   ───────────────────────────────────────────────────────────────────────────── */
:root[data-theme="dark"] #gridEstimation td,
:root[data-theme="dark"] #gridEstimation th,
:root[data-theme="dark"] .jexcel td,
:root[data-theme="dark"] .jexcel th,
:root[data-theme="dark"] .jspreadsheet td,
:root[data-theme="dark"] .jspreadsheet th,
:root[data-theme="dark"] .jss td,
:root[data-theme="dark"] .jss th,
:root[data-theme="dark"] .jss_content { color: var(--text) !important; }

:root[data-theme="dark"] #gridEstimation tbody td,
:root[data-theme="dark"] #gridEstimation .jss tbody td { background: #1a1a1c; }

:root[data-theme="dark"] #gridEstimation thead td,
:root[data-theme="dark"] #gridEstimation thead th,
:root[data-theme="dark"] .jss thead td,
:root[data-theme="dark"] .jss thead th {
  background: #2c2c2e !important;
  color: #aeaeb2 !important;
  border-bottom: 1px solid rgba(255,255,255,0.1) !important;
}

:root[data-theme="dark"] .jexcel_row,
:root[data-theme="dark"] .jss_row {
  background: #2c2c2e !important;
  color: #6e6e73 !important;
  border-right: 1px solid rgba(255,255,255,0.1) !important;
}

:root[data-theme="dark"] .jexcel_corner,
:root[data-theme="dark"] .jss_corner {
  background: #2c2c2e !important;
  border-color: rgba(255,255,255,0.1) !important;
}

/* Epic / subtotal rows in dark mode (override inline styles from JS) */
:root[data-theme="dark"] tr.row-epic td,
:root[data-theme="dark"] #gridEstimation .jss tbody tr.row-epic td { background-color: #3b2068 !important; color: #c4b5fd !important; }
:root[data-theme="dark"] tr.row-subtotal td,
:root[data-theme="dark"] #gridEstimation .jss tbody tr.row-subtotal td { background-color: #1e3a5f !important; color: #93c5fd !important; }

:root[data-theme="dark"] .jss_tabs,
:root[data-theme="dark"] .jexcel_tabs {
  background: #1d1d1f !important;
  border-bottom: 1px solid rgba(255,255,255,0.1) !important;
}

:root[data-theme="dark"] .jss_tab,
:root[data-theme="dark"] .jexcel_tab { color: #aeaeb2 !important; }

:root[data-theme="dark"] .jss_tab_selected,
:root[data-theme="dark"] .jexcel_tab_selected,
:root[data-theme="dark"] .jss_tab.selected,
:root[data-theme="dark"] .jexcel_tab.selected {
  color: var(--text) !important;
  border-bottom-color: var(--text) !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Chat Panel — Collapsible
   ───────────────────────────────────────────────────────────────────────────── */
.app-grid.chat-collapsed { --chat-panel-width: 52px !important; }
.app-grid.chat-collapsed .panel-right .panel-body { display: none; }
.app-grid.chat-collapsed .panel-right .panel-header { padding: 8px; justify-content: center; }
.app-grid.chat-collapsed .panel-right .panel-header > div { justify-content: center; }
.app-grid.chat-collapsed .panel-right h2 { display: none; }
.app-grid.chat-collapsed #modelSelector { display: none; }
.app-grid.chat-collapsed .panel-resizer { pointer-events: none; opacity: 0; }

/* ─────────────────────────────────────────────────────────────────────────────
   Fullscreen — Grid
   ───────────────────────────────────────────────────────────────────────────── */
body.is-fullscreen .panel-left,
body.is-fullscreen .panel-right,
body.is-fullscreen .panel-resizer,
body.is-fullscreen .navbar { display: none !important; }

body.is-fullscreen .app-grid {
  grid-template-columns: 0 1fr 0 0 !important;
  padding: 4px !important;
}

body.is-fullscreen .panel-center {
  border-radius: 0 !important;
  grid-column: 1 / -1 !important;
  height: 100vh !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   SOW Tab — Toast UI overrides
   ───────────────────────────────────────────────────────────────────────────── */
/* SOW pane: make Toast UI fill the flex container */
#sowEditorContainer { display: flex; flex-direction: column; }
#sowEditorContainer .toastui-editor-defaultUI { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
#sowEditorContainer .toastui-editor-main { flex: 1 1 auto; min-height: 0; }
#sowEditorContainer .toastui-editor-ww-container,
#sowEditorContainer .toastui-editor-md-container { height: 100% !important; }

/* Dark mode for Toast UI */
:root[data-theme="dark"] .toastui-editor-defaultUI { background: var(--panel-bg); border-color: var(--panel-border); }
:root[data-theme="dark"] .toastui-editor-toolbar { background: var(--panel-bg); border-color: var(--panel-border); }
:root[data-theme="dark"] .toastui-editor-toolbar-icons { color: var(--text-secondary); }
:root[data-theme="dark"] .toastui-editor-ww-container,
:root[data-theme="dark"] .toastui-editor-md-container { background: var(--panel-bg); }
:root[data-theme="dark"] .ProseMirror,
:root[data-theme="dark"] .CodeMirror { background: var(--panel-bg) !important; color: var(--text) !important; }
:root[data-theme="dark"] .editor-toolbar { background: #2c2c2e; border-color: var(--panel-border); }
:root[data-theme="dark"] .editor-toolbar a { color: var(--text-secondary) !important; }
:root[data-theme="dark"] .editor-toolbar a:hover { color: var(--text) !important; background: rgba(255,255,255,0.05) !important; }
:root[data-theme="dark"] .editor-preview { background: #1a1a1c; color: var(--text); }

/* ─────────────────────────────────────────────────────────────────────────────
   Role chips in Project Details
   ───────────────────────────────────────────────────────────────────────────── */
#roleChips .badge { cursor: pointer; transition: all var(--transition); }
#roleChips .badge:hover { opacity: 0.8; }

/* ─────────────────────────────────────────────────────────────────────────────
   Right Panel — Chat
   ───────────────────────────────────────────────────────────────────────────── */
/* User bubble — top strip of the right panel */
.user-bubble {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-bottom: 1px solid var(--panel-border);
  font-size: 11px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.user-bubble-name {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-icon-xs {
  width: 22px; height: 22px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--panel-border); border-radius: var(--border-radius-sm);
  color: var(--text-secondary); background: transparent;
  font-size: 11px; transition: all var(--transition);
}
.btn-icon-xs:hover { background: var(--app-bg); color: var(--text); }
:root[data-theme="dark"] .btn-icon-xs { color: var(--text-secondary); border-color: var(--panel-border); }

/* Hide user bubble when chat is collapsed */
.app-grid.chat-collapsed .user-bubble { display: none; }

.panel-right .panel-header { padding: 11px 16px; }
.panel-right .panel-body   { padding: 12px; }

/* Messages container */
.chat-messages {
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-md);
  padding: 14px;
  min-height: 200px;
  background: var(--app-bg);
  overflow: auto;
}

:root[data-theme="dark"] .chat-messages {
  background: rgba(0, 0, 0, 0.3);
  border-color: var(--panel-border);
}

/* Bubbles */
.chat-msg { display: flex; margin-bottom: 10px; }
.chat-msg:last-child { margin-bottom: 0; }

.chat-msg .bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.chat-msg.user { justify-content: flex-end; }
.chat-msg.user .bubble {
  background: #1d1d1f;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

:root[data-theme="dark"] .chat-msg.user .bubble {
  background: #f5f5f7;
  color: #1d1d1f;
}

.chat-msg.assistant { justify-content: flex-start; }
.chat-msg.assistant .bubble {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-bottom-left-radius: 4px;
  white-space: normal;
}

.chat-msg.assistant .bubble p         { margin: 0 0 8px; }
.chat-msg.assistant .bubble p:last-child { margin-bottom: 0; }
.chat-msg.assistant .bubble ul        { margin: 6px 0 10px; padding-left: 18px; }

.chat-msg.assistant .bubble h1,
.chat-msg.assistant .bubble h2,
.chat-msg.assistant .bubble h3,
.chat-msg.assistant .bubble h4,
.chat-msg.assistant .bubble h5,
.chat-msg.assistant .bubble h6 { margin: 0 0 6px; font-weight: 600; letter-spacing: -0.01em; }

.chat-msg.assistant .bubble h1 { font-size: 15px; }
.chat-msg.assistant .bubble h2 { font-size: 14px; }
.chat-msg.assistant .bubble h3,
.chat-msg.assistant .bubble h4,
.chat-msg.assistant .bubble h5,
.chat-msg.assistant .bubble h6 { font-size: 13px; }

.chat-msg.assistant .bubble pre {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: var(--border-radius-md);
  background: var(--app-bg);
  overflow: auto;
  border: 1px solid var(--panel-border);
}

.chat-msg.assistant .bubble code {
  font-family: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

:root[data-theme="dark"] .chat-msg.assistant .bubble {
  background: rgba(29, 29, 31, 0.7);
  border-color: var(--panel-border);
  color: var(--text);
}

/* Chat input */
.input-group { gap: 8px; }

.input-group .form-control {
  border-radius: var(--border-radius-sm);
  border-color: var(--panel-border);
  font-size: 13px;
  padding: 8px 12px;
  background: var(--panel-bg);
  color: var(--text);
}

.input-group .form-control:focus {
  border-color: var(--text-secondary);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.input-group .btn-primary {
  border-radius: var(--border-radius-sm);
  padding: 8px 14px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Buttons — ALL grayscale
   ───────────────────────────────────────────────────────────────────────────── */
.btn {
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition);
  letter-spacing: -0.01em;
}

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Primary — solid black */
.btn-primary {
  background: #1d1d1f;
  border-color: #1d1d1f;
  color: #ffffff;
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
  background: #000000;
  border-color: #000000;
  color: #ffffff;
}
.btn-primary:focus {
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.12);
}

/* Outline primary → black border */
.btn-outline-primary {
  color: #1d1d1f;
  border-color: #d2d2d7;
  background: transparent;
}
.btn-outline-primary:hover {
  background: #1d1d1f;
  border-color: #1d1d1f;
  color: #ffffff;
}

/* Secondary */
.btn-secondary {
  background: #6e6e73;
  border-color: #6e6e73;
  color: #ffffff;
}
.btn-secondary:hover { background: #3a3a3c; border-color: #3a3a3c; }

/* Outline secondary → ghost */
.btn-outline-secondary {
  color: var(--text-secondary);
  border-color: var(--panel-border);
  background: transparent;
}
.btn-outline-secondary:hover {
  background: var(--app-bg);
  border-color: var(--panel-border);
  color: var(--text);
}

/* Success → dark gray */
.btn-success {
  background: #3a3a3c;
  border-color: #3a3a3c;
  color: #ffffff;
}
.btn-success:hover { background: #1d1d1f; border-color: #1d1d1f; }

.btn-outline-success {
  color: #3a3a3c;
  border-color: var(--panel-border);
  background: transparent;
}
.btn-outline-success:hover {
  background: #3a3a3c;
  border-color: #3a3a3c;
  color: #ffffff;
}

/* Info → medium gray */
.btn-outline-info {
  color: var(--text-secondary);
  border-color: var(--panel-border);
  background: transparent;
}
.btn-outline-info:hover {
  background: var(--app-bg);
  border-color: var(--panel-border);
  color: var(--text);
}

/* Outline light (sidebar) */
.btn-outline-light {
  --bs-btn-color: rgba(255,255,255,0.75);
  --bs-btn-border-color: rgba(255,255,255,0.14);
  --bs-btn-hover-bg: rgba(255,255,255,0.09);
  --bs-btn-hover-border-color: rgba(255,255,255,0.22);
}

/* Danger — keep subtle red for destructive actions */
.btn-outline-danger {
  color: #c0392b;
  border-color: var(--panel-border);
  background: transparent;
}
.btn-outline-danger:hover {
  background: #c0392b;
  border-color: #c0392b;
  color: #ffffff;
}

/* Focus ring — muted */
.btn:focus { box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08); }
:root[data-theme="dark"] .btn:focus { box-shadow: 0 0 0 3px rgba(255,255,255,0.12); }
:root[data-theme="dark"] .btn-primary { background: #f5f5f7; border-color: #f5f5f7; color: #1d1d1f; }
:root[data-theme="dark"] .btn-primary:hover { background: #ffffff; border-color: #ffffff; }

/* ─────────────────────────────────────────────────────────────────────────────
   Form Controls
   ───────────────────────────────────────────────────────────────────────────── */
.form-control {
  font-size: 13px;
  border-radius: var(--border-radius-sm);
  border-color: var(--panel-border);
  padding: 8px 12px;
  background: var(--panel-bg);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
  border-color: var(--text-secondary);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
  background: var(--panel-bg);
  color: var(--text);
}

.form-control-sm { padding: 6px 10px; font-size: 12px; }

.form-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

textarea.form-control { resize: vertical; min-height: 80px; }

:root[data-theme="dark"] .form-control {
  background: rgba(255,255,255,0.06);
  border-color: var(--panel-border);
  color: var(--text);
}
:root[data-theme="dark"] .form-control:focus {
  box-shadow: 0 0 0 3px rgba(255,255,255,0.08);
  border-color: var(--text-muted);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Badges
   ───────────────────────────────────────────────────────────────────────────── */
.badge {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.01em;
}

.badge.text-bg-light {
  background: var(--app-bg) !important;
  color: var(--text-secondary) !important;
  border: 1px solid var(--panel-border);
}

.badge.text-bg-secondary {
  background: var(--app-bg) !important;
  color: var(--text-secondary) !important;
  border: 1px solid var(--panel-border);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Cards
   ───────────────────────────────────────────────────────────────────────────── */
.card {
  border-color: var(--panel-border);
  background: var(--panel-bg);
  border-radius: var(--border-radius-md);
}

.card-header {
  background: var(--panel-bg) !important;
  border-bottom-color: var(--panel-border);
  font-size: 12px;
}

:root[data-theme="dark"] .card {
  background: rgba(255,255,255,0.04);
  border-color: var(--panel-border);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Modals
   ───────────────────────────────────────────────────────────────────────────── */
.modal-content {
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--panel-border);
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.14);
  background: var(--panel-bg);
}

.modal-header {
  padding: 20px 24px;
  border-bottom-color: var(--panel-border);
}

.modal-title { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.modal-body  { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top-color: var(--panel-border); }

/* ─────────────────────────────────────────────────────────────────────────────
   Utilities
   ───────────────────────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted) !important; }
.small      { font-size: 12px; }
.fw-semibold { font-weight: 500; }

hr { border-color: var(--panel-border); opacity: 1; margin: 12px 0; }

/* ─────────────────────────────────────────────────────────────────────────────
   Scrollbars
   ───────────────────────────────────────────────────────────────────────────── */
::-webkit-scrollbar             { width: 6px; height: 6px; }
::-webkit-scrollbar-track       { background: transparent; }
::-webkit-scrollbar-thumb       { background: rgba(0,0,0,0.14); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.24); }

:root[data-theme="dark"] ::-webkit-scrollbar-thumb       { background: rgba(255,255,255,0.14); }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.24); }

/* ─────────────────────────────────────────────────────────────────────────────
   Alerts
   ───────────────────────────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--border-radius-md);
  font-size: 13px;
  border: 1px solid;
}

.alert-warning {
  background: #fafafa;
  border-color: #d2d2d7;
  color: #6e6e73;
}

.alert-danger {
  background: #fff5f5;
  border-color: #fca5a5;
  color: #991b1b;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Input group
   ───────────────────────────────────────────────────────────────────────────── */
.input-group-text {
  background: var(--app-bg);
  border-color: var(--panel-border);
  color: var(--text-secondary);
  font-size: 13px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Evidence Drop Zone
   ───────────────────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 1.5px dashed var(--panel-border);
  border-radius: var(--border-radius-md);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: var(--app-bg);
  user-select: none;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.02);
}

.drop-zone .bi { font-size: 16px; color: var(--text-muted); flex-shrink: 0; transition: color var(--transition); }
.drop-zone:hover .bi, .drop-zone.drag-over .bi { color: var(--text-secondary); }
.drop-zone p { font-size: 12px; color: var(--text-secondary); margin: 0; }
.drop-zone .drop-zone-hint { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* Evidence file name link */
.ev-filename {
  font-size: 11px;
  font-weight: 600;
  color: var(--text) !important;
  text-decoration: none !important;
  display: block;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}
.ev-filename:hover { color: var(--bs-primary) !important; text-decoration: underline !important; }
.ev-date { font-size: 10px; color: var(--text-muted); margin-top: 1px; }

.drop-zone-file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  background: var(--app-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.drop-zone-file-row .bi-file-earmark { color: var(--text-secondary); font-size: 14px; }

@keyframes spin { to { transform: rotate(360deg); } }

:root[data-theme="dark"] .drop-zone { background: rgba(255,255,255,0.03); }
:root[data-theme="dark"] .drop-zone:hover, :root[data-theme="dark"] .drop-zone.drag-over { background: rgba(255,255,255,0.05); }

/* ─────────────────────────────────────────────────────────────────────────────
   Toolbar action buttons
   ───────────────────────────────────────────────────────────────────────────── */
.panel-header .d-flex.align-items-center.gap-2 .btn { padding: 5px 10px; }
.panel-header .d-flex.align-items-center.gap-2 .btn i { font-size: 12px; }

/* ─────────────────────────────────────────────────────────────────────────────
   Sidebar evidence file cards
   ───────────────────────────────────────────────────────────────────────────── */
.panel-left .border.rounded.p-2 {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1) !important;
  border-radius: var(--border-radius-sm) !important;
  padding: 10px !important;
}

.panel-left .border.rounded.p-2 .fw-semibold { font-size: 12px; color: var(--sidebar-text); text-transform: none; }
.panel-left .border.rounded.p-2 .text-muted   { font-size: 11px; }

/* ─────────────────────────────────────────────────────────────────────────────
   OpenSpec Tab
   ───────────────────────────────────────────────────────────────────────────── */
.openspec-yaml-editor {
  flex: 1 1 auto;
  resize: none;
  border: none;
  border-radius: 0;
  font-size: 12px;
  line-height: 1.6;
  min-height: 400px;
  tab-size: 2;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
.openspec-yaml-editor:focus { box-shadow: none; outline: none; }

.openspec-tech-category { margin-bottom: 10px; }
.openspec-tech-category .category-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

:root[data-theme="dark"] .openspec-yaml-editor {
  background: var(--card-bg);
  color: var(--text);
}

