* { margin: 0; padding: 0; box-sizing: border-box; }

[hidden] { display: none !important; }

:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --border: #e2e8e5;
  --text: #1f352f;
  --text-secondary: #4a635b;
  --primary: #457b66;
  --primary-foreground: #ffffff;
  --primary-strong: #335d4d;
  --radius: 8px;
}

:root[data-theme="dark"] {
  --bg: #101815;
  --surface: #17221e;
  --surface-soft: #1e2b26;
  --border: #31443b;
  --text: #e7f0ec;
  --text-secondary: #b9cac2;
  --primary: #72b79b;
  --primary-foreground: #10201b;
  --primary-strong: #a6d8c5;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

a { color: inherit; }

.explore-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.explore-header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.explore-back {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s;
}

.explore-back:hover { color: var(--text); }

.explore-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.explore-grid {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.explore-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

:root[data-theme="dark"] .explore-card {
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.explore-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.explore-card-img-wrapper {
  width: 100%;
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}

.explore-card-img {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: cover;
  display: block;
}

.explore-card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.explore-card-img-wrapper { position: relative; }

.explore-card-body { padding: 12px 14px; }

.explore-card-prompt {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
  min-height: 39px;
}

.explore-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}

.explore-card-author {
  font-family: monospace;
  opacity: 0.8;
}

.explore-sentinel { height: 1px; }

.explore-loading {
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
  font-size: 14px;
}

.explore-empty {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-secondary);
  font-size: 16px;
}

.explore-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
}

.explore-modal-card {
  position: relative;
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.explore-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.explore-modal-img {
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 8px;
  background: var(--surface-soft);
}

/* Gallery */
.explore-modal-gallery {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.explore-modal-gallery-main {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.explore-modal-gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 2;
}

.explore-modal-gallery-nav:hover { background: rgba(0, 0, 0, 0.75); }
.explore-modal-gallery-nav:disabled { opacity: 0.3; cursor: default; }
.explore-modal-gallery-prev { left: 8px; }
.explore-modal-gallery-next { right: 8px; }

.explore-modal-gallery-counter {
  position: absolute;
  bottom: 8px;
  right: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
  z-index: 2;
}

.explore-modal-gallery-thumbs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.explore-modal-gallery-thumb {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border-radius: 6px;
  border: 2px solid transparent;
  background: var(--surface-soft);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
}

.explore-modal-gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.explore-modal-gallery-thumb.active {
  border-color: var(--primary);
}

.explore-modal-prompt {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  padding: 12px;
  background: var(--surface-soft);
  border-radius: 8px;
}

.explore-modal-params {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.explore-modal-param-tag {
  font-size: 12px;
  padding: 4px 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
}

.explore-modal-copy {
  align-self: flex-start;
  padding: 8px 16px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.explore-modal-copy:hover {
  background: var(--primary);
  color: var(--primary-foreground);
}
