:root {
  --bg: #0a0b0f;
  --bg2: #12141b;
  --ink: #e9eaee;
  --muted: #9096a3;
  --panel: rgba(22, 24, 32, 0.85);
  --panel-solid: #171922;
  --stroke: rgba(255, 255, 255, 0.09);
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --danger: #f87171;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --input-bg: #10121a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 12% 8%, rgba(139, 92, 246, 0.16), transparent 45%),
    radial-gradient(circle at 88% 15%, rgba(34, 211, 238, 0.12), transparent 40%),
    linear-gradient(165deg, #0d0f15 0%, var(--bg) 55%, #08090c 100%);
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(
      rgba(139, 92, 246, 0.06) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, rgba(34, 211, 238, 0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at center, black 20%, transparent 100%);
}

.shell {
  width: min(1080px, calc(100% - 2rem));
  margin: 2rem auto;
  position: relative;
  z-index: 1;
}

.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  padding: 1.6rem 1.2rem;
  border-right: 1px solid var(--stroke);
  background: rgba(14, 16, 22, 0.8);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
}

.brand .tag {
  display: inline-block;
  margin: 0 0 0.5rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

.brand-title {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff, #b8b3ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.nav-bottom {
  margin-top: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  transition: background 140ms ease, transform 140ms ease;
}

.nav-link:hover {
  background: rgba(139, 92, 246, 0.12);
  transform: translateX(2px);
}

.nav-link.active {
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  color: #fff;
  box-shadow: var(--shadow);
}

.nav-icon {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.8rem;
  font-weight: 700;
}

.nav-link.active .nav-icon {
  background: rgba(255, 255, 255, 0.2);
}

.content {
  padding: 2rem clamp(1rem, 3vw, 2.5rem);
  max-width: 1080px;
}

@media (max-width: 860px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--stroke);
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

.hero {
  margin-bottom: 1rem;
  animation: rise 500ms ease-out both;
}

.tag {
  display: inline-block;
  margin: 0;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

h1,
h2 {
  color: var(--ink);
}

h1 {
  margin: 0.6rem 0 0.3rem;
  font-size: clamp(2rem, 4.5vw, 3.3rem);
  letter-spacing: -0.03em;
}

.sub {
  margin: 0;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.panel {
  border: 1px solid var(--stroke);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 1rem;
  backdrop-filter: blur(6px);
  animation: rise 650ms ease-out both;
}

.panel h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.form {
  display: grid;
  gap: 0.8rem;
}

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--muted);
}

textarea,
input,
select,
button {
  font: inherit;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 0.68rem 0.72rem;
  background: var(--input-bg);
  color: var(--ink);
}

textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

input[type="number"] {
  color-scheme: dark;
}

select option {
  background: var(--panel-solid);
  color: var(--ink);
}

button {
  border: none;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  font-weight: 650;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.35);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.inline-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.field-label {
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--muted);
}

.field-hint {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.prompt-presets {
  display: grid;
  gap: 0.5rem;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 0.75rem 0.85rem;
  background: rgba(255, 255, 255, 0.02);
}

.preset-empty {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.preset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.preset-chip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 0.25rem 0.3rem 0.25rem 0.7rem;
  background: var(--input-bg);
}

.preset-name {
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.preset-name:hover {
  color: var(--accent-2);
}

.preset-remove {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: none;
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.preset-remove:hover {
  background: rgba(248, 113, 113, 0.25);
}

.preset-save-row {
  display: flex;
  gap: 0.5rem;
}

.preset-save-row input {
  flex: 1;
}

.secondary-btn {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 0.6rem 0.9rem;
  background: var(--input-bg);
  color: var(--ink);
  font-weight: 650;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.secondary-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.ratio-picker {
  display: grid;
  gap: 0.45rem;
}

.ratio-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ratio-btn {
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: var(--input-bg);
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 140ms ease;
}

.ratio-btn:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.ratio-btn.active {
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  border-color: transparent;
  color: #fff;
}

.reference-box {
  display: grid;
  gap: 0.45rem;
}

.reference-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-2);
  font-weight: 650;
  font-size: 0.85rem;
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

.reference-drop {
  display: grid;
  place-items: center;
  gap: 0.5rem;
  min-height: 100px;
  border: 1.5px dashed var(--stroke);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  padding: 0.9rem;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  transition: border-color 140ms ease, background 140ms ease;
}

.reference-drop:hover {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.06);
}

.reference-drop.is-dragover {
  border-color: var(--accent-2);
  background: rgba(34, 211, 238, 0.1);
  box-shadow: inset 0 0 0 2px rgba(34, 211, 238, 0.25);
}

.reference-drop img,
.reference-drop video {
  max-width: 100%;
  max-height: 160px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
}

.output {
  margin-top: 1rem;
}

.progress-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  margin: 0.6rem 0 1rem;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 300ms ease;
}

.status-text {
  color: var(--accent-2);
  font-weight: 600;
}

.status-text.is-error {
  color: var(--danger);
}

.result-media {
  margin-top: 0.7rem;
}

.result-media img,
.result-media video {
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: #000;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.result-actions button,
.result-actions .download-link {
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 0.55rem 0.9rem;
  font-weight: 650;
  font-size: 0.88rem;
  background: var(--input-bg);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.result-actions button:hover,
.result-actions .download-link:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.extend-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  margin-bottom: 0.3rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: rgba(139, 92, 246, 0.08);
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

.extend-banner .link-btn {
  white-space: nowrap;
}

.portfolio-storage-panel {
  margin-bottom: 1rem;
}

.storage-bar-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}

.storage-text {
  color: var(--muted);
  font-size: 0.85rem;
}

.storage-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--input-bg);
  border: 1px solid var(--stroke);
  overflow: hidden;
}

.storage-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 300ms ease;
}

.storage-bar-fill.is-full {
  background: linear-gradient(90deg, var(--danger), #dc2626);
}

.storage-warning {
  margin: 0.6rem 0 0;
  color: var(--danger);
  font-size: 0.85rem;
}

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

.portfolio-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.portfolio-video {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: #000;
}

.portfolio-image {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: #000;
  object-fit: contain;
}

.portfolio-prompt {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.portfolio-negative {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.portfolio-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.7rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
  padding: 1.5rem;
}

.login-panel {
  width: min(380px, 100%);
  animation: rise 500ms ease-out both;
}

.login-panel h2 {
  margin: 0.4rem 0 0.2rem;
}

.login-panel .sub {
  margin: 0 0 1rem;
  color: var(--muted);
}

.login-panel .status-text {
  margin-bottom: 0.8rem;
}

details {
  color: var(--muted);
}

details summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}

pre {
  overflow: auto;
  max-height: 260px;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 0.7rem;
  background: var(--input-bg);
  color: var(--muted);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 860px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .shell {
    width: min(1080px, calc(100% - 1rem));
    margin: 1rem auto;
  }
}
