:root {
  --bg-top: #f4f8ff;
  --bg-bottom: #eaf0f9;
  --panel: #ffffff;
  --ink: #111827;
  --sub: #60708a;
  --line: #d4deed;
  --line-strong: #bfccde;
  --primary: #1677ff;
  --primary-strong: #0b5fd0;
  --shadow: 0 10px 26px rgba(16, 24, 40, 0.1);
  --radius-lg: 16px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  min-height: 100dvh;
  color: var(--ink);
  font-family: "Plus Jakarta Sans", "Noto Sans KR", sans-serif;
  line-height: 1.45;
  background:
    radial-gradient(circle at 10% -10%, rgba(22, 119, 255, 0.12), transparent 35%),
    radial-gradient(circle at 92% 5%, rgba(53, 114, 211, 0.09), transparent 28%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  width: min(1280px, 96vw);
  min-height: 100dvh;
  height: auto;
  margin: 0 auto;
  padding: 0.7rem 0 0.7rem;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 0.55rem;
}

.hero {
  border-radius: 18px;
  padding: 0.8rem 1rem;
  color: #ecf3ff;
  background: linear-gradient(135deg, #132449 0%, #1f3d75 56%, #255597 100%);
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 0;
  font-size: clamp(1rem, 2.3vw, 1.35rem);
  line-height: 1.2;
}

.hero p {
  margin: 0.35rem 0 0;
  font-size: clamp(0.78rem, 1.8vw, 0.9rem);
  color: rgba(232, 241, 255, 0.95);
}

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

.view-tabs button {
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: #4d5f7b;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.view-tabs button.is-active {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}

.workspace {
  min-height: 0;
  height: auto;
  position: relative;
  overflow-x: hidden;
  overflow-y: visible;
}

.workspace-track {
  width: 100%;
  min-height: 100%;
  height: auto;
  display: flex;
  align-items: flex-start;
  transform: translateX(calc(var(--view-index, 0) * -100%));
  transition: transform 240ms ease;
  will-change: transform;
}

.app-view {
  display: block;
  flex: 0 0 100%;
  min-width: 0;
  width: 100%;
  height: auto;
}

.panel {
  width: 100%;
  height: auto;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  overflow: visible;
}

.workflow-panel {
  padding: 0.62rem;
  display: grid;
  grid-template-rows: auto auto;
  gap: 0.55rem;
}

.step-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 0.62rem;
  min-height: 0;
}

.step-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.step-card h2 {
  margin: 0;
  font-size: 0.98rem;
}

.step-card.is-locked {
  opacity: 0.72;
}

.step-card.is-active {
  border-color: rgba(22, 119, 255, 0.32);
}

#step1Card.is-compact {
  padding-bottom: 0.5rem;
}

#step1Card.is-compact .dropzone,
#step1Card.is-compact .text-button {
  display: none;
}

#step1Card.is-compact .step-card-head {
  margin-bottom: 0.32rem;
}

#step1Card.is-compact .upload-summary {
  grid-template-columns: 46px 1fr;
  gap: 0.45rem;
}

#step1Card.is-compact .upload-summary img {
  width: 46px;
  height: 46px;
}

#step1Card.is-compact .upload-summary-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

#step1Card.is-compact .upload-summary-meta p {
  font-size: 0.8rem;
}

#step1Card.is-compact .upload-summary-meta .secondary {
  min-height: 32px;
  padding: 0.32rem 0.58rem;
  font-size: 0.78rem;
}

#photoInput {
  display: none;
}

.dropzone {
  min-height: 102px;
  border-radius: 12px;
  border: 2px dashed #c5d5ea;
  background: #f5f9ff;
  display: grid;
  place-items: center;
  gap: 0.22rem;
  text-align: center;
  cursor: pointer;
  padding: 0.65rem;
}

.dropzone-icon {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: #e7f0ff;
  border: 1px solid #c3d8ff;
}

.dropzone strong {
  font-size: 0.95rem;
}

.dropzone small {
  font-size: 0.8rem;
  color: var(--sub);
}

.upload-summary {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 0.55rem;
  align-items: center;
}

.upload-summary img {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid #cad8ec;
}

.upload-summary-meta p {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 700;
  color: #324867;
  word-break: break-all;
}

.text-button {
  margin-top: 0.45rem;
  border: 0;
  background: transparent;
  color: #1d5cb4;
  font-size: 0.83rem;
  font-weight: 700;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 0.16em;
  cursor: pointer;
}

.lock-note {
  margin: 0 0 0.4rem;
  color: #69788f;
  font-size: 0.82rem;
}

#step2Card {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 0.48rem;
  min-height: 0;
}

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

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

.control-card {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fbfdff;
  padding: 0.42rem 0.52rem;
}

.control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.24rem;
  color: #304560;
  font-size: 0.83rem;
  font-weight: 700;
  gap: 0.45rem;
}

.control-head strong {
  color: #1f2f45;
}

input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(22, 119, 255, 0.8), rgba(22, 119, 255, 0.17));
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border-radius: 999px;
  border: 2px solid #ffffff;
  background: var(--primary);
  box-shadow: 0 4px 10px rgba(22, 119, 255, 0.35);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(22, 119, 255, 0.8), rgba(22, 119, 255, 0.17));
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid #ffffff;
  background: var(--primary);
  box-shadow: 0 4px 10px rgba(22, 119, 255, 0.35);
}

button,
select,
.download-link {
  min-height: 38px;
  padding: 0.42rem 0.7rem;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled {
  opacity: 0.56;
  cursor: not-allowed;
}

.primary {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}

.secondary {
  background: #f7fbff;
  border-color: #c7d4e7;
}

.rotation-quick {
  display: flex;
  justify-content: center;
  gap: 0.45rem;
}

.icon-round {
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  height: 36px;
  border-radius: 999px;
  padding: 0;
  line-height: 1;
}

.tilt-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.mini-icon {
  width: 28px;
  min-width: 28px;
  min-height: 28px;
  height: 28px;
  border-radius: 999px;
  padding: 0;
  line-height: 1;
}

.simple-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: #324b68;
  font-size: 0.82rem;
  font-weight: 600;
}

.simple-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

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

.status-message {
  margin: 0;
  min-height: 1rem;
  color: #4f607b;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-message.success {
  color: #166c46;
}

.status-message.error {
  color: #aa3b2a;
}

.canvas-wrap {
  min-height: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f7fbff;
  padding: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#editorCanvas {
  width: 100%;
  max-width: 100%;
  display: block;
  border-radius: 10px;
  border: 1px solid #c3d2e7;
  touch-action: none;
}

.result-panel {
  padding: 0.62rem;
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 0.48rem;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.result-head h2 {
  margin: 0;
  font-size: 1rem;
}

.download-link {
  text-decoration: none;
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, #178f5c, #167848);
  display: none;
}

.download-link.is-visible {
  display: inline-flex;
}

.output-meta {
  display: grid;
  gap: 0.35rem;
}

.output-meta > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9fcff;
  padding: 0.42rem 0.55rem;
  font-size: 0.82rem;
  color: #4d5f78;
}

.output-meta strong {
  color: #1c2e47;
}

.output-preview-box {
  position: relative;
  min-height: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f7fbff;
  padding: 0.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#outputCanvas {
  width: min(100%, 330px);
  height: auto;
  max-height: 100%;
  display: block;
  aspect-ratio: 35 / 45;
  border-radius: 10px;
  border: 1px solid #c0cfdf;
  background: #ffffff;
}

.processing-overlay {
  position: absolute;
  inset: 0.35rem;
  border-radius: 10px;
  background: rgba(14, 23, 35, 0.44);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-weight: 700;
}

.spinner {
  width: 15px;
  height: 15px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  animation: spin 700ms linear infinite;
}

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

.disclaimer {
  margin: 0;
  color: #5d6c83;
  font-size: 0.77rem;
}

.regulations {
  padding: 0.62rem;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 0.45rem;
  overflow: visible;
}

.reg-head h2 {
  margin: 0;
  font-size: 1rem;
}

.reg-head p {
  margin: 0.2rem 0 0;
  color: #5b6e88;
  font-size: 0.8rem;
}

.reg-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 0.95fr;
  gap: 0.42rem;
}

.reg-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fcff;
  padding: 0.5rem;
}

.reg-card h3 {
  margin: 0 0 0.3rem;
  font-size: 0.84rem;
  color: #1f3451;
}

.reg-list {
  margin: 0;
  padding-left: 0.95rem;
  color: #324a66;
  line-height: 1.45;
  font-size: 0.77rem;
}

.sample-photo {
  margin-top: 0.35rem;
  border-radius: 12px;
  border: 1px solid #c2d1e4;
  overflow: hidden;
  width: min(100%, 170px);
  aspect-ratio: 35 / 45;
  background: #f5f9ff;
}

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

.sample-caption {
  margin: 0.35rem 0 0;
  color: #5c6f89;
  font-size: 0.73rem;
}

.reg-footer {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 0.42rem;
  min-height: 0;
}

.bg-help p {
  margin: 0 0 0.38rem;
  color: #314a67;
  font-size: 0.76rem;
  line-height: 1.45;
}

.bg-help h3 {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.warn-icon {
  position: relative;
  display: inline-block;
  width: 1.08rem;
  height: 0.98rem;
  background: linear-gradient(180deg, #fde047 0%, #facc15 100%);
  border: 1px solid #b7791f;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  vertical-align: -0.06rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset;
}

.warn-icon::after {
  content: "!";
  position: absolute;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%);
  font-size: 0.7rem;
  font-weight: 900;
  color: #1f2937;
  line-height: 1;
}

.bg-help a {
  color: #1d5cb5;
  font-size: 0.78rem;
  font-weight: 700;
  text-underline-offset: 0.15em;
}

.link-list {
  display: grid;
  gap: 0.35rem;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fcff;
  padding: 0.5rem;
}

.link-list a {
  color: #1c5db8;
  font-size: 0.78rem;
  font-weight: 700;
  text-underline-offset: 0.15em;
}

@media (max-width: 700px) {
  .app-shell {
    width: 96vw;
    min-height: auto;
    padding-top: 0.5rem;
    gap: 0.45rem;
  }

  .hero {
    padding: 0.64rem 0.75rem;
    border-radius: 16px;
  }

  .hero p {
    font-size: 0.8rem;
    margin-top: 0.28rem;
  }

  .view-tabs button {
    min-height: 36px;
    font-size: 0.83rem;
  }

  .workflow-panel,
  .result-panel,
  .regulations {
    padding: 0.5rem;
  }

  .step-card {
    padding: 0.5rem;
  }

  #step1Card.is-compact .upload-summary {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }

  #step1Card.is-compact .upload-summary img {
    display: none;
  }

  #step1Card.is-compact .upload-summary-meta p {
    font-size: 0.76rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 48vw;
  }

  #step1Card.is-compact .upload-summary-meta .secondary {
    min-height: 30px;
    font-size: 0.76rem;
    padding: 0.28rem 0.5rem;
  }

  .dropzone {
    min-height: 88px;
  }

  .control-stack {
    gap: 0.32rem;
  }

  .control-card {
    padding: 0.34rem 0.44rem;
  }

  .control-head {
    font-size: 0.79rem;
  }

  #step2Card {
    grid-template-rows: auto auto auto;
  }

  .canvas-wrap {
    min-height: 220px;
  }

  .simple-check {
    font-size: 0.78rem;
  }

  button,
  .download-link {
    min-height: 36px;
    font-size: 0.84rem;
  }

  .result-head h2 {
    font-size: 0.95rem;
  }

  .output-meta > div {
    font-size: 0.78rem;
  }

  #outputCanvas {
    width: min(100%, 280px);
  }

  .disclaimer {
    font-size: 0.74rem;
  }

  .regulations {
    grid-template-rows: auto auto auto;
    overflow: visible;
  }

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

  .sample-card {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.45rem;
    align-items: center;
  }

  .sample-card .sample-photo {
    width: 110px;
    margin-top: 0;
  }

  .sample-card .sample-caption {
    margin: 0;
  }

  .reg-footer {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
