:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  --bg: #17181f;
  --panel: rgba(33, 36, 47, 0.96);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #eef2ff;
  --muted: #98a0bf;
  --muted-strong: #c8d0ef;
  --accent: #4d87ff;
  --accent-2: #2ec8b2;
  --danger: #ff8f8f;
  --success: #8de4ae;
}

* {
  box-sizing: border-box;
}

body {
  width: 360px;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(77, 135, 255, 0.22), transparent 38%),
    radial-gradient(circle at top right, rgba(46, 200, 178, 0.14), transparent 34%),
    linear-gradient(180deg, #181a22 0%, #121319 100%);
}

button,
input {
  font: inherit;
}

.popup {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  min-width: 0;
}

.brand strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.version {
  flex: 0 0 auto;
  padding: 4px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted-strong);
  font-size: 12px;
}

.actionGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.linkGrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.actionButton,
.linkButton {
  border: 1px solid var(--panel-border);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.actionButton:hover,
.linkButton:hover {
  border-color: rgba(77, 135, 255, 0.48);
  background: rgba(77, 135, 255, 0.14);
  transform: translateY(-1px);
}

.actionButton:disabled,
.linkButton:disabled,
.toggleCard input:disabled + .switchSlider {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.actionButton {
  min-height: 40px;
  padding: 0 8px;
  font-size: 12px;
}

.actionPrimary {
  background: linear-gradient(135deg, rgba(77, 135, 255, 0.95), rgba(62, 198, 170, 0.88));
  color: #09111c;
  font-weight: 700;
}

.actionPrimary:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: linear-gradient(135deg, rgba(102, 152, 255, 1), rgba(77, 214, 187, 0.94));
}

.panel {
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.18);
}

.sectionHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.sectionHead b {
  font-size: 13px;
}

.sectionHead span {
  color: var(--muted);
  font-size: 11px;
}

.toggleCard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.toggleCard + .toggleCard {
  margin-top: 8px;
}

.agentControlCard {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.agentControlLabel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.agentControlTools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.toggleMeta strong,
.toggleMeta small {
  display: block;
}

.toggleMeta strong {
  font-size: 13px;
}

.toggleMeta small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switchSlider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.18s ease;
}

.switchSlider::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  transition: transform 0.18s ease;
}

.switch input:checked + .switchSlider {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.switch input:checked + .switchSlider::before {
  transform: translateX(20px);
}

.copyPromptButton {
  min-height: 30px;
  border: 1px solid rgba(77, 135, 255, 0.32);
  border-radius: 8px;
  background: rgba(77, 135, 255, 0.12);
  color: #dbe7ff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.copyPromptButton:hover {
  border-color: rgba(77, 135, 255, 0.58);
  background: rgba(77, 135, 255, 0.18);
}

.copyPromptButton.secondary {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted-strong);
}

.copyPromptButton.secondary:hover {
  border-color: rgba(77, 135, 255, 0.48);
  background: rgba(77, 135, 255, 0.12);
}

.agentControlState {
  min-height: 16px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.agentControlState.success {
  color: var(--success);
}

.agentControlState.error {
  color: var(--danger);
}

.agentControlState.pending {
  color: var(--muted-strong);
}

.linkButton {
  min-height: 34px;
  padding: 0 8px;
  font-size: 12px;
  color: var(--muted-strong);
}

.linkButton.danger {
  color: var(--danger);
}

.debugPanel {
  display: grid;
  gap: 10px;
}

.debugPanel[hidden] {
  display: none;
}

.debugToolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.debugToolbar .linkButton {
  min-height: 30px;
  padding: 0 6px;
}

.debugToolbar .linkButton.is-active {
  border-color: rgba(77, 135, 255, 0.56);
  background: rgba(77, 135, 255, 0.16);
  color: var(--text);
}

.referenceCaptureBox {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.referenceCaptureHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.referenceCaptureHead b {
  font-size: 12px;
}

.referenceCaptureHead span {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.referenceCaptureSessionMeta {
  color: var(--muted-strong);
  font-size: 11px;
  line-height: 1.4;
}

.referenceCaptureObserver {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  background: rgba(8, 10, 18, 0.26);
}

.screenObserverPreviewBox {
  display: grid;
  gap: 6px;
}

.screenObserverPreview {
  width: 100%;
  min-height: 112px;
  max-height: 176px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(5, 8, 16, 0.88);
}

.screenObserverEmpty {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.referenceDropZone {
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 10px;
  border: 1px dashed rgba(152, 160, 191, 0.42);
  border-radius: 10px;
  background: rgba(8, 10, 18, 0.32);
  color: var(--muted-strong);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.referenceDropZone small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.referenceDropZone.is-dragging,
.referenceDropZone:hover {
  border-color: rgba(77, 135, 255, 0.58);
  background: rgba(77, 135, 255, 0.1);
}

.debugOutput {
  width: 100%;
  height: 156px;
  resize: vertical;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px;
  background: rgba(8, 10, 18, 0.72);
  color: var(--muted-strong);
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: 11px;
  line-height: 1.45;
  outline: none;
}

.debugOutput:focus {
  border-color: rgba(77, 135, 255, 0.55);
}

.debugOutput.compact {
  height: 88px;
}

.feedback {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.feedback.success {
  color: var(--success);
}

.feedback.error {
  color: var(--danger);
}

.consentFeatureMask {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 72px;
  bottom: 42px;
  z-index: 12;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(10, 12, 18, 0.62);
  color: var(--text);
  cursor: pointer;
}

.consentFeatureMask[hidden] {
  display: none;
}

.consentFeatureMask span {
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(23, 24, 31, 0.9);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28);
}

.legalBackdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 44px 14px 14px;
  background: rgba(8, 10, 18, 0.72);
}

.legalBackdrop[hidden] {
  display: none;
}

.legalDialog {
  position: relative;
  display: grid;
  width: min(306px, calc(100vw - 28px));
  max-height: calc(100vh - 58px);
  padding: 42px 22px 20px;
  border-radius: 16px;
  background: #ffffff;
  color: #2f3440;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.32);
}

.legalIconBadge {
  position: absolute;
  top: -31px;
  left: 50%;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  padding: 6px;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 9px 20px rgba(15, 23, 42, 0.16);
  transform: translateX(-50%);
}

.legalIconBadge img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 14px;
  object-fit: contain;
}

.legalHeader {
  display: block;
  padding: 0;
}

.legalVersion {
  position: absolute;
  top: 15px;
  right: 18px;
  color: #8a92a3;
  font-size: 11px;
  line-height: 1;
}

.legalHeader h1 {
  margin: 0;
  color: #2d3440;
  font-size: 16px;
  line-height: 1.35;
}

.legalHeader p {
  margin: 9px 0 0;
  color: #5b6372;
  font-size: 12px;
  line-height: 1.55;
}

.legalBody {
  max-height: 178px;
  margin-top: 13px;
  padding: 12px 12px 12px 14px;
  border-radius: 10px;
  background: #f5f7fb;
  color: #3f4654;
  overflow: auto;
  outline: none;
}

.legalBody p {
  margin: 0;
  color: #444c5c;
  font-size: 12px;
  line-height: 1.6;
}

.legalBody h2 {
  margin: 0 0 7px;
  color: #252b36;
  font-size: 12px;
  line-height: 1.45;
}

.legalBody p + h2,
.legalBody ul + h2 {
  margin-top: 10px;
}

.legalBody p + p {
  margin-top: 8px;
}

.legalBody ul {
  margin: 7px 0 0;
  padding-left: 17px;
  color: #444c5c;
  font-size: 12px;
  line-height: 1.6;
}

.legalBody li + li {
  margin-top: 5px;
}

.legalBody strong {
  color: #252b36;
}

.legalCheck {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  color: #4d5563;
  font-size: 12px;
  line-height: 1.5;
}

.legalCheck input {
  width: 16px;
  height: 16px;
  margin: 1px 0 0;
  accent-color: #4778df;
  flex: 0 0 auto;
}

.legalActions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.legalActions button {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.legalSecondary {
  border: 0;
  background: transparent;
  color: #5e6675;
}

.legalPrimary {
  border: 0;
  background: #4778df;
  color: #ffffff;
}

.legalPrimary:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}
