/* 설정 드로어 */
.drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: var(--overlay); opacity: 0; transition: opacity .22s var(--ease); }
.drawer-backdrop.show { opacity: 1; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(100vw, 460px); background: var(--surface); color: var(--text); border-left: 1px solid var(--border); box-shadow: var(--shadow-2); transform: translateX(100%); transition: transform .28s var(--ease); display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 10px; }
.drawer-head h2 { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.drawer-tabs { display: flex; gap: 4px; padding: 0 14px 12px; overflow-x: auto; border-bottom: 1px solid var(--border); }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--text-2); white-space: nowrap; border: 1px solid transparent; transition: all var(--dur); }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.on { background: color-mix(in srgb, var(--mode-color) 16%, transparent); border-color: color-mix(in srgb, var(--mode-color) 50%, transparent); color: var(--text); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px 40px; display: flex; flex-direction: column; gap: 26px; }
.set-group h3 { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.set-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.set-head h3 { margin: 0; }
.set-group > .hint { display: block; margin-top: 8px; }
.thumb-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 10px; }
.thumb { position: relative; display: flex; flex-direction: column; border-radius: 12px; overflow: hidden; cursor: pointer; border: 2px solid var(--border); background: var(--surface-2); transition: border-color var(--dur), box-shadow var(--dur); }
.thumb:hover { border-color: var(--border-2); }
.thumb.on { border-color: var(--mode-color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mode-color) 25%, transparent); }
.thumb input { position: absolute; opacity: 0; pointer-events: none; }
.thumb-img { display: block; aspect-ratio: 16 / 9; background: #000; }
.thumb-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb-cap { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 10px; min-width: 0; }
.thumb-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.thumb-title { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb-src { font-size: 11px; color: var(--muted); }
.thumb-badge { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--mode-color); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.thumb-open { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.thumb-open:hover { background: var(--surface-3); color: var(--text); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.toggle-row:last-child { border-bottom: 0; }
.toggle-label { font-size: 14px; font-weight: 600; display: flex; flex-direction: column; gap: 2px; }
.toggle-label .hint { margin: 0; font-weight: 400; }
.toggle { position: relative; width: 44px; height: 26px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-2); transition: background var(--dur); flex: none; }
.toggle .knob { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform var(--dur); }
.toggle.on { background: var(--mode-color); border-color: transparent; }
.toggle.on .knob { transform: translateX(18px); }
.announce-row { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.announce-row:last-of-type { border-bottom: 0; }
.announce-label { display: flex; align-items: baseline; gap: 8px; font-size: 14px; }
.announce-label .hint { margin: 0; }
.select { width: 100%; }
.keys { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 13px; color: var(--text-2); }
.keys kbd { margin-right: 6px; }
.danger-zone { padding-top: 10px; border-top: 1px solid var(--border); }

/* 화면 카드 */
.display-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.display-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px; border-radius: 14px; background: var(--surface-2); border: 2px solid transparent; text-align: left; transition: all var(--dur); }
.display-card:hover { border-color: var(--border-2); }
.display-card.on { border-color: var(--mode-color); background: color-mix(in srgb, var(--mode-color) 12%, var(--surface-2)); }
.display-card strong { font-size: 13.5px; }
.dc-ic { font-size: 22px; line-height: 1.1; }
.dc-desc { font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.graphic-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.graphic-card { position: relative; border-radius: 12px; overflow: hidden; border: 2px solid transparent; aspect-ratio: 16 / 10; background: #05060a; transition: all var(--dur); padding: 0; }
.graphic-card canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.graphic-card:hover { border-color: var(--border-2); }
.graphic-card.on { border-color: var(--mode-color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mode-color) 25%, transparent); }
.gc-label { position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 10px 8px; text-align: left; color: #fff; background: linear-gradient(to top, rgba(0, 0, 0, .85), transparent); display: flex; flex-direction: column; font-size: 11.5px; }
.gc-label strong { font-size: 12.5px; }
.gc-label span { color: rgba(255, 255, 255, .7); }
.sound-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }

/* 영상별 볼륨 */
.vvol-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.vvol-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px 40px 32px; align-items: center; gap: 8px; font-size: 13px; }
.vvol-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.vvol-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 12.5px; }
.vvol-val.inherit { color: var(--muted); font-weight: 500; }
.vvol-default { margin-top: 4px; font-size: 13px; font-weight: 600; }

/* 알림 선택기 */
.ap { display: flex; flex-direction: column; gap: 12px; }
.ap-sounds { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.ap-sound { display: flex; align-items: center; gap: 6px; padding: 8px 6px 8px 12px; border-radius: 12px; background: var(--surface-2); border: 2px solid transparent; cursor: pointer; transition: all var(--dur); }
.ap-sound:hover { border-color: var(--border-2); }
.ap-sound.on { border-color: var(--mode-color); background: color-mix(in srgb, var(--mode-color) 12%, var(--surface-2)); }
.ap-sound-text { flex: 1; display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.ap-sound-text span { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-row { display: grid; grid-template-columns: auto 1fr 32px; align-items: center; gap: 10px; }
.ap-label { font-size: 13.5px; font-weight: 600; }
.ap-vol { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.ap-repeat { border-bottom: 0; padding-top: 0; }
.modal.modal-wide { width: min(94vw, 520px); max-height: 88vh; overflow-y: auto; }
.modal-wide .modal-body { color: var(--text); }
@media (max-width: 480px) { .display-cards { grid-template-columns: 1fr; } .vvol-row { grid-template-columns: minmax(0, 1fr) 90px 36px 32px; } }

/* 수면 패널 (고르기 화면 + 빌더 모달 공용) */
.sleep-panel { display: flex; flex-direction: column; gap: 14px; }
.sp-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sp-label { font-weight: 700; font-size: 15px; }
.sp-time { font-size: 22px; font-weight: 800; padding: 6px 10px; border-radius: 12px; background: var(--input-bg); border: 1px solid var(--border-2); color: inherit; font-variant-numeric: tabular-nums; }
.sp-cycles { display: flex; flex-direction: column; gap: 6px; }
.sp-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.sp-summary { font-size: 15px; font-weight: 700; }
.sp-summary.warn { color: var(--warn); }
.sp-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* 기록 탭 */
.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-card { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.stat-card strong { font-size: 18px; letter-spacing: -.01em; }
.week-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; height: 120px; align-items: end; }
.wb { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; font-size: 12px; color: var(--muted); }
.wb-bar { width: 100%; max-width: 28px; min-height: 3px; border-radius: 8px 8px 3px 3px; background: linear-gradient(to top, #5b8cff, #8fb0ff); }

/* 계정 */
.acct-btn { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 700; font-size: 13px; }
.acct-btn:hover { border-color: var(--border-2); }
.acct-avatar { width: 44px; height: 44px; border-radius: 50%; background: #5b8cff; color: #fff; display: grid; place-items: center; font-weight: 800; overflow: hidden; flex: none; }
.acct-avatar.sm { width: 28px; height: 28px; font-size: 13px; }
.acct-avatar img { width: 100%; height: 100%; object-fit: cover; }
.acct-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-card { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; color: var(--text); }
.acct-loading { color: var(--muted); padding: 0 8px; }
.btn-google { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; }
.btn-google:hover { background: #f7f8f8; }
@media (max-width: 640px) { .acct-name { display: none; } .btn-google span { display: none; } }
/* 탭: 가로 스크롤 대신 줄바꿈 */
.drawer-tabs { flex-wrap: wrap; overflow: visible; row-gap: 6px; }
/* 썸네일 제목 두 줄까지 */
.thumb-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; }
.stats-modes { display: flex; flex-wrap: wrap; gap: 6px; }
.wb-stack { width: 100%; max-width: 28px; min-height: 3px; border-radius: 8px 8px 3px 3px; overflow: hidden; display: flex; flex-direction: column-reverse; background: var(--surface-3); }
.wb-stack span { display: block; min-height: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hour-bars { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; height: 70px; align-items: end; }
.hb { height: 100%; display: flex; align-items: flex-end; }
.hb div { width: 100%; min-height: 2px; border-radius: 3px 3px 1px 1px; background: #5b8cff; }
.hour-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin: 4px 0 10px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.subj-bars { display: flex; flex-direction: column; gap: 6px; }
.sb { display: grid; grid-template-columns: minmax(48px, 90px) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.sb-name { overflow-wrap: anywhere; }
.sb-bar { height: 8px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.sb-bar i { display: block; height: 100%; border-radius: 6px; }
.sb-val { color: var(--muted); font-variant-numeric: tabular-nums; }
.thumb-play { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: var(--text-2); background: var(--surface-3); }
.thumb-play:hover { background: var(--mode-color); color: #fff; }
.yt-preview { position: relative; width: 100%; aspect-ratio: 16 / 9; min-height: 200px; background: #000; border-radius: 12px; overflow: hidden; }
.yt-preview iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.modal.yt-preview-modal { width: min(94vw, 720px); }
