/* 색은 목업(design/)의 팔레트를 그대로 쓴다.
   글자색 = 무슨 요일인가, 배경색 = 그날의 상태. 두 정보가 다른 채널을 쓴다. */
:root {
  /*
   * 달력이 일요일 빨강·토요일 파랑을 써야 한다. 바탕에 또 다른 색을 얹으면
   * 셋이 싸운다. 그래서 강조색을 아예 두지 않고 먹빛과 여백으로만 위계를 만든다.
   * 종이 위에 잘 짜인 문서를 보는 느낌.
   */
  --ink: #171614;          /* 본문 먹빛. 순검정보다 살짝 따뜻하다 */
  --body: #4a4741;
  --mute: #8d8880;
  --line: #e6e2db;
  --canvas: #ffffff;
  --soft: #f6f4f0;         /* 종이 결 */
  --paper: #faf8f4;        /* 화면 바깥 바탕 */

  --accent: #171614;       /* 버튼·선택. 색이 아니라 농도로 강조한다 */
  --accent-soft: #efece6;
  --accent-pale: #f6f4f0;

  --sun: #c2554e;          /* 일요일·공휴일. 종이에 인쇄한 붉은색 */
  --sat: #4a6f9c;          /* 토요일 */
  --remote: #b08430;       /* 재택 */
  --remote-bg: #faf5ea;
  --remote-ink: #7d5c1c;
  --block-bg: #fbf1f0;
  --block-ink: #9c453e;

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* 인라인 display:flex 가 붙은 요소도 hidden 이면 확실히 숨긴다 */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
/*
 * 배경은 html 이 맡는다. body 에 걸면 스크롤 영역 밖(주소창 뒤 등)까지 못 덮는다.
 * 폰에서는 앱 카드가 화면을 다 채워 안 보이고, 넓은 화면에서만 드러난다.
 */
html {
  /* 종이 한 장을 깔아둔 느낌. 강조색이 없으니 배경도 조용해야 한다 */
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse 90% 60% at 50% 0%, rgba(255,255,255,.9), transparent 60%),
    radial-gradient(ellipse 70% 50% at 15% 100%, rgba(23,22,20,.035), transparent 60%),
    radial-gradient(ellipse 70% 50% at 85% 95%, rgba(23,22,20,.028), transparent 60%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-size: cover;
}
body {
  position: relative;
  font-family: 'Noto Sans KR', system-ui, -apple-system, sans-serif;
  background: transparent; color: var(--ink);
  font-size: 16px; line-height: 1.5;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; border: none; background: none; cursor: pointer; }

/* 화면 하나가 뷰포트를 꽉 채우고, 아래 버튼은 항상 바닥에 붙는다 */
.app {
  max-width: 430px; margin: 0 auto; min-height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--canvas);
}
/* 폰 폭보다 넓은 화면에서만 컬럼 경계를 준다 */
@media (min-width: 460px) {
  .app { box-shadow: 0 0 0 1px rgba(0,0,0,.05), 0 8px 40px rgba(0,0,0,.06); }
}
/* 결과 화면은 카드가 떠 보이도록 바탕이 회색이다. 컬럼 전체가 같은 색이어야 헤더가 안 뜬다 */
.app:has(#s-result:not([hidden])) { background: var(--soft); }
.screen { flex-grow: 1; display: flex; flex-direction: column; min-height: 100dvh; }
.screen[hidden] { display: none; }
.body { flex-grow: 1; padding: 0 24px; display: flex; flex-direction: column; gap: 24px; overflow-y: auto; }
.foot { padding: 16px 24px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 16px 20px 12px; }
/* 아이콘만 있는 버튼도 손가락이 닿는 크기를 지킨다. 결과 화면에선 한 겹 더 들어가 있어 자손 선택자로 잡는다 */
button[data-back] { width: 44px; height: 44px; margin-left: -10px; display: grid; place-items: center; flex-shrink: 0; border-radius: 12px; }
.bars { flex-grow: 1; display: flex; gap: 4px; }
.bars i { flex-grow: 1; height: 4px; border-radius: 99px; background: var(--line); }
.bars i.on { background: var(--ink); }

h1 { font-size: 28px; font-weight: 900; line-height: 1.3; letter-spacing: -0.8px; margin: 0; text-wrap: pretty; }
h1.hero { font-size: 33px; letter-spacing: -1px; }
.sub { font-size: 15px; color: var(--mute); margin: 0; }
.label { font-size: 13px; font-weight: 700; color: var(--mute); }

.btn { width: 100%; display: flex; align-items: center; justify-content: center; min-height: 56px; padding: 16px;
       border-radius: var(--r-md); font-size: 17px; font-weight: 700; text-align: center; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:disabled { background: var(--line); color: var(--mute); }
.btn.ghost { color: var(--mute); font-weight: 500; font-size: 15px; min-height: 48px; }

.card { border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 18px;
        display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; width: 100%; text-align: left; }
.card.sel { border: 1.5px solid var(--ink); padding: 15.5px 17.5px; }
.card .t { font-size: 17px; font-weight: 700; }
.card .d { font-size: 13px; color: var(--mute); }
.tick { width: 22px; height: 22px; border-radius: 99px; background: var(--ink); display: grid; place-items: center; flex-shrink: 0; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--canvas); color: var(--body);
        font-size: 14px; padding: 0 14px; min-height: 44px; border-radius: 99px; display: inline-flex; align-items: center; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }

.grid-m { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.grid-w { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.cell { min-height: 48px; border-radius: 12px; background: var(--soft); color: var(--mute);
        font-size: 15px; font-weight: 500; display: grid; place-items: center; }
.cell.on { background: var(--accent); color: #fff; font-weight: 700; }

.stepper { display: flex; align-items: center; justify-content: center; gap: 28px; padding: 8px 0; }
.round { width: 56px; height: 56px; border-radius: 99px; background: var(--soft); display: grid; place-items: center; flex-shrink: 0; }
.round.on { background: var(--ink); }
.big { font-size: 80px; font-weight: 900; color: var(--ink); line-height: 1; letter-spacing: -3px;
       font-variant-numeric: tabular-nums; }

.note { border-radius: var(--r-md); padding: 14px 16px; font-size: 13.5px; line-height: 1.6; display: flex; gap: 10px; }
.note.info { background: var(--soft); color: var(--body); }
.note.warn { background: var(--remote-bg); color: var(--remote-ink); }

/* 결과 */
.rescard { background: var(--canvas); border: 1px solid var(--line); border-radius: var(--r-lg);
           padding: 18px; display: flex; flex-direction: column; gap: 10px; width: 100%; text-align: left; }
.rescard.best { border: 1.5px solid var(--ink); padding: 17.5px; }
.tag { font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 99px; }
.tag.best { background: var(--ink); color: #fff; }
.tag.remote { background: var(--remote-bg); color: var(--remote-ink); }
.tag.cross { background: #e8f0fa; color: #3d6899; }
.num { font-size: 46px; font-weight: 900; line-height: 1; letter-spacing: -1.5px; font-variant-numeric: tabular-nums; }
.rescard.best .num { font-size: 58px; color: var(--ink); letter-spacing: -2.5px; }

/* 달력: 글자색은 요일, 배경색은 상태 */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal .h { font-size: 11px; font-weight: 700; color: var(--mute); text-align: center; padding: 4px 0; }
.cal .h.sun { color: var(--sun); } .cal .h.sat { color: var(--sat); }
.cal .d { font-size: 14px; text-align: center; padding: 9px 0; border-radius: 8px; color: #c8c9c7; }
.cal .d.in { font-weight: 700; color: var(--ink); }
.cal .d.in.sun { color: var(--sun); } .cal .d.in.sat { color: var(--sat); }
.cal .d.off { background: var(--accent-soft); }
.cal .d.leave { background: var(--ink); color: #fff !important; }
.cal .d.remote { background: var(--remote-bg); border: 1.5px dashed var(--remote); padding: 7.5px 0; color: var(--remote-ink) !important; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--body); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }


/* ── 화면 전환 ────────────────────────────────
   앞으로 갈 땐 오른쪽에서 들어오고 왼쪽으로 나간다. 뒤로는 반대.
   방향이 있어야 '어디로 가는지' 가 몸에 남는다. */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
@keyframes fadeOut { from { opacity: 1 } to { opacity: 0 } }
.screen.in { animation: fadeIn .28s cubic-bezier(.2,.8,.2,1) both }
.screen.out { animation: fadeOut .18s ease-in both }
@media (prefers-reduced-motion: reduce) { .screen { animation: none !important } }

/* 계산 중 */
.spinner {
  width: 52px; height: 52px; border-radius: 99px;
  border: 5px solid var(--accent-soft); border-top-color: var(--ink);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }
.crunch-row { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--mute);
              opacity: 0; animation: pop .45s ease both; }
.crunch-row i { width: 6px; height: 6px; border-radius: 99px; background: var(--mute); flex-shrink: 0; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) } to { opacity: .95; transform: none } }
@media (prefers-reduced-motion: reduce) { .spinner, .crunch-row { animation: none; opacity: 1 } }

button[data-home] { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; flex-shrink: 0; margin-right: -6px; }
button[data-home]:hover { background: var(--soft); }

/* ── 바텀시트 ──────────────────────────────────
   화면 전환 대신 시트를 올린다. 뒤 화면이 남아 있어야 '어디에 추가하는지'가 유지된다. */
.sheet-back {
  position: fixed; inset: 0; background: rgba(14,15,12,.45);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50; opacity: 0; transition: opacity .18s ease;
}
.sheet-back.on { opacity: 1; }
.sheet-back[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 430px; background: var(--canvas);
  border-radius: 24px 24px 0 0; max-height: 88dvh;
  display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .22s cubic-bezier(.2,.8,.2,1);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-back.on .sheet { transform: translateY(0); }
.sheet-grab { padding: 12px 0 8px; display: grid; place-items: center; flex-shrink: 0; }
.sheet-grab i { width: 40px; height: 4px; border-radius: 99px; background: var(--line); }
.sheet-head { padding: 0 24px 14px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.sheet-head h2 { font-size: 20px; font-weight: 900; letter-spacing: -0.5px; margin: 0; }
.sheet-body { padding: 0 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; flex-grow: 1; }
.sheet-foot { padding: 16px 24px 20px; flex-shrink: 0; display: flex; flex-direction: column; }

.tier-pick { display: flex; flex-direction: column; gap: 8px; }
.tier-pick button {
  display: flex; align-items: center; gap: 10px; min-height: 52px;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px;
  font-size: 15px; color: var(--body); width: 100%; text-align: left;
}
.tier-pick button.on { border-width: 2px; padding: 11px 15px; font-weight: 700; color: var(--ink); }
.tier-pick i { width: 9px; height: 9px; border-radius: 99px; flex-shrink: 0; }

.tabs { display: flex; background: var(--soft); border-radius: 12px; padding: 4px; gap: 4px; }
.tabs button { flex-grow: 1; min-height: 44px; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--mute); }
.tabs button.on { background: var(--canvas); color: var(--ink); font-weight: 700; }

.field {
  display: flex; align-items: center; gap: 10px; min-height: 52px;
  border: 1px solid var(--line); border-radius: 12px; padding: 0 16px;
}
.field input {
  border: none; outline: none; font: inherit; font-size: 15px; color: var(--ink);
  background: none; width: 100%; padding: 14px 0; min-width: 0;
}
.field input::placeholder { color: #c8c9c7; }
/* 아이폰에서 폰트가 16px 미만이면 입력할 때 화면이 확대된다. 날짜 칸은 16px로 고정한다 */
@media (max-width: 460px) { .field input { font-size: 16px; } }

.range-row { display: flex; align-items: center; gap: 10px; }
.range-row .field { flex-grow: 1; min-width: 0; }
.range-row .tilde { color: var(--mute); font-size: 15px; flex-shrink: 0; }

/* 결과 정렬 탭 — 헤더에 붙어 스크롤해도 남는다 */
.sortbar { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.sortbar::-webkit-scrollbar { display: none; }
.sortbar button {
  flex-shrink: 0; min-height: 40px; padding: 0 14px; border-radius: 99px;
  font-size: 14px; font-weight: 500; color: var(--mute); border: 1px solid var(--line); background: var(--canvas);
}
.sortbar button.on { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
/* 조건 칩은 누르면 그 단계로 돌아간다. 눌리는 것임을 알려야 한다 */
#res-cond .chip { cursor: pointer; }
#res-cond .chip::after { content: '›'; margin-left: 6px; opacity: .45; font-weight: 700; }
#res-list { display: flex; flex-direction: column; gap: 12px; padding-bottom: 24px; }
.month-sep { font-size: 13px; font-weight: 700; color: var(--mute); padding: 8px 2px 2px; }


/* ── 넓은 화면 ────────────────────────────────
   폰 레이아웃을 그대로 늘리면 430px 컬럼이 화면 한가운데 잘려 붙은 꼴이 된다.
   세로도 억지로 채우느라 버튼만 저 아래 떨어진다.
   데스크톱에서는 '가운데 카드'로 바꾼다. */
@media (min-width: 760px) {
  body { display: grid; place-items: center; min-height: 100dvh; padding: 40px 24px; }

  .app {
    max-width: 640px; width: 100%;
    min-height: 0;                    /* 화면 높이를 억지로 채우지 않는다 */
    border-radius: 24px; overflow: hidden;
    box-shadow: 0 1px 2px rgba(23,22,20,.05), 0 16px 48px rgba(23,22,20,.09);
  }
  .screen { min-height: 0; }

  /* 입력 단계는 내용만큼만 높고, 최소 높이만 확보해 단계마다 덜컹이지 않게 한다 */
  #s-start, #s-mindays, #s-leave, #s-when, #s-days { min-height: 560px; }
  .body { padding: 8px 40px 0; gap: 28px; }
  .foot { padding: 24px 40px 32px; }
  .topbar { padding: 24px 36px 12px; }

  h1 { font-size: 34px; }
  h1.hero { font-size: 40px; }
  .sub { font-size: 16px; }
  .big { font-size: 96px; }
  .card { padding: 20px 22px; }
  .card .t { font-size: 18px; }

  /* 결과는 카드가 여러 장이라 더 넓게 쓴다 */
  .app:has(#s-result:not([hidden])) { max-width: 900px; }
  .app:has(#s-detail:not([hidden])) { max-width: 620px; }
  #s-result, #s-detail { min-height: 0; }
  #s-result .body { padding: 24px 32px; max-height: calc(100dvh - 220px); }
  #s-result .topbar { padding: 24px 32px 16px; }
  #s-detail .body { padding: 8px 36px 0; }

  #res-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
  #res-list > .month-sep { grid-column: 1 / -1; padding-top: 12px; }
  #res-list > button:not(.rescard) { grid-column: 1 / -1; }
  #res-list > .rescard.best { grid-column: 1 / -1; }

  .cal .d { padding: 12px 0; font-size: 15px; }
  .cal .d.remote { padding: 10.5px 0; }

  /* 시트는 카드 안이 아니라 화면 기준으로 뜬다 */
  .sheet { border-radius: 24px; max-height: 82dvh; margin-bottom: 24px; }
  .sheet-back { align-items: center; }
  .sheet-back .sheet { transform: translateY(24px); }
  .sheet-back.on .sheet { transform: translateY(0); }
}

@media (min-width: 1280px) {
  .app:has(#s-result:not([hidden])) { max-width: 1100px; }
  #res-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ── 시트 안 달력 (여러 날 고르기) ── */
.pick-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pick-head strong { font-size: 15px; }
.pick-head button { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; }
.pick-head button:disabled { opacity: .3; }
.pick { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.pick .h { font-size: 11px; font-weight: 700; color: var(--mute); text-align: center; padding: 2px 0; }
.pick .h.sun { color: var(--sun) } .pick .h.sat { color: var(--sat) }
.pick button {
  aspect-ratio: 1; min-height: 40px; border-radius: 10px; font-size: 14px;
  display: grid; place-items: center; color: var(--ink); background: var(--canvas);
}
.pick button.sun { color: var(--sun) } .pick button.sat { color: var(--sat) }
.pick button.off { opacity: .28; pointer-events: none }
.pick button.on { background: var(--ink); color: #fff !important; font-weight: 700 }
.pick-sum { font-size: 13px; color: var(--mute); }

/* 재택을 쉬는 날로 칠지 정하는 스위치 */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.toggle-row span { font-size: 14px; font-weight: 700; color: var(--ink); }
.switch { width: 50px; height: 30px; border-radius: 99px; background: var(--line); position: relative;
          transition: background .18s ease; flex-shrink: 0; }
.switch i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 99px;
            background: var(--canvas); box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .18s cubic-bezier(.2,.8,.2,1); }
.switch.on { background: var(--ink); }
.switch.on i { transform: translateX(20px); }

/* 단계 전환 한마디 — 화면이 비어 있는 사이에만 뜬다. 팝업이 아니다 */
.reaction {
  position: fixed; inset: 0; z-index: 60; pointer-events: none;
  display: grid; place-items: center; padding: 0 32px;
  font-size: 26px; font-weight: 900; letter-spacing: -0.8px; color: var(--ink);
  text-align: center; text-wrap: balance;
  animation: reactIn .3s cubic-bezier(.2,.8,.2,1) both;
}
.reaction.out { animation: reactOut .2s ease-in both; }
@keyframes reactIn { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }
@keyframes reactOut { to { opacity: 0; transform: translateY(-8px) } }
@media (prefers-reduced-motion: reduce) { .reaction { display: none } }
