#emotional-memory-panel-root {
  position: fixed;
  right: 20px;
  top: 20px;
  z-index: 2147483000;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: #172033;
}

.em-panel-toggle {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(23, 32, 51, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 30px rgba(22, 34, 55, 0.18);
  color: #172033;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease;
}

.em-panel-toggle:hover {
  transform: translateY(-1px);
  background: #ffffff;
  box-shadow: 0 14px 36px rgba(22, 34, 55, 0.22);
}

.em-panel-toggle svg {
  width: 24px;
  height: 24px;
}

.em-panel {
  position: absolute;
  right: 0;
  top: 60px;
  width: min(420px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 100px));
  display: none;
  grid-template-rows: auto auto 1fr;
  overflow: hidden;
  border: 1px solid rgba(23, 32, 51, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 24px 64px rgba(22, 34, 55, 0.22);
  backdrop-filter: blur(14px);
}

.em-panel.is-open {
  display: grid;
}

.em-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid rgba(23, 32, 51, 0.08);
}

.em-panel-title {
  min-width: 0;
}

.em-panel-title strong {
  display: block;
  font-size: 15px;
  line-height: 20px;
  font-weight: 700;
}

.em-panel-title span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  line-height: 16px;
  color: #647086;
}

.em-panel-close,
.em-panel-action,
.em-panel-tab {
  border: 1px solid rgba(23, 32, 51, 0.12);
  background: #ffffff;
  color: #172033;
  cursor: pointer;
  font: inherit;
}

.em-panel-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: grid;
  place-items: center;
}

.em-panel-close svg {
  width: 18px;
  height: 18px;
}

.em-panel-controls {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(23, 32, 51, 0.08);
}

.em-panel-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.em-panel-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 3px;
  border-radius: 8px;
  background: #eef2f5;
}

.em-panel-tab {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
}

.em-panel-tab.is-active {
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(22, 34, 55, 0.12);
  font-weight: 700;
}

.em-panel-action {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 13px;
}

.em-panel-action.with-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.em-panel-action.with-icon svg {
  width: 16px;
  height: 16px;
}

.em-panel-action.primary {
  background: #1d6f6f;
  border-color: #1d6f6f;
  color: #ffffff;
}

.em-panel-action:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.em-panel-status {
  min-width: 0;
  flex: 1;
  font-size: 12px;
  color: #647086;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.em-panel-body {
  overflow: auto;
  padding: 14px;
}

.em-card {
  border: 1px solid rgba(23, 32, 51, 0.1);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
}

.em-card + .em-card {
  margin-top: 10px;
}

.em-card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 18px;
}

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

.em-metric {
  min-height: 64px;
  border-radius: 6px;
  background: #f6f8fa;
  padding: 9px;
}

.em-metric span {
  display: block;
  font-size: 11px;
  line-height: 14px;
  color: #647086;
}

.em-metric strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  line-height: 24px;
}

.em-list {
  display: grid;
  gap: 8px;
}

.em-list-item {
  border-radius: 6px;
  background: #f6f8fa;
  padding: 9px;
  font-size: 12px;
  line-height: 17px;
}

.em-list-item strong {
  display: block;
  margin-bottom: 3px;
}

.em-list-subitem {
  margin-top: 6px;
  padding-left: 9px;
  border-left: 2px solid #d8e1e8;
}

.em-list-subitem strong {
  margin-bottom: 2px;
  color: #3c4b63;
}

.em-user-summary {
  display: grid;
  gap: 8px;
  border-radius: 6px;
  background: #f6f8fa;
  padding: 10px;
  font-size: 13px;
  line-height: 19px;
}

.em-user-summary strong {
  font-size: 14px;
  line-height: 20px;
}

.em-user-summary p {
  margin: 0;
}

.em-user-reflections {
  display: grid;
  gap: 6px;
}

.em-gentle-step {
  color: #24546f;
  font-weight: 650;
}

.em-trend-section + .em-trend-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(23, 32, 51, 0.08);
}

.em-trend-scope {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 10px;
  border-radius: 999px;
  background: #eef6f6;
  padding: 0 9px;
  color: #1d6f6f;
  font-size: 12px;
  font-weight: 650;
}

.em-trend-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.em-trend-heading strong {
  font-size: 12px;
  line-height: 16px;
}

.em-trend-heading span {
  flex: 0 0 auto;
  font-size: 11px;
  line-height: 15px;
  color: #647086;
}

.em-trend-chart {
  height: 142px;
  border-radius: 6px;
  background: linear-gradient(180deg, #f6f8fa 0%, #ffffff 100%);
  border: 1px solid rgba(23, 32, 51, 0.08);
  overflow: hidden;
}

.em-trend-chart svg {
  display: block;
  width: 100%;
  height: 100%;
}

.em-trend-chart polyline {
  fill: none;
  stroke: #1d6f6f;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.em-trend-chart circle {
  fill: #ffffff;
  stroke: #1d6f6f;
  stroke-width: 2;
}

.em-chart-point-label rect {
  fill: rgba(255, 255, 255, 0.92);
  stroke: rgba(29, 111, 111, 0.18);
  stroke-width: 1;
}

.em-chart-point-label text {
  fill: #172033;
  font-size: 11px;
  font-weight: 650;
  text-anchor: middle;
}

.em-chart-grid {
  stroke: rgba(100, 112, 134, 0.32);
  stroke-width: 1;
}

.em-trend-caption {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  font-size: 11px;
  line-height: 15px;
  color: #647086;
}

.em-trend-caption strong {
  color: #172033;
  font-weight: 650;
}

.em-trend-caption span:last-child {
  text-align: right;
}

.em-topic-flow {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.em-topic-step {
  position: relative;
  flex: 0 0 auto;
  min-width: 92px;
  max-width: 130px;
  border-radius: 6px;
  background: #f6f8fa;
  padding: 8px;
}

.em-topic-step + .em-topic-step::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 50%;
  width: 8px;
  border-top: 1px solid #b8c6d1;
}

.em-topic-step span {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #dcebea;
  color: #1d6f6f;
  font-size: 11px;
  font-weight: 700;
}

.em-topic-step strong {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 16px;
}

.em-topic-step small,
.em-risk-row small {
  display: block;
  margin-top: 2px;
  color: #647086;
  font-size: 11px;
  line-height: 15px;
}

.em-risk-list {
  display: grid;
  gap: 6px;
}

.em-risk-row {
  display: grid;
  grid-template-columns: minmax(58px, auto) 1fr auto;
  gap: 8px;
  align-items: center;
  border-radius: 6px;
  background: #f6f8fa;
  padding: 8px;
  font-size: 12px;
  line-height: 16px;
}

.em-risk-row span {
  color: #647086;
}

.em-risk-row strong {
  font-weight: 650;
}

.em-risk-row.has-risk {
  background: #fff4e8;
}

.em-risk-row.has-risk strong {
  color: #8a4b00;
}

.em-report {
  margin: 0;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 6px;
  background: #f6f8fa;
  padding: 10px;
  font-size: 12px;
  line-height: 18px;
}

.em-empty {
  margin: 0;
  color: #647086;
  font-size: 13px;
  line-height: 19px;
}

@media (max-width: 640px) {
  #emotional-memory-panel-root {
    right: 12px;
    top: 12px;
  }

  .em-panel {
    top: 58px;
    width: calc(100vw - 24px);
    max-height: calc(100vh - 86px);
  }
}
