/* 차분한 어두운 색 — 좌선 중 눈부시지 않게 */
:root {
  --bg: #1c1a17;
  --card: #26231f;
  --line: #3a352f;
  --text: #ece6dc;
  --dim: #9c9387;
  --accent: #c9a46a;
  --accent-text: #1c1a17;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.screen {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.screen[hidden] { display: none; }

.title { text-align: center; margin: 12px 0 8px; }
.title h1 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: 2px; }
.title p { margin: 6px 0 0; color: var(--accent); font-size: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.row { display: flex; justify-content: space-between; align-items: baseline; }
label, .label { font-size: 16px; }
output { color: var(--accent); font-size: 16px; }
.hint { margin: 8px 0 0; color: var(--dim); font-size: 13px; }

input[type=range] { width: 100%; margin-top: 12px; accent-color: var(--accent); }

/* 접고 펴기 (항목별 익숙도) */
.fold > summary { list-style: none; cursor: pointer; user-select: none; align-items: center; }
.fold > summary::-webkit-details-marker { display: none; }
.fold-side { display: flex; align-items: center; gap: 8px; }
.fold-side output { font-size: 13px; }
.chev { color: var(--dim); transition: transform 0.2s; display: inline-block; transform: rotate(-90deg); }
.fold[open] .chev { transform: rotate(0deg); }

/* 맨 위 사용 한도 (명리분석관과 같은 양식) */
.topbar { max-width: 480px; margin: 0 auto; padding: 10px 16px 0; display: flex; justify-content: flex-end; }
.topbar:has(.usage[hidden]) { display: none; }
body.in-session .topbar { display: none; }
.usage { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 10px; border: 1px solid var(--line); border-radius: 10px; }
.usage[hidden] { display: none; }
.meters { display: flex; gap: 14px; cursor: help; }
.meter { display: flex; flex-direction: column; gap: 3px; min-width: 78px; }
.meter .lbl { font-size: 12px; color: var(--dim); white-space: nowrap; letter-spacing: -0.01em; }
.meter .lbl b { color: var(--text); }
.meter .lbl b.hi { color: #e07a5f; }
.meter .lbl .left { margin-left: 1px; font-size: 11px; color: var(--dim); opacity: 0.8; letter-spacing: -0.02em; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width 0.4s; }
.bar i.hi { background: #e07a5f; }
.meters.tts { padding-left: 12px; border-left: 1px solid var(--line); }
.usage-refresh { background: none; border: 0; padding: 2px 6px; font-size: 18px; color: var(--accent); cursor: pointer; }
.usage-refresh.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 말풍선 (명리분석관 TooltipLayer 와 같은 모양) */
.tooltip {
  position: fixed; z-index: 100;
  max-width: min(290px, calc(100vw - 16px));
  padding: 9px 12px; border-radius: 8px;
  background: #2e2a25; color: #f3efe7; border: 1px solid #4a443c;
  font-size: 13px; line-height: 1.55;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.35);
  pointer-events: none;
  white-space: pre-line; word-break: keep-all; overflow-wrap: anywhere;
}
.tooltip.wide { max-width: min(410px, calc(100vw - 16px)); }
@media (pointer: coarse) { .tooltip { pointer-events: auto; overscroll-behavior: contain; } }
.tooltip-title { font-weight: 700; margin-bottom: 5px; padding-bottom: 4px; border-bottom: 1px solid rgb(255 255 255 / 0.12); color: #ffe58a; }
.tt-body { display: flex; flex-direction: column; gap: 3px; }
.tt-gap { height: 3px; }
.tt-kv { padding-left: 0.9em; text-indent: -0.9em; }
.tt-kv > b { color: var(--accent); font-weight: 700; }
.tt-li { position: relative; padding-left: 0.95em; }
.tt-li::before { content: ''; position: absolute; left: 0.2em; top: 0.68em; width: 4px; height: 4px; border-radius: 50%; background: #9c9387; }
.tt-li.tt-kv { text-indent: 0; }
.tt-sub { padding-left: 1em; color: #ffe9a8; }
.tooltip.in { animation: tip-in 0.28s cubic-bezier(0.22, 1, 0.36, 1) both; }
.tooltip.in.swap { animation-duration: 0.14s; }
.tooltip.out { animation: tip-out 0.24s cubic-bezier(0.4, 0, 0.6, 1) both; }
@keyframes tip-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } }
@keyframes tip-out { to { opacity: 0; transform: translateY(4px) scale(0.99); } }
@media (prefers-reduced-motion: reduce) { .tooltip.in, .tooltip.out { animation-duration: 0.01s; } }

/* 종소리 목록 */
.bell-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bell-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.bell-item.on { border-color: var(--accent); background: rgba(201, 164, 106, 0.1); }
.bell-item .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--dim); flex: none; }
.bell-item.on .dot { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 2px var(--card); }
.bell-text { flex: 1; min-width: 0; }
.bell-name { font-size: 15px; }
.bell-desc { display: block; color: var(--dim); font-size: 12px; margin-top: 2px; }

/* 항목 목록 */
.check-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.check-item { border-top: 1px solid var(--line); padding-top: 12px; }
.check-item:first-child { border-top: none; padding-top: 0; }
.check-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.check-name { font-size: 15px; }
.check-share { color: var(--dim); font-size: 12px; margin-left: 6px; }
.preview { background: none; border: 1px solid var(--line); color: var(--dim); border-radius: 8px; padding: 4px 10px; font-size: 13px; cursor: pointer; }

.ratio-row { display: flex; align-items: center; gap: 10px; }
.ratio-row input[type=range] { flex: 1; margin-top: 6px; }
.ratio-out { min-width: 3.2em; text-align: right; font-size: 14px; }
.check-item.off .check-name, .check-item.off .ratio-out { color: var(--dim); }
.levels { display: flex; gap: 6px; margin-top: 8px; }
.levels button {
  flex: 1;
  padding: 8px 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--dim);
  font-size: 14px;
  cursor: pointer;
}
.levels button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

/* 버튼 */
button { font-family: inherit; }
.primary {
  margin-top: 6px;
  padding: 16px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
}
.warn { color: #e0a070; font-size: 13px; text-align: center; }

/* 설정 버튼(⚙)과 설정 창 */
.title { position: relative; }
.icon-btn { position: absolute; right: 0; top: 0; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--dim); display: grid; place-items: center; cursor: pointer; transition: color 0.2s, transform 0.4s; }
.icon-btn:hover { color: var(--accent); transform: rotate(45deg); }
.settings-line { margin-top: 10px; width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 10px 0 0; color: var(--dim); font-size: 13px; cursor: pointer; }
.settings-line:hover { color: var(--accent); }
.sheet { position: fixed; inset: 0; z-index: 150; background: rgb(0 0 0 / 0.6); display: flex; justify-content: center; align-items: flex-end; animation: sheet-fade 0.2s ease both; }
.sheet[hidden] { display: none; }
.sheet-panel { width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; background: var(--bg); border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; padding: 16px 16px 24px; display: flex; flex-direction: column; gap: 14px; animation: sheet-up 0.28s cubic-bezier(0.22, 1, 0.36, 1) both; overscroll-behavior: contain; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 600; }
.sheet-close { background: none; border: 1px solid var(--line); color: var(--dim); border-radius: 8px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
@keyframes sheet-fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 600px) { .sheet { align-items: center; } .sheet-panel { border-radius: 18px; border-bottom: 1px solid var(--line); } }

/* 마침 종(스누즈): 화면이 밝아지고 큰 중지 버튼 */
#done { transition: background 1.2s ease; }
#done.alarm { background: radial-gradient(circle at 50% 40%, #4a3f2c 0%, #2a2520 55%, var(--bg) 100%); }
#done.alarm .big-text { color: #fff6e6; }
.snooze-btn { margin-top: 28px; padding: 20px 44px; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: 22px; font-weight: 700; cursor: pointer; animation: snooze-pulse 2s ease-in-out infinite; }
.snooze-btn[hidden] { display: none; }
#snoozeInfo { margin-top: 12px; }
@keyframes snooze-pulse { 50% { box-shadow: 0 0 0 14px rgb(201 164 106 / 0.18); } }
.toggle { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; cursor: pointer; font-size: 15px; }
.toggle input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--accent); flex: none; }
.toggle small { display: block; color: var(--dim); font-size: 12px; margin-top: 2px; }

/* 소리 출처 */
.credits { color: var(--dim); font-size: 12px; margin-top: 4px; }
.credits summary { cursor: pointer; text-align: center; list-style: none; }
.credits summary::-webkit-details-marker { display: none; }
.credits ul { padding-left: 18px; line-height: 1.6; }
.credits a { color: var(--dim); }

/* 마친 뒤 검은 화면 (화면이 꺼진 것처럼 — 휴대폰 화면은 검은색일 때 거의 빛이 나지 않는다) */
.blackout { position: fixed; inset: 0; z-index: 300; background: #000; cursor: none; animation: black-in 2.5s ease both; }
.blackout[hidden] { display: none; }
@keyframes black-in { from { opacity: 0; } }

/* 좌선 중 */
#session, #done { justify-content: space-between; }
.session-center { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.big { font-size: 64px; margin: 6px 0; font-weight: 300; letter-spacing: 2px; color: #b8ae9f; }
.big-text { font-size: 28px; margin: 0 0 10px; }
.small { color: var(--dim); font-size: 14px; margin: 0; }
.now-text { color: #7d756a; font-size: 14px; line-height: 1.6; margin-top: 28px; min-height: 4.8em; }

.session-buttons { display: flex; gap: 10px; }
.session-buttons button {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}
.session-buttons .ghost { background: transparent; color: var(--dim); }
