/* Ruach 디자인 표준 — 부품. tokens.css · base.css 다음에 불러온다.
   넓은 화면(900px 이상) = 맥 창: 회색 사이드바 + 흰 창 · 좁은 화면 = 아이폰: 유리 위 막대 + 아래 탭 막대, 회색 바탕 위 흰 묶음 */

/* ───────── 틀 ───────── */
.shell { min-height: 100%; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
.side { position: sticky; top: 0; height: 100vh; height: 100dvh; background: var(--side); border-right: 1px solid var(--sep); padding: 14px 10px 12px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.brand { display: flex; align-items: center; gap: 9px; padding: 2px 8px; }
.brand img { width: 26px; height: 26px; border-radius: 7px; }
.brand b { font-size: 16px; font-weight: 700; letter-spacing: -0.03em; }
.side-label { font-size: 11.5px; font-weight: 600; color: var(--text-3); padding: 0 8px 4px; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item { justify-content: flex-start; height: 32px; padding: 0 10px 0 8px; gap: 9px; border-radius: 7px; font-size: 14px; font-weight: 500; color: var(--text); }
.nav-item svg { width: 17px; height: 17px; color: var(--accent); }
.nav-item:hover { background: var(--hover); }
.nav-item[aria-current="page"] { background: var(--sel); font-weight: 600; }
.me { margin-top: auto; justify-content: flex-start; height: 40px; padding: 0 8px 0 4px; gap: 9px; border-radius: var(--r-pill); font-size: 13.5px; font-weight: 500; }
.me:hover { background: var(--hover); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 55%, #fff), var(--accent)); color: #fff; font-size: 12px; font-weight: 600; flex: none; }
.win-area { min-width: 0; background: var(--win); }
.mtop, .tabbar { display: none; }

/* 사이드바가 없는 화면의 위 막대 (유리) */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 10px; height: var(--top); padding: 0 12px 0 16px; padding-top: env(safe-area-inset-top); box-sizing: content-box; background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-bottom: 1px solid var(--sep); }
.topbar h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.03em; white-space: nowrap; }

/* ───────── 쪽: 큰 제목 · 도구 · 묶음 ───────── */
.page { max-width: var(--page-w); margin: 0 auto; padding: 30px 36px 96px; display: flex; flex-direction: column; gap: 24px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.head h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.15; }
.head h1 small { font-size: 15px; font-weight: 500; color: var(--text-3); margin-left: 8px; letter-spacing: -0.01em; }
.head .sub { color: var(--text-2); font-size: 15px; margin-top: 6px; }
.head .acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sect { display: flex; flex-direction: column; gap: 8px; }
.sect > h2 { font-size: 13px; font-weight: 600; color: var(--text-2); padding: 0 12px; display: flex; align-items: center; justify-content: space-between; min-height: 30px; }
.foot-note { font-size: 13px; color: var(--text-3); padding: 0 12px; }

/* 묶음 목록: 줄 사이는 가는 선 하나, 테두리 없음 */
.list { background: var(--group); border-radius: var(--r-md); overflow: hidden; }
.list > * + * { box-shadow: inset 0 1px 0 var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 52px; width: 100%; text-align: left; height: auto; border-radius: 0; font-weight: 400; justify-content: flex-start; white-space: normal; color: inherit; }
button.row:hover:not(:disabled), a.row:hover { background: var(--hover); }
.row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row .t { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .d { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .v { font-size: 15px; color: var(--text-2); flex: none; }
.row .chev { color: var(--text-3); flex: none; display: flex; }
.empty { background: var(--group); border-radius: var(--r-md); padding: 34px 20px; text-align: center; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 14px; font-size: 14px; line-height: 1.6; }

/* 카드·타일 (홈 화면의 바로가기, 요약 숫자) */
.card { background: var(--win); border-radius: var(--r-lg); box-shadow: var(--shadow-card); padding: 18px 20px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 14px; height: auto; min-height: 120px; padding: 18px; border-radius: var(--r-xl); background: var(--win); box-shadow: var(--shadow-card); text-align: left; white-space: normal; color: var(--text); transition: transform .2s var(--ease), box-shadow .2s; }
.tile:hover { transform: translateY(-2px); }
.tile:active { transform: scale(.98); }
.tile .ic { width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); }
.tile b { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.tile small { font-size: 13px; color: var(--text-2); font-weight: 400; }
.stat { background: var(--group); border-radius: var(--r-md); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat span { font-size: 13px; color: var(--text-2); }
.stat b { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

/* ───────── 작은 부품 ───────── */
.seg { display: inline-flex; background: var(--fill); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { height: 28px; padding: 0 14px; font-size: 13px; border-radius: 7px; color: var(--text); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--thumb); box-shadow: var(--shadow-thumb); font-weight: 600; }
.seg.full { display: flex; }
.seg.full button { flex: 1; }
.chip { flex: none; height: 32px; min-width: 40px; padding: 0 12px; border-radius: var(--r-pill); background: var(--fill-2); color: var(--text); font-size: 14px; font-weight: 600; gap: 5px; }
.chip:hover:not(:disabled) { background: var(--fill); }
.chip[aria-pressed="true"] { background: var(--accent); color: #fff; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-pill); background: var(--fill); color: var(--text-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.accent { background: var(--accent-soft); color: var(--accent-text); }
.tag.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.tag.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.tag.err { background: var(--err-soft); color: var(--err); }

/* 메뉴 (유리) */
.menu { position: fixed; z-index: 60; min-width: 220px; padding: 5px; border-radius: var(--r-md); background: color-mix(in srgb, var(--raised) 94%, transparent); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px); box-shadow: var(--shadow-menu); display: flex; flex-direction: column; animation: apMenu .14s ease-out; }
@keyframes apMenu { from { opacity: 0; transform: scale(.97); } }
.menu button { justify-content: flex-start; height: 30px; font-weight: 400; font-size: 14px; padding: 0 10px; border-radius: var(--r-xs); color: var(--text); }
.menu button:hover, .menu button:focus-visible { background: var(--accent); color: #fff; box-shadow: none; }
.menu button.danger { color: var(--err); }
.menu button.danger:hover { background: var(--err); color: #fff; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 8px; }
.menu .lbl { font-size: 12px; color: var(--text-3); padding: 6px 10px 3px; }

/* 대화창: <dialog> + showModal(). 넓은 화면은 가운데 창, 좁은 화면은 아래에서 올라오는 시트 */
dialog { border: 0; padding: 0; border-radius: var(--r-lg); background: var(--raised); color: var(--text); box-shadow: var(--shadow-win); width: min(520px, calc(100% - 32px)); max-height: calc(100% - 48px); overflow: hidden; }
dialog[open] { animation: apPop .26s cubic-bezier(.2, .9, .25, 1.05); }
dialog::backdrop { background: var(--scrim); animation: apFade .18s ease-out; }
@keyframes apPop { from { opacity: 0; transform: translateY(6px) scale(.975); } }
@keyframes apFade { from { opacity: 0; } }
@keyframes apSheet { from { transform: translateY(40%); opacity: 0; } }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 6px 24px; gap: 8px; }
.dlg-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.dlg-x { width: 28px; height: 28px; border-radius: 50%; padding: 0; background: var(--fill); color: var(--text-2); }
.dlg-x:hover { filter: brightness(0.95); }
.dlg-x svg { width: 12px; height: 12px; }
.dlg-body { padding: 10px 24px 18px; display: flex; flex-direction: column; gap: 16px; overflow: auto; }
.dlg-msg { padding: 0 24px; color: var(--text-2); }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px 20px; }
.dlg-foot button { height: 34px; min-width: 76px; }
.dlg-foot .left { margin-right: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 알림 한 줄 */
.toast { position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80; background: rgb(40 40 44 / 0.88); color: #fff; padding: 10px 18px; border-radius: var(--r-pill); font-size: 14px; font-weight: 500; -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); box-shadow: 0 10px 30px rgb(0 0 0 / 0.25); max-width: calc(100% - 32px); animation: apFade .18s ease-out; }

/* ───────── 날짜 고르기 · 드롭다운 (pickers.js) ───────── */
.dpick { min-width: 0; }
.pfield { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; height: var(--h-input); padding: 0 12px; border-radius: var(--r); border: 1px solid var(--input-line); background: var(--input); color: var(--text); font-size: 15px; font-weight: 400; text-align: left; box-shadow: 0 0.5px 1px rgb(0 0 0 / 0.04); transition: border-color .12s, box-shadow .12s; }
.pfield:hover:not(:disabled), .pfield.pop-open { background: var(--input); border-color: var(--accent); }
.pfield:focus-visible, .pfield.pop-open, select.pop-open { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3.5px var(--ring); }
.pfield.empty { color: var(--text-3); }
.pfield .pi { flex: none; display: inline-flex; color: var(--accent-text); }
.pfield > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-root { position: fixed; inset: 0; z-index: 9000; }
.pop-scrim { position: absolute; inset: 0; background: transparent; }
.pop { position: fixed; background: color-mix(in srgb, var(--raised) 94%, transparent); -webkit-backdrop-filter: blur(28px) saturate(1.7); backdrop-filter: blur(28px) saturate(1.7); border-radius: var(--r-lg); box-shadow: var(--shadow-menu); padding: 12px; color: var(--text); animation: popIn .16s ease-out; }
.pop.low { left: 0; right: 0; bottom: 0; top: auto; width: auto; border-radius: 22px 22px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); animation: popUp .24s var(--ease); }
.pop-root:has(.pop.low) .pop-scrim { background: var(--scrim); }
@keyframes popIn { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
@keyframes popUp { from { transform: translateY(100%); } }
.dp-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 10px; }
.dp-head b { font-size: 17px; letter-spacing: -0.02em; }
.dp-nav { display: flex; gap: 2px; }
.dp-nav button { width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 22px; line-height: 1; color: var(--accent-text); background: transparent; }
.dp-nav button:hover { background: var(--hover); }
.dp-dow, .dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.dp-dow span { text-align: center; font-size: 12px; font-weight: 600; color: var(--text-2); padding: 4px 0 6px; }
.dp-dow .sun, .dd.sun { color: var(--err); }
.dp-dow .sat, .dd.sat { color: var(--accent-text); }
.dd { aspect-ratio: 1; height: auto; max-height: 42px; margin: 1px auto; width: 100%; max-width: 42px; padding: 0; border-radius: 50%; font-size: 16px; font-weight: 400; color: var(--text); background: transparent; display: flex; align-items: center; justify-content: center; transition: background .12s; }
.dd:hover { background: var(--hover); }
.dd.other { opacity: .35; }
.dd.today { font-weight: 700; color: var(--accent-text); }
.dd.sel { background: var(--accent); color: #fff !important; font-weight: 700; opacity: 1; }
.dp-foot { display: flex; justify-content: space-between; padding: 8px 4px 0; border-top: 0.5px solid var(--sep); margin-top: 8px; }
.dp-foot button { color: var(--accent-text); font-size: 15px; font-weight: 600; padding: 6px 8px; border-radius: 8px; background: transparent; }
.dp-foot .clr { color: var(--err); }
.pop:has(.sl) { padding: 6px; }
.sl { display: flex; flex-direction: column; gap: 1px; max-height: min(340px, 56vh); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.pop.low .sl { max-height: min(60vh, 460px); }
.sl-group { padding: 8px 10px 4px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.si { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; height: auto; min-height: 34px; padding: 6px 10px; border-radius: 9px; background: transparent; color: var(--text); font-size: 15px; font-weight: 400; text-align: left; white-space: normal; box-shadow: none; }
.pop.low .si { min-height: 46px; font-size: 17px; border-radius: 12px; }
.si-t { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.si-c { flex: none; display: inline-flex; width: 16px; color: var(--accent-text); }
.si.on { font-weight: 600; }
.si.kb:not(:disabled) { background: var(--accent); color: #fff; }
.si.kb:not(:disabled) .si-c { color: #fff; }
.si:disabled { opacity: .4; }
@media (hover: none) { .si.kb:not(:disabled) { background: transparent; color: var(--text); } .si.kb:not(:disabled) .si-c { color: var(--accent-text); } .si:active:not(:disabled) { background: var(--press); } }

/* ───────── 홈·로그인: 색 번짐 배경 + 유리 카드 (포탈) ───────── */
.mesh { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: var(--desk); }
.mesh i { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .75; }
.mesh i:nth-child(1) { width: 55vmax; height: 55vmax; left: -15vmax; top: -18vmax; background: var(--mesh-1); }
.mesh i:nth-child(2) { width: 48vmax; height: 48vmax; right: -14vmax; top: 8vmax; background: var(--mesh-2); }
.mesh i:nth-child(3) { width: 42vmax; height: 42vmax; left: 20vmax; bottom: -24vmax; background: var(--mesh-3); }
body:has(> .mesh) { background: transparent; }
.glass { background: color-mix(in srgb, var(--raised) 62%, transparent); -webkit-backdrop-filter: blur(28px) saturate(180%); backdrop-filter: blur(28px) saturate(180%); border: 1px solid color-mix(in srgb, #fff 55%, transparent); box-shadow: var(--shadow-card); }
:root[data-theme="dark"] .glass { border-color: rgb(255 255 255 / 0.1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .glass { border-color: rgb(255 255 255 / 0.1); } }
.auth { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; border-radius: var(--r-xl); padding: 40px 28px 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; text-align: center; }
.auth-card .sub { text-align: center; color: var(--text-2); font-size: 15px; margin-bottom: 8px; }
.auth-card input { height: 48px; font-size: 17px; border-radius: 14px; background: var(--fill); border-color: transparent; box-shadow: none; }
.auth-card input:focus { background: var(--raised); }
.auth-card button.primary { height: 48px; font-size: 17px; border-radius: 14px; }

/* ───────── 휴대폰 (899px 이하) ───────── */
@media (max-width: 899px) {
  body { background: var(--desk); }
  .shell { display: block; }
  .side { display: none; }
  .win-area { background: transparent; }
  /* 위 막대: 제목이 정확히 가운데 오도록 양쪽 칸 폭을 같게 */
  .mtop { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 50px; padding: 0 10px; padding-top: env(safe-area-inset-top); box-sizing: content-box; background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-bottom: 0.5px solid var(--sep); }
  .mtop .l { justify-self: start; display: flex; }
  .mtop .r { justify-self: end; display: flex; }
  .mtop .r button, .mtop .l button { padding: 0; height: 34px; width: 34px; border-radius: 50%; }
  .mtop .c { font-size: 16px; font-weight: 600; max-width: 56vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-top: 0.5px solid var(--sep); }
  .tabbar button { flex-direction: column; height: 48px; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--text-3); border-radius: 10px; }
  .tabbar button svg { width: 22px; height: 22px; }
  .tabbar button[aria-current="page"] { color: var(--accent); }
  .page { padding: 18px 16px calc(110px + env(safe-area-inset-bottom)); gap: 22px; }
  .head .acts { width: 100%; }
  .list, .empty, .stat { background: var(--win); }
  /* 작은 창은 아래에서 올라오는 시트 */
  dialog { width: 100% !important; max-width: none; margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92vh; max-height: 92dvh; }
  dialog[open] { animation: apSheet .3s cubic-bezier(.2, .9, .25, 1); }
  dialog form { max-height: 92vh; max-height: 92dvh; }
  .dlg-body { padding: 8px 18px 18px; }
  .dlg-head { padding: 16px 14px 4px 18px; }
  .dlg-msg { padding: 0 18px; }
  .dlg-foot { padding: 12px 18px calc(16px + env(safe-area-inset-bottom)); }
  .dlg-foot button:not(.left) { flex: 1; height: var(--h-touch); font-size: 16px; }
  .pfield { height: var(--h-touch); font-size: 16px; border-radius: var(--r-md); }
  .tiles { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .grid2 { grid-template-columns: 1fr; }
}
