* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: #1a1a1a;
  color: #e0e0e0;
  padding: 10px;
}

.container {
  max-width: 100%;
  margin: 0;
}

/* ─── Modern Toolbar ─────────────────────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #222;
  padding: 6px 12px;
  border-radius: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.toolbar-title {
  font-weight: 700;
  font-size: 0.95em;
  color: #4a9eff;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid #333;
  border-radius: 4px;
  padding: 3px 10px;
}

.toolbar-github {
  text-decoration: none;
  font-size: 0.75em;
  color: #888;
  margin-left: auto;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid #333;
  border-radius: 4px;
  padding: 3px 10px;
}

.toolbar-github:hover {
  color: #4a9eff;
}

.toolbar-actions {
  display: flex;
  align-items: stretch;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}

.toolbar-section {
  display: flex;
  align-items: center;
  gap: 3px;
  position: relative;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid #333;
  border-radius: 4px;
  padding: 3px 6px;
  flex: 1;
}

.toolbar-section-fixed {
  flex: 0 0 auto;
}

.toolbar-section-label {
  font-size: 0.6em;
  font-weight: 700;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 2px;
  white-space: nowrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 3px;
  position: relative;
}

.toolbar-sep {
  display: none;
}

.toolbar-btn {
  padding: 5px 9px;
  background: #333;
  color: #ccc;
  border: 1px solid #444;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.72em;
  white-space: nowrap;
  transition: background 0.15s;
}

.toolbar-btn:hover {
  background: #444;
  color: #fff;
}

/* Copy Bank Popover */
.toolbar-copy-bank {
  position: relative;
}

.copy-bank-popover {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: #2a2a2a;
  border: 1px solid #555;
  border-radius: 6px;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.copy-bank-popover label {
  font-size: 0.72em;
  color: #aaa;
}

.copy-bank-popover input {
  width: 44px;
  padding: 3px 4px;
  background: #1a1a1a;
  color: #e0e0e0;
  border: 1px solid #555;
  border-radius: 3px;
  font-size: 0.78em;
}

.popover-go {
  padding: 3px 10px;
  background: #4a9eff;
  color: #fff;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.72em;
  font-weight: 600;
}

.popover-go:hover {
  background: #3a8eef;
}

/* Channel count control in toolbar */
.toolbar .channel-display-control {
  display: flex;
  align-items: center;
  gap: 3px;
}

.toolbar .channel-display-control label {
  font-size: 0.72em;
  color: #888;
}

.toolbar .channel-display-control input {
  width: 42px;
  padding: 3px 4px;
  background: #1a1a1a;
  color: #e0e0e0;
  border: 1px solid #444;
  border-radius: 3px;
  font-size: 0.78em;
}

input[type="file"] {
  padding: 10px;
  background: #3a3a3a;
  color: #e0e0e0;
  border: 1px solid #4a4a4a;
  border-radius: 4px;
  cursor: pointer;
}

.scene-display {
  background: #2a2a2a;
  padding: 10px;
  border-radius: 8px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

th,
td {
  padding: 0px 6px;
  text-align: center;
  border: 1px solid #3a3a3a;
}

th {
  background: #3a3a3a;
  color: #4a9eff;
  font-weight: 600;
  position: sticky;
  top: 0;
}

.channel-label {
  background: #333;
  color: #aaa;
  font-weight: 500;
  font-size: 0.9em;
  padding: 4px 2px;
}

td.value {
  background: #2a2a2a;
  font-family: "Courier New", monospace;
}

td.value.active {
  background: #1a4d2e;
  color: #4ade80;
  font-weight: 600;
}

.empty-scene {
  padding: 40px;
  text-align: center;
  color: #666;
  font-style: italic;
}

.error {
  background: #4a1a1a;
  color: #ff6b6b;
  padding: 15px;
  border-radius: 4px;
  margin-bottom: 20px;
}

.scanner-header {
  background: #444;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
  min-width: 40px;
  max-width: 40px;
  width: 40px;
  padding: 8px 4px;
  font-weight: bold;
  font-size: 0.9em;
}

.scanner-header:hover {
  background: #555;
}

.scanner-header.selected {
  background: #2a5a8a;
}

.copy-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #444;
}

.copy-controls .copy-label {
  font-size: 0.8em;
  color: #4a9eff;
  font-weight: 600;
  white-space: nowrap;
}

.copy-row {
  display: flex;
  gap: 4px;
  align-items: center;
}

.copy-row label {
  font-size: 0.75em;
  color: #aaa;
  min-width: 35px;
}

.copy-row input {
  flex: 1;
  padding: 4px;
  background: #2a2a2a;
  color: #e0e0e0;
  border: 1px solid #4a4a4a;
  border-radius: 3px;
  font-size: 0.8em;
}

.copy-row button {
  padding: 4px 8px;
  background: #4a9eff;
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.75em;
  font-weight: 600;
}

.copy-row button:hover {
  background: #3a8eef;
}

.copy-row button:active {
  background: #2a7edf;
}

.slider-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 5px;
  gap: 3px;
}

.slider-value {
  font-family: "Courier New", monospace;
  font-size: 0.85em;
  font-weight: 600;
  color: #888;
  min-width: 30px;
  text-align: center;
}

.slider-value.active {
  color: #4ade80;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #3a3a3a;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #4a9eff;
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #4a9eff;
  cursor: pointer;
  border: none;
}

input[type="range"].active {
  background: linear-gradient(
    to right,
    #1a4d2e 0%,
    #1a4d2e calc(var(--value) * (100% - 14px) + 7px),
    #3a3a3a calc(var(--value) * (100% - 14px) + 7px),
    #3a3a3a 100%
  );
}

input[type="range"].active::-webkit-slider-thumb {
  background: #4ade80;
}

input[type="range"].active::-moz-range-thumb {
  background: #4ade80;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}

.action-buttons button {
  padding: 8px 12px;
  background: #3a3a3a;
  color: #e0e0e0;
  border: 1px solid #4a4a4a;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75em;
  white-space: nowrap;
}

.action-buttons button:hover {
  background: #4a4a4a;
}

.dmx-btn {
  background: #2a6e2a !important;
  border-color: #3a8e3a !important;
  color: #fff !important;
}

.dmx-btn:hover {
  background: #3a8e3a !important;
}

.dmx-btn.dmx-active {
  background: #cc3333 !important;
  border-color: #ee4444 !important;
  animation: dmx-pulse 1.2s ease-in-out infinite;
}

@keyframes dmx-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.dmx-mode-btn {
  background: #3a3a5a !important;
  border-color: #5a5a8a !important;
  color: #aac !important;
  font-size: 0.7em !important;
}

.dmx-mode-btn:hover {
  background: #4a4a6a !important;
}

.action-buttons button.primary {
  background: #4a9eff;
  border-color: #4a9eff;
}

.action-buttons button.primary:hover {
  background: #3a8eef;
}

/* AI Agent button */
.ai-btn {
  background: #1a4a3a !important;
  border-color: #2a7a5a !important;
  color: #4ade80 !important;
}

.ai-btn:hover {
  background: #2a5a4a !important;
}

.ai-btn.ai-active {
  background: #2a7a5a !important;
  border-color: #4ade80 !important;
  color: #fff !important;
}

.empty-indicator {
  color: #ff6b6b;
  font-size: 0.85em;
  font-style: italic;
}

.attr-select {
  cursor: pointer;
  font-weight: 600;
  text-align: center;
}

.attr-select:focus {
  outline: 2px solid #4a9eff;
}

.channel-label span {
  display: block;
  margin-top: 2px;
  font-weight: normal;
}

/* 2D Pan/Tilt Pad */
.pantilt-cell {
  width: 70px;
  height: 70px;
  position: relative;
}

.pantilt-pad {
  width: 62px;
  height: 62px;
  background: #2a2a2a;
  border: 2px solid #4a4a4a;
  border-radius: 4px;
  position: relative;
  cursor: crosshair;
}

.pantilt-pad::after {
  content: "";
  position: absolute;
  inset: -10px;
  z-index: 999;
  display: none;
}

.pantilt-pad:hover::after {
  display: block;
}

.pantilt-pad-overlay {
  display: none;
  position: absolute;
  width: 200px;
  height: 200px;
  background: #2a2a2a;
  border: 2px solid #4a9eff;
  border-radius: 4px;
  cursor: crosshair;
  z-index: 1000;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
}

.pantilt-pad:hover ~ .pantilt-pad-overlay,
.pantilt-pad-overlay:hover {
  display: block;
}

.pantilt-crosshair {
  position: absolute;
  width: 1px;
  height: 100%;
  background: #666;
  left: 50%;
  top: 0;
}

.pantilt-crosshair.horizontal {
  width: 100%;
  height: 1px;
  left: 0;
  top: 50%;
}

.pantilt-position {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #4a9eff;
  border: 2px solid #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.pantilt-pad-overlay .pantilt-position {
  width: 14px;
  height: 14px;
  background: #4ade80;
}

.pantilt-label {
  font-size: 0.7em;
  color: #888;
  margin-top: 2px;
  text-align: center;
}

/* Preset Dropdown */
.preset-dropdown {
  width: 100%;
  padding: 4px;
  background: #3a3a3a;
  color: #e0e0e0;
  border: 1px solid #4a4a4a;
  border-radius: 3px;
  font-size: 0.8em;
  cursor: pointer;
  text-align: center;
}

.preset-dropdown:hover {
  border-color: #4a9eff;
}

.preset-dropdown:focus {
  outline: 2px solid #4a9eff;
  border-color: #4a9eff;
}

.preset-dropdown.active {
  background: #1a4d2e;
  color: #4ade80;
  border-color: #4ade80;
}

.wled-fx-dropdown {
  width: 100%;
  padding: 4px;
  background: #3a3a3a;
  color: #e0e0e0;
  border: 1px solid #4a4a4a;
  border-radius: 3px;
  font-size: 0.7em;
  cursor: pointer;
  text-align: left;
  max-width: 90px;
}

.wled-fx-dropdown:hover {
  border-color: #ff6ec7;
}

.wled-fx-dropdown:focus {
  outline: 2px solid #ff6ec7;
  border-color: #ff6ec7;
}

.wled-fx-dropdown.active {
  background: #4d1a3a;
  color: #ff6ec7;
  border-color: #ff6ec7;
}

/* Scene navigation bar */
.scene-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.scene-bar-item {
  flex: 1;
  padding: 2px 0;
  text-align: center;
  background: #333;
  border: 1px solid #444;
  border-radius: 4px;
  font-size: 0.7em;
  font-weight: 600;
  color: #888;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.scene-bar-item:hover {
  background: #444;
  color: #ccc;
}

.scene-bar-item.active {
  background: #4a9eff;
  border-color: #4a9eff;
  color: #fff;
}

.scene-bar-item.has-data {
  color: #aaa;
  border-color: #555;
}

.scene-bar-item.has-data.active {
  background: #4a9eff;
  border-color: #4a9eff;
  color: #fff;
}

/* Copy/Paste buttons */
.copy-paste-cell {
  padding: 2px !important;
  background: #333;
  min-width: 22px !important;
  max-width: 22px !important;
  width: 22px !important;
  vertical-align: middle;
}

.copy-paste-cell .cp-btn {
  display: block;
  width: 100%;
  margin: 1px 0;
}

.dimmer-cell {
  cursor: pointer;
  min-width: 20px;
  max-width: 20px;
  width: 20px;
  padding: 2px;
  transition: opacity 0.2s;
}

.dimmer-cell:hover {
  opacity: 0.8;
}

.cp-btn {
  padding: 3px 4px;
  margin: 1px;
  background: #4a9eff;
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.65em;
  font-weight: 600;
  display: inline-block;
  width: 15px;
  user-select: none;
}

.cp-btn-fwd {
  background: #ff9900;
}

/* Scanner row flash effect when copy/paste/fill is activated */
@keyframes scanner-row-flash {
  0% {
    background-color: rgba(74, 158, 255, 0.4);
  }
  100% {
    background-color: transparent;
  }
}

tr.flash > td {
  animation: scanner-row-flash 0.5s ease-out;
}

/* AI agent scene flash — green pulse on scene-bar items */
@keyframes ai-scene-flash {
  0% {
    background-color: #4ade80;
    color: #000;
  }
  100% {
    background-color: transparent;
    color: inherit;
  }
}

.scene-bar-item.ai-flash {
  animation: ai-scene-flash 3s ease-out;
}

/* AI agent slider flash — green pulse on individual slider cells */
@keyframes ai-slider-flash {
  0% {
    box-shadow: inset 0 0 12px rgba(74, 222, 128, 0.7);
    background-color: rgba(74, 222, 128, 0.3);
  }
  50% {
    box-shadow: inset 0 0 6px rgba(74, 222, 128, 0.4);
    background-color: rgba(74, 222, 128, 0.15);
  }
  100% {
    box-shadow: none;
    background-color: transparent;
  }
}

td.ai-flash-slider {
  animation: ai-slider-flash 3s ease-out;
}

.cp-btn:hover {
  background: #3a8eef;
}

.cp-btn:active {
  background: #2a7edf;
}

/* Channel display control */
.channel-display-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85em;
  color: #aaa;
}

/* Color Picker */
.color-picker-cell {
  width: 70px;
  height: 70px;
  position: relative;
}

.color-picker-pad {
  width: 62px;
  height: 62px;
  border: 2px solid #4a4a4a;
  border-radius: 4px;
  position: relative;
  cursor: pointer;
}

.color-picker-pad::after {
  content: "";
  position: absolute;
  inset: -10px;
  z-index: 999;
  display: none;
}

.color-picker-pad:hover::after {
  display: block;
}

.color-preview {
  width: 100%;
  height: 100%;
  border-radius: 2px;
}

.color-picker-overlay {
  display: none;
  position: absolute;
  width: 200px;
  height: 200px;
  border: 2px solid #4a9eff;
  border-radius: 4px;
  cursor: crosshair;
  z-index: 1000;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  overflow: hidden;
}

.color-picker-pad:hover ~ .color-picker-overlay,
.color-picker-overlay:hover {
  display: block;
}

.color-gradient {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
}

.color-block {
  width: 100%;
  height: 100%;
}

.color-position {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.color-label {
  font-size: 0.65em;
  color: #888;
  margin-top: 2px;
  text-align: center;
}

.white-slider-container {
  width: 50px;
  margin: 2px auto 0;
}

.white-slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(to right, #000 0%, #fff 100%);
  border-radius: 2px;
  cursor: pointer;
}

.white-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4a9eff;
  cursor: pointer;
}

.white-slider::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4a9eff;
  cursor: pointer;
  border: none;
}

.white-slider.active::-webkit-slider-thumb {
  background: #4ade80;
}

.white-slider.active::-moz-range-thumb {
  background: #4ade80;
}

/* Operator Panel */
.operator-toggle-btn {
  background: #3a3a5a !important;
  border-color: #5a5a8a !important;
  color: #aac !important;
}

.operator-toggle-btn:hover {
  background: #4a4a6a !important;
}

.operator-toggle-btn.operator-active {
  background: #4a2a6a !important;
  border-color: #8a5abf !important;
  color: #d4aaff !important;
}

.operator-panel {
  background: #2a2a3a;
  border: 1px solid #4a4a6a;
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 10px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.op-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.op-section-label {
  font-weight: 700;
  font-size: 0.7em;
  color: #d4aaff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Inline controls row — everything in one line */
.op-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.op-inline label {
  font-size: 0.8em;
  color: #aaa;
  white-space: nowrap;
}

/* Separator dot between groups */
.op-sep {
  width: 1px;
  height: 20px;
  background: #4a4a6a;
  flex-shrink: 0;
}

/* Larger sliders */
.op-inline input[type="range"] {
  width: 180px;
  height: 22px;
  cursor: pointer;
  accent-color: #d4aaff;
}

.op-val {
  font-family: "Courier New", monospace;
  font-size: 0.8em;
  color: #d4aaff;
  min-width: 35px;
}

/* Bank grid */
.op-bank-grid {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  gap: 3px;
  margin-bottom: 6px;
}

.op-bank-btn {
  padding: 4px 0;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.75em;
  font-weight: 600;
  color: #ccc;
  text-align: center;
  user-select: none;
}

/* Color groups — every 5 banks */
.op-bank-btn.cg-1 {
  background: #2a3040;
  border-color: #3a5070;
}
.op-bank-btn.cg-2 {
  background: #2a3a2a;
  border-color: #3a6a3a;
}
.op-bank-btn.cg-3 {
  background: #3a2a2a;
  border-color: #6a3a3a;
}
.op-bank-btn.cg-4 {
  background: #3a3020;
  border-color: #6a5a2a;
}
.op-bank-btn.cg-5 {
  background: #2a2a3a;
  border-color: #4a3a6a;
}
.op-bank-btn.cg-6 {
  background: #2a3535;
  border-color: #3a6060;
}

.op-bank-btn:hover {
  filter: brightness(1.4);
}

.op-bank-btn.active {
  background: #6a3abf;
  border-color: #8a5abf;
  color: #fff;
  filter: none;
}

/* Transport buttons */
.op-transport-btn {
  padding: 5px 12px;
  border: 1px solid #4a4a6a;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8em;
  font-weight: 600;
  color: #e0e0e0;
  background: #3a3a5a;
}

.op-transport-btn:hover:not(:disabled) {
  background: #4a4a6a;
}

.op-transport-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.operator-status {
  font-size: 0.8em;
  font-weight: 600;
}

/* Tap button */
.op-tap-btn {
  padding: 5px 16px;
  border: 2px solid #f59e0b;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85em;
  font-weight: 700;
  color: #f59e0b;
  background: #3a3020;
  user-select: none;
  transition: background 0.08s;
}

.op-tap-btn:hover {
  background: #4a4020;
}

.op-tap-btn.tap-flash {
  background: #f59e0b;
  color: #1a1a1a;
}

/* Master dimmer */
.op-checkbox-label {
  font-size: 0.8em;
  color: #ccc;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  user-select: none;
}

.op-checkbox-label input[type="checkbox"] {
  accent-color: #d4aaff;
}

/* Effect buttons */
.op-fx-btn {
  padding: 6px 14px;
  border: 2px solid #555;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.8em;
  font-weight: 700;
  color: #ccc;
  background: #2a2a2a;
  user-select: none;
  transition:
    background 0.1s,
    border-color 0.1s,
    color 0.1s;
}

.op-fx-btn:hover {
  background: #3a3a3a;
}

.op-blackout.active {
  background: #1a1a1a;
  border-color: #ff4444;
  color: #ff4444;
  box-shadow: 0 0 8px rgba(255, 68, 68, 0.4);
}

.op-strobe.active {
  background: #3a3010;
  border-color: #ffcc00;
  color: #ffcc00;
  box-shadow: 0 0 8px rgba(255, 204, 0, 0.4);
}

.op-random.active {
  background: #2a1a3a;
  border-color: #d4aaff;
  color: #d4aaff;
  box-shadow: 0 0 8px rgba(212, 170, 255, 0.4);
}

.op-hint {
  font-size: 0.65em;
  color: #666;
  font-style: italic;
}

/* ─── AI Chat Panel ──────────────────────────────────────────── */

.app-layout {
  display: flex;
  gap: 0;
  min-height: calc(100vh - 20px);
}

.app-layout > .container {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  transition: flex 0.25s ease;
}

.ai-chat-panel {
  width: 0;
  min-width: 0;
  overflow: hidden;
  background: #1e1e2e;
  border-left: 1px solid #3a3a5a;
  display: flex;
  flex-direction: column;
  transition:
    width 0.25s ease,
    min-width 0.25s ease;
  position: sticky;
  top: 0;
  height: 100vh;
  align-self: flex-start;
  flex-shrink: 0;
  margin-top: -10px;
  margin-bottom: -10px;
  margin-right: -10px;
  margin-left: 10px;
}

.ai-chat-panel.open {
  width: 380px;
  min-width: 380px;
}

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #252540;
  border-bottom: 1px solid #3a3a5a;
  flex-shrink: 0;
}

.ai-chat-title {
  font-weight: 700;
  font-size: 0.9em;
  color: #4ade80;
}

.ai-chat-header-actions {
  display: flex;
  gap: 4px;
}

.ai-model-select {
  background: #1e1e36;
  color: #ccc;
  border: 1px solid #444;
  border-radius: 4px;
  font-size: 0.78em;
  padding: 3px 4px;
  cursor: pointer;
  outline: none;
}

.ai-model-select:hover,
.ai-model-select:focus {
  border-color: #4ade80;
  color: #fff;
}

.ai-chat-key-btn,
.ai-chat-close-btn {
  background: none;
  border: 1px solid #444;
  border-radius: 4px;
  color: #aaa;
  font-size: 0.85em;
  cursor: pointer;
  padding: 3px 7px;
  transition: background 0.15s;
}

.ai-chat-key-btn:hover,
.ai-chat-close-btn:hover {
  background: #3a3a5a;
  color: #fff;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-msg {
  max-width: 92%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.82em;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.ai-msg.user {
  align-self: flex-end;
  background: #2a5a8a;
  color: #e8f0fe;
  border-bottom-right-radius: 3px;
}

.ai-msg.assistant {
  align-self: flex-start;
  background: #2a2a3a;
  color: #d0d0e0;
  border-bottom-left-radius: 3px;
}

.ai-msg.system {
  align-self: center;
  background: #333;
  color: #888;
  font-size: 0.75em;
  font-style: italic;
  border-radius: 6px;
  text-align: center;
}

.ai-msg.tool-info {
  align-self: flex-start;
  background: #1a2a1a;
  color: #6abf6a;
  font-size: 0.72em;
  font-family: "Courier New", monospace;
  border-radius: 6px;
  border-left: 3px solid #4ade80;
  padding: 6px 10px;
}

.ai-msg.tool-counter {
  align-self: center;
  background: #1a1a2a;
  color: #7aa2f7;
  font-size: 0.75em;
  font-family: "Courier New", monospace;
  border-radius: 6px;
  border: 1px solid #3a3a5a;
  padding: 6px 14px;
  text-align: center;
  animation: ai-tool-pulse 1.5s ease-in-out infinite;
}

.ai-msg.tool-counter.done {
  color: #4ade80;
  border-color: #2a4a2a;
  background: #1a2a1a;
  animation: none;
}

.ai-msg.tool-counter .tool-counter-icon {
  margin-right: 4px;
}

@keyframes ai-tool-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.ai-msg .ai-typing {
  display: inline-block;
  width: 6px;
  height: 14px;
  background: #4ade80;
  margin-left: 2px;
  animation: ai-blink 0.7s infinite;
  vertical-align: middle;
  border-radius: 1px;
}

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

.ai-chat-input-bar {
  display: flex;
  padding: 8px 10px;
  gap: 6px;
  background: #252540;
  border-top: 1px solid #3a3a5a;
  flex-shrink: 0;
}

.ai-chat-input {
  flex: 1;
  padding: 8px 10px;
  background: #1a1a2a;
  color: #e0e0e0;
  border: 1px solid #444;
  border-radius: 6px;
  font-size: 0.82em;
  outline: none;
}

.ai-chat-input:focus {
  border-color: #4ade80;
}

.ai-chat-send-btn {
  padding: 8px 14px;
  background: #2a7a5a;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
  transition: background 0.15s;
}

.ai-chat-send-btn:hover {
  background: #3a9a6a;
}

.ai-chat-send-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* API Key input in chat */
.ai-key-prompt {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0;
}

.ai-key-prompt input {
  padding: 6px 8px;
  background: #1a1a2a;
  color: #e0e0e0;
  border: 1px solid #555;
  border-radius: 4px;
  font-size: 0.85em;
}

.ai-key-prompt button {
  padding: 5px 10px;
  background: #4a9eff;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8em;
  font-weight: 600;
}

.ai-key-prompt button:hover {
  background: #3a8eef;
}
