:root {
  --bg: #0c1024;
  --card: #111735;
  --card-alt: #0f142d;
  --accent: #f2c94c;
  --text: #e7ecf7;
  --muted: #9ba5c4;
  --stroke: #1d2443;
  --success: #2fbf6a;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  font-family: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(120% 80% at 50% 0%, rgba(242, 201, 76, 0.08), transparent 45%), var(--bg);
  min-height: 100vh;
}

.app { display: flex; flex-direction: column; min-height: 100vh; }
.app__header {
  padding: 18px 18px 10px;
  position: sticky;
  top: 0;
  z-index: 3;
  background: linear-gradient(180deg, rgba(12,16,36,0.92) 0%, rgba(12,16,36,0.92) 70%, rgba(12,16,36,0.5) 100%);
  backdrop-filter: blur(8px);
}
.logo { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.logo__emoji { font-size: 22px; }
.logo__title { font-weight: 700; letter-spacing: -0.01em; margin: 0; font-size: 18px; }
.logo__subtitle { color: var(--muted); font-size: 14px; }

.pill { display: inline-flex; background: var(--card); border-radius: 999px; padding: 4px; gap: 4px; margin-bottom: 12px; }
.pill__btn { border: none; padding: 8px 14px; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; }
.pill__btn--active { background: var(--accent); color: #0b0c12; box-shadow: var(--shadow); }

.chips { display: flex; gap: 8px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--card);
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip--active { background: var(--accent); color: #0b0c12; border-color: var(--accent); }

.app__main { flex: 1; padding: 0 18px 90px; }
.tab { display: none; }
.tab--active { display: block; }

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.card {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background: var(--card);
  min-height: 200px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 14px 50px rgba(0,0,0,0.45); }
.card__image {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
  background: var(--card-alt);
}
.card__content { padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; }
.card__title { font-weight: 700; font-size: 15px; margin: 0; }
.card__media { margin: 0; }
.card__tags { display: flex; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.card__footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color: var(--muted);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.badge--success { background: rgba(47, 191, 106, 0.16); color: #c6f5d8; }
.badge--accent { background: rgba(242, 201, 76, 0.16); color: var(--accent); }
.badge--copy {
  background: var(--accent);
  color: #0b0c12;
  justify-content: center;
  min-width: 38px;
  box-shadow: var(--shadow);
  border: none;
  cursor: pointer;
}

.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 12px;
}

.btn {
  border: none;
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}
.btn--primary { background: var(--accent); color: #0b0c12; box-shadow: var(--shadow); }
.btn--ghost { background: rgba(255,255,255,0.06); color: var(--text); border: 1px solid var(--stroke); }
.btn--compact { padding: 10px 12px; font-size: 14px; margin-left: auto; }

.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #0f1a33;
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 9999;
}
.toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px 16px calc(32px + env(safe-area-inset-bottom, 0));
  background: linear-gradient(180deg, rgba(12,16,36,0.6) 0%, rgba(12,16,36,0.9) 100%);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--stroke);
}
.tabbar__btn {
  font-size: large;
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 10px 8px;
  font-weight: 700;
  cursor: pointer;
}
.tabbar__btn--active { background: var(--accent); color: #0b0c12; border-color: var(--accent); }

.modal { position: fixed; inset: 0; z-index: 20; }
.modal.hidden { display: none; }
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(4,6,12,0.7); backdrop-filter: blur(10px);
}
.modal__content {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, 92vw);
  max-height: 90vh;
  background: var(--card);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.modal__image {
  width: 100%;
  display: block;
  object-fit: contain;
  max-height: 45vh;
}
.modal__body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.modal__actions {
  display: flex;
  gap: 10px;
}
.modal__actions--top {
  padding: 10px 16px 6px;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 2;
}
.modal__title { font-weight: 800; font-size: 18px; }
.modal__text {
  color: var(--text);
  opacity: 0.92;
  line-height: 1.4;
  white-space: pre-line;
}
.modal__actions { display: flex; gap: 10px; }
.modal__close {
  position: absolute; top: 8px; right: 8px;
  border: none; background: rgba(0,0,0,0.35);
  color: var(--text); width: 32px; height: 32px; border-radius: 50%;
  font-size: 20px; cursor: pointer;
}

.builder { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.builder__group { background: var(--card); border: 1px solid var(--stroke); border-radius: 16px; overflow: hidden; }
.builder__group--open { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(242,201,76,0.2); }
.builder__header {
  width: 100%;
  padding: 12px;
  border: none;
  background: none;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text);
  text-align: left;
  min-height: 48px;
}
.builder__title {font-size: 18px; font-weight: 700; margin: 0; }
.builder__summary {
  margin-left: auto;
  color: var(--muted);
  font-size: 18px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}
.builder__chevron { color: var(--muted); transition: transform 0.15s ease; }
.builder__group--open .builder__chevron { transform: rotate(180deg); }
.builder__body { padding: 0 12px 12px; border-top: 1px solid var(--stroke); }
.builder__body[hidden] { display: none; }
.builder__options { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.option {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: var(--card-alt);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}
.option--active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(242,201,76,0.25); }

.builder__result {
  position: sticky;
  bottom: 70px;
  margin-top: 14px;
  /* margin-bottom: 14px; */
  background: var(--card);
  border-radius: 16px;
  padding: 12px;
  border: 1px solid var(--stroke);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.builder__label { color: var(--text); font-size: 16px; font-weight: 700; }
.builder__hint { color: var(--muted); font-size: 12px; line-height: 1.4; }
.builder__actions { display: flex; gap: 10px; }
textarea {
  width: 100%;
  min-height: 70px;
  background: var(--card-alt);
  border: 1px solid var(--stroke);
  color: var(--text);
  border-radius: 12px;
  padding: 10px;
  resize: vertical;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 10px;
}
.stat__value { font-size: 22px; font-weight: 800; }
.stat__label { color: var(--muted); font-size: 13px; }

.favorites__header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.favorites__title { font-weight: 800; }
.favorites__hint { color: var(--muted); font-size: 12px; }

.admin-body { background: radial-gradient(120% 80% at 50% 0%, rgba(242, 201, 76, 0.08), transparent 45%), var(--bg); }
.admin {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 18px 36px;
}
.admin__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0 6px;
}
.admin__badge {
  background: rgba(242,201,76,0.16);
  color: var(--accent);
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  font-weight: 700;
  box-shadow: var(--shadow);
}
.admin__main { display: flex; flex-direction: column; gap: 14px; }
.panel {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.panel--ghost { background: linear-gradient(135deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01)); }
.panel__title { font-weight: 800; font-size: 18px; margin-bottom: 8px; }
.panel__divider { border-top: 1px solid var(--stroke); margin: 12px 0; }
.grid-2 {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 700; color: var(--text); }
.field input,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: var(--card-alt);
  color: var(--text);
  font-size: 14px;
}
.field textarea { min-height: 120px; }
.field__hint { color: var(--muted); font-size: 12px; }
.field--inline { flex-direction: column; gap: 4px; }
.checkbox { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; }
.actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.result { min-height: 120px; }
.result-card {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 10px;
  background: var(--card);
}
.result-card__image {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 12px;
  background: var(--card-alt);
}
.result-card__body { display: flex; flex-direction: column; gap: 6px; }
.result-card__title { font-weight: 800; font-size: 16px; }
.result-card__meta { color: var(--muted); font-size: 13px; }
.result-card__flags { display: flex; gap: 8px; align-items: center; }
.result-card__tags { color: var(--muted); font-size: 13px; }
.result-card__prompt {
  white-space: pre-wrap;
  background: var(--card-alt);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 10px;
  color: var(--text);
  font-size: 13px;
  max-height: 260px;
  overflow: auto;
}

@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .modal__content { width: 94vw; max-height: 92vh; }
  .modal__image { max-height: 46vh; }
  .result-card { grid-template-columns: 1fr; }
}
