:root {
  --sg-bg-soft: rgba(255, 253, 247, 0.9);
  --sg-bg-strong: #fffefb;
  --sg-bg-accent: rgba(var(--accent-rgb), 0.08);
  --sg-line-soft: rgba(32, 35, 33, 0.08);
  --sg-shadow-soft: 0 18px 48px rgba(46, 41, 33, 0.1);
}

.sg-main {
  min-width: 0;
}

.sg-shell {
  max-width: none;
  margin: 0 auto;
  padding: 22px 18px 40px;
}

.sg-panel {
  border: 1px solid var(--portal-soft-line, rgba(32, 35, 33, 0.08));
  border-radius: 18px;
  background: var(--portal-panel, rgba(255, 253, 247, 0.92));
  box-shadow: var(--portal-warm-shadow, 0 18px 48px rgba(46, 41, 33, 0.1));
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sg-header {
  padding: 14px 16px;
  border-radius: 18px;
  background: transparent;
}

.sg-intro-text {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.9;
}

.sg-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 8px 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--sg-bg-strong);
}

.sg-search-row i,
.sg-search-row svg,
.sg-search-row [data-lucide] {
  width: 20px;
  height: 20px;
  color: var(--muted);
  flex-shrink: 0;
}

.sg-search-row input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
}

.sg-search-row input::placeholder {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.sg-search-submit {
  border: 0;
  border-radius: 999px;
  padding: 9px 18px;
  background: var(--cinnabar);
  color: #fffdf7;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.sg-search-submit:hover {
  opacity: 0.9;
}

.sg-count {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.sg-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border: 1px solid var(--portal-soft-line, rgba(32, 35, 33, 0.08));
  border-radius: var(--radius-lg, 18px);
  background: var(--portal-panel, rgba(255, 253, 247, 0.92));
  box-shadow: var(--portal-warm-shadow, 0 18px 48px rgba(46, 41, 33, 0.1));
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.sg-card:hover {
  transform: translateY(-2px);
  border-color: rgba(var(--accent-rgb), 0.28);
  box-shadow: 0 24px 52px rgba(46, 41, 33, 0.14);
}

.sg-card:active {
  transform: translateY(0);
  box-shadow: 0 12px 28px rgba(46, 41, 33, 0.1);
}

.sg-card-name {
  font-size: 17px;
  font-weight: 900;
  color: var(--ink);
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sg-card-cat {
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--sg-bg-accent);
  color: var(--cinnabar);
  font-size: 11px;
  font-weight: 800;
}

.sg-empty {
  padding: 48px 18px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: var(--sg-bg-strong);
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

/* 弹窗 */
.sg-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(33, 36, 31, 0.5);
  backdrop-filter: blur(4px);
}

.sg-modal-overlay.show {
  display: flex;
}

.sg-modal {
  width: min(440px, 90vw);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: #fffefb;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(33, 36, 31, 0.2);
  overflow: hidden;
}

.sg-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 0.5px solid var(--portal-soft-line, rgba(32, 35, 33, 0.08));
  flex-shrink: 0;
}

.sg-modal-title {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  color: var(--ink, #221f1b);
}

.sg-modal-close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(var(--accent-rgb), 0.08);
  cursor: pointer;
}

.sg-modal-close i,
.sg-modal-close svg {
  width: 18px;
  height: 18px;
  color: var(--muted, #8a8580);
}

.sg-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}

.sg-modal-section {
  margin-bottom: 18px;
}

.sg-modal-section:last-child {
  margin-bottom: 0;
}

.sg-modal-section.hidden {
  display: none;
}

.sg-modal-section-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--cinnabar, #b94132);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 0.5px solid var(--portal-soft-line, rgba(32, 35, 33, 0.08));
}

.sg-modal-section-text {
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink, #221f1b);
  word-break: break-word;
}

.sg-modal-palace-text {
  font-weight: 700;
  color: var(--ink, #221f1b);
}

@media (max-width: 760px) {
  .sg-shell {
    width: 100%;
    min-width: 0;
    padding: 0 0 32px;
  }

  .sg-panel {
    width: 100%;
    min-width: 0;
    padding: 16px;
    border-radius: 18px;
  }

  .sg-header {
    width: 100%;
    min-width: 0;
    padding: 0;
  }

  .sg-intro-text {
    display: none;
  }

  .sg-search-row {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 0 6px 0 14px;
    overflow: hidden;
  }

  .sg-search-row input {
    width: 0;
    min-width: 0;
    font-size: 14px;
  }

  .sg-search-submit {
    padding: 8px 14px;
    font-size: 13px;
  }

  .sg-list {
    grid-template-columns: 1fr;
  }

  .sg-card {
    padding: 16px;
  }

  .sg-card-name {
    font-size: 16px;
  }

  .sg-modal {
    max-height: 80vh;
  }
}
