:root {
  color-scheme: dark;
  --bg: #13091f;
  --surface: #151521;
  --surface-2: #1d1c2b;
  --line: #343148;
  --text: #e8e7ee;
  --muted: #a5a1b8;
  --brand: #8b5cf6;
  --brand-dark: #a78bfa;
  --ink: #0f0e18;
  --table-head: #241b3f;
  --table-row: #181724;
  --table-row-hover: #211d33;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(88, 28, 135, 0.34), transparent 34%),
    linear-gradient(180deg, #180a28 0%, var(--bg) 46%, #0d0716 100%);
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans KR", "Noto Sans JP", Arial, sans-serif;
}

.landing-body {
  min-height: 100vh;
  overflow: hidden;
}

.landing-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 0;
}

.landing-visual {
  position: relative;
  display: block;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

.landing-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 50%, rgba(88, 28, 135, 0.14), rgba(8, 4, 14, 0.44)),
    rgba(8, 4, 14, 0.18);
}

.landing-visual img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.start-button {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  transform: translate(-50%, -50%);
  padding: 28px 82px;
  border: 3px solid rgba(244, 241, 255, 0.92);
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.9);
  color: #ffffff;
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-decoration: none;
  pointer-events: auto;
  box-shadow: 0 0 34px rgba(167, 139, 250, 0.72), 0 18px 42px rgba(0, 0, 0, 0.38);
  animation: startPulse 1.05s ease-in-out infinite;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.start-button:hover {
  transform: translate(-50%, -50%) scale(1.12);
  background: rgba(167, 139, 250, 0.96);
  box-shadow: 0 0 58px rgba(216, 211, 255, 0.9), 0 22px 50px rgba(0, 0, 0, 0.42);
}

@keyframes startPulse {
  0%,
  100% {
    opacity: 0.78;
    box-shadow: 0 0 22px rgba(139, 92, 246, 0.46), 0 18px 42px rgba(0, 0, 0, 0.38);
  }
  50% {
    opacity: 1;
    box-shadow: 0 0 48px rgba(216, 211, 255, 0.86), 0 18px 42px rgba(0, 0, 0, 0.38);
  }
}

.admin-corner {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 12;
  pointer-events: auto;
}

.admin-entry {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(216, 211, 255, 0.28);
  border-radius: 999px;
  background: rgba(21, 21, 33, 0.52);
  color: rgba(216, 211, 255, 0.62);
  cursor: pointer;
  font-size: 10px;
  font-weight: 900;
  opacity: 0.5;
}

.admin-entry:hover {
  opacity: 0.95;
  background: rgba(29, 28, 43, 0.88);
}

.admin-popover {
  position: absolute;
  right: 0;
  bottom: 26px;
  width: 230px;
  padding: 12px;
  border: 1px solid #4c4567;
  border-radius: 10px;
  background: #151521;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5);
}

.admin-popover input {
  margin-bottom: 8px;
}

.admin-popover p {
  min-height: 18px;
  color: #fca5a5;
  font-size: 12px;
}

.admin-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.version-badge {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10;
  padding: 6px 10px;
  border: 1px solid #4c4567;
  border-radius: 999px;
  background: rgba(21, 21, 33, 0.94);
  color: #d8d3ff;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

.home-button {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  padding: 6px 10px;
  border: 1px solid #4c4567;
  border-radius: 999px;
  background: rgba(21, 21, 33, 0.86);
  color: #d8d3ff;
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.cancel-all-button {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 12;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid rgba(216, 211, 255, 0.22);
  border-radius: 3px;
  background: rgba(21, 21, 33, 0.46);
  color: rgba(216, 211, 255, 0.48);
  font-size: 12px;
  line-height: 1;
  opacity: 0.42;
}

.cancel-all-button:hover {
  opacity: 0.9;
  border-color: rgba(216, 211, 255, 0.42);
}

.studio {
  width: 100%;
  margin: 0 auto;
  padding: 18px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  width: 80%;
  margin-left: auto;
  margin-right: auto;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  letter-spacing: 0;
}

.subcopy,
.card-header p,
#generationStatus {
  color: var(--muted);
  line-height: 1.45;
}

.elapsed-time {
  margin-top: 3px;
  color: rgba(216, 211, 255, 0.58);
  font-size: 11px;
  line-height: 1.3;
}

.admin-status {
  margin-top: 8px;
  color: #d8d3ff;
  font-size: 12px;
  font-weight: 900;
}

.top-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.9fr) minmax(420px, 1.1fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
  width: 80%;
  margin-left: auto;
  margin-right: auto;
}

.brief-card {
  max-width: none;
}

.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
  padding: 18px;
}

.prompt-card {
  display: flex;
  flex-direction: column;
}

.output-card {
  width: 80%;
  margin-left: auto;
  margin-right: auto;
}

.output-card.card {
  padding-left: 12px;
  padding-right: 12px;
}

.card-header {
  margin-bottom: 14px;
}

.card-header h2 {
  margin-bottom: 4px;
  font-size: 19px;
}

.output-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

label {
  display: grid;
  gap: 6px;
  margin: 12px 0;
  color: #d6d2e8;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(139, 92, 246, 0.24);
  border-color: var(--brand);
  background: #222136;
}

textarea {
  min-height: 78px;
  resize: vertical;
  line-height: 1.45;
}

textarea.large {
  flex: 1;
  min-height: 760px;
  margin-top: 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 15px;
  line-height: 1.55;
}

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

.field-row.compact {
  grid-template-columns: 1.3fr 0.7fr;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #201f31;
  color: var(--text);
  padding: 10px 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

button:hover {
  border-color: var(--brand);
}

button.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.loader {
  display: none;
  width: 30px;
  height: 30px;
  border: 3px solid #343148;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-overlay {
  display: none;
  position: absolute;
  inset: 86px 18px 18px;
  z-index: 5;
  place-items: center;
  align-content: center;
  gap: 14px;
  border: 1px solid rgba(139, 92, 246, 0.28);
  border-radius: 8px;
  background: rgba(15, 14, 24, 0.92);
  color: var(--text);
  text-align: center;
  backdrop-filter: blur(2px);
}

.generating .loading-overlay {
  display: grid;
}

.big-loader {
  width: 72px;
  height: 72px;
  border: 7px solid #343148;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-overlay strong {
  font-size: 22px;
}

.loading-overlay span {
  color: var(--muted);
  font-size: 14px;
}

.generating .loader {
  display: block;
}

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

.progress-panel {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.generating .progress-panel {
  display: grid;
}

.progress-step {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #1d1c2b;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.progress-step.active {
  border-color: var(--brand);
  background: #271d45;
  color: #d8d3ff;
}

.result-output {
  min-height: 560px;
  max-height: none;
  padding: 6px;
  width: 100%;
  overflow: auto;
  border-radius: 6px;
  background: #11101b;
  border: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.5;
}

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

.result-output h3 {
  margin: 0 0 12px;
  font-size: 17px;
}

.result-summary {
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 6px;
  background: #1d1c2b;
  color: var(--text);
  white-space: pre-wrap;
}

.scenario-section {
  margin-bottom: 22px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.scenario-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: collapse;
  background: var(--table-row);
}

.scenario-table th,
.scenario-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
  max-width: none;
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

.scenario-table td {
  background: var(--table-row);
  color: var(--text);
}

.plain-result {
  margin: 0;
  color: var(--text);
  background: transparent;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, "Courier New", monospace;
}

.scenario-table th:nth-child(4),
.scenario-table td:nth-child(4),
.scenario-table th:nth-child(5),
.scenario-table td:nth-child(5),
.scenario-table th:nth-child(6),
.scenario-table td:nth-child(6),
.scenario-table th:nth-child(7),
.scenario-table td:nth-child(7),
.scenario-table th:nth-child(8),
.scenario-table td:nth-child(8),
.scenario-table th:nth-child(9),
.scenario-table td:nth-child(9),
.scenario-table th:nth-child(10),
.scenario-table td:nth-child(10) {
  min-width: 0;
}

.scenario-table th:nth-child(1),
.scenario-table td:nth-child(1) {
  width: 42px;
}

.scenario-table th:nth-child(2),
.scenario-table td:nth-child(2) {
  width: 78px;
}

.scenario-table th:nth-child(3),
.scenario-table td:nth-child(3) {
  width: 54px;
}

.scenario-table th:nth-child(4),
.scenario-table td:nth-child(4) {
  width: 14%;
}

.scenario-table th:nth-child(5),
.scenario-table td:nth-child(5),
.scenario-table th:nth-child(6),
.scenario-table td:nth-child(6) {
  width: 11%;
}

.scenario-table th:nth-child(7),
.scenario-table td:nth-child(7),
.scenario-table th:nth-child(8),
.scenario-table td:nth-child(8),
.scenario-table th:nth-child(10),
.scenario-table td:nth-child(10) {
  width: 13%;
}

.scenario-table th:nth-child(9),
.scenario-table td:nth-child(9) {
  width: 8%;
}

.scenario-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--table-head);
  color: #d8d3ff;
  font-size: 12px;
  white-space: nowrap;
}

.scenario-table td:first-child,
.scenario-table td:nth-child(2),
.scenario-table td:nth-child(3) {
  white-space: nowrap;
  font-weight: 800;
}

.scenario-table tr:hover td {
  background: var(--table-row-hover);
}

summary {
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

@media (max-width: 1100px) {
  .hero {
    width: 100%;
  }

  .top-grid {
    grid-template-columns: 1fr;
    width: 100%;
  }

  textarea.large {
    min-height: 360px;
  }

  .progress-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .output-card {
    width: 80%;
  }
}

@media (max-width: 1100px) {
  .output-card {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .studio {
    padding: 16px;
  }

  .field-row,
  .field-row.compact,
  .progress-panel {
    grid-template-columns: 1fr;
  }
}
