/* 팔레트: #FEEAC9 #FFCDC9 #FDACAC #FD7979 · #FFC7C7 #FFE2E2 #F6F6F6 #8785A2 */
:root {
  --peach: #feeac9;
  --blush: #ffcdc9;
  --rose: #fdacac;
  --coral: #fd7979;
  --pink: #ffc7c7;
  --pink-soft: #ffe2e2;
  --mist: #f6f6f6;
  --lavender: #8785a2;
  /* 글자용 라벤더: #8785a2는 흰 배경 대비 3.56:1이라 작은 글씨에 쓰지 않는다 */
  --lavender-text: #6b6987;

  --bg: var(--mist);
  --surface: #ffffff;
  --ink: #2e2c40;
  --muted: #66647f;
  --line: #ebe6ea;
  --accent: var(--coral);
  --accent-ink: #2e2c40;
  --chip: var(--pink-soft);
  --chip-ink: #5a3a44;
  --chip-alt: var(--peach);
  --chip-alt-ink: #5b4527;
  --chip-cool: #e9e8f1;
  --chip-cool-ink: #47455e;
  --danger: #c2413f;
  --radius: 16px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1d29;
    --surface: #282737;
    --ink: #f6f6f6;
    --muted: #a9a7c2;
    --line: #37364a;
    --accent: var(--coral);
    --accent-ink: #2e2c40;
    --chip: #463645;
    --chip-ink: #ffe2e2;
    --chip-alt: #4a3f33;
    --chip-alt-ink: #feeac9;
    --chip-cool: #3a3950;
    --chip-cool-ink: #dddcf0;
    --danger: #ff9a98;
    --lavender-text: #a9a7c2;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  font-feature-settings: 'ss06';
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

h1 {
  font-size: 22px;
  margin: 0;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 16px;
  margin: 0;
}

code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.88em;
}

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

.small {
  font-size: 13px;
}

.error {
  color: var(--danger);
  margin: 0;
}

/* 로그인 */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, var(--peach), var(--pink-soft) 45%, var(--bg) 80%);
}

.login-card {
  width: min(380px, 100%);
  display: grid;
  gap: 12px;
}

.tagline {
  margin: -6px 0 4px;
  color: var(--lavender-text);
  font-weight: 600;
}

.login-icon {
  border-radius: 18px;
  box-shadow: 0 8px 24px rgb(253 121 121 / 0.3);
}

/* 공통 컨트롤 */
input[type='text'],
input[type='password'],
input[type='number'],
select {
  width: 100%;
  font: inherit;
  font-size: 16px; /* iOS 확대 방지 */
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
}

input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 2px;
}

.btn {
  font: inherit;
  font-weight: 650;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 12px;
  padding: 11px 14px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.btn.ghost {
  background: transparent;
  width: 100%;
}

.btn.danger {
  color: var(--danger);
}

.btn,
.icon-link,
.pill,
.tabs button,
.chips span,
.segmented span,
.remote-keys button {
  transition: transform 0.25s var(--ease), background-color 0.25s var(--ease), opacity 0.25s var(--ease);
}

.btn:active,
.icon-link:active,
.pill:active,
.remote-keys button:active {
  transform: scale(0.97);
}

.tabs button:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
}

/* 숫자는 폭을 맞춘다 (가격·경쟁률·카운트) */
.price,
.meta,
.facts,
.summary,
.dday,
#status {
  font-variant-numeric: tabular-nums;
}

/* 카드가 차례로 나타난다 */
.card {
  animation: rise 0.5s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* 불러오는 중 자리표시 */
.card.skeleton {
  animation: none;
}

.skeleton .thumb,
.skeleton i {
  display: block;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--chip-cool) 0%, var(--surface) 50%, var(--chip-cool) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

.skeleton i {
  height: 12px;
}

.skeleton i:nth-child(1) {
  width: 40%;
}

.skeleton i:nth-child(2) {
  width: 90%;
  height: 16px;
}

.skeleton i:nth-child(3) {
  width: 55%;
  height: 16px;
}

.skeleton i:nth-child(4) {
  width: 70%;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* 연결됨 점이 천천히 숨 쉰다 */
.pill.on::before {
  animation: breathe 2.4s ease-in-out infinite;
}

@keyframes breathe {
  50% {
    opacity: 0.35;
  }
}

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

.small-btn {
  padding: 7px 12px;
  font-size: 14px;
}

.top-text {
  min-width: 0;
}

.top-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-top: 2px;
}

.pill {
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px 2px 7px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
}

.pill::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.pill.on {
  background: var(--chip-alt);
  color: var(--chip-alt-ink);
}

.pill.on::before {
  background: #4fae7f;
}

.pill.off {
  background: var(--chip);
  color: var(--chip-ink);
}

.pill.off::before {
  background: var(--coral);
}

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 8px;
  border-radius: 999px;
  cursor: pointer;
}

.icon-btn.spinning svg {
  animation: spin 0.9s linear infinite;
}

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

/* 레이아웃 */
.top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 12px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

main {
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 92px);
  max-width: 720px;
  margin: 0 auto;
}

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabs button {
  font: inherit;
  font-size: 11px;
  font-weight: 650;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 4px 8px;
  display: grid;
  justify-items: center;
  gap: 3px;
  cursor: pointer;
}

.tabs svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.tabs button[aria-current='page'] {
  color: var(--coral);
}

.list-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.empty {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
  color: var(--muted);
  padding: 56px 24px;
}

.empty img {
  border-radius: 16px;
  opacity: 0.9;
}

.empty p {
  margin: 0;
  max-width: 280px;
}

/* 자동 신청 배너 */
.banner {
  display: grid;
  gap: 10px;
  padding: 14px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--peach), var(--pink));
  color: #2e2c40;
}

.banner strong {
  font-size: 16px;
}

.banner .row .btn {
  background: rgb(255 255 255 / 0.75);
  border-color: transparent;
  color: #2e2c40;
}

.banner .row .btn.primary {
  background: #2e2c40;
  color: #fff;
}

.countdown {
  height: 4px;
  border-radius: 4px;
  background: rgb(255 255 255 / 0.6);
  overflow: hidden;
}

.countdown i {
  display: block;
  height: 100%;
  background: var(--coral);
  transition: width 1s linear;
}

/* 카드 */
.events {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.card.pending {
  border-color: var(--rose);
  box-shadow: 0 0 0 1px var(--rose);
}

.thumb {
  position: relative;
  width: 96px;
  height: 120px;
}

.thumb img,
.card > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  background: var(--chip);
  display: block;
}

.dday {
  position: absolute;
  left: 6px;
  top: 6px;
  font-size: 11px;
  font-weight: 750;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.92);
  color: #2e2c40;
}

.dday.urgent {
  background: var(--coral);
}

.card .body {
  min-width: 0;
  display: grid;
  gap: 4px;
  align-content: start;
}

.brand {
  font-size: 12px;
  font-weight: 700;
  color: var(--lavender-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand em {
  font-style: normal;
  font-weight: 500;
  color: var(--muted);
}

.name {
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.price {
  font-weight: 750;
}

.price s {
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
  font-size: 13px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  font-size: 12px;
}

.tag {
  background: var(--chip-cool);
  color: var(--chip-cool-ink);
  border-radius: 6px;
  padding: 2px 7px;
  font-weight: 600;
}

.tag.hot {
  background: var(--chip);
  color: var(--chip-ink);
}

.tag.warm {
  background: var(--chip-alt);
  color: var(--chip-alt-ink);
}

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

.card .actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  align-items: center;
}

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

.card .actions .spacer {
  flex: 1;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.pick input {
  width: 20px;
  height: 20px;
  accent-color: var(--coral);
}

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

.badge {
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--chip-cool);
  color: var(--chip-cool-ink);
  white-space: nowrap;
}

.badge.ok {
  background: var(--chip-alt);
  color: var(--chip-alt-ink);
}

.badge.bad {
  background: var(--chip);
  color: var(--chip-ink);
}

/* 신청 내역 */
.summary b {
  font-size: 16px;
}

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
}

.history-item {
  grid-template-columns: 64px 1fr;
}

.history-item img {
  width: 64px;
  height: 76px;
}

.history-item .actions a,
.history-item .actions button {
  flex: 0 1 auto;
}

/* 설정 */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  display: grid;
  gap: 12px;
}

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

.stack {
  display: grid;
  gap: 8px;
}

.account-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--chip-alt);
  color: var(--chip-alt-ink);
}

.account-card img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface);
}

.account-who {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.account-who strong {
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-who .muted {
  color: inherit;
  opacity: 0.8;
}

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

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

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.switch-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--coral);
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

legend,
.field > span {
  display: block;
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 6px;
}

.field em {
  font-style: normal;
  color: var(--muted);
  font-weight: 400;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chips label,
.segmented label {
  position: relative;
}

.chips input,
.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chips span {
  display: inline-block;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 14px;
  cursor: pointer;
}

.chips input:checked + span {
  background: var(--pink);
  color: #2e2c40;
  border-color: var(--rose);
  font-weight: 650;
}

.chips input:focus-visible + span,
.segmented input:focus-visible + span {
  outline: 2px solid var(--coral);
  outline-offset: 2px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3px;
}

.segmented span {
  display: block;
  text-align: center;
  padding: 9px 4px;
  border-radius: 9px;
  font-weight: 650;
  color: var(--muted);
  cursor: pointer;
}

.segmented input:checked + span {
  background: var(--coral);
  color: #2e2c40;
}

.hint-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: -4px;
}

.hint-row .btn {
  flex: none;
  white-space: nowrap;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -16px;
  padding: 12px 16px 0;
  border-top: 1px solid var(--line);
}

/* 원격 로그인 */
.remote {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #1e1d29;
  color: #f6f6f6;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.remote-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
}

.remote-screen {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 0 8px;
}

.remote-screen img {
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 390 / 780;
  border-radius: 12px;
  background: #fff;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.remote-controls {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
}

.remote-type {
  display: flex;
  gap: 8px;
}

.remote-type .btn {
  flex: none;
  white-space: nowrap;
}

.remote-keys {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.remote-keys button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font: inherit;
  font-size: 13px;
  border: 0;
  border-radius: 10px;
  padding: 10px 2px;
  background: #36354a;
  color: #f6f6f6;
}

/* 화면 보기 */
.shot {
  position: fixed;
  inset: 0;
  z-index: 11;
  background: rgb(30 29 41 / 0.92);
  overflow: auto;
  padding: calc(env(safe-area-inset-top) + 12px) 12px 24px;
}

.shot img {
  width: 100%;
  margin-top: 10px;
  border-radius: 12px;
}

.remote-keys svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.toast {
  position: fixed;
  left: 50%;
  /* 아래쪽 저장 버튼·입력칸을 가리지 않게 위에 띄운다 */
  top: calc(env(safe-area-inset-top) + 76px);
  transform: translateX(-50%);
  z-index: 20;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  max-width: calc(100% - 32px);
}
