/* TimerHouse 홈. 기준: DESIGN.md (색·글꼴·간격 토큰은 아래 :root와 같은 이름을 쓴다) */
:root {
  --bg: #F3F4F5;
  --surface: #FFFFFF;
  --surface-hover: #FAFAFB;
  --ink: #1A1C20;
  --ink-2: #555D6D;
  --ink-3: #6B7280;
  --line: #E5E7EA;
  --signal: #C8460C;
  --signal-hover: #A9390A;
  --signal-ink: #FFFFFF;
  --signal-arc: #FF6A1A;
  --link: #1F4FD1;
  --float: 0 4px 16px rgba(26, 28, 32, 0.08);
  --switch-off: #B9BFC6;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101316;
    --surface: #1A1F23;
    --surface-hover: #20262B;
    --ink: #E7EAE9;
    --ink-2: #AEB5B9;
    --ink-3: #959DA3;
    --line: #2A3036;
    --signal: #FF8A47;
    --signal-hover: #FF9D63;
    --signal-ink: #101316;
    --link: #8FA8FF;
    --float: 0 4px 16px rgba(0, 0, 0, 0.4);
    --switch-off: #4A525A;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  word-break: keep-all; /* 한글을 낱말 단위로 줄바꿈 */
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -48px; padding: 10px 14px; border-radius: 8px; background: var(--ink); color: var(--bg); z-index: 10; }
.skip:focus { top: 12px; }
.card { background: var(--surface); border-radius: 16px; }

/* 헤더: 로고 + 알약형 검색창 + 내 타이머 */
.top-in {
  max-width: 992px; margin: 0 auto; padding: 24px 16px 8px;
  display: flex; align-items: center; gap: 16px;
}
.logo { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; flex: none; }
.search {
  flex: 1; min-width: 0; height: 56px; display: flex; align-items: center;
  background: var(--surface); border-radius: 9999px; padding: 0 8px 0 24px;
}
.search:focus-within { box-shadow: 0 0 0 2px var(--link); }
.search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent;
  font: 400 18px var(--font); color: var(--ink);
}
.search input::placeholder { color: var(--ink-3); }
.search input::-webkit-search-cancel-button { display: none; }
.search button { width: 44px; height: 44px; border: 0; border-radius: 9999px; background: transparent; display: grid; place-items: center; }
.search button:hover { background: var(--bg); }
.mine-link { display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px; border-radius: 9999px; font-size: 14px; font-weight: 500; flex: none; }
.mine-link:hover { background: var(--surface); }

/* 본문: 왼쪽 600 + 오른쪽 320 */
.page {
  max-width: 992px; margin: 0 auto; padding: 24px 16px 64px;
  display: grid; grid-template-columns: minmax(0, 1fr) 320px; column-gap: 24px; row-gap: 32px;
  align-items: start;
}
.page > :not(.side) { grid-column: 1; }
/* 오른쪽 열: 빠른 타이머 바로 아래에 많이 쓰는 타이머 */
.side {
  grid-column: 2; grid-row: 1 / span 6; display: flex; flex-direction: column; gap: 24px;
  position: sticky; top: 24px; max-height: calc(100dvh - 48px); /* 스크롤해도 두 카드가 함께 따라온다 */
}
.side .popular { min-height: 0; display: flex; flex-direction: column; }
.side .popular .list { overflow-y: auto; overscroll-behavior: contain; } /* 화면이 낮으면 목록만 안에서 스크롤 */

.intro h1 { margin: 0; font-size: 40px; line-height: 1.1; font-weight: 800; letter-spacing: -0.03em; }
.intro p { margin: 8px 0 0; color: var(--ink-2); }
.intro .search-msg { margin-top: 12px; font-size: 14px; color: var(--ink); }
.intro .search-msg:empty { display: none; }
.sec-h { margin: 0 0 12px; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }

/* 바로 시작 칩 */
.quick { margin-top: -16px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 44px; padding: 0 18px; border-radius: 9999px; border: 0;
  background: var(--surface); font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums;
  transition: background-color 150ms, transform 150ms;
}
.chip:hover { background: var(--surface-hover); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.chip-custom { color: var(--ink-2); }

/* 빠른 타이머 카드 */
.timer { padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.timer-head { align-self: stretch; display: flex; justify-content: space-between; align-items: center; }
.timer-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.timer-state { font-size: 13px; color: var(--ink-3); }
.dial { position: relative; width: 220px; height: 220px; }
.dial svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.dial-track { fill: none; stroke: var(--line); stroke-width: 10; }
.dial-arc { fill: none; stroke: var(--signal-arc); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 553 553; transition: stroke-dasharray 250ms linear; }
.dial-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.time { font-size: 48px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.dial-label { font-size: 14px; color: var(--ink-2); max-width: 160px; text-align: center; }
.timer-actions { align-self: stretch; display: flex; gap: 8px; }
.btn-start {
  flex: 1; height: 48px; border: 0; border-radius: 8px; background: var(--signal); color: var(--signal-ink);
  font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background-color 150ms, transform 150ms;
}
.btn-start:hover { background: var(--signal-hover); }
.btn-start .i-pause, .btn-start.running .i-play { display: none; }
.btn-start.running .i-pause { display: block; }
.role-panel:not(:empty) { margin-bottom: 4px; }
.btn-icon { width: 48px; height: 48px; border: 0; border-radius: 8px; background: var(--bg); display: grid; place-items: center; transition: transform 150ms; }

/* 목적별 / 역할별 전환 스위치 */
.rooms-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.rooms-head .sec-h { margin: 0; }
.view-toggle { display: flex; align-items: center; gap: 8px; flex: none; }
.vt-label { font-size: 14px; color: var(--ink-3); cursor: pointer; user-select: none; transition: color 150ms; }
.vt-label.on { color: var(--ink); font-weight: 700; }
.switch {
  position: relative; width: 52px; height: 32px; padding: 0; border: 0; border-radius: 9999px;
  background: var(--switch-off); transition: background-color 150ms;
}
.switch::after { content: ""; position: absolute; inset: -6px; } /* 누르는 영역 44px 이상 */
.switch .knob {
  position: absolute; left: 4px; top: 4px; width: 24px; height: 24px; border-radius: 9999px;
  background: #FFFFFF; box-shadow: 0 1px 3px rgba(26, 28, 32, 0.25); transition: transform 150ms;
}
.switch[aria-checked="true"] { background: var(--ink); }
.switch[aria-checked="true"] .knob { transform: translateX(20px); }
@media (prefers-color-scheme: dark) { .switch .knob { background: #101316; } .switch[aria-checked="true"] .knob { background: #101316; } }

/* 역할 타일 + 역할별 목록 */
.role-grid { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.room.role { width: 100%; border: 0; text-align: left; color: var(--ink); --c: var(--ink-2); }
.room.role[aria-pressed="true"] { background: var(--ink); color: var(--bg); --c: var(--bg); }
.role-time { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.role-hint { margin: 0; padding: 20px; border-radius: 16px; background: var(--surface); color: var(--ink-2); font-size: 15px; }

/* 방 타일 4×2 */
.room-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.room {
  height: 96px; padding: 16px; border-radius: 16px; background: var(--surface);
  display: flex; flex-direction: column; justify-content: space-between;
  font-size: 16px; font-weight: 700;
  transition: background-color 150ms, transform 150ms;
}
.room:hover { background: var(--surface-hover); }
.room svg { width: 24px; height: 24px; fill: none; stroke: var(--c); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* 번호 매긴 목록 (카드 하나 안에 줄) */
.list { list-style: none; margin: 0; padding: 4px 16px; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.list li + li { border-top: 1px solid var(--line); }
.rank { width: 20px; flex: none; font-size: 16px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.li-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.li-main a, .li-name { font-size: 16px; font-weight: 700; }
.li-main a:hover { text-decoration: underline; }
.meta { font-size: 13px; color: var(--ink-3); }
.btn-play {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 8px;
  background: var(--signal); color: var(--signal-ink); display: grid; place-items: center;
  transition: background-color 150ms, transform 150ms;
}
.btn-play:hover { background: var(--signal-hover); }

/* 가이드 */
.guide-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.guide-list a { display: flex; flex-direction: column; gap: 2px; padding: 16px; border-radius: 16px; background: var(--surface); font-weight: 700; transition: background-color 150ms; }
.guide-list a:hover { background: var(--surface-hover); }
.guide-list .meta { font-weight: 400; }

/* 푸터 */
.foot { border-top: 1px solid var(--line); }
.foot-in { max-width: 992px; margin: 0 auto; padding: 32px 16px 16px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.foot h2 { margin: 0 0 8px; font-size: 14px; font-weight: 700; }
.foot nav { display: flex; flex-direction: column; gap: 4px; }
.foot nav a { font-size: 14px; color: var(--ink-2); padding: 4px 0; width: fit-content; }
.foot nav a:hover { color: var(--ink); text-decoration: underline; }
.foot-note { max-width: 992px; margin: 0 auto; padding: 8px 16px 40px; font-size: 13px; color: var(--ink-3); }

/* 눌림 */
.chip:active, .room:active, .btn-start:active, .btn-icon:active, .btn-play:active { transform: scale(0.98); }

/* 모바일: 한 줄, 검색창은 둘째 줄, 타이머 카드는 칩 아래 */
@media (max-width: 767px) {
  .top-in { flex-wrap: wrap; padding-top: 16px; gap: 12px; }
  .search { order: 3; flex-basis: 100%; height: 52px; padding-left: 20px; }
  .search input { font-size: 16px; }
  .mine-link { margin-left: auto; }
  .page { grid-template-columns: minmax(0, 1fr); row-gap: 28px; padding-top: 16px; }
  .page > :not(.side), .side { grid-column: 1; }
  .side { grid-row: auto; position: static; max-height: none; }
  .side .popular .list { overflow-y: visible; }
  .timer { flex-direction: row; flex-wrap: wrap; justify-content: space-between; }
  .intro { order: -3; } .quick { order: -2; } .side { order: -1; }
  .role-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .intro h1 { font-size: 28px; }
  .dial { width: 120px; height: 120px; }
  .time { font-size: 24px; }
  .dial-label { font-size: 12px; max-width: 90px; }
  .timer-head { flex-basis: 100%; }
  .timer-actions { flex: 1; align-self: center; flex-direction: column; }
  .btn-start { flex: none; }
  .btn-icon { width: 100%; }
  .room { height: 84px; padding: 12px; font-size: 14px; }
  .foot-in { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 359px) {
  .room-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .chip:active, .room:active, .btn-start:active, .btn-icon:active, .btn-play:active { transform: none; }
}
