/* 리셋 + 공용 컴포넌트 (버튼, 입력, 칩, 세그먼트, 카드, 토스트, 모달) */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; line-height: 1.5; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
code { font-family: var(--mono); font-size: .85em; background: var(--surface-3); padding: .1em .4em; border-radius: 6px; }
kbd { font-family: var(--mono); font-size: .8em; background: var(--surface-3); border: 1px solid var(--border-2); border-bottom-width: 2px; padding: .1em .5em; border-radius: 6px; }
:focus-visible { outline: 2px solid var(--mode-color); outline-offset: 2px; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; }
.view { position: absolute; inset: 0; }
.view-player { z-index: 1; opacity: 0; pointer-events: none; transition: opacity .35s var(--ease); }
.view-builder { z-index: 2; overflow: auto; background: var(--bg); transition: opacity .3s var(--ease), transform .3s var(--ease); }
#app[data-view="player"] .view-player { opacity: 1; pointer-events: auto; }
#app[data-view="player"] .view-builder { opacity: 0; pointer-events: none; transform: scale(.985); }

/* 버튼 */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: var(--r-m); background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; font-size: 14px; transition: background var(--dur), transform var(--dur), border-color var(--dur), filter var(--dur); }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.98); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.btn-primary { background: var(--mode-color); color: #fff; border-color: transparent; box-shadow: 0 8px 24px -8px var(--mode-color); }
.btn-primary:hover { background: var(--mode-color); filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); }
.btn-xl { padding: 16px 32px; font-size: 18px; border-radius: var(--r-l); }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: var(--text-2); transition: background var(--dur), color var(--dur); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.danger:hover { color: var(--danger); }
.ic { display: block; }
.linklike { color: var(--mode-color); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* 입력 */
input[type="text"], input[type="number"], .select, select { background: var(--input-bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; color: var(--text); outline: none; transition: border-color var(--dur); }
input:focus, select:focus { border-color: var(--mode-color); }
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.range { width: 100%; accent-color: var(--mode-color); }

/* 칩 / 세그먼트 / 스테퍼 / 카드 */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text-2); transition: all var(--dur); }
.chip:hover { border-color: var(--border-2); color: var(--text); }
.chip.on { background: color-mix(in srgb, var(--mode-color) 18%, transparent); border-color: var(--mode-color); color: var(--text); }
.segmented { display: inline-flex; flex-wrap: wrap; padding: 4px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.segmented button { padding: 7px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text-2); transition: all var(--dur); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.stepper { width: 32px; height: 32px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); font-size: 18px; line-height: 1; color: var(--text-2); }
.stepper:hover { color: var(--text); border-color: var(--border-2); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l); box-shadow: var(--shadow-1); }
.hint { color: var(--muted); font-size: 12.5px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.fast-badge { font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: .08em; background: var(--warn); color: #2a1b00; padding: 3px 8px; border-radius: 999px; }

/* 토스트 */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; width: min(92vw, 520px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--glass-border); box-shadow: var(--shadow-2); font-size: 14px; color: var(--text); opacity: 0; transform: translateY(12px); transition: all .25s var(--ease); }
.toast.show { opacity: 1; transform: none; }
.toast.hide { opacity: 0; transform: translateY(8px); }
.toast-msg { flex: 1; }
.toast-action { font-weight: 700; color: var(--mode-color); white-space: nowrap; }
.toast-close { color: var(--muted); display: grid; place-items: center; }
.toast-warn { border-left: 3px solid var(--warn); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-success { border-left: 3px solid var(--success); }

/* 모달 */
.modal-backdrop { position: fixed; inset: 0; z-index: 90; background: var(--overlay); display: grid; place-items: center; padding: 20px; opacity: 0; transition: opacity .2s var(--ease); }
.modal-backdrop.show { opacity: 1; }
.modal { width: min(92vw, 420px); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-l); padding: 24px; box-shadow: var(--shadow-2); transform: translateY(8px) scale(.98); transition: transform .22s var(--ease); }
.show .modal { transform: none; }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; letter-spacing: -.01em; }
.modal-body { color: var(--text-2); font-size: 14px; }
.modal-lead { font-weight: 700; color: var(--text); font-size: 16px; }
.modal-sub { margin-top: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.debug { position: fixed; left: 8px; bottom: 8px; z-index: 200; font: 11px var(--mono); background: rgba(0, 0, 0, .7); color: #9f9; padding: 8px; border-radius: 8px; margin: 0; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; border: 2px solid var(--bg); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ===== 잘림 방지 ===== */
/* 포커스 링이 스크롤 컨테이너에 잘리지 않게 안쪽으로 */
.drawer :focus-visible, .modal :focus-visible, .choice-card :focus-visible, .preset-row :focus-visible { outline-offset: -2px; }
/* 유튜브가 보이는 동안 토스트는 아래쪽 바 높이를 넘지 않게 */
.toasts[data-single="1"] .toast { max-height: 96px; overflow: hidden; }
