/* iPhone Messages-style chat. Light mode, faithful to iOS 17/18 vibe. */

:root {
  --imsg-blue: #007AFF;
  --imsg-gray: #E9E9EB;
  --imsg-text: #000;
  --imsg-bg: #FFFFFF;
  --imsg-border: rgba(0,0,0,0.08);
  --imsg-muted: #8E8E93;
  --imsg-header-bg: rgba(247,247,247,0.92);
  --imsg-compose-bg: rgba(247,247,247,0.92);
  --imsg-input-bg: #FFFFFF;
  --imsg-input-border: rgba(0,0,0,0.12);
}

/* ChatGPT-style shell colors */
:root {
  --shell-bg: #FFFFFF;
  --shell-side: #F7F7F8;
  --shell-side-hover: #ECECF1;
  --shell-side-active: #E0E0E5;
  --shell-text: #202123;
  --shell-muted: #6E6E80;
  --shell-border: #E5E5EA;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--shell-bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--imsg-text);
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--shell-side);
  border-right: 1px solid var(--shell-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-header {
  padding: 14px 12px 8px;
  display: flex; flex-direction: column; gap: 10px;
}
.brand {
  display: flex; align-items: center; gap: 10px; padding: 4px 4px;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #f4a4c8, #c98aff);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.brand-name { font-weight: 600; color: var(--shell-text); font-size: 14px; flex: 1; }
.icon-btn {
  background: transparent; border: none; padding: 4px;
  color: #777; cursor: pointer; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: #f0f0f3; color: var(--shell-text); }
.new-chat {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--shell-border);
  color: var(--shell-text);
  font-weight: 500; font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.new-chat:hover { background: #f0f0f3; }

.chat-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 6px 8px 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.chat-list-empty {
  padding: 16px 12px;
  color: var(--shell-muted);
  font-size: 13px;
}
.chat-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--shell-text);
  transition: background 0.12s;
}
.chat-item:hover { background: var(--shell-side-hover); }
.chat-item.active { background: var(--shell-side-active); }
.chat-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #f4a4c8, #c98aff);
  color: #fff; font-weight: 600; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.chat-meta { min-width: 0; flex: 1 1 auto; }
/* Approved-design chip: a small thumbnail of the design the client confirmed,
   with an iOS-green check so the master sees it at a glance. The wrapper is a
   fixed 30x30 flex item (never grows/shrinks) and the image fills it exactly,
   so an oversized source can never break the row layout. */
.chat-approved {
  position: relative;
  width: 30px; height: 30px;
  flex: 0 0 auto;
  display: block;
}
.chat-approved img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  /* subtle ring matched to the sidebar bg so the chip reads as a distinct tile */
  box-shadow: 0 0 0 1.5px var(--shell-side), 0 1px 3px rgba(0,0,0,0.18);
}
.chat-approved .check {
  position: absolute; right: -3px; bottom: -3px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #34C759;            /* iOS system green = "confirmed" */
  color: #fff; font-size: 9px; line-height: 1; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--shell-side);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.chat-row1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.chat-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 11px; color: var(--shell-muted); flex: 0 0 auto; }
.chat-preview {
  font-size: 12.5px; color: var(--shell-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-footer {
  border-top: 1px solid var(--shell-border);
  padding: 10px 12px;
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 4px;
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: #4A4A4F; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}
.user-name { font-size: 13px; font-weight: 600; color: var(--shell-text); }
.user-sub { font-size: 11.5px; color: var(--shell-muted); }

/* ---------- Phone wrap (right column) ---------- */
.phone-wrap {
  background: #C6C6C6;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 18px;
}

.phone {
  width: 100%;
  max-width: 430px;
  height: 100%;
  background: var(--imsg-bg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  border-radius: 44px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.25);
  border: 8px solid #111;
}

/* ---------- Mobile responsive ---------- */
.backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
  z-index: 50;
}
.backdrop.show { opacity: 1; pointer-events: auto; }

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: 84vw; max-width: 320px;
    transform: translateX(-100%);
    transition: transform 0.22s ease-out;
    z-index: 60;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }
  .sidebar.open { transform: translateX(0); }
  .phone-wrap {
    padding: 0;
    background: var(--imsg-bg);
  }
  .phone {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    max-width: 100%;
  }
}

/* ------- iOS status bar ------- */
.status-bar {
  height: 44px;
  flex: 0 0 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  background: var(--imsg-header-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.status-bar .time { font-variant-numeric: tabular-nums; }
.status-right {
  display: flex; align-items: center; gap: 6px;
}
.battery { display: flex; align-items: center; gap: 1px; }
.battery-shell {
  width: 22px; height: 11px; border: 1px solid currentColor; border-radius: 3px; padding: 1px;
}
.battery-fill {
  height: 100%; width: 80%; background: currentColor; border-radius: 1px;
}
.battery-cap {
  width: 1.5px; height: 4px; background: currentColor; border-radius: 1px;
}

/* ------- conversation header ------- */
.convo-header {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: 4px 8px 8px;
  background: var(--imsg-header-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--imsg-border);
}
.back, .facetime {
  background: transparent; border: 0; padding: 6px;
  color: var(--imsg-blue); display: flex; justify-content: center; align-items: center;
  cursor: pointer;
}
.who { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #f4a4c8, #c98aff);
  color: #fff; font-weight: 600; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.name-row { display: flex; align-items: center; gap: 3px; color: #000; }
.name { font-size: 11px; font-weight: 500; letter-spacing: -0.1px; }
.chev { color: #C7C7CC; }

/* ------- thread ------- */
.thread {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--imsg-bg);
}

.timestamp {
  text-align: center; color: var(--imsg-muted); font-size: 11px;
  margin: 12px 0 4px;
}

.bubble {
  max-width: 75%;
  padding: 8px 13px;
  font-size: 16.5px;
  line-height: 1.28;
  border-radius: 18px;
  word-wrap: break-word;
  white-space: pre-wrap;
  position: relative;
  margin-top: 1px;
}
.bubble.image-bubble {
  padding: 0;
  overflow: hidden;
  background: transparent;
  border-radius: 18px;
}
.bubble.image-bubble img {
  display: block;
  max-width: 100%;
  height: auto;
}
/* Progressive design generation: placeholder → blurred partials → sharp final */
.bubble.image-bubble.design-pending {
  background: var(--imsg-gray);
}
.design-pending-inner {
  width: 190px; height: 190px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  color: var(--imsg-muted); font-size: 12.5px; font-weight: 500;
}
.design-spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(0,0,0,0.10);
  border-top-color: var(--imsg-blue);
  animation: design-spin 0.8s linear infinite;
}
@keyframes design-spin { to { transform: rotate(360deg); } }
/* Partial frames arrive low-detail: blur them, clear the blur on the final. */
.bubble.image-bubble img.progressive {
  filter: blur(8px);
  transform: scale(1.015);
  transition: filter 0.6s ease, transform 0.6s ease;
}
.bubble.image-bubble img {
  transition: filter 0.6s ease, transform 0.6s ease;
}
@media (prefers-reduced-motion: reduce) {
  .design-spinner { animation-duration: 1.6s; }
  .bubble.image-bubble img.progressive { transition: none; filter: blur(4px); }
}

.row { display: flex; }
.row.from-user { justify-content: flex-end; }
.row.from-assistant { justify-content: flex-start; }

.bubble.user {
  background: var(--imsg-blue);
  color: #fff;
  border-bottom-right-radius: 18px;
}
.bubble.assistant {
  background: var(--imsg-gray);
  color: #000;
  border-bottom-left-radius: 18px;
}

/* Blinking cursor while the model is streaming */
.bubble.streaming-bubble::after {
  content: '▋';
  display: inline-block;
  animation: blink-cursor 0.7s step-end infinite;
  opacity: 0.7;
  margin-left: 1px;
}
@keyframes blink-cursor {
  50% { opacity: 0; }
}

/* Tail on the LAST bubble of a run (iMessage style) */
.row.tail .bubble.user {
  border-bottom-right-radius: 4px;
}
.row.tail .bubble.user::after {
  content: "";
  position: absolute;
  right: -7px;
  bottom: 0;
  width: 14px; height: 17px;
  background: var(--imsg-blue);
  border-bottom-left-radius: 16px 14px;
  z-index: -1;
}
.row.tail .bubble.user::before {
  content: "";
  position: absolute;
  right: -10px;
  bottom: 0;
  width: 10px; height: 17px;
  background: var(--imsg-bg);
  border-bottom-left-radius: 10px;
}
.row.tail .bubble.assistant {
  border-bottom-left-radius: 4px;
}
.row.tail .bubble.assistant::after {
  content: "";
  position: absolute;
  left: -7px;
  bottom: 0;
  width: 14px; height: 17px;
  background: var(--imsg-gray);
  border-bottom-right-radius: 16px 14px;
  z-index: -1;
}
.row.tail .bubble.assistant::before {
  content: "";
  position: absolute;
  left: -10px;
  bottom: 0;
  width: 10px; height: 17px;
  background: var(--imsg-bg);
  border-bottom-right-radius: 10px;
}

/* run grouping spacing */
.row + .row { margin-top: 1px; }
.row.run-start { margin-top: 6px; }

/* typing indicator */
.typing {
  display: inline-flex;
  align-items: center;
  background: var(--imsg-gray);
  border-radius: 18px;
  padding: 10px 14px;
  gap: 4px;
}
.typing span {
  width: 7px; height: 7px;
  background: #B0B0B5;
  border-radius: 50%;
  animation: blink 1.3s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* attachment preview chip in compose */
.attach-row {
  display: flex; gap: 6px; padding: 4px 12px 0; flex-wrap: wrap;
}
.attach-chip {
  position: relative;
  width: 56px; height: 56px;
  border-radius: 10px;
  overflow: hidden;
  background: #ddd;
}
.attach-chip img { width: 100%; height: 100%; object-fit: cover; }
.attach-chip .x {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,0.55); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; cursor: pointer;
  border: 0;
}

/* ------- compose ------- */
.compose {
  flex: 0 0 auto;
  background: var(--imsg-compose-bg);
  border-top: 0.5px solid var(--imsg-border);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  padding: 8px 8px 14px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.plus, .sample-btn {
  background: #E5E5EA; color: var(--imsg-muted);
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 0; cursor: pointer;
  flex: 0 0 auto;
}
.sample-btn:hover { background: #d5d5dd; color: var(--imsg-blue); }
.input-wrap {
  flex: 1 1 auto;
  display: flex; align-items: center;
  background: var(--imsg-input-bg);
  border: 1px solid var(--imsg-input-border);
  border-radius: 18px;
  padding: 6px 6px 6px 14px;
  min-height: 32px;
}
#input {
  flex: 1 1 auto;
  border: 0; outline: none; background: transparent;
  font-size: 16px;
  font-family: inherit;
  padding: 2px 0;
}
.send {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 0;
  background: var(--imsg-blue);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}
.send:disabled {
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
}

/* fade in new bubbles */
.row { animation: pop 0.18s ease-out; }
@keyframes pop {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* empty state inside the thread */
.thread-empty {
  margin: auto;
  color: var(--imsg-muted);
  font-size: 14px;
  padding: 24px;
  text-align: center;
}

/* ---------- New chat modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center; justify-content: center;
  padding: 22px;                 /* never let the dialog touch the viewport edge */
  z-index: 80;
}
.modal-backdrop.show { display: flex; }
.modal {
  width: 92%;
  max-width: 380px;
  max-height: calc(100dvh - 44px);   /* fit the screen; body scrolls inside */
  background: #fff;
  border-radius: 14px;
  padding: 20px 18px 16px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.3);
  display: flex; flex-direction: column; gap: 12px;
  overflow: hidden;                  /* scrolling lives on .modal-scroll */
}
/* Settings dialog: sticky title + actions, scrollable body */
.settings-modal { max-width: 440px; padding-bottom: 0; }
.settings-modal .modal-title {
  position: sticky; top: 0; background: #fff; z-index: 2;
  padding-bottom: 10px; margin-bottom: -2px;
}
.modal-scroll {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding-right: 4px;                /* room for the scrollbar */
  scrollbar-width: thin;
}
.settings-modal .modal-actions {
  position: sticky; bottom: 0; z-index: 2;
  margin: 0 -18px; padding: 12px 18px 14px;
  background: #fff; border-top: 1px solid #ececf0;
}
.modal-title { font-size: 17px; font-weight: 600; color: var(--shell-text); }
.modal-label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12.5px; color: var(--shell-muted); font-weight: 500;
}
.modal-label input {
  border: 1px solid var(--shell-border);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  color: var(--shell-text);
}
.modal-label input:focus { border-color: var(--imsg-blue); }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px;
}
.btn-ghost, .btn-primary {
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  border: 0; cursor: pointer;
  font-family: inherit;
}
.btn-ghost { background: transparent; color: var(--shell-muted); }
.btn-ghost:hover { background: #f0f0f3; color: var(--shell-text); }
.btn-primary { background: var(--imsg-blue); color: #fff; }
.btn-primary:hover { filter: brightness(0.95); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Settings modal */
.settings-section {
  display: flex; flex-direction: column; gap: 10px;
  padding: 4px 0;
}
.settings-label {
  font-size: 13px; font-weight: 600; color: var(--shell-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.radio-group {
  display: flex; flex-direction: column; gap: 8px;
}
.radio-option {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--shell-border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.radio-option:hover { background: #f8f8fa; }
.radio-option input[type="radio"] { margin-top: 2px; cursor: pointer; }
.radio-option:has(input:checked) {
  border-color: var(--imsg-blue);
  background: rgba(0, 122, 255, 0.04);
}
.radio-body { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.radio-title { font-size: 14px; font-weight: 600; color: var(--shell-text); }
.radio-sub { font-size: 12px; color: var(--shell-muted); line-height: 1.45; }
.settings-status {
  font-size: 12px; color: var(--shell-muted);
  min-height: 16px;
}

/* ---------- Lightbox / carousel ---------- */
.lightbox {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10, 10, 14, 0.94);
  z-index: 1000;
  align-items: center; justify-content: center;
}
.lightbox.show { display: flex; }
.lightbox img {
  max-width: 92vw; max-height: 90vh;
  object-fit: contain;
  box-shadow: 0 10px 60px rgba(0, 0, 0, 0.7);
  border-radius: 6px;
}
.lb-btn {
  position: absolute;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 0;
  width: 48px; height: 48px;
  font-size: 32px; line-height: 44px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  user-select: none;
  transition: background 0.15s, transform 0.05s;
}
.lb-btn:hover  { background: rgba(255, 255, 255, 0.22); }
.lb-btn:active { transform: scale(0.95); }
.lb-prev, .lb-next { top: 50%; transform: translateY(-50%); border-radius: 50%; }
.lb-prev:active, .lb-next:active { transform: translateY(-50%) scale(0.95); }
.lb-prev  { left: 18px; }
.lb-next  { right: 18px; }
.lb-close { top: 18px; right: 18px; border-radius: 50%; font-size: 26px; line-height: 22px; }
.lb-counter {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  background: rgba(0, 0, 0, 0.45);
  padding: 5px 12px;
  border-radius: 12px;
}
.bubble.image-bubble img { cursor: zoom-in; }

/* Auto-linked URLs inside assistant text */
.bubble.assistant a { color: var(--imsg-blue); text-decoration: underline; word-break: break-all; }

/* Admin config grid (Models & providers) */
.cfg-grid { display: flex; flex-direction: column; gap: 8px; }
.cfg-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cfg-row label { font-size: 13px; color: #444; flex: 0 0 42%; }
.cfg-hint { color: #999; font-weight: 400; }
.cfg-row select, .cfg-row input[type="text"] {
  flex: 1 1 auto; min-width: 0; padding: 6px 8px; font-size: 13px;
  border: 1px solid #d2d2d7; border-radius: 8px; background: #fff; color: #111;
}
.cfg-row select:focus, .cfg-row input[type="text"]:focus { outline: 2px solid var(--imsg-blue); border-color: transparent; }
.cfg-sep { height: 1px; background: #ececf0; margin: 4px 0; }
.cfg-sub { font-size: 12px; font-weight: 700; color: #8a8a90; letter-spacing: 0.02em; margin: 8px 0 2px; }
.cfg-keys { margin-top: 10px; font-size: 12px; color: #777; display: flex; flex-wrap: wrap; gap: 6px; }
.cfg-key { padding: 2px 8px; border-radius: 999px; background: #f0f0f3; }
.cfg-key.ok { background: #e3f6ea; color: #1b7a3f; }
.cfg-key.missing { background: #fdecec; color: #b3261e; }
.eval-link {
  display: inline-block; align-self: flex-start;
  font-size: 13px; font-weight: 600; color: var(--imsg-blue);
  text-decoration: none; padding: 6px 10px; border-radius: 8px;
  background: #eef4ff; margin-bottom: 2px;
}
.eval-link:hover { background: #e1ecff; }

/* ---------- Per-message debug panel (admin debug mode) ---------- */
.row.from-assistant .dbg-panel {
  max-width: min(78%, 540px);
  margin: 2px 0 4px 8px;
  font-family: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  color: #3a3f4b;
  background: #f6f7f9;
  border: 1px solid #e3e5ea;
  border-radius: 12px;
  overflow: hidden;
}
.dbg-panel > summary {
  list-style: none;
  cursor: pointer;
  padding: 6px 10px;
  color: #6b7280;
  font-weight: 600;
  letter-spacing: 0.01em;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dbg-panel > summary::-webkit-details-marker { display: none; }
.dbg-panel > summary::before {
  content: "▸";
  font-size: 10px;
  color: #9aa1ad;
  transition: transform 0.12s ease;
}
.dbg-panel[open] > summary::before { transform: rotate(90deg); }
.dbg-panel > summary:hover { background: #eef0f4; }
.dbg-body { padding: 2px 8px 8px; display: flex; flex-direction: column; gap: 6px; }
.dbg-entry {
  background: #fff;
  border: 1px solid #ebedf1;
  border-radius: 8px;
  padding: 6px 8px;
}
.dbg-row1 { display: flex; align-items: baseline; gap: 8px; }
.dbg-kind { flex: 1 1 auto; font-weight: 700; color: #2b303b; word-break: break-all; }
.dbg-cost { color: #1b7a3f; font-weight: 700; white-space: nowrap; }
.dbg-lat { color: #b06a00; font-weight: 700; white-space: nowrap; }
.dbg-row2 { color: #8a909c; margin-top: 2px; }
.dbg-text {
  margin-top: 5px; padding-top: 5px; border-top: 1px dashed #e8eaee;
  color: #4a4f5a; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
}
.dbg-text .dbg-k {
  display: inline-block; font-size: 9px; text-transform: uppercase;
  letter-spacing: 0.06em; color: #aab0bb; margin-right: 5px;
}
.dbg-entry-error { background: #fff5f5; border-color: #f3c9c9; }
.dbg-entry-error .dbg-kind { color: #b3261e; }
.dbg-entry-error .dbg-row2 { color: #c2554d; }
.dbg-text.dbg-err { color: #b3261e; border-top-color: #f3c9c9; }
.dbg-text.dbg-err .dbg-k { color: #d98b86; }
