/* ── 앱 셸 ───────────────────────────────────────────────────── */
.appbar {
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.appbar__in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  height: 62px;
}

.credit {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}

.credit b {
  color: var(--eraser);
}

.appmain {
  padding: 30px 0 80px;
}

/* ── 로그인 팝업 (모달 오버레이) ─────────────────────────────── */
#gateView {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 13, 16, 0.65); /* --void 색상 기반의 투명 어둡기 */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex !important;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

#gateView[hidden] {
  display: none !important;
}

.gate {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 36px 30px 30px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
  animation: gate-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.gate__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0;
  background: var(--paper);
  color: var(--muted);
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  padding-bottom: 2px;
  transition: background 0.15s ease, color 0.15s ease;
}

.gate__close:hover {
  background: var(--line);
  color: var(--ink);
}

@keyframes gate-pop {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.gate h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 27px;
  letter-spacing: -0.035em;
}

.gate p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.field {
  margin-top: 16px;
}

.field label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}

.field input:focus {
  background: #fff;
}

.gate__switch {
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.gate__switch button {
  border: 0;
  background: none;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.note {
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  background: var(--eraser-dim);
  color: #8f1a2c;
}

.note[hidden] {
  display: none;
}

/* ── 작업 화면 ───────────────────────────────────────────────── */
.studio {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
}

@media (min-width: 960px) {
  .studio {
    grid-template-columns: 1.35fr 0.65fr;
    align-items: start;
  }
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
}

.panel__title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}

.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.mode {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 11px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s var(--ease);
}

.mode b {
  display: block;
  font-size: 14px;
}

.mode span {
  font-size: 12px;
  color: var(--muted);
}

.mode[aria-pressed="true"] {
  border-color: var(--eraser);
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--eraser);
}

/* 캔버스 무대 */
.drop {
  position: relative;
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  min-height: 300px;
  display: grid;
  place-items: center;
  overflow: hidden;
  text-align: center;
  padding: 24px;
}

.drop.is-over {
  border-color: var(--eraser);
}

.drop__hint b {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}

.drop__hint span {
  font-size: 13px;
  color: var(--muted);
}

.canvas-stack {
  position: relative;
  display: none;
  line-height: 0;
  max-width: 100%;
}

.canvas-stack.is-on {
  display: block;
}

.canvas-stack canvas {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

#maskCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

#maskCanvas[hidden] {
  display: none;
}

.brushbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}

.brushbar[hidden] {
  display: none;
}

.brushbar input[type="range"] {
  flex: 1;
  accent-color: var(--eraser);
}

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

.actions .btn {
  flex: 1 1 auto;
}

/* 결과 */
.result {
  margin-top: 18px;
}

.result[hidden] {
  display: none;
}

.result__box {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  padding: 14px;
}

.result__box img {
  margin-inline: auto;
  max-height: 420px;
  width: auto;
}

/* 크레딧 구매 */
.buy {
  display: grid;
  gap: 8px;
}

.buy__row {
  display: flex;
  gap: 8px;
}

.buy__row input {
  flex: 1;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: var(--mono);
  background: var(--paper);
}

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

.chip {
  flex: 1;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.buy__total {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 13px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

.buy__total b {
  font-size: 16px;
}

/* 기록 */
.log {
  margin-top: 8px;
  font-size: 13px;
}

.log__row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.log__row:last-child {
  border-bottom: 0;
}

.log__empty {
  color: var(--muted);
  font-size: 13px;
  padding: 6px 0;
}

/* 진행 표시 */
.bar {
  height: 3px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
  margin-top: 14px;
}

.bar[hidden] {
  display: none;
}

.bar i {
  display: block;
  height: 100%;
  width: 35%;
  background: var(--eraser);
  animation: slide 1.1s infinite var(--ease);
}

@keyframes slide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(320%);
  }
}
