/* Style adapted from Uiverse.io by Priyanshu02020 */
:root {
  --form-width: 315px;
  --aspect-ratio: 1.33;
  --page-bg: #1c1c1c;
  --login-box-color: #272727;
  --input-color: #3a3a3a;
  --button-color: #373737;
  --footer-color: rgba(255, 255, 255, 0.5);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #fff;
}

.hidden { display: none !important; }

.auth-wrap {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  background: var(--login-box-color);
  border-radius: 24px;
  width: calc(var(--form-width) + 1px);
  height: calc(var(--form-width) * var(--aspect-ratio) + 1px);
  z-index: 8;
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.2),
    0 8px 16px rgba(0, 0, 0, 0.2),
    0 0 8px rgba(255, 255, 255, 0.1),
    0 0 16px rgba(255, 255, 255, 0.08);
}

.container::before {
  content: "";
  position: absolute;
  inset: -50px;
  z-index: -2;
  background: conic-gradient(from 45deg, transparent 75%, #fff, transparent 100%);
  animation: spin 4s ease-in-out infinite;
}

@keyframes spin { 100% { transform: rotate(360deg); } }

.login-box {
  background: var(--login-box-color);
  border-radius: 24px;
  padding: 28px;
  width: var(--form-width);
  height: calc(var(--form-width) * var(--aspect-ratio));
  position: absolute;
  z-index: 10;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  box-shadow:
    inset 0 40px 60px -8px rgba(255, 255, 255, 0.12),
    inset 4px 0 12px -6px rgba(255, 255, 255, 0.12),
    inset 0 0 12px -4px rgba(255, 255, 255, 0.12);
}

.form {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 10px;
}

.logo {
  width: 65px;
  height: 65px;
  background: linear-gradient(135deg, rgba(255,255,255,0.2), rgba(0,0,0,0.2));
  box-shadow:
    8px 8px 16px rgba(0, 0, 0, 0.2),
    -8px -8px 16px rgba(255, 255, 255, 0.06);
  border-radius: 20px;
  border: 2px solid #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  flex-shrink: 0;
}

.logo::before {
  content: "";
  position: absolute;
  bottom: 10px;
  width: 50%;
  height: 20%;
  border-top-left-radius: 40px;
  border-top-right-radius: 40px;
  border-bottom-right-radius: 20px;
  border-bottom-left-radius: 20px;
  border: 2.5px solid #fff;
}

.logo::after {
  content: "";
  position: absolute;
  top: 10px;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  border: 2.5px solid #fff;
}

.logo-sm { width: 42px; height: 42px; border-radius: 14px; }
.logo-sm::before { bottom: 6px; border-width: 2px; }
.logo-sm::after { top: 6px; border-width: 2px; }

.header {
  text-align: center;
  font-size: 24px;
  font-weight: bold;
  padding: 6px;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
}

.input {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 12px;
  background: var(--input-color);
  color: white;
  outline: none;
  font-size: 14px;
  font-family: inherit;
}

.input:focus { border: 1px solid #fff; }

.button {
  width: 100%;
  height: 40px;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: grid;
  place-content: center;
  gap: 10px;
  background: var(--button-color);
  color: white;
  transition: 0.3s;
  box-shadow:
    inset 0px 3px 6px -4px rgba(255, 255, 255, 0.6),
    inset 0px -3px 6px -2px rgba(0, 0, 0, 0.8);
}

.button:hover {
  background: rgba(255, 255, 255, 0.25);
  box-shadow:
    inset 0px 3px 6px rgba(255, 255, 255, 0.6),
    inset 0px -3px 6px rgba(0, 0, 0, 0.8),
    0px 0px 8px rgba(255, 255, 255, 0.05);
}

.button:disabled { opacity: 0.5; cursor: not-allowed; }

.sign-in { margin-top: 5px; }

.footer {
  width: 100%;
  text-align: left;
  color: var(--footer-color);
  font-size: 12px;
}

.footer .link {
  position: relative;
  color: var(--footer-color);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer .link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 0;
  border-radius: 6px;
  height: 1px;
  background: currentColor;
  transition: width 0.3s ease;
}

.footer .link:hover { color: #fff; }
.footer .link:hover::after { width: 100%; }

/* ---- studio layout ---- */
.studio {
  display: flex;
  min-height: 100vh;
}

.panel {
  width: 340px;
  flex-shrink: 0;
  background: var(--login-box-color);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow:
    inset 0 40px 60px -8px rgba(255, 255, 255, 0.08),
    4px 0 16px rgba(0, 0, 0, 0.35);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.label {
  font-size: 12px;
  color: var(--footer-color);
  margin-top: 6px;
}

.seg {
  display: flex;
  gap: 6px;
}

.seg-btn {
  flex: 1;
  padding: 9px 4px;
  border: none;
  border-radius: 12px;
  background: var(--input-color);
  color: var(--footer-color);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.25s;
  box-shadow:
    inset 0px 2px 4px -3px rgba(255, 255, 255, 0.5),
    inset 0px -2px 4px -2px rgba(0, 0, 0, 0.8);
}

.seg-btn:hover { color: #fff; background: rgba(255,255,255,0.18); }

.seg-btn.active {
  background: var(--button-color);
  color: #fff;
  box-shadow:
    inset 0px 3px 6px rgba(255, 255, 255, 0.4),
    inset 0px -3px 6px rgba(0, 0, 0, 0.8),
    0 0 8px rgba(255, 255, 255, 0.08);
}

.prompt { resize: vertical; min-height: 110px; }

.generate { margin-top: 8px; }

.logout {
  margin-top: auto;
  height: 34px;
  font-size: 12px;
  border-radius: 17px;
  opacity: 0.8;
}

.status { min-height: 16px; }
.status.error { color: #ff8a8a; }

.gallery {
  flex: 1;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  align-content: start;
  overflow-y: auto;
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--footer-color);
  padding-top: 15vh;
  font-size: 14px;
}

.card {
  background: var(--login-box-color);
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.3),
    0 0 8px rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
}

.card img {
  width: 100%;
  display: block;
  aspect-ratio: 1;
  object-fit: cover;
  cursor: zoom-in;
}

.card .meta {
  padding: 10px 12px;
  font-size: 11.5px;
  color: var(--footer-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.card .meta .dl {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.card.loading .ph {
  aspect-ratio: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--footer-color);
  font-size: 13px;
  background:
    linear-gradient(110deg, rgba(255,255,255,0.03) 40%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.03) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}

@keyframes shimmer { to { background-position-x: -200%; } }

.card.failed .ph {
  aspect-ratio: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 12px;
  color: #ff8a8a;
  font-size: 12px;
  background: rgba(255, 100, 100, 0.06);
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  cursor: zoom-out;
}

.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 12px; }

@media (max-width: 760px) {
  .studio { flex-direction: column; }
  .panel { width: 100%; }
}
