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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #11111e;
  color: #d8d0f0;
  font-family: 'Courier New', monospace;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Header ── */

#gallery-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: #0d0d1a;
  border-bottom: 1px solid #252540;
  flex-shrink: 0;
}

.back-link {
  color: #7777aa;
  text-decoration: none;
  font-size: 0.82rem;
  opacity: 0.75;
  transition: opacity 0.2s, color 0.2s;
  white-space: nowrap;
}

.back-link:hover {
  opacity: 1;
  color: #aaaadd;
}

#gallery-header h1 {
  font-size: 1.1rem;
  color: #b8a8ff;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  flex: 1;
}

#tabs {
  display: flex;
  gap: 0.4rem;
}

.tab {
  background: transparent;
  border: 1px solid #333355;
  color: #7777aa;
  padding: 0.35rem 1rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  border-radius: 4px;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  letter-spacing: 0.06em;
}

.tab:hover {
  border-color: #5555aa;
  color: #b0a0ee;
}

.tab.active {
  background: #22224a;
  border-color: #6655cc;
  color: #c4b4ff;
}

/* ── Main content ── */

#gallery-main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.section {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: 1.5rem;
}

.section.active {
  display: block;
}

.section-hint {
  text-align: center;
  color: #555577;
  font-size: 0.78rem;
  margin-bottom: 1.5rem;
  letter-spacing: 0.06em;
}

/* ── Card grid ── */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem;
}

.gallery-card {
  background: #191926;
  border: 1px solid #27274a;
  border-radius: 8px;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  transition: border-color 0.2s, background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.gallery-card:hover {
  border-color: #4444aa;
  background: #1f1f36;
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(80, 60, 180, 0.25);
}

.gallery-card.active {
  border-color: #8866ff;
  background: #22224a;
  box-shadow: 0 0 18px rgba(140, 100, 255, 0.35);
}

.card-emoji {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 0.1rem;
}

.card-name {
  font-size: 0.88rem;
  color: #c0b0f8;
  font-weight: bold;
  letter-spacing: 0.02em;
}

.card-desc {
  font-size: 0.75rem;
  color: #7788aa;
  line-height: 1.5;
  flex: 1;
}

.card-badge {
  font-size: 0.68rem;
  color: #444466;
  letter-spacing: 0.04em;
  margin-top: 0.1rem;
}

.cursor-card {
  cursor: pointer;
}

.cursor-card.active .card-badge {
  color: #9977ff;
}

.cursor-card.active .card-badge::before {
  content: '● ';
}

.widget-card {
  cursor: pointer;
}

.widget-card .card-badge {
  color: #4455aa;
  transition: color 0.2s;
}

.widget-card:hover .card-badge {
  color: #8877ff;
}

/* ── Widget Preview Modal ── */

.widget-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.widget-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(3px);
}

.widget-modal-box {
  position: relative;
  z-index: 1;
  width: min(88vw, 860px);
  height: min(86vh, 680px);
  background: #0d0d1a;
  border: 1px solid #2a2a55;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 48px rgba(100, 60, 200, 0.3), 0 8px 32px rgba(0, 0, 0, 0.6);
}

.widget-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.1rem;
  border-bottom: 1px solid #222244;
  flex-shrink: 0;
  background: #0a0a16;
}

.widget-modal-title {
  font-size: 0.88rem;
  color: #c0b0f8;
  letter-spacing: 0.06em;
}

.widget-modal-close {
  background: transparent;
  border: 1px solid #2a2a55;
  color: #6666aa;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}

.widget-modal-close:hover {
  border-color: #5555aa;
  color: #b0a0ee;
}

.widget-modal-body {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.widget-modal-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555577;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  background: #0d0d1a;
}

.widget-modal-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #11111e;
  display: block;
  transition: opacity 0.3s;
}
