:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --text: #1f2328;
  --muted: #667085;
  --line: #e4e2dc;
  --accent: #2f6f4f;
  --notice-bg: #e6f0fb;  --notice: #1d5fa8;
  --long-bg: #fdecea;    --long: #b42318;
  --ended-bg: #eeeeee;   --ended: #555555;
  --room-bg: #eef5ef;    --room: #2f6f4f;
}
:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161816;
    --panel: #202320;
    --text: #e8e8e3;
    --muted: #9aa19b;
    --line: #333833;
    --accent: #7cc39b;
    --notice-bg: #1c2b3d;  --notice: #8fbef2;
    --long-bg: #3a1f1c;    --long: #f4a49b;
    --ended-bg: #2c2c2c;   --ended: #b5b5b5;
    --room-bg: #1f2d24;    --room: #9ad3b0;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
    --bg: #161816;
    --panel: #202320;
    --text: #e8e8e3;
    --muted: #9aa19b;
    --line: #333833;
    --accent: #7cc39b;
    --notice-bg: #1c2b3d;  --notice: #8fbef2;
    --long-bg: #3a1f1c;    --long: #f4a49b;
    --ended-bg: #2c2c2c;   --ended: #b5b5b5;
    --room-bg: #1f2d24;    --room: #9ad3b0;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
}
main { max-width: 880px; margin: 0 auto; padding: 0 16px 48px; }

/* 상단 */
.bar {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg);
  padding: 12px 0 8px;
  border-bottom: 1px solid var(--line);
}
h1 { font-size: 20px; margin: 0 0 10px; }
[hidden] { display: none !important; }
input[type=search], select {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
}
input[type=search] { width: 100%; }
.filters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.filters label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; min-width: 0; }
.filters select { width: 100%; }
.summary { color: var(--muted); font-size: 14px; margin: 8px 0 0; }

/* 목록 */
.animals { list-style: none; margin: 8px 0 0; padding: 0; }
.row {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: inherit; text-decoration: none;
}
.row:active { transform: scale(.995); }
.row img, .nophoto {
  width: 64px; height: 64px; flex: none;
  object-fit: cover; border-radius: 10px;
  background: var(--line);
}
.info { flex: 1; min-width: 0; }
.name { font-weight: 600; }
.sub { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }
.mono { font-variant-numeric: tabular-nums; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--room-bg); color: var(--room); }
.badge.notice { background: var(--notice-bg); color: var(--notice); }
.badge.long { background: var(--long-bg); color: var(--long); font-weight: 600; }
.badge.ended { background: var(--ended-bg); color: var(--ended); }
.badge.room { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.days { flex: none; text-align: right; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.days small { font-size: 13px; font-weight: 500; margin-left: 1px; }
.days.long { color: var(--long); }
.more {
  display: block; width: 100%; min-height: 44px;
  font: inherit; color: var(--accent);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}

/* 개체카드 */
.card-bar { padding: 8px 0; }
.back { font: inherit; color: var(--accent); background: none; border: 0; padding: 10px 0; min-height: 44px; cursor: pointer; }
.card { padding-top: 12px; }
.photos { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; }
.photos img, .nophoto.big {
  height: 260px; max-width: 90%; flex: none;
  object-fit: cover; border-radius: 12px; scroll-snap-align: start;
  background: var(--line);
}
.nophoto.big { width: 100%; }
.head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin: 16px 0 8px; }
h2 { margin: 0; font-size: 24px; }
.days.big { font-size: 36px; line-height: 1.1; }
.days.big span { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
section { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px; margin-top: 12px; }
h3 { font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; vertical-align: top; padding: 7px 0; border-top: 1px solid var(--line); }
tr:first-child th, tr:first-child td { border-top: 0; }
th { width: 7.5em; font-weight: 500; color: var(--muted); font-size: 14px; }
td { word-break: keep-all; overflow-wrap: anywhere; }
.foot { color: var(--muted); font-size: 12px; margin-top: 16px; }

/* 상단 탭 */
.tabs { display: flex; max-width: 880px; margin: 0 auto; padding: 0 16px; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs a {
  white-space: nowrap;
  padding: 12px 14px 10px; color: var(--muted); text-decoration: none; font-weight: 600;
  border-bottom: 3px solid transparent;
}
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
a.back { display: inline-block; text-decoration: none; }

/* 버튼 */
.primary, .ghost {
  font: inherit; min-height: 44px; padding: 8px 16px; border-radius: 10px; cursor: pointer;
}
.primary { background: var(--accent); color: var(--bg); border: 0; font-weight: 600; }
.primary:disabled { opacity: .45; cursor: default; }
.ghost { background: none; color: var(--text); border: 1px solid var(--line); }
.wide { width: 100%; margin-top: 10px; }

/* 배치도 */
h2.floor { font-size: 16px; margin: 20px 0 8px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.grid .tile, .grid.wide .tile { padding: 8px 6px; }
.grid.wide { margin-top: 6px; }
.tile { cursor: pointer; }
.tile-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.tile-head a { color: var(--text); text-decoration: none; }
.tile.drop { outline: 3px solid var(--accent); outline-offset: -2px; background: var(--room-bg); }
/* 이름표 = 작은 사진 + 번호 */
.dchips { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 5px; margin-top: 4px; }
.dchip {
  position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 2px;
  font: inherit; color: var(--text); background: var(--bg);
  border: 2px solid var(--line); border-radius: 10px; padding: 2px; cursor: grab; touch-action: manipulation;
}
.dchip img, .dchip .nophoto { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 7px; background: var(--line); }
.dchip .num {
  font-size: 10.5px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.03em;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3;
}
.dchip.on { border-color: var(--accent); background: var(--accent); color: var(--bg); }
.dchip.on::after {
  content: "✓"; position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); color: var(--bg); font-size: 12px; font-weight: 700; line-height: 18px; text-align: center;
}
.dchip.ended { border-style: dashed; opacity: .7; }
.dchip { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.dchip.lifting { opacity: .35; }
.dchip.ghost {
  position: fixed; left: 0; top: 0; z-index: 30; width: 60px; pointer-events: none;
  border-color: var(--accent); box-shadow: 0 10px 24px rgba(0, 0, 0, .35); transform-origin: center;
}
.ghost-n {
  position: absolute; top: -8px; left: -8px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px;
  background: var(--long); color: #fff; font-size: 12px; line-height: 22px; text-align: center;
}
.tile.unplaced .dchips { max-height: 140px; overflow-y: auto; }
.src { font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.socpill { display: inline-block; padding: 1px 10px; border-radius: 999px; color: #fff; font-weight: 700; font-size: 13px; }
.socpill.높음 { background: #1e7a3c; } .socpill.중간 { background: #e8b317; color: #3a2d00; }
.socpill.낮음 { background: #cf3030; } .socpill.관찰 { background: #8a948e; }
.noteform textarea {
  font: inherit; color: var(--text); background: var(--bg); resize: vertical;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.noteform select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
#print-view { max-width: 1100px; }
.tabbadge {
  display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px; vertical-align: 1px;
  border-radius: 9px; background: var(--long); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}
.tile.unplaced { border-color: var(--notice); background: var(--notice-bg); }
.tile.unplaced .hint { margin: 2px 0 0; font-size: 12px; color: var(--notice); }
.tile.unplaced .dchips { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
.dchip .inday { font-size: 10px; text-align: center; color: var(--muted); line-height: 1.2; }
.dchip .inday.iso { color: var(--long); font-weight: 700; }
.dchip.on .inday { color: var(--bg); }
.picksum { font-size: 20px; margin: 4px 0 8px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }

/* 알림 */
.toast {
  position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); z-index: 20;
  display: flex; gap: 12px; align-items: center; max-width: calc(100% - 32px);
  padding: 10px 14px; border-radius: 12px; background: var(--text); color: var(--bg);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .3); font-size: 14px;
}
.toast button { font: inherit; font-weight: 700; color: var(--accent); background: none; border: 0; padding: 6px 4px; cursor: pointer; white-space: nowrap; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast button { color: #2f6f4f; } }
:root[data-theme="dark"] .toast button { color: #2f6f4f; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  padding: 8px; min-height: 72px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  color: inherit; text-decoration: none;
}
.tile b { font-size: 16px; }
.tile .cnt { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.tile.empty { opacity: .7; }
.tile.kind { border-style: dashed; }
.tile.over { border-color: var(--long); }
.tile.unplaced { margin-top: 12px; border-color: var(--notice); background: var(--notice-bg); }
.tile .hint { font-size: 12px; color: var(--notice); }
.dots { display: flex; flex-wrap: wrap; gap: 3px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--muted); }
.dots i.on { background: var(--accent); border-color: var(--accent); }
.dots i.over { background: var(--long); border-color: var(--long); }
.kindtag { font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--ended-bg); color: var(--ended); align-self: flex-start; font-weight: 500; }
.tile .warn { position: absolute; top: 8px; right: 8px; font-size: 11px; color: var(--long); }

/* 방 화면 */
.roomhead { padding: 12px 0 4px; }
.roomhead h2 { display: flex; gap: 8px; align-items: center; }
.roomhead .sub { white-space: normal; }
.overtext { color: var(--long); font-weight: 600; }
.warnbox { background: var(--long-bg); color: var(--long); padding: 8px 12px; border-radius: 10px; font-size: 14px; }
.animals li.checkable { display: flex; align-items: stretch; gap: 6px; }
.animals li.checkable .row { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; padding: 0 6px; margin-bottom: 8px; cursor: pointer; }
.check input { width: 24px; height: 24px; accent-color: var(--accent); }
.sub.extra { color: var(--accent); }

/* 선택 막대 */
.selbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; gap: 8px; align-items: center; justify-content: flex-end;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line);
}
.selbar span { margin-right: auto; font-weight: 600; }
body:has(.selbar:not([hidden])) main { padding-bottom: 90px; }

/* 시트 */
.sheet {
  width: min(560px, 100%); max-height: 90vh; margin: auto auto 0; padding: 16px;
  border: 0; border-radius: 16px 16px 0 0;
  background: var(--panel); color: var(--text);
}
.sheet::backdrop { background: rgba(0, 0, 0, .45); }
.sheet h3 { margin: 0 0 8px; font-size: 18px; color: var(--text); }
.label { font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.roompick { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 5px; }
.pick {
  font: inherit; font-size: 14px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 2px; min-height: 48px; word-break: keep-all;
  display: flex; flex-direction: column; align-items: center; cursor: pointer;
}
.pick small { color: var(--muted); font-size: 12px; }
.pick.full small { color: var(--long); }
.pick.on { border: 2px solid var(--accent); background: var(--room-bg); }
.pick:disabled { opacity: .4; }
.pick.out { grid-column: span 3; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: 14px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; min-height: 36px; cursor: pointer;
}
.chip.on { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.sheet input[type=text], .sheet input[type=search] {
  font: inherit; width: 100%; margin-top: 8px; padding: 10px 12px; min-height: 44px;
  color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
.picklist { list-style: none; margin: 8px 0 0; padding: 0; max-height: 38vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.picklist label { display: flex; gap: 10px; align-items: center; padding: 6px 10px; border-top: 1px solid var(--line); cursor: pointer; }
.picklist li:first-child label { border-top: 0; }
.picklist input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.picklist img, .picklist .nophoto { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex: none; }
.picklist small { color: var(--muted); }
.msg { color: var(--long); min-height: 1em; font-size: 14px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; }
.actions .primary { flex: 1; }

/* 카드: 위치·이력 */
.where { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0 10px; }
.where a { color: var(--accent); }
.history { list-style: none; margin: 0 0 10px; padding: 0; }
.history li { display: flex; flex-wrap: wrap; gap: 2px 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.history span { color: var(--muted); font-size: 14px; }
.history small { width: 100%; color: var(--muted); }

/* 방 화면 버튼 두 개 */
.twobtn { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.btnlink { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.linkbtn { font: inherit; font-size: 14px; color: var(--accent); background: none; border: 0; padding: 6px 0; cursor: pointer; }

/* 관계 기록 */
.loghead { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 0 8px; flex-wrap: wrap; }
.loghead h2 { margin: 0; font-size: 20px; }
.recorder { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.recorder input {
  font: inherit; width: 7em; padding: 6px 8px; min-height: 36px;
  color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button {
  font: inherit; font-weight: 700; font-size: 18px; min-height: 52px;
  color: var(--text); background: var(--panel); border: 0; border-left: 1px solid var(--line); cursor: pointer;
}
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--accent); color: var(--bg); }
#lg-kind button[data-kind="충돌"].on { background: var(--long); color: #fff; }
.seg.small { margin-top: 10px; }
.seg.small button { font-size: 14px; font-weight: 500; min-height: 40px; }
.dogs { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.dog {
  font: inherit; color: var(--text); background: var(--panel);
  border: 2px solid var(--line); border-radius: 12px; padding: 4px; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px; align-items: stretch;
}
.dog img, .dog .nophoto { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.dog span { font-weight: 600; font-size: 15px; text-align: center; }
.dog.on { border-color: var(--accent); background: var(--room-bg); }
#lg-kind:has(.on[data-kind="충돌"]) ~ .dogs .dog.on { border-color: var(--long); background: var(--long-bg); }
#log textarea {
  font: inherit; width: 100%; margin-top: 12px; padding: 10px 12px; resize: vertical;
  color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
}
.okmsg { color: var(--accent); }
#lg-save { position: sticky; bottom: 10px; z-index: 3; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); }
#lg-save:disabled { opacity: 1; background: var(--line); color: var(--muted); }
.recent-h { margin-top: 24px; }
.recent { list-style: none; margin: 0; padding: 0; }
.recent li { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 6px; }
.recent li > div { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.recent p { margin: 4px 0 0; }
.sub.wrap { white-space: normal; }

/* 카드: 사진 올리기 · 우리 기록 */
.photobar { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.upload { display: inline-flex; align-items: center; cursor: pointer; font-size: 14px; }
.photobar .sub { white-space: normal; font-size: 13px; }
.sechead { display: flex; justify-content: space-between; align-items: center; }
.noteform label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); margin: 8px 0; }
.noteform input {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
.noteform .actions { margin-bottom: 10px; }

/* 관계 보기 */
.relhead { padding: 12px 0 4px; }
.relhead h2 { margin: 0 0 8px; font-size: 20px; }
.filters.two { grid-template-columns: 1fr 1fr; }
#rel-tabs { display: flex; flex-wrap: wrap; margin-top: 8px; }
#rel-tabs button { flex: 1 1 30%; border-top: 1px solid var(--line); margin-top: -1px; }
.rank { list-style: none; margin: 6px 0 0; padding: 0; counter-reset: rk; }
.rank li {
  display: flex; gap: 10px; align-items: center; counter-increment: rk;
  padding: 10px 12px; margin-bottom: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.rank li::before { content: counter(rk); color: var(--muted); font-variant-numeric: tabular-nums; min-width: 1.4em; }
.rank li.summary::before { content: ""; }
.rk-main { flex: 1; min-width: 0; }
.rk-main a { color: var(--text); font-weight: 600; }
.rk-main small { display: block; color: var(--muted); font-size: 13px; }
.rk-num { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#rel-list h3 { margin-top: 14px; }

/* 관계 격자 카드 */
:root {
  --g-aff1: #e3f6ee; --g-aff2: #a6e3c9; --g-aff3: #5ccaa0; --g-afftext: #0f4d36;
  --g-conf: #f8c4c8; --g-conftext: #7a1f26;
  --g-hurt: #e5484d; --g-hurttext: #ffffff;
  --g-none: #e9e7e2; --g-nonetext: #9a9a9a;
  --aff3: #3f9257; --risk4: #e0614a;   /* 네트워크 선 */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --g-none: #0a0a0a; --g-nonetext: #6b6b6b; --aff3: #5ccaa0; --risk4: #e5484d; }
}
:root[data-theme="dark"] { --g-none: #0a0a0a; --g-nonetext: #6b6b6b; --aff3: #5ccaa0; --risk4: #e5484d; }
.gridcard { padding: 14px 14px 10px; margin-top: 12px; }
.gc-title { font-size: 20px; color: var(--text); margin: 0 0 8px; }
.gc-title span { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.gc-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.gc-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.gc-legend .aff2 { background: var(--g-aff3); }
.gc-legend .conf { background: var(--g-conf); }
.gc-legend .hurt { background: var(--g-hurt); }
.gc-legend .none { background: var(--g-none); border: 1px solid var(--line); }
.gc-scroll { overflow-x: auto; }
.gc-grid { display: grid; gap: 4px; align-items: stretch; min-width: max-content; }
.gc-col { text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 2px 4px; white-space: nowrap; }
.gc-row {
  display: flex; align-items: center; justify-content: flex-end; padding-right: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap;
}
.gc {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-height: 34px; border-radius: 6px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.gc.self { background: transparent; }
.gc.none { background: var(--g-none); color: var(--g-nonetext); }
.gc.aff1 { background: var(--g-aff1); color: var(--g-afftext); }
.gc.aff2 { background: var(--g-aff2); color: var(--g-afftext); }
.gc.aff3 { background: var(--g-aff3); color: var(--g-afftext); }
.gc.conf { background: var(--g-conf); color: var(--g-conftext); }
.gc.hurt { background: var(--g-hurt); color: var(--g-hurttext); }
.gc-aff {
  position: absolute; top: 2px; right: 3px; font-size: 10px; line-height: 1;
  padding: 1px 3px; border-radius: 4px; background: var(--g-aff3); color: var(--g-afftext);
}
.gc-help { margin: 10px 0 0; font-size: 12px; }
.netwrap { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.net { width: 100%; max-width: 560px; display: block; margin: 0 auto; }
.n-aff { stroke: var(--aff3); stroke-opacity: .8; }
.n-conf { fill: none; stroke: var(--risk4); stroke-opacity: .85; }
.n-arrow { fill: var(--risk4); }
.n-node { fill: var(--bg); stroke: var(--muted); stroke-width: 2; }
.n-node.lead { stroke: var(--long); stroke-width: 3; }
.n-label { font-size: 12px; font-weight: 700; fill: var(--text); }
.n-init { font-size: 11px; font-weight: 700; fill: var(--long); }

/* 합사 점검 */
.riskbox { margin-top: 10px; padding: 8px 12px; border-radius: 10px; background: var(--long-bg); color: var(--long); font-size: 14px; }
.riskbox ul { margin: 4px 0 0; padding-left: 18px; }

@media (max-width: 420px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters label:last-child { grid-column: span 2; }
}

@media print {
  .bar, .back, .more { display: none; }
}

.selbar button { white-space: nowrap; padding: 8px 12px; }
#mapcount { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.syncinfo { font-size: 12px; margin-top: 2px; }

/* 배치도 도구: 개 찾기 · 층 바로가기 · 간단히 보기 */
.maptools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0 8px; }
.mapsearch { flex: 1 1 220px; display: flex; flex-direction: column; gap: 2px; }
.mapsearch input { width: 100%; }
.mapsearch .sub { font-size: 12px; color: var(--accent); white-space: normal; }
.mapbtns { display: flex; gap: 6px; align-items: center; }
.ghost.small { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.maptoggle { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); white-space: nowrap; cursor: pointer; }
.maptoggle input { width: 20px; height: 20px; accent-color: var(--accent); }
h2.floor { scroll-margin-top: 130px; }
.tile-sub { display: flex; gap: 6px; align-items: center; min-height: 0; }
.tile-sub:empty { display: none; }
.tile-log {
  margin-left: auto; font-size: 12px; font-weight: 600; color: var(--accent); text-decoration: none;
  border: 1px solid var(--accent); border-radius: 999px; padding: 3px 9px;
}
.tile.found { outline: 3px solid #f0b400; outline-offset: -2px; }
.dchip.found { border-color: #f0b400; box-shadow: 0 0 0 2px #f0b400; }
#rooms.compact .dchip img, #rooms.compact .dchip .nophoto { display: none; }
#rooms.compact .dchips { grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); }
#rooms.compact .dchip { padding: 6px 2px; }
#rooms.compact .dchip .num { font-size: 12px; }

/* 호출명 */
.noname { font-size: 11px; font-weight: 500; color: var(--muted); border: 1px dashed var(--line); border-radius: 4px; padding: 0 4px; vertical-align: 2px; }
.namehint { display: flex; gap: 8px; align-items: center; margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.namehint[hidden] { display: none !important; }
.namelist { list-style: none; margin: 8px 0; padding: 0; max-height: 62vh; overflow-y: auto; }
.namelist li { display: grid; grid-template-columns: 48px minmax(0, 1fr) minmax(0, 9em) 1.4em; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.namelist img, .namelist .nophoto { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; }
.namelist .nm-info { display: flex; flex-direction: column; min-width: 0; }
.namelist .nm-info small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.namelist input { font: inherit; width: 100%; min-height: 44px; padding: 8px 10px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.nm-state { color: var(--accent); font-weight: 700; }
.queuebar {
  position: sticky; top: 0; z-index: 6; display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap;
  padding: 8px 16px; background: var(--notice-bg); color: var(--notice); font-size: 14px; border-bottom: 1px solid var(--line);
}
.queuebar[hidden] { display: none !important; }

/* 개체 화면 맨 위 현장 정보 */
.field { margin-top: 10px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--panel); }
.fband { display: flex; gap: 10px; align-items: center; padding: 10px 12px; color: #fff; background: #5a6660; }
.fband.높음 { background: #1e7a3c; } .fband.중간 { background: #d99a00; color: #2a1f00; }
.fband.낮음 { background: #c22a2a; } .fband.관찰 { background: #5a6660; }
.fband b { font-size: 20px; white-space: nowrap; }
.fband span { font-size: 14px; font-weight: 600; line-height: 1.3; }
.fedit { margin-left: auto; font: inherit; font-size: 13px; color: inherit; background: rgba(255,255,255,.18); border: 0; border-radius: 999px; padding: 6px 12px; min-height: 36px; cursor: pointer; white-space: nowrap; }
.fhnd { margin: 0; padding: 10px 12px 4px 30px; font-weight: 600; line-height: 1.5; }
.fnone { margin: 0; padding: 10px 12px 4px; color: var(--muted); font-size: 14px; }
.falert { margin: 8px 12px 12px; padding: 8px 10px; border-left: 4px solid #c22a2a; background: var(--long-bg); color: var(--long); font-weight: 700; border-radius: 4px; }
.falert.ok { border-left-color: #1e7a3c; background: var(--room-bg); color: var(--room); font-weight: 600; }
button.noname { font: inherit; font-size: 12px; cursor: pointer; background: none; color: var(--accent); border-color: var(--accent); padding: 2px 8px; vertical-align: 4px; }
.kawisbox { margin-top: 12px; }
.kawisbox summary { cursor: pointer; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; color: var(--muted); font-weight: 600; list-style-position: inside; }
.kawisbox[open] summary { border-radius: 12px 12px 0 0; }
#sheet-ok.warn { background: var(--long); color: #fff; }
.riskbox li { margin-bottom: 3px; }
#sheet-ok.warn { background: var(--long); color: #fff; }
.riskbox li { margin-bottom: 3px; }

/* PC: 넓은 화면을 쓴다 (폰은 그대로) */
@media (min-width: 1000px) {
  main, .tabs { max-width: 1240px; }
  .animals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .animals .row { margin-bottom: 0; height: 100%; }
  .animals li.summary { grid-column: 1 / -1; }
  .filters { grid-template-columns: repeat(3, minmax(0, 220px)); }
  .relcols { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
  .relcols:has(> .relcol:only-child) { grid-template-columns: minmax(0, 1fr); }
  .relcols .gridcard { margin-top: 8px; }
  .card { max-width: 860px; margin: 0 auto; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
@media (min-width: 1500px) {
  main, .tabs { max-width: 1480px; }
  .animals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.bar.maptools { position: static; border-bottom: 0; }
.namelist li { grid-template-columns: 48px minmax(0, 1fr) minmax(0, 8em) 1.2em; }
.namelist .nm-info b { white-space: nowrap; }

/* 이름표 번호가 잘리지 않게: 말줄임 대신 줄바꿈, 연도는 작게 */
.dchips { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); }
.dchip .num { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; word-break: keep-all; font-size: 12px; line-height: 1.15; padding: 1px 0; }
.dchip .num small { font-size: 9px; font-weight: 600; opacity: .75; }
#rooms.compact .dchip .num { font-size: 13px; }

/* 의견 보내기 */
.fbbtn {
  position: fixed; right: 14px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 4;
  font: inherit; font-size: 13px; font-weight: 700; color: var(--bg); background: var(--accent);
  border: 0; border-radius: 999px; padding: 10px 14px; min-height: 40px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
}
body:has(.selbar:not([hidden])) .fbbtn, body:has(#print-view:not([hidden])) .fbbtn { display: none; }
.sheet textarea, #fb-msg {
  font: inherit; width: 100%; margin-top: 8px; padding: 10px 12px; resize: vertical;
  color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
#fb-who { font: inherit; width: 100%; margin-top: 8px; padding: 10px 12px; min-height: 44px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
@media print { .fbbtn { display: none !important; } }

/* ☰ 메뉴 (의견 보내기 · 화면 밝기) — 떠 있던 [의견] 버튼이 저장·옮기기 버튼을 가려서 탭 줄로 옮김 */
.tabs { align-items: center; }
.menubtn {
  margin-left: auto; flex: none; font: inherit; font-size: 20px; line-height: 1; color: var(--text);
  background: none; border: 1px solid var(--line); border-radius: 10px; width: 40px; height: 40px; cursor: pointer;
}
@media (max-width: 420px) { .tabs { padding: 0 8px; gap: 0; } .tabs a { padding: 12px 9px 10px; } }
#mn-theme { margin-top: 2px; }

/* 카드 다시 뽑기 상태 */
.cardstate { margin: 2px 0 8px; font-size: 13px; color: var(--muted); }
.cardstate.todo { color: var(--notice); }

/* 작은 버튼 키우기 (장갑·젖은 손) */
.linkbtn { min-height: 44px; padding: 10px 8px; font-size: 15px; font-weight: 600; }
.recent .linkbtn { margin-top: 2px; }
.tile-log { padding: 6px 12px; font-size: 13px; }
.ghost.small { min-height: 42px; }
button.noname { padding: 6px 10px; font-size: 13px; }
.chip { min-height: 42px; padding: 8px 14px; }
.check input { width: 28px; height: 28px; }
