:root {
  --bg: #f2e9de;
  --surface: #fffdf8;
  --card: #f7f1e8;
  --ink: #202124;
  --muted: #65605a;
  --primary: #6d55f2;
  --secondary: #88a987;
  --reward: #e6b85c;
  --accent: #b96a83;
  --mist: #e8eef0;
  --line: rgba(32, 33, 36, 0.12);
  --shadow: 0 28px 70px rgba(66, 50, 36, 0.22);
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(109, 85, 242, 0.14), transparent 30%),
    radial-gradient(circle at 84% 16%, rgba(136, 169, 135, 0.2), transparent 28%),
    linear-gradient(135deg, #fff9ef, var(--bg));
}
button, input { font: inherit; }
button { cursor: pointer; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(230px, 300px) minmax(390px, 1fr) minmax(240px, 320px);
  gap: 26px;
  padding: 28px;
  align-items: center;
}
.panel {
  background: rgba(255, 253, 248, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 30px;
  box-shadow: 0 18px 45px rgba(66, 50, 36, 0.12);
  backdrop-filter: blur(18px);
  padding: 18px;
}
.brand { display: grid; gap: 8px; margin-bottom: 18px; }
.eyebrow { color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.brand h1 { margin: 0; font-size: 28px; line-height: 1.08; letter-spacing: -0.04em; }
.brand p, .hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.status { margin-top: 12px; padding: 10px 12px; border-radius: 16px; background: rgba(232, 238, 240, 0.7); color: var(--muted); font-size: 12px; line-height: 1.35; }
.status.error { background: rgba(185, 106, 131, 0.16); color: #793b51; }

.screen-list { display: grid; gap: 8px; max-height: 58vh; overflow: auto; padding-right: 4px; }
.screen-button, .tab-button, .action-button, .upload-label, .small-button {
  border: 0;
  border-radius: 999px;
  background: rgba(247, 241, 232, 0.8);
  color: var(--ink);
  padding: 11px 13px;
  text-align: left;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}
.screen-button { width: 100%; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.screen-button small { color: var(--muted); font-size: 11px; }
.screen-button:hover, .tab-button:hover, .action-button:hover, .upload-label:hover, .small-button:hover { transform: translateY(-1px); background: #fffaf0; }
.screen-button.active, .tab-button.active { background: var(--ink); color: #fffdf8; box-shadow: 0 8px 20px rgba(32, 33, 36, 0.22); }
.screen-button.active small { color: rgba(255, 253, 248, 0.7); }

.stage { display: grid; place-items: center; min-width: 0; }
.telephone-frame {
  width: min(415px, 92vw);
  filter: drop-shadow(var(--shadow));
}
.fallback-device {
  width: min(410px, 92vw);
  aspect-ratio: 390 / 844;
  border-radius: 56px;
  padding: 12px;
  background: linear-gradient(145deg, #2b2928, #050505);
  box-shadow: var(--shadow);
  position: relative;
}
.fallback-device::before {
  content: "";
  position: absolute;
  top: 18px;
  left: 50%;
  width: 112px;
  height: 32px;
  transform: translateX(-50%);
  border-radius: 0 0 18px 18px;
  background: #050505;
  z-index: 4;
}
.phone-app {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  border-radius: 48px;
  background: var(--surface);
  position: relative;
}
.fallback-device .phone-app { border-radius: 44px; }
.phone-app::before {
  content: "9:41";
  position: absolute;
  z-index: 5;
  top: 16px;
  left: 35px;
  font-weight: 800;
  font-size: 13px;
}
.phone-app::after {
  content: "●●● 5G ◒";
  position: absolute;
  z-index: 5;
  top: 16px;
  right: 30px;
  font-weight: 800;
  font-size: 12px;
}
.app-view {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto auto;
  padding-top: 52px;
}
.screen-content {
  overflow: auto;
  padding: 10px 20px 18px;
  scrollbar-width: none;
}
.screen-content::-webkit-scrollbar { display: none; }

.topline { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.kicker { color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.screen-title { margin: 3px 0 0; font-size: 27px; line-height: 1.08; letter-spacing: -0.045em; }
.screen-subtitle { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.avatar {
  width: 48px; height: 48px; border-radius: 18px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--primary), #9c86ff);
  color: white; font-weight: 900;
  box-shadow: 0 10px 22px rgba(109, 85, 242, 0.28);
}
.hero-banner {
  min-height: 160px;
  border-radius: 28px;
  margin-bottom: 16px;
  padding: 18px;
  display: flex;
  align-items: flex-end;
  color: #fffdf8;
  background: linear-gradient(145deg, #9b8df2, #ffb8a3);
  background-size: cover;
  background-position: center;
  box-shadow: 0 16px 36px rgba(66, 50, 36, 0.14);
}
.hero-banner span { font-size: 46px; font-weight: 300; letter-spacing: -0.08em; text-shadow: 0 4px 16px rgba(0,0,0,.18); }

.card-stack, .item-stack { display: grid; gap: 12px; }
.item-stack { gap: 0; margin-top: 12px; }
.card {
  border-radius: 24px;
  background: var(--card);
  padding: 16px;
  box-shadow: 0 8px 24px rgba(66, 50, 36, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.72);
}
.card.hero { background: linear-gradient(145deg, #fff3df, #f7f1e8); }
.card.reward { background: linear-gradient(145deg, #fff8dc, #f7f1e8); text-align: center; }
.card.reward h3 { font-size: 34px; color: var(--primary); }
.card.photo {
  min-height: 180px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(140deg, #eed0ad, #c77d5b 45%, #5c6b55);
  background-size: cover;
  background-position: center;
  color: #fffdf8;
}
.card.photo::after { content: ""; position: absolute; inset: auto 16px 16px auto; width: 86px; height: 86px; border-radius: 30px; background: rgba(255,255,255,.18); }
.card h3 { margin: 0 0 7px; font-size: 18px; line-height: 1.25; letter-spacing: -0.02em; }
.card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.card.photo p, .card.photo .meta { color: rgba(255, 253, 248, 0.9); }
.meta { color: var(--muted); font-size: 12px; line-height: 1.35; }
.message { width: fit-content; max-width: 92%; padding: 13px 15px; border-radius: 20px; line-height: 1.42; font-size: 14px; }
.message.ava { background: var(--card); border-bottom-left-radius: 8px; }
.message.user { justify-self: end; background: var(--ink); color: var(--surface); border-bottom-right-radius: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { border-radius: 999px; background: rgba(255, 253, 248, .82); color: var(--ink); padding: 8px 11px; font-size: 12px; font-weight: 700; }
.metric-row, .list-row { width: 100%; display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 0; border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; color: inherit; }
.metric-row:first-child, .list-row:first-child { border-top: 0; padding-top: 0; }
.list-row.clickable:hover span:first-child { color: var(--primary); }
.badge { border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 800; background: rgba(136, 169, 135, .22); color: #496c48; white-space: nowrap; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { min-height: 48px; border: 0; border-radius: 16px; background: rgba(255,253,248,.75); padding: 7px 5px; text-align: center; font-size: 11px; color: var(--muted); }
.day strong { display: block; color: var(--ink); font-size: 14px; margin-bottom: 3px; }
.day.active { background: var(--secondary); color: white; }
.day.active strong { color: white; }
.progress { height: 9px; border-radius: 999px; background: rgba(32, 33, 36, .08); overflow: hidden; margin: 13px 0 7px; }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--reward)); }

.action-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.action-button { background: var(--primary); color: var(--surface); padding: 10px 13px; font-weight: 800; font-size: 12px; text-align: center; }
.action-button.secondary { background: rgba(255,253,248,.8); color: var(--ink); border: 1px solid var(--line); }
.composer {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  background: rgba(255,253,248,.96);
}
.composer button, .composer span { border: 0; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 999px; background: transparent; color: var(--muted); }
.composer input { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 9px 12px; font-size: 12px; }
.bottom-tabs {
  display: grid;
  grid-template-columns: repeat(var(--tab-count, 5), 1fr);
  gap: 4px;
  padding: 9px 12px 18px;
  background: rgba(255,253,248,.96);
  border-top: 1px solid var(--line);
}
.tab-button { padding: 8px 4px; text-align: center; font-size: 10px; font-weight: 800; display: grid; gap: 2px; justify-items: center; }
.tab-icon { font-size: 17px; }

.loader { display: grid; gap: 12px; }
.control-grid { display: grid; gap: 10px; }
.control-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 800; }
.inline-control { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.inline-control input { min-width: 0; border: 1px solid var(--line); border-radius: 999px; padding: 10px 12px; background: rgba(255,253,248,.9); color: var(--ink); }
.small-button { background: var(--ink); color: var(--surface); font-weight: 900; padding: 10px 12px; }
.upload-zone {
  border: 1.5px dashed rgba(32, 33, 36, .22);
  border-radius: 24px;
  padding: 18px;
  background: rgba(255,253,248,.55);
  text-align: center;
}
.upload-zone.dragging { border-color: var(--primary); background: rgba(109,85,242,.10); }
.upload-label { display: inline-block; margin-top: 10px; font-weight: 800; }
input[type="file"] { display: none; }
.details { display: grid; gap: 10px; }
.details code { word-break: break-all; font-size: 12px; color: var(--muted); }

@media (max-width: 1080px) {
  .shell { grid-template-columns: 1fr; align-items: start; padding: 16px; }
  .panel { border-radius: 24px; }
  .screen-list { display: flex; overflow-x: auto; max-height: none; padding-bottom: 4px; }
  .screen-button { min-width: 190px; }
  .stage { order: -1; }
  .telephone-frame, .fallback-device { width: min(410px, 96vw); }
}
@media (max-width: 430px) {
  .shell { padding: 0; gap: 0; }
  .project-panel, .loader { border-radius: 0; box-shadow: none; }
  .stage { background: #050505; }
  .telephone-frame { width: 100vw; height: 100vh; filter: none; }
  .fallback-device { width: 100vw; height: 100vh; aspect-ratio: auto; border-radius: 0; padding: 0; box-shadow: none; }
  .fallback-device::before { top: 7px; }
  .phone-app { border-radius: 0; }
}
