﻿:root {
  color-scheme: dark;
  --bg: #080914;
  --panel: rgba(255, 255, 255, 0.09);
  --panel-strong: rgba(255, 255, 255, 0.14);
  --text: #f7f7ff;
  --muted: #aeb3cf;
  --line: rgba(255, 255, 255, 0.16);
  --primary: #8b5cf6;
  --primary-2: #22d3ee;
  --danger: #fb7185;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.52), inset 0 1px 0 rgba(255,255,255,.12);
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 8%, rgba(56, 189, 248, 0.58), transparent 30%),
    radial-gradient(circle at 88% 12%, rgba(168, 85, 247, 0.58), transparent 32%),
    radial-gradient(circle at 78% 86%, rgba(244, 63, 94, 0.36), transparent 34%),
    radial-gradient(circle at 28% 78%, rgba(34, 197, 94, 0.22), transparent 30%),
    linear-gradient(135deg, #060713 0%, #111041 38%, #1d1238 68%, #070814 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.055) 1px, transparent 1px),
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.16), transparent 1px);
  background-size: 52px 52px, 52px 52px, 22px 22px;
  opacity: .58;
  mask-image: radial-gradient(circle at 50% 42%, black, transparent 76%);
}

body::after {
  content: "";
  position: fixed;
  inset: -20%;
  pointer-events: none;
  background:
    conic-gradient(from 120deg at 50% 50%, rgba(34,211,238,.18), rgba(168,85,247,.16), rgba(244,63,94,.13), rgba(34,211,238,.18));
  filter: blur(70px);
  opacity: .75;
  animation: aura 12s ease-in-out infinite alternate;
  z-index: -1;
}

.heart-trail {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(var(--s)) rotate(var(--r));
  color: #ff5ca8;
  font-size: 18px;
  line-height: 1;
  text-shadow:
    0 0 10px rgba(255, 92, 168, .85),
    0 0 22px rgba(236, 72, 153, .55);
  animation: heart-float .9s ease-out forwards;
}

@keyframes heart-float {
  0% {
    opacity: 1;
    filter: blur(0);
  }
  100% {
    opacity: 0;
    filter: blur(1px);
    transform: translate(calc(-50% + var(--x)), -118px) scale(.2) rotate(calc(var(--r) + 36deg));
  }
}

@keyframes aura {
  from { transform: rotate(0deg) scale(1); }
  to { transform: rotate(10deg) scale(1.08); }
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.user-hero {
  position: relative;
  padding: 24px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 34px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.13), rgba(255,255,255,.045)),
    radial-gradient(circle at 12% 18%, rgba(34,211,238,.22), transparent 34%),
    radial-gradient(circle at 88% 22%, rgba(236,72,153,.2), transparent 32%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  overflow: hidden;
}

.user-hero::before {
  content: "";
  position: absolute;
  inset: -1px;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(255,255,255,.34), transparent 28%, transparent 72%, rgba(34,211,238,.2));
  opacity: .6;
}

.user-hero > * {
  position: relative;
  z-index: 1;
}

.user-hero h1 {
  background: linear-gradient(90deg, #fff, #fbcfe8 42%, #67e8f9);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 16px 70px rgba(236,72,153,.28);
}

.user-hero p {
  color: #dbe4ff;
}

.eyebrow {
  color: var(--primary-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
}

h1, h2, p { margin: 0; }

h1 {
  margin-top: 10px;
  font-size: clamp(42px, 7vw, 86px);
  line-height: .92;
  letter-spacing: -0.07em;
}

.hero p {
  max-width: 620px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(18px);
  white-space: nowrap;
}

.status-pill span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #34d399;
  box-shadow: 0 0 24px #34d399;
}

.workspace {
  display: grid;
  grid-template-columns: 430px 1fr;
  gap: 22px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 32px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.145), rgba(255,255,255,.055)),
    linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,0));
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  position: relative;
  overflow: hidden;
}

.controls,
.preview {
  isolation: isolate;
}

.controls::after {
  content: "";
  position: absolute;
  right: -80px;
  bottom: -90px;
  width: 190px;
  height: 190px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(236,72,153,.32), transparent 68%);
  pointer-events: none;
}

.preview::after {
  content: "";
  position: absolute;
  left: -90px;
  top: 32%;
  width: 220px;
  height: 220px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(34,211,238,.24), transparent 70%);
  pointer-events: none;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(255,255,255,.22), transparent 28%, transparent 72%, rgba(34,211,238,.13));
  opacity: .65;
}

.controls { padding: 24px; }
.controls > *, .preview > * { position: relative; z-index: 1; }

.field { display: grid; gap: 9px; }

label {
  color: #dfe3ff;
  font-size: 14px;
  font-weight: 700;
}

textarea, input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  outline: none;
  color: var(--text);
  background: rgba(5, 8, 22, 0.58);
  padding: 14px 15px;
  font: inherit;
  transition: border .2s, box-shadow .2s, transform .2s;
}

textarea {
  min-height: 188px;
  resize: vertical;
  line-height: 1.65;
}

textarea:focus, input:focus, select:focus {
  border-color: rgba(34,211,238,.9);
  box-shadow: 0 0 0 4px rgba(34,211,238,.12);
}

select option { color: #111827; }

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 20px;
}

.quick-prompts button {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #eef2ff;
  background: rgba(255,255,255,.08);
  padding: 9px 12px;
  cursor: pointer;
  transition: transform .2s, border-color .2s, background .2s;
}

.quick-prompts button:hover {
  transform: translateY(-2px);
  border-color: rgba(34,211,238,.7);
  background: rgba(34,211,238,.13);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.generate {
  position: relative;
  width: 100%;
  margin-top: 22px;
  border: 0;
  border-radius: 20px;
  color: white;
  background: linear-gradient(135deg, var(--primary), #ec4899 48%, var(--primary-2));
  padding: 17px 20px;
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 18px 45px rgba(139, 92, 246, 0.36);
}

.generate:hover { transform: translateY(-1px); }
.generate:disabled { cursor: wait; filter: grayscale(.2); opacity: .76; }
.generate .loading { display: none; }
.is-loading .generate .idle { display: none; }
.is-loading .generate .loading { display: inline; }

.hint {
  margin-top: 13px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.preview {
  min-height: 690px;
  padding: 24px;
}

.preview-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.preview h2 {
  margin-top: 6px;
  font-size: 28px;
}

.download-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.download {
  border: 1px solid rgba(34,211,238,.48);
  border-radius: 999px;
  color: white;
  text-decoration: none;
  padding: 11px 14px;
  background: rgba(34,211,238,.13);
  cursor: pointer;
  font: inherit;
}

.canvas {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 540px;
  border: 1px dashed rgba(255,255,255,.2);
  border-radius: 28px;
  background:
    linear-gradient(45deg, rgba(255,255,255,.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,.035) 25%, transparent 25%),
    rgba(2, 6, 23, .42);
  background-size: 28px 28px;
  overflow: hidden;
}

.canvas img {
  max-width: 100%;
  max-height: 74vh;
  width: auto;
  height: auto;
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(0,0,0,.44);
}

.empty-state {
  max-width: 340px;
  text-align: center;
  color: var(--muted);
}

.empty-state .spark {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border-radius: 24px;
  color: white;
  font-size: 36px;
  background: linear-gradient(135deg, rgba(139,92,246,.75), rgba(34,211,238,.7));
}

.empty-state p {
  color: white;
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 8px;
}

.revised, .error {
  margin-top: 16px;
  border-radius: 18px;
  padding: 14px 16px;
}

.image-meta {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  color: #dbeafe;
  font-weight: 800;
  text-align: center;
}

.revised {
  color: #dbeafe;
  background: rgba(59,130,246,.12);
  border: 1px solid rgba(59,130,246,.25);
}

.revised p {
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.55;
}

.error {
  color: #ffe4e6;
  background: rgba(251,113,133,.14);
  border: 1px solid rgba(251,113,133,.38);
}

.hidden { display: none !important; }

.admin-shell {
  width: min(1380px, calc(100% - 32px));
}

.admin-hero h1 {
  font-size: clamp(34px, 5vw, 64px);
}

.admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(34,211,238,.48);
  border-radius: 999px;
  color: white;
  text-decoration: none;
  padding: 12px 16px;
  background: rgba(34,211,238,.13);
}

.admin-login {
  max-width: 480px;
  margin: 40px auto 0;
}

.admin-card {
  position: relative;
  z-index: 1;
  padding: 26px;
  display: grid;
  gap: 18px;
}

.admin-dashboard {
  display: grid;
  gap: 20px;
}

.admin-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

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

.stat-card {
  padding: 18px;
}

.stat-card span {
  position: relative;
  z-index: 1;
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.stat-card strong {
  position: relative;
  z-index: 1;
  display: block;
  font-size: 24px;
  line-height: 1.1;
}

.admin-workspace {
  grid-template-columns: 430px 1fr;
}

.admin-config h2 {
  position: relative;
  z-index: 1;
  margin-bottom: 10px;
}

.muted-line {
  color: var(--muted);
  font-size: 12px;
}

.admin-table-panel {
  padding: 24px;
  min-width: 0;
}

.table-wrap {
  position: relative;
  z-index: 1;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(2, 6, 23, .38);
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.log-table th,
.log-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  text-align: left;
  vertical-align: top;
  color: #e5e7ff;
  font-size: 13px;
}

.log-table th {
  color: var(--primary-2);
  font-weight: 800;
  background: rgba(255,255,255,.05);
}

.prompt-cell {
  max-width: 380px;
  color: var(--muted) !important;
  line-height: 1.45;
}

.result {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 9px;
  font-weight: 800;
  white-space: nowrap;
}

.result.ok {
  color: #bbf7d0;
  background: rgba(34,197,94,.15);
}

.result.bad {
  color: #fecdd3;
  background: rgba(251,113,133,.15);
}

.empty-row {
  text-align: center !important;
  color: var(--muted) !important;
  padding: 34px !important;
}

@media (max-width: 920px) {
  .hero { align-items: flex-start; flex-direction: column; }
  .workspace { grid-template-columns: 1fr; }
  .preview { min-height: auto; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 20px, 1180px); padding: 22px 0; }
  .panel { border-radius: 24px; }
  .grid { grid-template-columns: 1fr; }
  .canvas { min-height: 390px; }
  .stats-grid { grid-template-columns: 1fr; }
}
