/* ===== InnerBetter 공용 컴포넌트 스타일 (모든 값은 tokens.css 토큰 참조) ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans); color: var(--color-text); background: var(--color-bg);
  font-size: var(--text-md); line-height: var(--leading-normal); letter-spacing: var(--tracking-tight);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
img { max-width: 100%; display: block; }
.logo-invert { filter: invert(1); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Button ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--btn-height-md); padding: 0 var(--space-4); border-radius: var(--btn-radius);
  font-weight: var(--weight-semibold); font-size: var(--text-md); line-height: 1; white-space: nowrap;
  transition: transform var(--duration-fast) var(--ease-standard), background var(--duration-normal), box-shadow var(--duration-normal), border-color var(--duration-normal);
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--color-primary); color: var(--color-text-inverse); }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-brand { background: var(--color-brand); color: var(--color-text-on-brand); }
.btn-brand:hover { background: var(--color-brand-hover); }
.btn-ghost { background: var(--color-bg-subtle); color: var(--color-text); }
.btn-ghost:hover { background: var(--color-bg-muted); }
.btn-outline { background: var(--color-bg); border: 1.5px solid var(--color-border-strong); color: var(--color-text); }
.btn-outline:hover { border-color: var(--color-border-focus); }
.btn-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.btn-sm { height: var(--btn-height-sm); padding: 0 var(--space-3); font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn-lg { height: var(--btn-height-lg); padding: 0 var(--space-6); font-size: var(--text-lg); border-radius: var(--radius-md); }
.btn-icon { width: var(--btn-height-sm); height: var(--btn-height-sm); padding: 0; border-radius: var(--radius-sm); }

/* ---------- Switch ---------- */
.switch { position: relative; width: var(--switch-w); height: var(--switch-h); border-radius: var(--radius-full); background: var(--color-border-strong); transition: background var(--duration-normal); flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: calc(var(--switch-h) - 6px); height: calc(var(--switch-h) - 6px); border-radius: 50%; background: var(--color-bg); transition: transform var(--duration-normal) var(--ease-out); box-shadow: var(--shadow-sm); }
.switch.on { background: var(--color-primary); }
.switch.on::after { transform: translateX(calc(var(--switch-w) - var(--switch-h))); }
.switch.brand.on { background: var(--color-brand); }
.switch.brand.on::after { background: var(--color-primary); }

/* ---------- Badge ---------- */
.badge { display: inline-flex; align-items: center; gap: var(--space-1); padding: 3px 9px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--weight-semibold); line-height: 1.4; white-space: nowrap; }
.badge-brand { background: var(--color-brand); color: var(--color-text-on-brand); }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-muted { background: var(--color-bg-subtle); color: var(--color-text-muted); }
.badge-inverse { background: var(--color-bg-inverse); color: var(--color-text-inverse); }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; left: 50%; bottom: var(--space-8); transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--space-2); z-index: var(--z-toast); pointer-events: none; }
.toast { background: var(--color-bg-inverse); color: var(--color-text-inverse); padding: var(--space-3) var(--space-5); border-radius: var(--radius-md); font-size: var(--text-md); font-weight: var(--weight-medium); box-shadow: var(--shadow-md); animation: toast-in var(--duration-normal) var(--ease-out); display: flex; align-items: center; gap: var(--space-3); }
.toast.error { background: var(--color-danger); }
.toast.ok { background: var(--color-success); }
.toast.brand { background: var(--color-brand); color: var(--color-text-on-brand); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: var(--color-bg-overlay); display: none; align-items: center; justify-content: center; z-index: var(--z-modal); padding: var(--space-5); backdrop-filter: blur(2px); }
.modal-backdrop.open { display: flex; }
.modal { background: var(--color-bg); border-radius: var(--radius-lg); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; box-shadow: var(--shadow-lg); animation: modal-in var(--duration-normal) var(--ease-out); }
.modal.wide { max-width: 760px; }
.modal { scrollbar-width: none; -ms-overflow-style: none; }   /* 스크롤은 되지만 스크롤바는 숨김 */
.modal::-webkit-scrollbar { display: none; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-5) var(--space-6) var(--space-3); }
.modal-head h3 { margin: 0; font-size: var(--text-xl); font-weight: var(--weight-bold); }
.modal-body { padding: var(--space-2) var(--space-6) var(--space-5); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-6) var(--space-6); border-top: 1px solid var(--color-border); }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); }
.field label { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-text-muted); }
.field input[type=text], .field input[type=number], .field input[type=tel], .field input[type=password], .field input[type=email], .field select, .field textarea {
  height: var(--input-height); border: 1.5px solid var(--color-border); border-radius: var(--input-radius); padding: 0 var(--space-3);
  font-size: var(--text-md); background: var(--color-bg); outline: none; transition: border-color var(--duration-normal);
}
.field textarea { height: auto; padding: var(--space-3); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--color-border-focus); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-3); }
.hint { font-size: var(--text-xs); color: var(--color-text-muted); }

/* ---------- 셀렉트 박스 커스텀 디자인 (프로젝트 공통) ----------
 * Chrome 135+ 의 customizable select(appearance: base-select)로 옵션 목록까지 브랜드 디자인으로 그립니다.
 * 지원하지 않는 브라우저는 기본 드롭다운을 쓰되 트리거(화살표·테두리)만 같은 디자인을 적용합니다. */
select {
  appearance: none; -webkit-appearance: none; cursor: pointer; color: var(--color-text);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23151515' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px 16px; padding-right: 34px !important;
}
select:focus-visible { outline: none; border-color: var(--color-border-focus) !important; }
@supports (appearance: base-select) {
  select, ::picker(select) { appearance: base-select; }
  select { background-image: none; padding-right: var(--space-3) !important; display: inline-flex; align-items: center; gap: var(--space-2); line-height: 1; }
  select::picker-icon {
    content: ''; width: 16px; height: 16px; margin-left: auto; flex: none;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23151515' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>") center / 16px 16px no-repeat;
    transition: transform var(--duration-normal);
  }
  select:open::picker-icon { transform: rotate(180deg); }
  select:open { border-color: var(--color-border-focus) !important; }
  ::picker(select) {
    border: 1.5px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-bg); color: var(--color-text);
    box-shadow: var(--shadow-md); padding: 6px; margin: 6px 0; min-width: anchor-size(width);
    opacity: 0; transform: translateY(-4px); transition: opacity var(--duration-fast), transform var(--duration-fast), overlay var(--duration-fast) allow-discrete, display var(--duration-fast) allow-discrete;
  }
  ::picker(select):popover-open { opacity: 1; transform: none; }
  @starting-style { ::picker(select):popover-open { opacity: 0; transform: translateY(-4px); } }
  select option {
    display: flex; align-items: center; gap: var(--space-2); padding: 9px 12px; border-radius: 8px; margin: 6px 0;   /* 옵션 사이 간격 6px (위아래 여백이 겹쳐 6px) */
    font-size: var(--text-md); font-weight: var(--weight-medium); color: var(--color-text); cursor: pointer; white-space: nowrap;
    transition: background var(--duration-fast);
  }
  select option:hover, select option:focus-visible { background: var(--color-bg-subtle); outline: none; }
  select option:checked { background: var(--color-bg-brand-soft); font-weight: var(--weight-semibold); }
  select option:checked:hover { background: var(--color-brand); }
  select option::checkmark {
    order: 1; margin-left: auto; content: ''; width: 14px; height: 14px; flex: none;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23151515' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M5 12l5 5 9-10'/></svg>") center / 14px 14px no-repeat;
  }
  select option:first-of-type { margin-top: 0; }
  select option:last-of-type { margin-bottom: 0; }
  select option:disabled { color: var(--color-text-subtle); cursor: default; }
  select optgroup { padding: 4px 0; }
  select optgroup::before { display: block; padding: 6px 12px 4px; font-size: 11px; font-weight: var(--weight-semibold); color: var(--color-text-muted); letter-spacing: var(--tracking-wide); }
}
