:root {
  --accent: #E8590C;
  --accent-ink: #ffffff;
  --bg: #fff7f2;
  --card: #ffffff;
  --ink: #1f1a17;
  --muted: #6b625c;
  --line: #f0e2d8;
  --done: #2f9e44;
  --radius: 16px;
  --gap: clamp(12px, 3vw, 20px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17120f;
    --card: #221b17;
    --ink: #f4ede8;
    --muted: #b3a79f;
    --line: #3a2e27;
    --done: #69db7c;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ---------- 기본: 바형폰 / 폴드 커버화면 (한 열) */
.layout {
  max-width: 560px;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top) + var(--gap))
    calc(env(safe-area-inset-right) + 16px)
    calc(env(safe-area-inset-bottom) + var(--gap))
    calc(env(safe-area-inset-left) + 16px);
  display: grid;
  gap: var(--gap);
}
.pane { display: grid; gap: var(--gap); align-content: start; min-width: 0; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand img { border-radius: 10px; }
.brand h1 { margin: 0; font-size: 1.25rem; line-height: 1.2; }
.brand p { margin: 0; color: var(--muted); font-size: .85rem; }

.big-btn {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: clamp(22px, 7vw, 40px) 16px;
  border-radius: calc(var(--radius) + 6px);
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  box-shadow: 0 8px 24px rgb(232 89 12 / .28);
  -webkit-tap-highlight-color: transparent;
  transition: transform .08s;
}
.big-btn:active { transform: scale(.98); }
.big-btn-icon { font-size: clamp(2rem, 9vw, 3rem); line-height: 1; }
.big-btn-text { font-size: clamp(1.3rem, 6vw, 1.75rem); font-weight: 800; }
.big-btn-sub {
  font-size: .85rem; opacity: .9; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1 1 0; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 10px; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.wide { width: 100%; margin-bottom: 8px; }
.link-btn {
  border: 0; background: none; color: var(--accent); font: inherit; font-size: .85rem;
  font-weight: 600; cursor: pointer; padding: 4px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}
.card h2 {
  margin: 0 0 10px; font-size: 1rem;
  display: flex; justify-content: space-between; align-items: center;
}
.hint, .small { color: var(--muted); font-size: .85rem; margin: 8px 0 0; }
.small-list { margin: 8px 0 0; padding-left: 1.2em; font-size: .88rem; color: var(--muted); }
.small-list li + li { margin-top: 6px; }
details { margin-top: 10px; }
summary { cursor: pointer; font-weight: 600; font-size: .92rem; padding: 6px 0; }

.steps { list-style: none; counter-reset: s; margin: 0; padding: 0; display: grid; gap: 6px; }
.steps li {
  counter-increment: s;
  display: grid; grid-template-columns: 32px 1fr; column-gap: 10px; align-items: center;
  padding: 10px; border-radius: 12px; background: var(--bg); cursor: pointer;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.steps li::before {
  content: counter(s);
  grid-row: span 2;
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: .9rem;
}
.steps li small { grid-column: 2; color: var(--muted); font-size: .78rem; }
.steps li.done { opacity: .55; text-decoration: line-through; }
.steps li.done::before { content: "✓"; background: var(--done); }

.url-form input {
  width: 100%; min-height: 48px; padding: 0 12px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--ink); font: inherit; font-size: 16px; /* iOS 확대 방지 */
}
.url-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.toast {
  min-height: 0; font-size: .9rem; text-align: center; color: var(--accent); font-weight: 600;
}
.toast:empty { display: none; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* ---------- 폴드 펼친 화면 / 태블릿 / 가로 (두 열) */
@media (min-width: 640px) {
  .layout {
    max-width: 1100px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }
}
/* 가로로 낮은 화면(폰 가로모드): 큰 버튼 높이 줄이기 */
@media (max-height: 480px) and (orientation: landscape) {
  .big-btn { padding: 14px; }
}

/* ---------- 듀얼 스크린 / 힌지가 있는 기기 (화면이 좌우로 나뉨) */
@media (horizontal-viewport-segments: 2) {
  .layout {
    max-width: none;
    grid-template-columns: env(viewport-segment-width 0 0) env(viewport-segment-width 1 0);
    column-gap: calc(env(viewport-segment-left 1 0) - env(viewport-segment-right 0 0));
    padding-left: 0; padding-right: 0;
  }
  .pane { padding: 0 16px; }
}
/* 위아래로 나뉜 경우 (반쯤 접은 테이블탑 모드) */
@media (vertical-viewport-segments: 2) {
  .layout {
    max-width: none;
    grid-template-columns: 1fr;
    grid-template-rows: env(viewport-segment-height 0 0) env(viewport-segment-height 0 1);
    row-gap: calc(env(viewport-segment-top 0 1) - env(viewport-segment-bottom 0 0));
  }
  .pane { overflow-y: auto; }
}
