#psg-summarizer-root {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 2147483647;
  isolation: isolate;
  pointer-events: none;
  font-family: inherit;
  --psg-accent: #02907d;
  --psg-accent-2: #42ab58;
  --psg-accent-soft: #d8f4e2;
  --psg-panel-bg: #f8fafc;
  --psg-card-bg: #ffffff;
  --psg-text: #0f172a;
  --psg-muted: #475569;
  --psg-border: #dbe4ee;
  --psg-shadow: 0 20px 50px rgba(15, 23, 42, 0.16);
}

#psg-summarizer-root.psg-panel-open #psg-summarize-btn {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

#psg-summarize-btn {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #02907d, #42ab58);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 14px 28px rgba(2, 144, 125, 0.28);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

#psg-summarize-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(2, 144, 125, 0.34);
}

.psg-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}

.psg-btn-icon svg,
.psg-panel-eyebrow-icon svg,
.psg-empty-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.psg-btn-label {
  white-space: nowrap;
}

#psg-summary-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 380px;
  max-width: calc(100vw - 40px);
  margin-top: 12px;
  background: var(--psg-panel-bg);
  border-radius: 24px;
  box-shadow: var(--psg-shadow);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  max-height: min(78vh, 760px);
  pointer-events: auto;
}

.psg-hidden {
  display: none;
}

#psg-summary-panel.psg-hidden {
  display: none;
}

.psg-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 18px 14px;
  background:
    radial-gradient(circle at top right, rgba(216, 244, 226, 0.95), transparent 42%),
    linear-gradient(180deg, #ffffff, #f3fcf7);
  color: var(--psg-text);
  border-bottom: 1px solid var(--psg-border);
}

.psg-panel-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.psg-panel-toolbar {
  padding: 12px 18px 0;
}

.psg-panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.psg-panel-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--psg-accent-soft);
  color: var(--psg-accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.psg-panel-eyebrow-icon {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#psg-close-panel {
  position: relative;
  z-index: 5;
  width: 36px;
  height: 36px;
  background: #ffffff;
  border: 1px solid var(--psg-border);
  border-radius: 50%;
  color: var(--psg-text);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#psg-close-panel:hover {
  background: #f1f5f9;
}

.psg-secondary-btn {
  padding: 9px 12px;
  border: 1px solid var(--psg-border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--psg-text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.psg-secondary-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.psg-secondary-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.psg-panel-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 18px 0;
}

.psg-control-label {
  color: var(--psg-muted);
  font-size: 13px;
  font-weight: 600;
}

.psg-length-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.psg-length-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.psg-length-option {
  position: relative;
  display: block;
  cursor: pointer;
}

.psg-length-pill {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 12px;
  border: 1px solid var(--psg-border);
  border-radius: 14px;
  background: #fff;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.psg-length-pill strong {
  font-size: 13px;
  color: var(--psg-text);
}

.psg-length-pill small {
  color: var(--psg-muted);
  font-size: 11px;
}

.psg-length-option input:checked + .psg-length-pill {
  border-color: rgba(2, 144, 125, 0.45);
  background: linear-gradient(180deg, #ffffff, #eefbf4);
  box-shadow: 0 10px 20px rgba(2, 144, 125, 0.12);
  transform: translateY(-1px);
}

.psg-length-option:hover .psg-length-pill {
  border-color: rgba(2, 144, 125, 0.35);
}

#psg-summary-content {
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px;
  padding-bottom: 30px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  color: var(--psg-text);
  font-size: 14px;
  line-height: 1.65;
}

.psg-empty-state {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 14px;
  align-items: start;
  padding: 18px;
  background: var(--psg-card-bg);
  border: 1px solid var(--psg-border);
  border-radius: 18px;
}

.psg-empty-state p {
  margin: 4px 0 0;
  color: var(--psg-muted);
}

.psg-empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, #02907d, #42ab58);
  color: #fff;
  font-size: 18px;
}

.psg-summary-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.psg-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--psg-accent-soft);
  color: var(--psg-accent);
  font-size: 12px;
  font-weight: 700;
}

.psg-summary-card {
  padding: 16px;
  background: var(--psg-card-bg);
  border: 1px solid var(--psg-border);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.psg-summary-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.psg-summary-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(2, 144, 125, 0.14), rgba(66, 171, 88, 0.16));
  color: var(--psg-accent);
  font-size: 16px;
  flex: 0 0 auto;
}

.psg-summary-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.psg-summary-card h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--psg-accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.psg-summary-card p {
  margin: 0;
}

.psg-summary-card ul {
  margin: 0;
  padding-left: 18px;
}

.psg-summary-card li + li {
  margin-top: 8px;
}

.psg-summary-card.psg-takeaway {
  background: linear-gradient(180deg, #ffffff, #f3fcf7);
}

.psg-loading {
  color: var(--psg-muted);
}

.psg-error-card {
  padding: 16px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 18px;
  color: #9a3412;
}

@media (max-width: 768px) {
  #psg-summarizer-root {
    left: 14px;
    bottom: 14px;
  }

  #psg-summary-panel {
    width: min(100vw - 28px, 360px);
    max-height: calc(100vh - 110px);
  }

  #psg-summarize-btn {
    padding: 11px 16px;
    font-size: 13px;
  }

  .psg-length-options {
    grid-template-columns: 1fr;
  }
}
