/* 토큰: 라이트를 기본으로 :root에 전부 정의하고, 다크는 OS 설정과 토글 양쪽에서 덮어쓴다. */
:root {
  color-scheme: light;
  --page:        #f9f9f7;
  --surface-1:   #fcfcfb;
  --text-1:      #0b0b0b;
  --text-2:      #52514e;
  --muted:       #898781;
  --grid:        #e1e0d9;
  --axis:        #c3c2b7;

  --series-1:    #2a78d6;  /* 캐시 */
  --series-2:    #eb6834;  /* 포워드 */
  --series-3:    #1baf7a;  /* 차단 */
  --seq:         #2a78d6;

  --good:        #0ca30c;
  --warning:     #fab219;
  --serious:     #ec835a;
  --critical:    #d03b3b;

  /* 항공기 고도 램프. 고도는 연속량이라 무지개가 아니라 단일 색조 순차로 간다.
     라이트는 밝은 단계에서 어두운 단계로, 다크는 표면에 맞춰 반대 방향으로 고른다. */
  --alt-1: #86b6ef;
  --alt-2: #5598e7;
  --alt-3: #2a78d6;
  --alt-4: #1c5cab;
  --alt-5: #104281;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface-1: #1a1a19;
    --text-1: #ffffff; --text-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --seq: #3987e5;
    --alt-1: #1c5cab; --alt-2: #2a78d6; --alt-3: #5598e7; --alt-4: #86b6ef; --alt-5: #b7d3f6;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface-1: #1a1a19;
  --text-1: #ffffff; --text-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --seq: #3987e5;
  --alt-1: #1c5cab; --alt-2: #2a78d6; --alt-3: #5598e7; --alt-4: #86b6ef; --alt-5: #b7d3f6;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--page); color: var(--text-1);
  font: 15px/1.55 -apple-system, "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; }

/* ---------------------------------------------------------- 레이아웃 */
header.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--surface-1); border-bottom: 1px solid var(--grid);
}
header.top .brand { font-weight: 700; letter-spacing: -.02em; margin-right: 4px; }
nav.tabs { display: flex; gap: 4px; }
nav.tabs a {
  text-decoration: none; color: var(--text-2); padding: 6px 12px; border-radius: 8px;
  font-size: 14px;
}
nav.tabs a:hover { background: var(--page); }
nav.tabs a[aria-current="page"] { background: var(--page); color: var(--text-1); font-weight: 600; }
.spacer { flex: 1 1 auto; }
button.ghost {
  background: transparent; border: 1px solid var(--grid); color: var(--text-2);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer;
  font-family: inherit;
}
button.ghost:hover { color: var(--text-1); border-color: var(--axis); }

/* 헤더의 로그인 상태 */
.who { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.who b { color: var(--text-1); font-weight: 600; }
.role {
  display: inline-block; border: 1px solid var(--grid); border-radius: 999px; padding: 1px 8px;
  font-size: 11.5px; color: var(--muted); white-space: nowrap;
}
.role.admin { color: var(--seq); border-color: color-mix(in srgb, var(--seq) 40%, var(--grid)); }
.logout-form { margin: 0; }

/* 승인 대기 건수. 탭에 붙어 있어야 가입 신청이 묻히지 않는다. */
.pill {
  display: inline-block; margin-left: 5px; min-width: 17px; padding: 0 5px;
  border-radius: 999px; background: var(--critical); color: #fff;
  font-size: 11px; font-weight: 600; text-align: center; line-height: 17px;
}

/* 게스트는 조회만 한다. 서버가 어차피 403으로 끊지만, 눌러도 안 되는 버튼을
   그대로 두면 고장난 화면으로 보이므로 아예 감춘다. */
body[data-role="guest"] .admin-only,
body[data-role="guest"] .iconbtn { display: none !important; }

main { max-width: 1180px; margin: 0 auto; padding: 20px; }
h2 { font-size: 15px; margin: 0; letter-spacing: -.01em; }
.sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card {
  background: var(--surface-1); border: 1px solid var(--grid); border-radius: 14px;
  padding: 16px; min-width: 0;
}
.card.wide { grid-column: 1 / -1; }
.card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.card-head .spacer { flex: 1; }

/* ---------------------------------------------------------- 스탯 타일 */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tile { background: var(--surface-1); border: 1px solid var(--grid); border-radius: 14px; padding: 14px 16px; }
.tile .label { color: var(--muted); font-size: 12px; }
.tile .value {
  font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.tile .value small { font-size: 14px; font-weight: 500; color: var(--text-2); margin-left: 2px; }
.tile .foot { color: var(--text-2); font-size: 12px; margin-top: 4px; }

/* 진행 막대 */
.meter { height: 6px; background: var(--grid); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 3px; background: var(--seq); }

/* ---------------------------------------------------------- 상태 배지 */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text-2); white-space: nowrap;
}
.badge svg { flex: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* ---------------------------------------------------------- 표 */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--grid); }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.truncate { max-width: 1px; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.scroll-x { overflow-x: auto; }

/* ---------------------------------------------------------- 차트 */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; }
.legend .item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .n { color: var(--text-1); font-variant-numeric: tabular-nums; font-weight: 600; }

.tooltip {
  position: absolute; pointer-events: none; opacity: 0; transition: opacity .1s;
  background: var(--surface-1); border: 1px solid var(--axis); border-radius: 9px;
  padding: 8px 10px; font-size: 12.5px; box-shadow: 0 6px 20px rgba(0,0,0,.14);
  white-space: nowrap; z-index: 10; color: var(--text-1);
}
.tooltip .t-row { display: flex; align-items: center; gap: 6px; }
.tooltip .t-row .n { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.tooltip .t-head { color: var(--muted); margin-bottom: 4px; }

details.tableview { margin-top: 10px; }
details.tableview summary {
  cursor: pointer; color: var(--text-2); font-size: 12.5px; list-style: none;
  display: inline-flex; align-items: center; gap: 5px;
}
details.tableview summary::-webkit-details-marker { display: none; }
details.tableview summary::before { content: "▸"; color: var(--muted); }
details.tableview[open] summary::before { content: "▾"; }
details.tableview > div { margin-top: 8px; max-height: 320px; overflow: auto; }

/* ---------------------------------------------------------- 파일 드롭 */
.dropzone {
  display: block;  /* label은 기본이 inline이라 내부 block 요소에 테두리가 쪼개진다 */
  border: 2px dashed var(--axis); border-radius: 14px; padding: 34px 20px; text-align: center;
  color: var(--text-2); background: var(--surface-1); transition: border-color .15s, background .15s;
  cursor: pointer;
}
.dropzone.hover { border-color: var(--seq); background: var(--page); color: var(--text-1); }
.dropzone strong { color: var(--text-1); display: block; font-size: 16px; margin-bottom: 4px; }
input[type=file] { display: none; }

.uploads { margin-top: 12px; display: grid; gap: 8px; }
.uprow { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.uprow .bar { flex: 1; height: 5px; background: var(--grid); border-radius: 3px; overflow: hidden; }
.uprow .bar > i { display: block; height: 100%; background: var(--seq); width: 0; transition: width .15s; }

.qrbox { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.qrbox .qr {
  background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--grid);
  width: 148px; height: 148px; flex: none;
}
.qrbox .qr svg { width: 100%; height: 100%; display: block; }

.iconbtn {
  background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 4px 6px;
  border-radius: 6px; font-size: 13px; font-family: inherit;
}
.iconbtn:hover { color: var(--critical); background: var(--page); }

.empty { color: var(--muted); font-size: 13.5px; padding: 18px 2px; text-align: center; }
.ok {
  background: color-mix(in srgb, var(--good) 10%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--good) 35%, var(--surface-1));
  color: var(--text-1); border-radius: 10px; padding: 10px 12px; font-size: 13px;
}
.err {
  background: color-mix(in srgb, var(--critical) 10%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--critical) 35%, var(--surface-1));
  color: var(--text-1); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px;
}
select.select {
  background: var(--surface-1); color: var(--text-1); font-family: inherit; font-size: 13.5px;
  border: 1px solid var(--grid); border-radius: 9px; padding: 7px 10px; max-width: 100%;
}
select.select:disabled { color: var(--muted); }

.seg { display: inline-flex; border: 1px solid var(--grid); border-radius: 9px; overflow: hidden; }
.seg button {
  background: transparent; border: 0; padding: 6px 12px; font-size: 13px; cursor: pointer;
  color: var(--text-2); font-family: inherit;
}
.seg button[aria-pressed="true"] { background: var(--page); color: var(--text-1); font-weight: 600; }

@media (max-width: 560px) {
  main { padding: 14px; }
  .tile .value { font-size: 22px; }
}

/* ---------------------------------------------------------- 로그인 */
/* 폰에서 여는 일이 많아 세로 가운데가 아니라 위쪽에 붙인다(키보드가 올라와도 안 밀린다). */
main.login { max-width: 400px; margin: 0 auto; padding: 48px 20px; }
.login-card { padding: 24px; }
.login-brand { font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.login-form { display: grid; gap: 12px; margin-top: 18px; }
.login-form label { display: flex; flex-direction: column; gap: 4px; }
.login-form input {
  background: var(--page); color: var(--text-1); font-family: inherit; font-size: 15px;
  border: 1px solid var(--grid); border-radius: 9px; padding: 10px 12px; width: 100%;
}
.login-form input:focus { outline: 2px solid var(--seq); outline-offset: -1px; border-color: var(--seq); }
.login-form button {
  background: var(--text-1); color: var(--page); border: 1px solid var(--text-1);
  border-radius: 9px; padding: 11px 16px; font-size: 14.5px; font-family: inherit;
  cursor: pointer; font-weight: 600; margin-top: 4px;
}
.login-form button:hover { opacity: .85; }
.login-guest {
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--grid);
  display: grid; gap: 6px; justify-items: center; text-align: center;
}
.login-guest button { width: 100%; padding: 9px 14px; }

/* ---------------------------------------------------------- 폰 미러링 */
.steps { margin: 0 0 14px; padding-left: 20px; color: var(--text-2); font-size: 13.5px; line-height: 1.9; }
.steps b { color: var(--text-1); }

.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
/* label은 기본이 inline이라 내부 block 요소에 레이아웃이 쪼개진다 */
.form-row label { display: flex; flex-direction: column; gap: 4px; flex: 1 1 150px; min-width: 0; }
.form-row input {
  background: var(--surface-1); color: var(--text-1); font-family: inherit; font-size: 13.5px;
  border: 1px solid var(--grid); border-radius: 9px; padding: 8px 10px; width: 100%;
}
.form-row input:focus { outline: 2px solid var(--seq); outline-offset: -1px; border-color: var(--seq); }
.form-row button {
  background: var(--text-1); color: var(--page); border: 1px solid var(--text-1);
  border-radius: 9px; padding: 9px 16px; font-size: 13.5px; font-family: inherit;
  cursor: pointer; font-weight: 600; flex: none;
}
.form-row button:hover:not(:disabled) { opacity: .85; }
.form-row button:disabled { opacity: .5; cursor: default; }
.form-row button.ghost {
  background: transparent; color: var(--text-2); border-color: var(--grid); font-weight: 400;
}

.result {
  margin: 14px 0 0; padding: 10px 12px; border: 1px solid var(--grid); border-left-width: 3px;
  border-radius: 9px; background: var(--surface-1); color: var(--text-1);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto;
}

@media (max-width: 560px) {
  .form-row label { flex: 1 1 100%; }
  .form-row button { width: 100%; }
}

/* ---------------------------------------------------------- 항공기 스코프 */
/* 정사각형이라 카드 폭을 그대로 주면 화면을 다 잡아먹는다. 폭을 묶고 가운데 정렬. */
#scope { max-width: 620px; margin: 0 auto; }
#scope svg { touch-action: none; }
/* 마크가 겹쳐도 서로 구분되도록 표면색 링을 두른다. */
#scope .ac { stroke: var(--surface-1); stroke-width: 2; paint-order: stroke; cursor: pointer; }
#scope .ac:hover { stroke: var(--text-1); }
#scope .ac.old { opacity: .45; }
#scope .ring { fill: none; stroke: var(--grid); }
#scope .spoke { stroke: var(--grid); }
#scope .rlabel, #scope .clabel { fill: var(--muted); font-size: 11px; }
#scope .aclabel { fill: var(--text-2); font-size: 11px; }
#scope .home { fill: none; stroke: var(--axis); stroke-width: 1.5; }

/* 지도 (Leaflet). 스코프와 같은 고도 색·같은 마크 모양을 쓴다. */
#map {
  height: 540px; border-radius: 12px; overflow: hidden; border: 1px solid var(--grid);
  background: var(--page);
}
@media (max-width: 560px) { #map { height: 380px; } }
/* 지도 자체가 어두운 타일을 깔아도 컨트롤·툴팁은 우리 토큰을 따라야 한다. */
.leaflet-container { background: var(--page); font: inherit; }
.leaflet-bar a, .leaflet-control-attribution {
  background: var(--surface-1); color: var(--text-2); border-color: var(--grid);
}
.leaflet-bar a:hover { background: var(--page); color: var(--text-1); }
.leaflet-control-attribution { font-size: 10.5px; }
.leaflet-control-attribution a { color: var(--text-2); }

.map-ac svg { overflow: visible; }
.map-ac .ac { stroke: var(--surface-1); stroke-width: 2; paint-order: stroke; cursor: pointer; }
.map-ac .ac.old { opacity: .45; }
.map-ac .ac.sel { stroke: var(--text-1); stroke-width: 2.5; }
.map-ac .ac.emg { stroke: var(--critical); stroke-width: 3; }
.map-aclabel, .map-rlabel {
  color: var(--text-2); font-size: 11px; white-space: nowrap; pointer-events: none;
  /* 타일 위 글자는 배경 대비가 들쭉날쭉하다. 표면색 외곽선으로 어디서나 읽히게 한다. */
  text-shadow: 0 0 3px var(--surface-1), 0 0 3px var(--surface-1), 0 0 3px var(--surface-1);
}
.map-rlabel { color: var(--muted); font-variant-numeric: tabular-nums; }
/* 툴팁은 스코프의 .tooltip과 같은 모양으로 맞춘다. */
.leaflet-tooltip.map-tip {
  background: var(--surface-1); border: 1px solid var(--axis); color: var(--text-1);
  border-radius: 9px; padding: 8px 10px; font-size: 12.5px;
  box-shadow: 0 6px 20px rgba(0,0,0,.14);
}
.leaflet-tooltip.map-tip::before { display: none; }
.map-tip .t-row { display: flex; align-items: center; gap: 10px; }
.map-tip .t-row .n { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.map-tip .t-head { color: var(--muted); margin-bottom: 4px; }

/* 항적선. 마크보다 후퇴시켜 위치가 먼저 읽히게 한다. */
#scope .trail { fill: none; stroke-width: 1.5; stroke-opacity: .38; stroke-linejoin: round; }
#scope .trail.sel { stroke-opacity: 1; stroke-width: 2.5; }
#scope .ac.sel { stroke: var(--text-1); stroke-width: 2.5; }
/* 비상 기체는 색만으로 알리지 않는다 — 링을 더 두껍게 줘서 형태로도 구분된다. */
#scope .ac.emg { stroke: var(--critical); stroke-width: 3; }

th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--text-1); }
th.sortable[aria-sort]::after { content: " ▾"; }
th.sortable[aria-sort="ascending"]::after { content: " ▴"; }
/* 수신 기체가 60대를 넘으면 표만으로 화면 두세 배가 되어 아래 이력 섹션이 묻힌다.
   높이를 묶고 안에서 스크롤시키되, 헤더는 붙여 둬서 정렬 기준이 계속 보이게 한다. */
.tablebox { max-height: 520px; overflow: auto; }
.tablebox thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-1); border-bottom: 1px solid var(--grid);
}
#table tbody tr { cursor: pointer; }
#table tbody tr:hover { background: var(--page); }
#table tbody tr.sel { background: color-mix(in srgb, var(--seq) 12%, var(--surface-1)); }

/* 필터 줄은 차트 위 한 줄에 모은다. */
.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin: 14px 0 0; }
/* label은 기본이 inline이라 내부 block 요소에 레이아웃이 쪼개진다 */
.filters label { display: flex; flex-direction: column; gap: 3px; }
.filters .sub { margin: 0; }

/* 기체 상세 */
.detail { margin-top: 14px; border-top: 1px solid var(--grid); padding-top: 12px; }
.detail-body { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.detail-body .kv { flex: 1 1 320px; }
.photo { flex: 0 0 280px; max-width: 100%; }
.photo img { width: 100%; height: auto; border-radius: 10px; display: block; border: 1px solid var(--grid); }
.photo .credit { margin-top: 4px; font-size: 11.5px; }
.photo .nophoto {
  border: 1px dashed var(--grid); border-radius: 10px; padding: 22px 12px;
  text-align: center; background: var(--page);
}
.kv { display: grid; gap: 8px 16px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.kv > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.kv b { font-weight: 600; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }

/* 서버 자체 점검 */
.checks { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.chk {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 10px 12px; border-radius: 10px; background: var(--page);
  border-left: 3px solid var(--good);
}
.chk.bad { border-left-color: var(--critical); }
.chk-ico { flex: none; color: var(--good); line-height: 1.5; }
.chk.bad .chk-ico { color: var(--critical); }
.chk-body { min-width: 0; }
.chk-body b { display: block; font-weight: 600; }
.chk-body .sub { word-break: break-word; }

/* 홈 화면의 항공기 요약 */
.flysum { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.flysum > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.flysum b { font-size: 19px; font-weight: 650; letter-spacing: -.01em; }

/* 이벤트 피드 */
.events { display: grid; gap: 2px; }
.ev {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 10px; border-radius: 9px; font-size: 13.5px;
  border-left: 3px solid var(--grid); background: var(--page);
}
.ev.critical { border-left-color: var(--critical); }
.ev.serious  { border-left-color: var(--serious); }
.ev.info     { border-left-color: var(--seq); }
.ev-ico { flex: none; }
.ev.critical .ev-ico { color: var(--critical); }
.ev.serious  .ev-ico { color: var(--serious); }
.ev.info     .ev-ico { color: var(--seq); }
.ev-when { flex: none; font-variant-numeric: tabular-nums; }
.ev-what { font-weight: 600; }
.ev .spacer { flex: 1 1 auto; }

/* 자동 조작 패널 */
.panel { margin-top: 12px; }
.panel > p.sub { margin: 0 0 10px; line-height: 1.6; }
.seg { margin-top: 4px; }

.editor { margin-top: 14px; border-top: 1px solid var(--grid); padding-top: 12px; }
.step {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end;
  padding: 8px; border: 1px solid var(--grid); border-radius: 10px; margin-bottom: 8px;
  background: var(--surface-1);
}
.step .step-tag {
  font-size: 12px; color: var(--text-2); background: var(--page);
  border: 1px solid var(--grid); border-radius: 6px; padding: 4px 8px; flex: none; align-self: center;
}
/* label은 기본이 inline이라 내부 block 요소에 레이아웃이 쪼개진다 */
.step label { display: flex; flex-direction: column; gap: 3px; flex: 1 1 90px; min-width: 0; }
.step input {
  background: var(--page); color: var(--text-1); font-family: inherit; font-size: 13px;
  border: 1px solid var(--grid); border-radius: 7px; padding: 6px 8px; width: 100%;
}
.step > button { margin-left: auto; align-self: center; }

/* 관제 교신 녹음 */
.recbar {
  margin-top: 10px; padding: 8px 12px; border-radius: 9px;
  background: color-mix(in srgb, var(--critical) 10%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--critical) 32%, var(--surface-1));
  color: var(--text-1); font-size: 13.5px;
}
.recbar b { font-variant-numeric: tabular-nums; }
.recdone {
  margin-top: 10px; padding: 8px 12px; border-radius: 9px;
  background: color-mix(in srgb, var(--good) 10%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--good) 32%, var(--surface-1));
  font-size: 13.5px;
}

/* 교신 상대 후보 */
.traffic:not(:empty) { margin-top: 6px; border-top: 1px solid var(--grid); padding-top: 4px; }

/* 세그먼트 버튼에 캡션을 붙이는 자리. label을 쓰면 클릭이 첫 버튼으로
   전달되어 선택이 되돌아가므로 label이 아니라 div를 쓴다. */
.field { display: flex; flex-direction: column; gap: 4px; flex: 0 0 auto; }
.field .sub { margin: 0; }

/* 관제 교신 전사 */
.tx { margin-top: 6px; border-top: 1px solid var(--grid); padding-top: 4px; }
.txrow { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--grid); }
.txrow:last-of-type { border-bottom: 0; }
.txt { flex: 0 0 62px; font-variant-numeric: tabular-nums; }
.txen { font-size: 13px; color: var(--text-2); }
.txko { font-size: 14px; color: var(--text-1); font-weight: 600; margin-top: 1px; }

/* ---------------------------------------------------------- 화면 미러링 카드
   기기마다 ws-scrcpy iframe 하나. 타일 아래 모서리를 끌어 개별 크기 조절이
   되도록 resize를 열어 두되, resize는 overflow가 visible이면 먹지 않는다. */
#mirror-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, max-content);
  /* 타일을 칸보다 넓게 끌었을 때 페이지가 깨지지 않도록 여기서 스크롤을 받는다. */
  overflow-x: auto;
  align-items: start;
  /* 타일 폭은 영상 비율이 정한다(폰이 세로로 길어 칸보다 훨씬 좁다).
     그대로 두면 넓은 빈칸 왼쪽에 홀로 붙어 더 작아 보이므로 가운데로 모은다. */
  justify-content: center;
  justify-items: center;
}

.mirror-tile {
  display: flex;
  flex-direction: column;
  /* 가로·세로를 따로 끌어 늘릴 수 있게 둘 다 연다. resize는 overflow가 visible이면
     먹지 않는다. 폭을 직접 지정하면 그리드의 stretch가 풀려(auto가 아니게 되므로)
     칸보다 넓게도 끌 수 있다. 넘친 만큼은 #mirror-grid가 가로 스크롤로 받는다. */
  min-width: 260px;
  min-height: 360px;
  resize: both;
  overflow: hidden;
  border: 1px solid var(--grid);
  border-radius: 10px;
  background: #000;
}

.mirror-tile-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--grid);
}

.mirror-tile-name {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 전체화면일 때는 인라인으로 박힌 폭·높이를 무시하고 화면을 다 쓴다.
   폰이 21.9:9라 창 높이로는 폭이 300px대에 머문다 — 크게 보는 유일한 방법이다. */
.mirror-tile:fullscreen {
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  border-radius: 0;
  border: 0;
}

/* 손가락으로도 눌리는 크기로. 예전 2px 8px는 마우스로도 잘 빗나갔다. */
.mirror-tile-bar button {
  padding: 5px 11px;
  font-size: 14px;
  line-height: 1.2;
}

.mirror-tile iframe {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #000;
}

/* 카드 헤더의 열/높이 컨트롤 */
.mirror-ctl {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  margin-right: 10px;
  white-space: nowrap;
}

.mirror-ctl input[type="range"] { width: 160px; height: 22px; }
.mirror-ctl .select { font-size: 13px; padding: 5px 8px; }
#mirror-card .card-head > button { padding: 6px 12px; font-size: 13px; }

/* 좁은 화면(폰·태블릿 세로)에서는 타일 하나가 폭을 다 쓰고, 머리의 조절기들이
   줄바꿈으로 흩어지지 않게 한 줄씩 내려 놓는다. */
@media (max-width: 760px) {
  #mirror-grid { gap: 10px; }
  /* 폭은 영상 비율이 잡은 값을 그대로 쓰되 화면 밖으로 넘치지만 않게 한다.
     100%로 강제하면 좌우에 검은 여백만 생기고 영상은 그대로다. */
  .mirror-tile { max-width: 100%; min-width: 0; }
  .mirror-ctl { margin-right: 0; }
  .mirror-ctl input[type="range"] { width: 100%; min-width: 140px; }
  #mirror-card .card-head { gap: 8px; }
  .mirror-tile-keys button { padding: 8px 12px; font-size: 13.5px; }
}

/* .card-head는 baseline 정렬이라 슬라이더·셀렉트가 삐뚤어진다. 이 카드만 center로. */
#mirror-card .card-head {
  align-items: center;
  flex-wrap: wrap;
  row-gap: 8px;
}

/* USB 원클릭 설정 — 이 카드의 주 동작이라 눈에 띄게 둔다 */
.usb-setup {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--grid);
  border-radius: 10px;
  background: var(--page);
}
.usb-setup .spacer { flex: 1; }


/* 미러링 단축키 안내 */
.kbd-table { border-collapse: collapse; margin-top: 8px; }
.kbd-table td { padding: 5px 14px 5px 0; vertical-align: top; font-size: 13px; }
.kbd-table td:first-child { white-space: nowrap; }
.kbd-table td:last-child { color: var(--text-2); }
kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--grid);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-1);
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-1);
}

/* 타일별 폰 조작 버튼 줄 (⌨ 토글로 접었다 편다) */
.mirror-tile-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--grid);
}
.mirror-tile-keys button {
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.3;
}
.mirror-tile-keys-toggle.on { color: var(--text-1); border-color: var(--text-2); }

/* 좌표 찍기 대기 중인 버튼 */
.pick-btn.on, .step-pick.on {
  background: #4da3ff;
  border-color: #4da3ff;
  color: #06213d;
}
.step-pick { padding: 3px 8px; font-size: 12px; }

/* 예약 실행 목록 */
.sch-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.sch-table th, .sch-table td { padding: 6px 10px 6px 0; text-align: left; vertical-align: middle; }
.sch-table th { font-size: 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--grid); }
.sch-table td { border-bottom: 1px solid var(--grid); }
.sch-table tr:last-child td { border-bottom: 0; }
.sch-table .nowrap { white-space: nowrap; }
.sch-table button { padding: 2px 8px; font-size: 12px; }

label.chk { display: inline-flex; align-items: center; gap: 4px; margin-right: 8px; }
label.chk input { margin: 0; }
