:root {
  --intent-bg: rgba(7, 8, 10, 0.86);
  --intent-bg-strong: rgba(0, 0, 0, 0.52);
  --intent-border: rgba(255, 255, 255, 0.14);
  --intent-border-strong: rgba(255, 255, 255, 0.28);
  --intent-text: #f4f4f0;
  --intent-dim: rgba(244, 244, 240, 0.62);
  --intent-muted: rgba(244, 244, 240, 0.42);
  --intent-accent: #d7ff6f;
  --intent-accent-ink: #101307;
  --intent-error: #ff8c8c;
  --intent-ok: #93eb98;
  --intent-shadow: 0 20px 60px rgba(0, 0, 0, 0.42);
}

#intent-panel {
  position: fixed;
  top: 14px;
  left: 14px;
  width: min(430px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  color: var(--intent-text);
  background: linear-gradient(180deg, rgba(17, 19, 20, 0.92), var(--intent-bg));
  border: 1px solid var(--intent-border);
  box-shadow: var(--intent-shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font: 12px/1.42 ui-monospace, SFMono-Regular, Menlo, monospace;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  z-index: 10;
  transition: transform 0.18s ease, opacity 0.18s ease;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

#intent-panel.collapsed {
  transform: translateY(-10px);
  opacity: 0;
  pointer-events: none;
}

#intent-panel * {
  box-sizing: border-box;
}

.control-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.control-title {
  font-size: 12px;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.control-help {
  margin-top: 5px;
  color: var(--intent-muted);
  font-size: 11px;
  line-height: 1.25;
}

#intent-panel .status {
  max-width: 190px;
  color: var(--intent-dim);
  font-size: 11px;
  line-height: 1.25;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#intent-panel .status[data-kind="ok"] { color: var(--intent-ok); }
#intent-panel .status[data-kind="error"] { color: var(--intent-error); }
#intent-panel .status[data-kind="info"],
#intent-panel .status[data-kind="typing"] { color: var(--intent-text); }

.select-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#intent-panel label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--intent-muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#intent-panel .prompt-label {
  margin-bottom: -6px;
}

#intent-panel select,
#intent-panel textarea,
#intent-panel button {
  border-radius: 6px;
  border: 1px solid var(--intent-border);
  background: var(--intent-bg-strong);
  color: var(--intent-text);
  font: inherit;
}

#intent-panel select {
  min-width: 0;
  width: 100%;
  height: 32px;
  padding: 0 28px 0 9px;
  text-transform: none;
  letter-spacing: 0;
}

.intent-input-shell {
  position: relative;
}

#intent-panel textarea {
  width: 100%;
  min-height: 90px;
  max-height: 210px;
  resize: vertical;
  padding: 10px 44px 10px 10px;
  outline: none;
  background: rgba(0, 0, 0, 0.46);
}

#intent-panel textarea:focus,
#intent-panel select:focus {
  border-color: var(--intent-accent);
  box-shadow: 0 0 0 1px rgba(215, 255, 111, 0.18);
}

#intent-panel button {
  min-height: 32px;
  padding: 0 11px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, opacity 0.12s;
  letter-spacing: 0.02em;
}

#intent-panel button:hover:not(:disabled) {
  background: var(--intent-accent);
  color: var(--intent-accent-ink);
  border-color: var(--intent-accent);
}

#intent-panel button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#intent-panel button.primary {
  background: rgba(215, 255, 111, 0.15);
  border-color: rgba(215, 255, 111, 0.56);
  color: var(--intent-accent);
  min-width: 70px;
}

#intent-panel button.primary:hover:not(:disabled) {
  background: var(--intent-accent);
  color: var(--intent-accent-ink);
}

#intent-panel button.active {
  background: var(--intent-accent);
  color: var(--intent-accent-ink);
  border-color: var(--intent-accent);
}

.action-row,
.utility-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.icon-btn {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 30px;
  min-height: 30px;
  padding: 0;
  display: grid;
  place-items: center;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

.icon-btn circle {
  fill: currentColor;
  stroke: none;
}

#intent-panel .progress-strip {
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  position: relative;
  border-radius: 999px;
}

#intent-panel .progress-strip::after {
  content: '';
  position: absolute;
  inset: 0 70% 0 0;
  background: var(--intent-accent);
  animation: progress-sweep 1.1s linear infinite;
  display: none;
}

#intent-panel .progress-strip.is-active::after {
  display: block;
}

@keyframes progress-sweep {
  0% { left: -30%; right: 100%; }
  50% { left: 30%; right: 30%; }
  100% { left: 100%; right: -30%; }
}

#intent-panel .attachments {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

#intent-panel .attachments.hidden {
  display: none;
}

#intent-panel .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--intent-border);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
}

#intent-panel .chip-x {
  min-height: 0;
  background: transparent;
  border: none;
  color: var(--intent-dim);
  cursor: pointer;
  padding: 0 0 0 2px;
  font-size: 13px;
  line-height: 1;
}

#intent-panel .chip-x:hover {
  color: var(--intent-text);
  background: transparent;
}

#intent-panel .drop-zone {
  border: 1px dashed var(--intent-border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 11px;
  color: var(--intent-muted);
  text-align: center;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

#intent-panel .drop-zone.drag-over {
  border-color: var(--intent-accent);
  color: var(--intent-text);
  background: rgba(215, 255, 111, 0.08);
}

#intent-panel .spec-preview {
  max-height: 200px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--intent-border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 10.5px;
  color: var(--intent-dim);
  white-space: pre;
  display: none;
}

#intent-panel.show-spec .spec-preview {
  display: block;
}

#intent-panel .intent-trace {
  display: grid;
  gap: 6px;
  color: var(--intent-dim);
  font-size: 11px;
}

#intent-panel .intent-trace:empty {
  display: none;
}

#intent-panel .trace-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  padding: 7px 8px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 6px;
}

#intent-panel .trace-key {
  color: var(--intent-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 10px;
}

#intent-panel .trace-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.utility-hidden {
  display: none;
}

#mosaic-loader {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
}

#mosaic-loader.is-active {
  opacity: 1;
}

.mosaic-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  grid-template-rows: repeat(10, 1fr);
}

.mosaic-grid span {
  background: rgba(0, 0, 0, 0.16);
  opacity: 0.18;
  animation: mosaic-pulse 1.15s ease-in-out infinite;
  animation-delay: calc(var(--i) * 12ms);
}

.mosaic-grid span:nth-child(3n) { background: rgba(215, 255, 111, 0.11); }
.mosaic-grid span:nth-child(4n) { background: rgba(255, 255, 255, 0.08); }
.mosaic-grid span:nth-child(7n) { background: rgba(55, 92, 120, 0.18); }

.mosaic-status {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(360px, calc(100vw - 32px));
  color: rgba(244, 244, 240, 0.74);
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 7px 10px;
  font: 11px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes mosaic-pulse {
  0%, 100% { opacity: 0.07; transform: scale(1); }
  45% { opacity: 0.32; transform: scale(1.015); }
}

@media (max-width: 560px) {
  #intent-panel {
    top: 8px;
    left: 8px;
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    padding: 10px;
  }

  .control-head {
    grid-template-columns: 1fr;
  }

  #intent-panel .status {
    max-width: none;
    text-align: left;
  }

  .select-grid {
    grid-template-columns: 1fr;
  }

  .action-row button {
    flex: 1 1 auto;
  }
}
