/* RAON Remote 공통 디자인 토큰과 부품 (UI 솔루션 가이드 기준) */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');

:root {
  --brand-orange: #F15922; /* 로고, 선택 표시 선, 진행 막대. 글자에는 쓰지 않음 */
  --brand-amber: #FBA819;
  --action: #CC4512;       /* 주 버튼 배경, 링크 글자 (흰 글자 대비 4.74:1) */
  --action-press: #A8380E;
  --action-soft: #FDF0EA;
  --ink: #111111;
  --ink-2: #374151;
  --ink-3: #6B7280;
  --line: #E5E7EB;
  --surface: #F7F7F5;
  --card: #FFFFFF;
  --success: #15803D;
  --warning: #B45309;
  --danger: #B91C1C;
  --danger-soft: #FEF2F2;
  --hover: #F3F4F6;

  --r-input: 6px;
  --r-card: 10px;
  --shadow-card: 0 1px 3px rgba(0,0,0,.08);
  --shadow-dialog: 0 8px 24px rgba(0,0,0,.16);
  --t-fast: 120ms;
  --t-dialog: 200ms;
  --font: 'Pretendard Variable', Pretendard, -apple-system, 'Malgun Gothic', 'Apple SD Gothic Neo', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px; line-height: 1.5; color: var(--ink);
  /* 게이트원과 같이: 낱말 단위로 줄바꿈, 마지막 줄에 한 낱말만 남지 않게 */
  word-break: keep-all; overflow-wrap: break-word; text-wrap: pretty;
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}
a { color: var(--action); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; }
strong, b { font-weight: 600; }
.display { font-size: 32px; line-height: 40px; font-weight: 600; }
.title { font-size: 20px; line-height: 28px; font-weight: 600; }
.label { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-2); }
.caption { font-size: 12px; line-height: 16px; color: var(--ink-3); }
.muted { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 포커스: 2px 오렌지 테두리로 통일 */
:focus-visible { outline: 2px solid var(--brand-orange); outline-offset: 2px; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-input);
  font: inherit; font-size: 14px; font-weight: 400; cursor: pointer; white-space: nowrap;
  border: 1px solid transparent; text-decoration: none !important;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--action); color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--action-press); }
.btn-secondary { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { background: var(--hover); border-color: #D1D5DB; }
.btn-text { background: transparent; color: var(--ink-2); padding: 0 8px; }
.btn-text:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.btn-danger { background: var(--card); color: var(--danger); border-color: #FCA5A5; }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-danger-fill { background: var(--danger); color: #fff; font-weight: 600; }
.btn-danger-fill:hover:not(:disabled) { background: #991B1B; }
.btn-lg { height: 52px; padding: 0 24px; font-size: 16px; font-weight: 600; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; }
.btn .spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 입력칸 ---------- */
.field { display: flex; flex-direction: column; gap: 4px; }
.field > label, .field > .label { font-size: 14px; line-height: 20px; color: var(--ink-2); }
.input, select.input, textarea.input {
  height: 40px; padding: 0 12px; border: 1px solid #D1D5DB; border-radius: var(--r-input);
  background: var(--card); color: var(--ink); font: inherit; font-size: 16px; width: 100%;
  transition: border-color var(--t-fast);
}
textarea.input { height: auto; min-height: 96px; padding: 8px 12px; resize: vertical; }
.input:hover { border-color: #9CA3AF; }
.input:focus { outline: none; border-color: var(--brand-orange); box-shadow: 0 0 0 1px var(--brand-orange); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.field-error { font-size: 13px; line-height: 18px; color: var(--danger); min-height: 18px; }
.field-help { font-size: 13px; line-height: 18px; color: var(--ink-3); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--action); }

/* ---------- 카드 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-card); }

/* ---------- 상태 배지: 점 + 글자 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--hover); color: var(--ink-2);
}
.badge::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.badge.online { background: #F0FDF4; color: var(--success); }
.badge.connecting { background: #FFF4EE; color: var(--action); }
.badge.connecting::before { background: var(--brand-orange); }
.badge.offline { background: #F3F4F6; color: var(--ink-3); }
.badge.check { background: #FFFBEB; color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- 대화상자 ---------- */
.dialog-backdrop {
  position: fixed; inset: 0; background: rgba(17,17,17,.45); display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 100; animation: fade var(--t-dialog) ease-out;
}
.dialog {
  width: 100%; max-width: 440px; max-height: calc(100vh - 48px); overflow: auto;
  background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow-dialog);
  padding: 24px; display: flex; flex-direction: column; gap: 16px; animation: rise var(--t-dialog) ease-out;
}
.dialog.wide { max-width: 640px; }
.dialog h2 { font-size: 16px; line-height: 24px; font-weight: 600; }
.dialog p { margin: 0; color: var(--ink-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.dialog-actions .left { margin-right: auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- 알림(토스트) ---------- */
.toasts { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  min-width: 260px; max-width: 420px; padding: 12px 16px; border-radius: var(--r-card); background: #1F2937; color: #fff;
  box-shadow: var(--shadow-dialog); font-size: 14px; display: flex; gap: 12px; align-items: flex-start; animation: rise var(--t-dialog) ease-out;
}
.toast.error { background: var(--danger); }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; }

/* ---------- 안내 페이지 ---------- */
.msg-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.msg-card { max-width: 480px; padding: 32px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.msg-card h1 { font-size: 20px; line-height: 28px; font-weight: 600; }
.msg-card p { margin: 0; color: var(--ink-2); }
.msg-logo { height: 20px; margin-bottom: 8px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- 아이콘 (icons.js 의 ico) ---------- */
/* 선은 글자색, 옅은 채움은 --ico-tint. 주 버튼은 흰 선에 흰 채움, 나머지는 브랜드 오렌지 채움 */
.ico { flex: none; display: inline-block; vertical-align: -4px; --ico-tint: var(--brand-orange); }
.btn .ico { margin-left: -2px; }
.btn-sm .ico { width: 18px; height: 18px; }
.btn-primary .ico, .btn-danger-fill .ico { --ico-tint: #fff; --ico-knock: var(--action); }
.btn-danger .ico { --ico-tint: var(--danger); }
/* 아이콘만 있는 버튼: 정사각형 */
.btn-icon, .btn-text.btn-sm:not(:has(span)) { width: 32px; padding: 0; }
.btn-text.btn-sm:not(:has(span)) .ico { margin: 0; }
