:root {
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --text: #0f172a;
  --text-subtle: #475569;
  --line: rgba(15, 23, 42, 0.13);
  --accent: #0f766e;
  --accent-soft: rgba(15, 118, 110, 0.13);
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.11);
  --radius-xl: 26px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Pretendard Variable", "Noto Sans KR", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 14% 8%, #ffffff 0%, rgba(255, 255, 255, 0.2) 20%, transparent 52%),
    radial-gradient(circle at 90% 16%, #dbeafe 0%, transparent 45%),
    linear-gradient(145deg, #eef2ff 0%, #f8fafc 50%, #e8edf3 100%);
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  z-index: 0;
  border-radius: 999px;
  pointer-events: none;
}

.orb-1 {
  width: 340px;
  height: 340px;
  right: -120px;
  top: -80px;
  background: radial-gradient(circle at 30% 30%, rgba(14, 165, 233, 0.35), rgba(14, 165, 233, 0.04));
}

.orb-2 {
  width: 320px;
  height: 320px;
  left: -130px;
  bottom: -90px;
  background: radial-gradient(circle at 60% 60%, rgba(16, 185, 129, 0.28), rgba(16, 185, 129, 0.03));
}

.grain {
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(15, 23, 42, 0.07) 0.5px, transparent 0.5px);
  background-size: 4px 4px;
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
}

.layout {
  position: relative;
  z-index: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: 48px 22px 80px;
}

.hero {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4.2vw, 3.8rem);
  line-height: 1.03;
  letter-spacing: -0.02em;
}

h1 span {
  display: block;
  color: #1e3a8a;
}

.hero-copy {
  margin: 16px 0 0;
  color: var(--text-subtle);
  line-height: 1.6;
}

.workspace {
  margin-top: 30px;
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
}

.card {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.form-card,
.output-card {
  padding: 22px;
}

.output-card {
  grid-column: 1 / -1;
}

.section-title-wrap h2 {
  margin: 0;
  font-size: 1.22rem;
}

.section-title-wrap p {
  margin: 6px 0 0;
  color: var(--text-subtle);
  font-size: 0.9rem;
}

.field-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  font-size: 0.84rem;
  color: #1f2937;
  font-weight: 620;
}

.span-2 {
  grid-column: span 2;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
  border-radius: var(--radius-lg);
  padding: 11px 12px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.gallery-track:focus-visible {
  border-color: rgba(15, 118, 110, 0.58);
  box-shadow: 0 0 0 4px var(--accent-soft);
  outline: none;
}

input[type="range"] {
  padding: 0;
  border: none;
  background: transparent;
  accent-color: var(--accent);
}

.inline-control {
  display: flex;
  gap: 8px;
}

.inline-control-wide {
  flex-wrap: wrap;
}

.inline-control-wide button {
  white-space: nowrap;
}

.provider-toggle {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toggle-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.8rem;
}

.toggle-option input[type="radio"] {
  margin: 0;
}

.toggle-option:has(input:checked) {
  border-color: rgba(15, 118, 110, 0.45);
  background: rgba(15, 118, 110, 0.13);
  color: #0f766e;
  font-weight: 640;
}

.prompt-provider-panel.is-hidden {
  display: none;
}

#character-custom {
  margin-top: 8px;
}

.inline-control select,
.inline-control input {
  flex: 1;
}

.masterpiece-field {
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.65));
  padding: 14px;
}

.masterpiece-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.current-work {
  font-size: 0.76rem;
  color: #1e40af;
  background: rgba(219, 234, 254, 0.65);
  border: 1px solid rgba(30, 64, 175, 0.2);
  border-radius: 999px;
  padding: 5px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 55%;
}

.gallery-tabs {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-btn {
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: rgba(255, 255, 255, 0.9);
  color: #1f2937;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.tab-btn.is-active {
  border-color: rgba(15, 118, 110, 0.42);
  background: rgba(15, 118, 110, 0.13);
  color: #0f766e;
  font-weight: 620;
}

.gallery-shell {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 8px;
}

.gallery-nav {
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 0;
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 130ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.gallery-track {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 4px 8px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  white-space: nowrap;
}

.gallery-track::-webkit-scrollbar {
  height: 9px;
}

.gallery-track::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.2);
  border-radius: 999px;
}

.frame-card {
  flex: 0 0 auto;
  width: auto;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 10px 6px 12px;
  position: relative;
  scroll-snap-align: start;
  text-align: left;
  transition: transform 160ms ease;
}

.frame-hanger {
  width: 2px;
  height: 14px;
  background: rgba(15, 23, 42, 0.45);
  margin: 0 auto -2px;
}

.frame-outer {
  border-radius: 8px;
  padding: 10px;
  background: linear-gradient(130deg, #2b2f36, #5d6674 30%, #1f242b 66%, #7b8593);
  border: 1px solid rgba(15, 23, 42, 0.35);
  box-shadow:
    0 18px 24px rgba(15, 23, 42, 0.24),
    0 3px 6px rgba(15, 23, 42, 0.12);
  position: relative;
  transition: transform 170ms ease, box-shadow 200ms ease;
}

.frame-outer::before {
  content: "";
  position: absolute;
  inset: -10px 16px auto;
  height: 20px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.35), transparent 62%);
  filter: blur(3px);
  pointer-events: none;
}

.frame-inner {
  background: #0b1220;
  border: 2px solid rgba(226, 232, 240, 0.5);
  border-radius: 4px;
  overflow: hidden;
  aspect-ratio: auto;
  width: 320px;
  height: 380px;
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.frame-inner.is-broken {
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  background:
    linear-gradient(140deg, rgba(15, 23, 42, 0.85), rgba(30, 41, 59, 0.95)),
    repeating-linear-gradient(
      45deg,
      rgba(148, 163, 184, 0.2) 0,
      rgba(148, 163, 184, 0.2) 8px,
      rgba(100, 116, 139, 0.1) 8px,
      rgba(100, 116, 139, 0.1) 16px
    );
}

.frame-inner.is-broken .artwork-image {
  display: none;
}

.frame-failure-message {
  color: rgba(241, 245, 249, 0.92);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-align: center;
  display: block;
}

.frame-failure-hint {
  color: rgba(226, 232, 240, 0.96);
  font-size: 0.83rem;
  text-align: center;
  display: block;
}

.frame-failure-panel {
  display: none;
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 4;
  width: calc(100% - 24px);
  max-width: 330px;
  padding: 10px 12px;
  box-sizing: border-box;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(226, 232, 240, 0.35);
  box-shadow: 0 8px 14px rgba(2, 6, 23, 0.3);
}

.frame-failure-panel:not(.is-hidden) {
  display: flex;
}

.artwork-image {
  width: auto;
  height: 100%;
  object-fit: contain;
  display: block;
}

.frame-reload-btn {
  margin-top: 4px;
  border: 1px solid rgba(15, 23, 42, 0.22);
  background: rgba(255, 255, 255, 0.94);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 620;
  width: 100%;
}

.frame-reload-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 12px rgba(15, 23, 42, 0.12);
}

.frame-reload-btn.is-hidden {
  display: none;
}

.frame-reload-btn:active {
  transform: scale(0.98);
}

.frame-reload-btn:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.45);
  outline-offset: 2px;
}

.frame-caption {
  margin-top: 8px;
  display: grid;
  gap: 2px;
}

.caption-title {
  font-size: 0.84rem;
  font-weight: 650;
  color: #0f172a;
}

.caption-artist {
  font-size: 0.76rem;
  color: #475569;
}

.frame-card.is-selected .frame-outer {
  outline: 3px solid rgba(15, 118, 110, 0.5);
  outline-offset: 3px;
  box-shadow:
    0 20px 30px rgba(15, 23, 42, 0.29),
    0 0 0 5px rgba(15, 118, 110, 0.14);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.quick-actions {
  margin-top: 14px;
}

.plan-field {
  margin-top: 14px;
}

.help-text {
  margin: -2px 0 0;
  font-size: 0.79rem;
  color: var(--text-subtle);
}

.primary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 10px 14px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 130ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.primary-btn {
  background: linear-gradient(125deg, #0f766e 0%, #0369a1 100%);
  color: white;
  font-weight: 650;
}

.ghost-btn {
  background: white;
  border-color: var(--line);
  color: #1f2937;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(3, 105, 161, 0.28);
}

.ghost-btn:hover {
  transform: translateY(-1px);
  background: #f8fafc;
  box-shadow: 0 8px 14px rgba(15, 23, 42, 0.11);
}

.tab-btn:hover {
  transform: translateY(-1px);
  background: #f8fafc;
}

.gallery-nav:hover {
  transform: translateY(-1px);
  background: #ffffff;
  box-shadow: 0 8px 14px rgba(15, 23, 42, 0.16);
}

.frame-card:hover .frame-outer {
  transform: translateY(-4px);
  box-shadow:
    0 26px 30px rgba(15, 23, 42, 0.28),
    0 5px 8px rgba(15, 23, 42, 0.13);
}

.primary-btn:active,
.ghost-btn:active,
.tab-btn:active,
.gallery-nav:active {
  transform: scale(0.98);
}

.frame-card:active .frame-outer {
  transform: translateY(-1px) scale(0.995);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.action-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.action-row.compact {
  margin-top: 10px;
  margin-bottom: 12px;
}

.action-toolbar-row {
  justify-content: flex-start;
}

.action-toolbar-row .ghost-btn,
.action-toolbar-row .image-generate-btn {
  margin: 0;
}

.copy-guide {
  margin: -4px 0 6px;
  line-height: 1.45;
}

.copy-guide strong {
  color: #92400e;
}

.build-account-panel {
  margin-top: 12px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid rgba(49, 130, 246, 0.22);
  border-radius: 15px;
  background: linear-gradient(135deg, rgba(239, 247, 255, 0.96), rgba(255, 255, 255, 0.92));
}

.build-account-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.build-account-label {
  color: #1b64da;
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.09em;
}

.build-account-copy strong {
  color: #000c3d;
  font-size: 0.98rem;
}

.build-account-copy small {
  color: #6b7684;
  font-size: 0.76rem;
  line-height: 1.45;
}

.build-account-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.build-badge {
  min-height: 34px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #e8f3ff;
  color: #1b64da;
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.google-signin-slot {
  min-height: 40px;
  display: flex;
  align-items: center;
}

.image-control-row {
  justify-content: flex-start;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.image-model-select {
  min-width: 220px;
}

.image-api-input {
  min-width: 260px;
  flex: 1 1 320px;
}

.image-control-row .ghost-btn {
  white-space: nowrap;
}

.image-generate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(194, 65, 12, 0.26);
  padding: 13px 22px;
  min-height: 52px;
  background: linear-gradient(125deg, #c2410c 0%, #ea580c 48%, #f59e0b 100%);
  color: #fff;
  font-size: 0.98rem;
  font-weight: 760;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 14px 24px rgba(234, 88, 12, 0.3);
  transition: transform 140ms ease, box-shadow 190ms ease, filter 190ms ease;
}

.image-generate-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.03);
  box-shadow: 0 18px 28px rgba(234, 88, 12, 0.38);
}

.image-generate-btn:active {
  transform: scale(0.985);
}

.status {
  margin: 0;
  color: var(--text-subtle);
  font-size: 0.86rem;
}

.badge {
  font-size: 0.77rem;
  color: #0c4a6e;
  background: rgba(224, 242, 254, 0.9);
  border: 1px solid rgba(14, 116, 144, 0.24);
  border-radius: 999px;
  padding: 7px 11px;
  white-space: nowrap;
}

.generated-image-section {
  margin-top: 14px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  padding: 12px;
}

.generated-image {
  width: 100%;
  max-height: 640px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(15, 23, 42, 0.06);
}

.is-hidden {
  display: none !important;
}

.footnote {
  margin-top: 14px;
  border: 1px dashed rgba(15, 23, 42, 0.2);
  border-radius: 14px;
  padding: 10px 14px;
  color: #334155;
  background: rgba(255, 255, 255, 0.57);
  font-size: 0.84rem;
}

.reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: reveal-up 620ms cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}

.reveal-delay-1 {
  animation-delay: 120ms;
}

.reveal-delay-2 {
  animation-delay: 220ms;
}

@keyframes reveal-up {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .field-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .current-work {
    max-width: 65%;
  }
}

@media (max-width: 760px) {
  .gallery-shell {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .gallery-nav {
    display: none;
  }

  .gallery-track {
    padding: 10px 0 8px;
  }

  .frame-card {
    padding-left: 0;
    padding-right: 0;
  }

  .masterpiece-topline {
    flex-direction: column;
    align-items: flex-start;
  }

  .current-work {
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  .layout {
    padding: 34px 14px 50px;
  }

  .form-card,
  .output-card {
    padding: 17px;
  }

  .inline-control {
    flex-wrap: wrap;
  }

  .action-row {
    flex-wrap: wrap;
  }

  .build-account-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .build-account-actions {
    justify-content: flex-start;
  }
}
