:root {
  --bg: #0b1020;
  --bg2: #11182e;
  --card: #161f3a;
  --card2: #1d2747;
  --line: #2a3556;
  --text: #e6ebff;
  --muted: #8b97c2;
  --primary: #4f7cff;
  --primary-d: #3a63e0;
  --green: #2ecc71;
  --red: #ff5d6c;
  --yellow: #ffce54;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  /* 네이티브 컨트롤(date/time 피커, 스크롤바)을 다크로 렌더 */
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* hidden 속성이 display 지정 클래스(.view, .subform 등)보다 우선하도록 */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #1a2547 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* 상단바 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: rgba(11,16,32,.8); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 20px; font-weight: 800; letter-spacing: .3px; display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
/* 인라인 SVG 아이콘 */
.ic { width: 1.05em; height: 1.05em; vertical-align: -0.18em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: inline-block; flex: none; }
.warn { color: var(--yellow); }
.brand-ic { width: 26px; height: 26px; color: #7aa2ff; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tdur { font-size: 11px; opacity: .8; margin-left: 5px; }
.brand span { background: linear-gradient(90deg,#7aa2ff,#9d7bff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-email { color: var(--muted); font-size: 13px; }

#app { max-width: 860px; margin: 0 auto; padding: 18px 16px 60px; }
.view { display: flex; flex-direction: column; gap: 18px; }

/* 홈: 히어로 */
.hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 26px 24px; border-radius: var(--radius); border: 1px solid var(--line); background: linear-gradient(120deg, rgba(79,124,255,.20), rgba(157,123,255,.10) 60%), var(--card); box-shadow: var(--shadow); overflow: hidden; }
.hero-greet { font-size: 24px; font-weight: 800; }
.hero-sub { color: var(--muted); margin-top: 5px; font-size: 14px; }
.hero-ic { width: 60px; height: 60px; flex: none; color: rgba(122,162,255,.45); fill: none; stroke: currentColor; stroke-width: 1.6; }

/* 홈: 검색 */
.home-search { display: flex; align-items: center; gap: 10px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; transition: .15s; }
.home-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,124,255,.2); }
.home-search .ic { color: var(--muted); flex: none; }
.home-search input { flex: 1; width: auto; background: transparent; border: none; padding: 13px 0; }
.home-search input:focus { outline: none; box-shadow: none; }

.section-label { color: var(--muted); font-size: 13px; font-weight: 600; margin: 2px 2px -6px; }

/* 도구 카드 실시간 현황 */
.tool-stat { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(46,204,113,.18); display: inline-block; }
.dot-idle { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); opacity: .55; display: inline-block; }

/* 홈: 도구 그리드 */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tool-card { display: flex; flex-direction: column; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: .15s; }
.tool-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.tool-card.soon { opacity: .5; pointer-events: none; }
.tool-ic { width: 46px; height: 46px; border-radius: 12px; background: rgba(79,124,255,.14); display: grid; place-items: center; color: var(--primary); }
.tool-ic svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool-name { font-size: 16px; font-weight: 700; }
.tool-desc { font-size: 13px; color: var(--muted); line-height: 1.5; flex: 1; }
.tool-cat { font-size: 11px; color: var(--muted); background: var(--bg2); border: 1px solid var(--line); border-radius: 20px; padding: 3px 10px; align-self: flex-start; }
.soon-badge { font-size: 11px; font-weight: 700; color: var(--yellow); background: rgba(255,206,84,.14); border-radius: 20px; padding: 2px 8px; }

/* 변환·계산 유틸 */
.subtabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.subtab { background: transparent; border: none; color: var(--muted); padding: 9px 14px; cursor: pointer; font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; font-family: inherit; }
.subtab:hover { color: var(--text); }
.subtab.active { color: var(--text); border-bottom-color: var(--primary); }
.cpanel { display: flex; flex-direction: column; gap: 12px; }
.conv-sub { font-size: 13px; font-weight: 600; color: var(--muted); }
.conv-divider { border-top: 1px dashed var(--line); margin: 6px 0; }
.conv-result { font-size: 22px; font-weight: 800; color: var(--green); background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 16px; word-break: break-all; }
.conv-rows { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.conv-rows > div { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.conv-rows span { font-size: 12px; color: var(--muted); }
.conv-rows b { font-size: 18px; word-break: break-all; }
.ttools { display: flex; flex-wrap: wrap; gap: 8px; }
textarea { background: var(--bg2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 11px 12px; font-size: 14px; width: 100%; font-family: inherit; resize: vertical; }
textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,124,255,.2); }

/* 도구 헤더 (도구 내부 상단) */
.tool-header { display: flex; align-items: center; gap: 12px; padding-bottom: 2px; }
.tool-header h2 { margin: 0; font-size: 20px; }
.tool-header .ic { width: 22px; height: 22px; color: var(--primary); }
#back-home { white-space: nowrap; }

/* 카드 */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card h2 { margin: 0; font-size: 16px; }
.muted { color: var(--muted); font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 6px 0; }
.err { color: var(--red); font-size: 13px; margin: 6px 0 0; }

/* 폼 */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input, select {
  background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 11px 12px; font-size: 14px; width: 100%;
  font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,124,255,.2); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.subform { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.row-end { display: flex; gap: 10px; justify-content: flex-end; }
.row-between { display: flex; gap: 12px; align-items: flex-end; }
.grow { flex: 1; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline span { color: var(--muted); }

/* 버튼 */
.btn {
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: .15s; font-family: inherit;
}
.btn:hover { border-color: var(--primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-d); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn.block { width: 100%; margin-top: 14px; }

/* 로그인 — 전체화면 split */
.auth-screen { position: fixed; inset: 0; z-index: 50; display: flex; }
.auth-hero {
  flex: 1.15; position: relative; overflow: hidden;
  display: flex; align-items: center; padding: 56px;
  background:
    radial-gradient(900px 520px at 16% 20%, rgba(79,124,255,.45), transparent 55%),
    radial-gradient(820px 620px at 90% 82%, rgba(157,123,255,.42), transparent 55%),
    linear-gradient(135deg, #16204a 0%, #0b1020 72%);
}
.auth-hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 38px 38px;
  -webkit-mask-image: radial-gradient(circle at 28% 38%, #000, transparent 78%);
  mask-image: radial-gradient(circle at 28% 38%, #000, transparent 78%);
}
.auth-hero-inner { position: relative; z-index: 1; max-width: 470px; }
.auth-hero-brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; }
.auth-hero-brand svg { width: 30px; height: 30px; color: #9db4ff; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.auth-hero-title { font-size: 40px; line-height: 1.18; font-weight: 800; letter-spacing: -.5px; margin: 30px 0 14px; }
.auth-hero-desc { color: #c5cef0; font-size: 16px; line-height: 1.6; margin: 0 0 28px; }
.auth-features { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.auth-features li { position: relative; padding-left: 24px; color: #d7ddf5; font-size: 14px; }
.auth-features li::before { content: ""; position: absolute; left: 2px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: #7aa2ff; box-shadow: 0 0 0 4px rgba(122,162,255,.18); }
.auth-features em { color: var(--muted); font-style: normal; font-size: 12px; }

.auth-formside { flex: 1; display: grid; place-items: center; background: var(--bg); padding: 24px; }
.auth-formbox { width: min(360px, 100%); }
.auth-formbrand { display: none; align-items: center; gap: 8px; font-size: 20px; font-weight: 800; margin-bottom: 24px; justify-content: center; }
.auth-formbrand svg { width: 26px; height: 26px; color: var(--primary); fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.auth-formtitle { font-size: 26px; font-weight: 800; margin: 0; }
.auth-formsub { color: var(--muted); font-size: 14px; margin: 6px 0 24px; }
#auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 0 0; }

@media (max-width: 880px) {
  .auth-hero { display: none; }
  .auth-formbrand { display: flex; }
}

/* 체크박스 라벨 / 관리자 태그 */
.chk { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; cursor: pointer; }
.chk input { width: auto; accent-color: var(--primary); }
.admin-tag { font-size: 11px; font-weight: 700; color: var(--primary); background: rgba(79,124,255,.16); border-radius: 20px; padding: 2px 8px; margin-left: 4px; }

/* 모드 선택 */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.mode-pick { flex-direction: row; align-items: flex-start; gap: 10px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; cursor: pointer; color: var(--text); }
.mode-pick input { width: auto; margin-top: 3px; accent-color: var(--primary); }
.mode-pick b { display: block; font-size: 14px; }
.mode-pick span { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; line-height: 1.4; }
.mode-pick:has(input:checked) { border-color: var(--primary); background: rgba(79,124,255,.12); }

#range-fields, #specific-fields { margin-top: 4px; }
.advanced { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; }
.advanced summary { cursor: pointer; padding: 12px 0; color: var(--muted); font-size: 13px; }
.advanced[open] { padding-bottom: 12px; }

/* 검색 결과 */
.search-result { margin: 10px 0; display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.train-row { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 12px; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; cursor: pointer; }
.train-row:hover { border-color: var(--primary); }
.train-row:has(input:checked) { border-color: var(--primary); background: rgba(79,124,255,.12); }
.train-row input { width: auto; flex: none; accent-color: var(--primary); width: 18px; height: 18px; }
.train-row .tnum { font-weight: 700; min-width: 52px; color: var(--text); }
.train-row .ttime { color: var(--muted); margin-right: auto; }
.seat-tag { font-size: 12px; padding: 2px 8px; border-radius: 20px; }
.seat-ok { color: var(--green); background: rgba(46,204,113,.14); }
.seat-no { color: var(--red); background: rgba(255,93,108,.12); }
.seat-wait { color: var(--yellow); background: rgba(255,206,84,.14); }

/* SRT 계정 목록 */
.acct-list { display: flex; flex-direction: column; gap: 8px; }
.acct-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; }
.acct-item .meta { font-size: 13px; }
.acct-item .meta b { font-size: 14px; }
.acct-item .meta span { color: var(--muted); }
.acct-actions { display: flex; gap: 6px; }

/* 텔레그램 */
.tg-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tg-on { font-weight: 600; }
.tg-on .ic { color: var(--green); }
.tg-steps { margin: 12px 0 10px; padding-left: 20px; color: var(--muted); font-size: 13px; line-height: 1.9; }
.tg-steps a { color: var(--primary); }
#tg-link { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 10px; }
code { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; font-size: 12px; color: var(--yellow); }

/* 작업 목록 */
.jobs-list { display: flex; flex-direction: column; gap: 12px; }
.job-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.job-card.reserved { border-color: var(--green); background: rgba(46,204,113,.08); }
.job-card.error, .job-card.failed { border-color: var(--red); }
.job-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.job-route { font-size: 16px; font-weight: 700; }
.job-route small { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: 8px; }
.badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.badge.watching { color: var(--primary); background: rgba(79,124,255,.16); }
.badge.reserved { color: var(--green); background: rgba(46,204,113,.16); }
.badge.stopped { color: var(--muted); background: rgba(139,151,194,.14); }
.badge.error, .badge.failed { color: var(--red); background: rgba(255,93,108,.14); }
.job-msg { color: var(--muted); font-size: 13px; margin: 8px 0; }
.job-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.job-seen { font-size: 11px; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; max-height: 64px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; }
.job-actions { display: flex; gap: 8px; margin-top: 10px; }
.reserve-box { margin-top: 10px; padding: 12px; border: 1px solid var(--green); border-radius: 10px; background: rgba(46,204,113,.1); }
.reserve-box .rn { font-size: 18px; font-weight: 800; color: var(--green); }
.reserve-box .deadline { color: var(--yellow); font-weight: 700; }

.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { color: var(--muted); text-align: center; padding: 24px; font-size: 14px; }

/* 토스트 */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--line); color: var(--text); padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; z-index: 100; max-width: 90vw; }
.toast.ok { border-color: var(--green); }
.toast.bad { border-color: var(--red); }

@media (max-width: 560px) {
  .modes { grid-template-columns: 1fr; }
  .row-between { flex-direction: column; align-items: stretch; }
}
