/* ===== 색상 변수 ===== */
:root {
  --bg: #f3f5f8;
  --text: #1c2430;
  --panel: #ffffff;
  --border: #d5dbe3;
  --border-light: #e7ebf0;
  --muted: #7a8594;
  --label: #4a5563;
  --input-bg: #f7f9fb;
  --shadow: rgba(16, 24, 40, 0.06);

  --accent: #1f7fc9;
  --accent-hover: #186aa8;
  --accent-soft: #e3f0fa;

  --notice-bg: #e8f2fb;
  --notice-border: #cfe2f4;
  --notice-text: #23578a;

  --subtle-bg: #eef1f5;
  --subtle-hover: #e2e7ed;

  --success: #2e9e5b;
  --error: #e5484d;
  --error-bg: #fdecec;
}

body.dark {
  color-scheme: dark;

  --bg: #0d1218;
  --text: #e6eaef;
  --panel: #131a22;
  --border: #2a3542;
  --border-light: #222c37;
  --muted: #aeb9c6;
  --label: #b4bfcc;
  --input-bg: #0f161d;
  --shadow: rgba(0, 0, 0, 0.35);

  --accent: #4cc3ff;
  --accent-hover: #7dd5ff;
  --accent-soft: rgba(76, 195, 255, 0.14);

  --notice-bg: #142333;
  --notice-border: #1f3850;
  --notice-text: #a6cbec;

  --subtle-bg: rgba(255, 255, 255, 0.06);
  --subtle-hover: rgba(255, 255, 255, 0.1);

  --success: #4cc27e;
  --error: #ff6b6b;
  --error-bg: #3a2426;
}

/* ===== 기본 ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans KR", "Segoe UI", "Malgun Gothic", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background-color: var(--bg);
  color: var(--text);
  transition: background-color 0.25s, color 0.25s;
}

button {
  font: inherit;
}

/* ===== 왼쪽 아이콘 레일 (목업: 64px 폭, 위에서 아래로 로고 · 예측 · 기록 / 아래쪽에 상태·테마·계정) ===== */
#rail {
  position: fixed;
  z-index: 100;
  left: 16px;
  top: 16px;
  bottom: 16px;
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  backdrop-filter: blur(10px);
}
.brand-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; margin: 8px 0 14px; }
.rail-logo { color: var(--accent); }
.rail-spacer { flex: 1; }

/* 예측 / 기록 화면 전환 (data-view 로 JS 가 .active 를 켠다) */
#rail .view-tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 52px;
  padding: 6px 0;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 12px;
  transition: background-color 0.2s, color 0.2s;
}
#rail .view-tab:hover { color: var(--text); background-color: var(--subtle-hover); }
#rail .view-tab.active { color: var(--accent); font-weight: 700; background-color: var(--accent-soft); }
.tab-count {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 17px;
  padding: 0 4px;
  font-size: 10px;
  line-height: 17px;
  text-align: center;
  color: var(--on-accent);
  background-color: var(--accent);
  border-radius: 999px;
}
.tab-count:empty { display: none; }

/* 서버 상태: 글자는 접근성용으로 남기고 화면에는 점 하나만 (마우스를 올리면 모델·장치 정보) */
.model-status {
  width: 10px;
  height: 10px;
  margin: 6px 0;
  padding: 0;
  font-size: 0;
  background-color: var(--muted);
  border: 0;
  border-radius: 50%;
}
.model-status::before { display: none; }
.model-status.ok { background-color: var(--success); }
.model-status.down { background-color: var(--error); }

.btn-theme {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 18px;
  color: var(--muted);
  background-color: transparent;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}
.btn-theme:hover { color: var(--text); background-color: var(--subtle-hover); }
body.dark .icon-sun { display: none; }
body:not(.dark) .icon-moon { display: none; }

.account { position: relative; margin-bottom: 4px; }
.account-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  background-color: var(--subtle-bg);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.account-btn:hover { background-color: var(--subtle-hover); }
.account-pop {
  position: absolute;
  left: calc(100% + 14px);
  bottom: 0;
  min-width: 240px;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background-color: var(--panel);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}
.account-pop .action-group { flex-wrap: wrap; }
#user-email { font-size: 13px; color: var(--label); word-break: break-all; }

.action-group { display: flex; align-items: center; gap: 8px; }

/* 화면 제목 (분석 기록 화면) */
.view-head h1 { margin: 8px 0 4px; font-size: 18px; font-weight: 600; }
.view-head p { margin: 0; font-size: 13px; color: var(--muted); }

/* 공통 버튼 */
.btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.btn-ghost {
  background-color: transparent;
  color: var(--label);
  border-color: var(--border);
}

.btn-ghost:hover {
  background-color: var(--subtle-bg);
}

.btn-primary {
  background-color: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: progress;
}

.btn-theme {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 16px;
  background-color: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.btn-theme:hover {
  background-color: var(--subtle-bg);
}

/* 닫기(×) 버튼: 모달 공통 */
.notice-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--notice-text);
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.6;
}

.notice-close:hover {
  opacity: 1;
}

/* ===== 레이아웃 ===== */
.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 32px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background-color: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  box-shadow: 0 1px 2px var(--shadow);
  transition: background-color 0.25s, border-color 0.25s;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background-color: var(--accent-soft);
  border-radius: 6px;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--label);
}

.form-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.form-hint:empty {
  display: none;
}

/* ===== 1. 입력 방식 ===== */
.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background-color: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.segmented label {
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: block;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--label);
  border-radius: 6px;
  transition: background-color 0.2s, color 0.2s;
}

.segmented input:checked + span {
  background-color: var(--accent);
  color: var(--on-accent);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dropzone {
  position: relative;
  margin-top: 16px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 24px;
  background-color: var(--input-bg);
  transition: border-color 0.2s, background-color 0.2s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background-color: var(--accent-soft);
}

.dropzone.input-error {
  border-color: var(--error);
  background-color: var(--error-bg);
}

.dropzone-label {
  display: block;
  text-align: center;
  cursor: pointer;
}

.dropzone-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 88px;
}

/* 파일을 올린 뒤: 테두리만 실선으로. 높이는 안내 문구일 때와 같게 유지 */
.dropzone.has-file {
  border-style: solid;
}

/* 썸네일 + 파일 정보를 한 줄로 (안내 문구와 같은 높이 88px) */
.dropzone-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: 88px;
}

.dropzone-preview img {
  display: block;
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 2px 8px var(--shadow);
}

.dropzone-fileicon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 88px;
  color: var(--accent);
  background-color: var(--accent-soft);
  border-radius: 6px;
}

.dropzone-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  text-align: left;
}

.dropzone-change {
  font-size: 12px;
  color: var(--muted);
}

.dropzone-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  color: var(--label);
  background-color: var(--panel);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.dropzone-remove:hover {
  color: var(--error);
  border-color: var(--error);
}

.dropzone-icon {
  color: var(--muted);
  margin-bottom: 4px;
}

.dropzone-text {
  font-size: 14px;
  color: var(--text);
}

.dropzone-hint {
  font-size: 12px;
  color: var(--muted);
}

#dropzone-filename {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}

/* ===== 2. 조건 ===== */
.cond-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}

.num-input {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.num-input input {
  width: 72px;
  padding: 6px 8px;
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  color: var(--text);
  background-color: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.num-input input:focus {
  outline: none;
  border-color: var(--accent);
}

.num-input input.wide {
  width: 120px;
}

input.input-error {
  border-color: var(--error) !important;
  background-color: var(--error-bg) !important;
}

input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#dx-block {
  margin-top: 24px;
}

/* ===== 입력 검증 ===== */
.field-error {
  display: none;
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--error);
}

.field-error.visible {
  display: block;
}

/* ===== 실행 바 ===== */
.run-bar {
  display: flex;
  align-items: center;
  gap: 16px;
}

.run-bar .btn-primary {
  padding: 12px 24px;
  font-size: 14px;
}

.run-summary {
  font-size: 13px;
  color: var(--muted);
}

/* ===== 3. 결과 ===== */
.viewer-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 16px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.viewer-empty-icon {
  color: var(--muted);
  opacity: 0.55;
}

.viewer-empty-title {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.viewer-empty-sub {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  opacity: 0.75;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.result-card {
  margin: 0;
  padding: 12px;
  background-color: var(--input-bg);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-card figcaption {
  font-size: 13px;
  font-weight: 600;
  color: var(--label);
}

.result-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background-color: white;
  border-radius: 6px;
}

/* 배수구 후보 표시: 비율 좌표가 그림과 정확히 맞도록 틀을 그림 크기에 맞춘다 */
.result-image {
  position: relative;
}

.result-image img {
  display: block;
  aspect-ratio: auto;
}

.drain-marker {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid #e5534b;
  border-radius: 50%;
  background-color: rgba(229, 83, 75, 0.25);
  box-shadow: 0 0 0 2px #fff;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.result-card a {
  align-self: flex-start;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}

.result-card a:hover {
  text-decoration: underline;
}

.result-info {
  margin: 16px 0 0;
  padding-left: 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--label);
}

.result-info li:first-child {
  font-weight: 600;
  color: var(--text);
}

/* ===== 분석 기록 패널 ===== */
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.history-header .card-title {
  margin: 0;
}

.btn-clear {
  padding: 6px 12px;
  font-size: 12px;
  background-color: var(--subtle-bg);
  color: var(--label);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.btn-clear:hover {
  background-color: var(--subtle-hover);
}

/* 로그인 전 안내 (가운데) */
.history-locked {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 16px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.history-locked-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.history-locked-sub {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.history-locked-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.history-tip {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
}

/* 기록 표 */
.history-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: 8px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.history-table th {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  color: var(--muted);
  background-color: var(--input-bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.history-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.history-table tr:last-child td {
  border-bottom: none;
}

.date-row td {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--label);
  background-color: var(--subtle-bg);
}

.date-row span {
  margin-left: 8px;
  font-weight: 400;
  color: var(--muted);
}

.history-row {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
}

.history-row:hover {
  background-color: var(--accent-soft);
}

.name-cell {
  min-width: 180px;
  white-space: nowrap;
}

.record-name {
  font-weight: 600;
  color: var(--text);
}

.icon-btn {
  margin-left: 4px;
  padding: 0 4px;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
}

.history-row:hover .icon-btn,
.icon-btn:focus-visible {
  opacity: 1;
}

.icon-btn:hover {
  color: var(--accent);
}

.rename-input {
  width: 100%;
  min-width: 160px;
  padding: 4px 8px;
  font-size: 13px;
  color: var(--text);
  background-color: var(--input-bg);
  border: 1px solid var(--accent);
  border-radius: 6px;
  outline: none;
  user-select: text;
}

.muted-cell {
  color: var(--muted);
  white-space: nowrap;
}

.file-cell {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.history-buttons button {
  padding: 4px 12px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background-color: var(--panel);
  color: var(--label);
  cursor: pointer;
}

.history-buttons button:hover {
  background-color: var(--subtle-bg);
}

.history-empty {
  padding: 24px 0 !important;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* 기록 상세 모달 */
.detail-card {
  width: 640px;
  max-width: calc(100% - 32px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 24px;
  background-color: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.detail-head h3 {
  margin: 0;
  font-size: 18px;
}

.detail-body {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  align-items: start;
}

.detail-body.no-img {
  grid-template-columns: 1fr;
}

.detail-body img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background-color: white;
  border-radius: 6px;
}

.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  margin: 0;
  font-size: 13px;
}

.detail-list dt {
  color: var(--muted);
  white-space: nowrap;
}

.detail-list dd {
  margin: 0;
  color: var(--text);
  word-break: break-all;
}

.detail-card .auth-modal-actions {
  margin-top: 16px;
}

@media (max-width: 600px) {
  .detail-body { grid-template-columns: 1fr; }
}

/* ===== 로그인 / 회원가입 모달 ===== */
.auth-modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.auth-modal-card {
  background-color: var(--panel);
  width: 340px;
  max-width: calc(100% - 32px);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.auth-modal-card h3 {
  margin: 0 0 16px;
  font-size: 18px;
  color: var(--text);
}

.auth-modal-card input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 12px;
  background-color: var(--input-bg);
  color: var(--text);
}

.auth-modal-card input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.auth-modal-actions button {
  flex: 1;
  padding: 10px;
  font-size: 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-confirm {
  background-color: var(--accent);
  color: var(--on-accent);
}

.btn-confirm:hover {
  background-color: var(--accent-hover);
}

.btn-cancel {
  background-color: var(--subtle-bg);
  color: var(--label);
}

.btn-cancel:hover {
  background-color: var(--subtle-hover);
}

#auth-message {
  margin: 12px 0 0;
  font-size: 13px;
  min-height: 16px;
}

#auth-message.error { color: var(--error); }
#auth-message.success { color: var(--success); }

/* ===== 반응형 ===== */
@media (max-width: 860px) {
  .card { padding: 16px; }
  .cond-grid { grid-template-columns: 1fr; }
  .run-bar { flex-direction: column; align-items: stretch; }
}

/* ===== 지도 우선 화면 (C안, 목업 수치 그대로) =====
   지도가 화면 전체를 채우고(cover) 왼쪽·아래에 어두운 그라데이션을 깐다. 그 위에
   조건 패널(왼쪽) · 요약 칩 + 기록 서랍(오른쪽) · 시간 슬라이더(아래)가 떠 있다.
   1000px 이하(모바일)는 레일이 상단바가 되고 지도 → 칩 → 시간 → 조건 → 기록 순으로 쌓는다. */
:root {
  --glass: rgba(255, 255, 255, 0.94);
  --glass-border: rgba(16, 24, 40, 0.12);
  --scrim: 243, 245, 248;
  --on-accent: #ffffff;
}
body.dark {
  --glass: rgba(13, 18, 24, 0.9);
  --glass-border: rgba(255, 255, 255, 0.12);
  --scrim: 13, 18, 24;
  --on-accent: #06202e;
}

.stage {
  position: relative;
  z-index: 1;
  height: 100vh;
  min-height: 640px;
  overflow: hidden;
}

.stage-map {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  container-type: size;
  cursor: grab;
  user-select: none;
  touch-action: pan-y;   /* 세로 스크롤은 페이지에 넘기고, 가로 드래그·핀치는 지도가 받는다 */
}
.stage-map.zoomed { touch-action: none; }   /* 확대한 뒤에는 손가락 이동이 곧 지도 이동 */
.stage-map.dragging { cursor: grabbing; }
.stage-map .stage-empty { cursor: default; }

/* 지도(정사각)를 화면의 긴 변에 맞춰 꽉 채운다. 짧은 변 쪽은 가운데를 기준으로 잘린다 */
.stage-square {
  --side: max(100cqw, 100cqh);
  position: relative;
  flex: none;
  width: var(--side);
  height: var(--side);
  background: #fff;
  /* 보이는 창을 --cx/--cy(0~1, 지도 좌표)가 가운데 오도록 옮긴다. JS 가 배수구 후보에 맞춰 정한다 */
  transform: translate(calc((0.5 - var(--cx, 0.5)) * var(--side)), calc((0.5 - var(--cy, 0.5)) * var(--side)))
             translate(var(--tx, 0px), var(--ty, 0px)) scale(var(--zoom, 1));
}
/* 전체 보기: 잘리지 않게 짧은 변에 맞추고, 뒤는 같은 그림을 흐리게 깐다 */
.stage-map.fit .stage-square {
  --side: min(100cqw, 100cqh);
  transform: translate(var(--tx, 0px), var(--ty, 0px)) scale(var(--zoom, 1));
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.35);
}
.stage-bg {
  position: absolute;
  inset: -30px;
  width: calc(100% + 60px);
  height: calc(100% + 60px);
  object-fit: cover;
  filter: blur(26px) brightness(0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
body:not(.dark) .stage-bg { filter: blur(26px) brightness(0.9); }
.stage-map.fit .stage-bg,
.stage-map.zoomed-out .stage-bg { opacity: 1; }
.stage-map.zoomed-out .stage-scrim { opacity: 0.55; }

.stage-square > img,
.stage-square > canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.stage-map.fit .stage-square > img,
.stage-map.fit .stage-square > canvas { border-radius: 14px; }

/* 패널 글씨가 잘 읽히도록 왼쪽 · 아래를 어둡게 (목업의 그라데이션 2장) */
.stage-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(0deg, rgba(var(--scrim), 0.7), rgba(var(--scrim), 0) 220px),
    linear-gradient(90deg, rgba(var(--scrim), 0.72) 0%, rgba(var(--scrim), 0) 34%, rgba(var(--scrim), 0) 70%, rgba(var(--scrim), 0.6) 100%);
}
.stage-map.fit .stage-scrim { opacity: 0.55; }
.stage-square[style*="none"] ~ .stage-scrim { display: none; }   /* 결과 없을 땐 그라데이션 없음 */

.stage-empty {
  position: relative;
  margin-left: 440px;   /* 왼쪽 레일·조건 패널을 피해 남는 공간의 가운데에 놓는다 */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 420px;
  padding: 32px;
  text-align: center;
  background: var(--glass);
  border: 1px dashed var(--border);
  border-radius: 18px;
}

/* 배수구 후보: 지도 위 빨간 원 + 라벨 카드 (목업 그대로) */
.stage-square .drain-marker {
  width: 26px;
  height: 26px;
  border: 3px solid #ff5a5f;
  background: transparent;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9), 0 0 24px rgba(255, 90, 95, 0.6);
  transform: translate(-50%, -50%) scale(calc(1 / var(--zoom, 1)));
}
.marker-label {
  --inv: calc(1 / var(--zoom, 1));   /* 지도가 --zoom 배 커져도 라벨은 같은 크기로 */
  position: absolute;
  transform-origin: 0 0;
  transform: translate(calc(26px * var(--inv)), calc(-30px * var(--inv))) scale(var(--inv));
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  white-space: nowrap;
  pointer-events: none;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
}
.marker-label b { font-size: 13px; color: #ff8a8e; }
body:not(.dark) .marker-label b { color: #b42328; }
.marker-label span { font-size: 12px; color: var(--muted); }
.marker-label.left { transform: translate(calc((-100% - 26px) * var(--inv)), calc(-30px * var(--inv))) scale(var(--inv)); }
.marker-label.below { transform: translate(calc(26px * var(--inv)), calc(-4px * var(--inv))) scale(var(--inv)); }
.marker-label.left.below { transform: translate(calc((-100% - 26px) * var(--inv)), calc(-4px * var(--inv))) scale(var(--inv)); }

.stage-fit,
.stage-toggle {
  position: absolute;
  z-index: 4;
  bottom: 118px;   /* 아래 시간 슬라이더 바로 위 */
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
}
.stage-toggle { left: 0; bottom: calc(100% + 10px); display: flex; gap: 2px; padding: 4px; }   /* 시간 슬라이더(.timeline) 기준 */
.stage-toggle button {
  min-height: 36px;
  padding: 0 14px;
  color: var(--label);
  font-weight: 600;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.stage-toggle button.on { color: var(--on-accent); background-color: var(--accent); }
.stage-fit {
  right: 16px;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.stage-fit:hover { background-color: var(--accent-soft); }
.stage-zoom {
  position: absolute;
  z-index: 4;
  right: 16px;
  bottom: 170px;
  flex-direction: column;
  overflow: hidden;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
}
.stage-zoom button {
  width: 52px;
  height: 44px;
  padding: 0;
  color: var(--text);
  font: inherit;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.stage-zoom button + button { border-top: 1px solid var(--glass-border); }
.stage-zoom button:hover:not(:disabled) { background-color: var(--accent-soft); }
.stage-zoom button:disabled { opacity: 0.35; cursor: default; }
.stage-zoom #zoom-reset { font-size: 12px; font-weight: 700; }

/* --- 조건 패널 (목업: 왼쪽 96px, 위 16px, 폭 340px) --- */
.panel {
  position: absolute;
  z-index: 5;
  left: 96px;
  top: 16px;
  width: 340px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  padding: 16px 18px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(10px);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h1 { margin: 0; font-size: 16px; font-weight: 700; }
.panel-fold {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: -8px -10px -8px 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.panel-fold:hover { color: var(--text); }

.panel .segmented { display: flex; width: 100%; padding: 3px; }
.panel .segmented label { flex: 1; }
.panel .segmented span { padding: 7px 6px; text-align: center; font-size: 13px; }
/* 목업의 패널은 설명 문구 없이 컨트롤만. 입력 방식·강우·시간 안내는 숨기고(고급 설정 안 설명만 남김), 오류는 그대로 보인다 */
.panel > form .form-hint { display: none; }
.panel .adv-body .form-hint { display: block; margin: 8px 0 0; }

/* 파일: 없으면 올리기 영역, 있으면 목업의 '파일 칩' */
.panel .dropzone { margin-top: 12px; padding: 12px; }
.panel .dropzone-empty { height: 76px; }
.dropzone.has-file {
  padding: 8px;
  background-color: var(--subtle-bg);
  border: 0;
  border-radius: 12px;
}
.dropzone.has-file:hover { background-color: var(--subtle-hover); }
.dropzone-preview { display: flex; align-items: center; justify-content: flex-start; gap: 10px; height: auto; text-align: left; }
.panel .dropzone-preview img,
.panel .dropzone-fileicon { flex: none; width: 44px; height: 44px; border-radius: 8px; box-shadow: none; }
.panel .dropzone-info { flex: 1; min-width: 0; }
.panel #dropzone-filename { display: block; overflow: hidden; font-size: 13px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.dropzone-status { display: block; font-size: 11px; color: var(--muted); }
.dropzone-status.ok { color: var(--success); }
.panel .dropzone-change { flex: none; padding: 10px 4px; font-size: 13px; color: var(--accent); }
.panel .dropzone-remove { top: -9px; right: -9px; width: 22px; height: 22px; font-size: 14px; }

.panel-row { margin-top: 16px; }
.panel-row-head { display: flex; align-items: baseline; justify-content: space-between; }
.panel-row .field-label { margin: 0; font-size: 13px; font-weight: 400; color: var(--muted); }
.panel .num-input { gap: 3px; font-size: 12px; }
.panel .num-input input {
  width: 48px;
  padding: 2px 4px;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background-color: transparent;
  border-color: transparent;
}
.panel .num-input input:hover { border-color: var(--border); }
.panel .num-input input:focus { background-color: var(--input-bg); border-color: var(--accent); }
.panel .num-input input.wide { width: 110px; border-color: var(--border); }
.panel input[type="range"] { display: block; width: 100%; margin: 6px 0 0; accent-color: var(--accent); cursor: pointer; }

.rain-presets { display: flex; gap: 8px; margin-top: 10px; }
.rain-presets button {
  flex: 1;
  min-height: 44px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}
.rain-presets button:hover { background-color: var(--subtle-bg); }
.rain-presets button.on {
  color: var(--accent);
  font-weight: 700;
  background-color: var(--accent-soft);
  border: 2px solid var(--accent);
}

.panel-adv { margin-top: 16px; border: 1px solid var(--border-light); border-radius: 12px; }
.panel-adv summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 46px;
  padding: 0 14px;
  list-style: none;
  cursor: pointer;
}
.panel-adv summary::-webkit-details-marker { display: none; }
.panel-adv summary span { font-size: 12px; color: var(--muted); }
.adv-body { display: flex; flex-direction: column; gap: 14px; padding: 0 14px 14px; }
.adv-body #dx-block { margin-top: 0; }
.panel select,
.check-card select {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  color: var(--text);
  font: inherit;
  background-color: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.panel .adv-body .field-label { font-size: 13px; font-weight: 400; color: var(--muted); }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--accent); }

.panel .run-bar { display: block; margin-top: 16px; }
.panel .run-bar .btn-primary {
  width: 100%;
  height: 46px;
  padding: 0;
  font-size: 15px;
  font-weight: 700;
  border-radius: 12px;
}
.panel .run-summary { display: none; }

.panel-pill {
  position: absolute;
  z-index: 5;
  left: 96px;
  top: 16px;
  height: 56px;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  color: var(--text);
  font: inherit;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  cursor: pointer;
}
.panel-pill svg { color: var(--accent); }
.panel-pill span { color: var(--muted); font-variant-numeric: tabular-nums; }

/* --- 요약 칩 + 도구 버튼 (목업: 오른쪽 위) --- */
.chips {
  position: absolute;
  z-index: 5;
  top: 16px;
  right: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  max-width: 600px;
}
.chip {
  flex-direction: column;
  padding: 8px 14px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
}
.chip-label { font-size: 11px; color: var(--muted); }
.chip-value { font-size: 12px; color: var(--muted); }
.chip-value b { margin-right: 2px; font-size: 20px; color: var(--text); font-variant-numeric: tabular-nums; }
.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 16px;
  color: var(--text);
  font: inherit;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  cursor: pointer;
}
.chip-btn:hover { background-color: var(--accent-soft); }
.chip-btn[aria-pressed="true"] { border-color: var(--accent); }

/* --- 기록 서랍 (목업: 오른쪽 20px, 위 96px, 폭 300px) --- */
.drawer {
  position: absolute;
  z-index: 5;
  right: 20px;
  top: 96px;
  width: 300px;
  max-height: calc(100% - 210px);
  overflow-y: auto;
  padding: 14px 14px 10px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.drawer-head h2 { margin: 0; font-size: 14px; }
.drawer-head a { padding: 10px 2px; font-size: 12px; color: var(--accent); text-decoration: none; }
.drawer-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.drawer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px;
  color: var(--text);
  font: inherit;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
}
.drawer-item:hover { background-color: var(--subtle-bg); }
.drawer-item.active {
  background-color: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.drawer-item img,
.drawer-noimg { flex: none; width: 52px; height: 52px; object-fit: cover; background: var(--border-light); border-radius: 8px; }
.drawer-text { display: flex; flex-direction: column; min-width: 0; }
.drawer-name { overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.drawer-sub { overflow: hidden; font-size: 12px; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.drawer-empty { padding: 14px 6px; font-size: 13px; color: var(--muted); text-align: center; }
.drawer-empty .btn { margin-top: 10px; }

/* --- 시간 슬라이더 (목업: 아래 가운데, 폭 760px, 원형 재생 버튼) --- */
.timeline {
  position: absolute;
  z-index: 5;
  left: 452px;
  right: 20px;
  bottom: 24px;
  max-width: 780px;
  margin: 0 auto;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
}
.tl-play {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  color: var(--on-accent);
  background-color: var(--accent);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.tl-play:disabled { opacity: 0.45; cursor: not-allowed; }
.tl-main { flex: 1; min-width: 0; }
.tl-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 2px; }
.tl-label { font-size: 13px; color: var(--muted); }
.tl-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.timeline input[type="range"] { display: block; width: 100%; margin: 0; accent-color: var(--accent); }
.tl-scale { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-scale + .tl-progress { margin-top: 8px; }
/* 시점별 예측 진행: 잘 보이게 크게 + 진행 막대 */
.tl-progress { align-items: center; gap: 10px; font-size: 14px; font-weight: 700; color: var(--text); }
.tl-progress .spinner { flex: none; width: 16px; height: 16px; border-width: 2.5px; }
.timelapse-status { flex: none; font-variant-numeric: tabular-nums; }
.tl-progress-bar { flex: 1; height: 6px; overflow: hidden; background-color: var(--subtle-hover); border-radius: 3px; }
.tl-progress-bar i { display: block; width: 0; height: 100%; background-color: var(--accent); border-radius: 3px; transition: width 0.25s; }
.tl-progress.error { font-weight: 400; color: var(--error); }
.tl-progress.error .spinner,
.tl-progress.error .tl-progress-bar { display: none; }
.tl-legend { flex: 0 0 150px; }
.tl-legend-bar { height: 8px; background: linear-gradient(to right, #0b3a73, #1f6fb5, #8bbbe0, #f0f6fc); border-radius: 4px; }
.tl-legend-labels { display: flex; justify-content: space-between; margin-top: 3px; font-size: 11px; color: var(--muted); }

/* --- 알림(토스트) --- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 3000;
  max-width: min(520px, calc(100% - 32px));
  padding: 12px 18px;
  color: #fff;
  font-size: 13px;
  background: #1f2933;
  border-radius: 10px;
  opacity: 0;
  transform: translate(-50%, 20px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --- 결과 이미지 / 입력 확인 / 읽을 수 없는 이미지 창 (목업: 어두운 카드, 둥근 22px) --- */
.gallery-card,
.check-card,
.unr-card {
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 28px 30px;
  background-color: var(--panel);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}
.gallery-card { width: min(1040px, calc(100% - 32px)); }
.check-card { width: min(940px, calc(100% - 32px)); }
.unr-card { width: min(900px, calc(100% - 32px)); border-left: 6px solid #e8a33d; }

.check-card h3,
.unr-card h3 { margin: 0 0 6px; font-size: 22px; }
.chk-sub { margin: 0 0 20px; color: var(--muted); }
.chk-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.chk-flow figure { flex: 1 1 220px; min-width: 0; margin: 0; }
.chk-flow img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #fff; border: 1px solid var(--glass-border); border-radius: 12px; }
.chk-flow img.chk-hl { border: 2px solid var(--accent); }
.chk-flow figcaption { display: flex; flex-direction: column; margin-top: 8px; font-size: 13px; color: var(--muted); }
.chk-flow figcaption b { color: var(--text); }
.chk-arrow { flex: none; color: var(--muted); }
.chk-legend-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 20px; font-size: 13px; color: var(--muted); }
.chk-legend { width: 220px; height: 12px; border-radius: 6px; }
.chk-dir { display: flex; flex-wrap: wrap; gap: 12px; margin: 20px 0 0; padding: 0; border: 0; }
.chk-dir legend { margin-bottom: 10px; padding: 0; font-weight: 700; }
.chk-opt { flex: 1 1 300px; display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border: 2px solid var(--glass-border); border-radius: 14px; cursor: pointer; }
.chk-opt:has(input:checked) { background-color: var(--accent-soft); border-color: var(--accent); }
.chk-opt input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--accent); }
.chk-opt small { display: block; font-size: 13px; color: var(--muted); }
.chk-scheme { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-size: 13px; color: var(--label); }
.chk-scheme select { width: auto; min-width: 240px; }
.chk-warn { margin: 12px 0 0; padding-left: 18px; font-size: 12px; color: var(--muted); }
.chk-warn:empty { display: none; }
#check-modal.busy .check-card { opacity: 0.65; pointer-events: none; }
.check-card .auth-modal-actions { margin-top: 20px; }
.check-card .auth-modal-actions button { height: 48px; border-radius: 12px; font-weight: 700; }
.check-card .auth-modal-actions button:disabled { opacity: 0.5; cursor: progress; }

.unr-top { display: flex; flex-wrap: wrap; gap: 22px; }
.unr-top img { flex: 0 0 190px; width: 190px; height: 190px; object-fit: cover; border: 1px solid var(--glass-border); border-radius: 12px; }
.unr-top > div { flex: 1 1 360px; }
.unr-badge { display: inline-block; margin-bottom: 8px; padding: 2px 10px; color: #f0b866; font-size: 13px; font-weight: 700; background: rgba(232, 163, 61, 0.16); border-radius: 8px; }
body:not(.dark) .unr-badge { color: #8a5200; }
.unr-why { margin: 0; padding-left: 20px; }
.unr-msg { margin: 10px 0 0; font-size: 12px; color: var(--muted); word-break: keep-all; }
.unr-card h4 { margin: 22px 0 10px; font-size: 15px; }
.unr-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.unr-opt { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; color: var(--text); font: inherit; text-align: left; background: transparent; border: 1px solid var(--glass-border); border-radius: 14px; cursor: pointer; }
.unr-opt span { font-size: 13px; color: var(--muted); }
.unr-opt:hover { background-color: var(--subtle-bg); }
.unr-opt.primary { background-color: var(--accent-soft); border: 2px solid var(--accent); }
.unr-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-top: 20px; padding-top: 14px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--glass-border); }
.unr-foot a { color: var(--muted); }
.unr-foot .btn-cancel { height: 48px; padding: 0 24px; border: 0; border-radius: 12px; font-weight: 700; cursor: pointer; }

/* 분석 기록 화면: 왼쪽 레일(16 + 64 + 여백)만큼 비켜 앉는다 */
.page { max-width: none; padding: 24px 32px 40px 112px; }
.page > * { width: 100%; max-width: 1120px; margin-left: auto; margin-right: auto; }

/* --- 패널 드래그 이동: 원래 자리에서 옮긴 만큼(--dx/--dy)만 이동 --- */
.movable { transform: translate(var(--dx, 0px), var(--dy, 0px)); }
.stage img { -webkit-user-drag: none; }   /* 그림을 끌어도 파일 끌기가 시작되지 않게 */
.movable.moving { z-index: 6; box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45); }
.drag-handle { cursor: grab; touch-action: none; user-select: none; }
.moving .drag-handle,
.drag-handle.moving { cursor: grabbing; }
.grip {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  width: 20px;
  min-height: 44px;
  color: var(--muted);
  border-radius: 8px;
  opacity: 0.55;
}
.grip:hover { opacity: 1; background-color: var(--subtle-bg); }
.chips > .grip { background: var(--glass); border: 1px solid var(--glass-border); border-radius: 12px; opacity: 0.9; }
.timeline > .grip { margin-left: -8px; }
#layout-reset:disabled { opacity: 0.3; cursor: default; }
#layout-reset:disabled:hover { background-color: transparent; color: var(--muted); }

/* --- 빈 화면(빠른 시작) · 예측 중 · 파일 놓기 --- */
.stage-empty { max-width: 460px; padding: 32px 36px; border-style: solid; border-color: var(--glass-border); }
.stage-empty .viewer-empty-icon { color: var(--accent); opacity: 1; }
.stage-empty .viewer-empty-title { font-size: 17px; font-weight: 700; color: var(--text); }
.empty-steps { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; padding: 0; list-style: none; text-align: left; }
.empty-steps li { display: flex; align-items: center; gap: 10px; color: var(--label); }
.empty-steps b {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 12px;
  color: var(--accent);
  background-color: var(--accent-soft);
  border-radius: 50%;
}
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 12px 0 4px; }
.empty-actions .btn { min-height: 44px; padding: 0 18px; font-size: 14px; border-radius: 12px; }

.stage-loading {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  font-weight: 700;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}
.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stage-drop {
  position: absolute;
  z-index: 20;
  inset: 12px 12px 12px 92px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  pointer-events: none;
  background: rgba(var(--scrim), 0.72);
  border: 3px dashed var(--accent);
  border-radius: 22px;
}
.stage.file-over .stage-drop { display: flex; }

/* --- 다듬기: 떠 있는 요소가 부드럽게 나타나고, 키보드 초점이 또렷하게 보인다 --- */
@keyframes float-in { from { opacity: 0; } to { opacity: 1; } }
.panel, .panel-pill, .drawer, .timeline, .chip, .chip-btn, .stage-toggle, .stage-zoom { animation: float-in 0.18s ease-out; }
.chip-btn, .rain-presets button, .drawer-item, .stage-toggle button, .stage-zoom button, .btn-theme, #rail .view-tab, .tl-play {
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.tl-play:hover:not(:disabled), .panel .run-bar .btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
:is(button, a, input, select, summary, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .panel, .panel-pill, .drawer, .timeline, .chip, .chip-btn, .stage-toggle, .stage-zoom { animation: none; }
  .spinner { animation-duration: 2.4s; }
}

/* --- 모바일: 레일은 위쪽 가로 바, 지도 → 칩 → 시간 슬라이더 → 조건 패널 → 기록 순으로 쌓는다 --- */
@media (max-width: 1000px) {
  #rail {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    bottom: auto;
    width: auto;
    height: 56px;
    flex-direction: row;
    gap: 4px;
    padding: 0 12px;
    background: var(--panel);
    border: 0;
    border-bottom: 1px solid var(--glass-border);
    border-radius: 0;
    backdrop-filter: none;
  }
  .brand-wrap { margin: 0 6px 0 0; }
  #rail .view-tab { flex-direction: row; gap: 6px; width: auto; padding: 8px 12px; font-size: 13px; }
  .tab-count { position: static; }
  .rail-spacer { flex: 1; }
  .model-status { margin: 0 6px; }
  .account { margin: 0; }
  .account-pop { left: auto; right: 0; bottom: auto; top: calc(100% + 10px); }

  .stage { display: flex; flex-direction: column; height: auto; min-height: 0; overflow: visible; }
  .stage-map { position: relative; inset: auto; order: 1; width: 100%; max-height: 82vh; aspect-ratio: 1 / 1; }
  .stage-empty { margin: 16px; }
  .stage-fit { display: none !important; }   /* 정사각이라 채우기와 전체 보기가 같다 */
  .stage-zoom { right: 12px; bottom: 12px; }
  .chips { position: static; order: 2; justify-content: flex-start; max-width: none; padding: 10px 12px 0; }
  .timeline { position: relative; left: auto; right: auto; bottom: auto; order: 3; max-width: none; margin: 64px 12px 0; }   /* 위 64px = 지도/시간 변화 전환 자리 */
  .tl-legend { display: none; }
  .panel,
  .panel-pill { position: static; order: 4; width: auto; max-height: none; margin: 12px; }
  .drawer { position: static; order: 5; width: auto; max-height: none; margin: 0 12px 16px; }
  .chk-flow .chk-arrow { display: none; }
  .movable { transform: none !important; }   /* 세로로 쌓이는 화면에서는 옮긴 위치를 쓰지 않는다 */
  .grip, #layout-reset { display: none; }
  .stage-drop { inset: 8px; }
  .page { padding: 16px; }
  .page > * { max-width: none; }
}

@media (max-width: 480px) {
  #rail .view-tab span:not(.tab-count) { display: none; }   /* 좁은 폭에서는 아이콘만 */
  .check-card, .unr-card, .gallery-card { padding: 18px 16px; }
}

/* ===== 크리스마스 장식 (body.xmas, 🎄 버튼) =====
   전체 디자인은 그대로 두고 은은하게만 더한다:
   배경 눈, 로고 산타 모자, 상단바 아래 전구 줄, 기본 버튼에 아주 옅은 붉은 기 */
:root { --snow: rgba(150, 168, 190, 0.55); }
body.dark { --snow: rgba(255, 255, 255, 0.55); }

#snow-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  display: none;
}
body.xmas #snow-canvas { display: block; }

/* 눈은 카드 뒤에 깔리도록 본문을 위로 올린다 */
.page,
.stage { position: relative; z-index: 1; }

.brand-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.xmas-hat {
  position: absolute;
  top: -9px;
  left: -10px;
  transform: rotate(-18deg);
  display: none;
  pointer-events: none;
}
body.xmas .xmas-hat { display: block; }

/* 화면 맨 위 작은 전구 줄 (빨강·초록·금색 점) */
body.xmas::before {
  content: "";
  position: fixed;
  z-index: 1000;
  left: 0;
  right: 0;
  top: 0;
  height: 6px;
  pointer-events: none;
  background-image:
    radial-gradient(circle, #e0484d 0 2px, transparent 2.5px),
    radial-gradient(circle, #3fae5f 0 2px, transparent 2.5px),
    radial-gradient(circle, #e8b84a 0 2px, transparent 2.5px);
  background-size: 54px 6px;
  background-position: 0 0, 18px 0, 36px 0;
  background-repeat: repeat-x;
  opacity: 0.85;
}

.btn-xmas[aria-pressed="true"] {
  border-color: #3fae5f;
  background-color: rgba(63, 174, 95, 0.12);
}

body.xmas .btn-primary {
  box-shadow: 0 0 0 1px rgba(224, 72, 77, 0.25);
}

@media (prefers-reduced-motion: reduce) {
  body.xmas #snow-canvas { display: none; }
}

/* 단계 번호(1·2·3) 왼쪽 위에 작은 크리스마스 이모지 */
body.xmas .step-num { position: relative; }
body.xmas .step-num::before {
  content: attr(data-xmas);
  position: absolute;
  top: -9px;
  left: -9px;
  font-size: 13px;
  line-height: 1;
  transform: rotate(-12deg);
  pointer-events: none;
}

/* ===== 첫 화면: 프로젝트 로고 ===== */
.splash {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e6eaef;
  background: radial-gradient(circle at 50% 42%, #14212e 0%, #0d1218 62%);
  cursor: pointer;
  transition: opacity 0.45s ease, visibility 0.45s;
}
.splash.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-inner { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 24px; }
.splash-img { max-width: min(320px, 70vw); max-height: 240px; margin-bottom: 18px; object-fit: contain; animation: float-in 0.6s ease-out; }
.splash-logo { margin-bottom: 18px; filter: drop-shadow(0 0 22px rgba(76, 195, 255, 0.35)); }
.splash-drop { stroke-dasharray: 260; stroke-dashoffset: 260; animation: splash-draw 0.9s ease-out forwards; }
.splash-line { stroke-dasharray: 70; stroke-dashoffset: 70; animation: splash-draw 0.6s ease-out forwards; }
.splash-line.l1 { animation-delay: 0.55s; }
.splash-line.l2 { animation-delay: 0.75s; }
.splash-line.l3 { animation-delay: 0.95s; }
@keyframes splash-draw { to { stroke-dashoffset: 0; } }
.splash-name { margin: 0; font-size: 44px; font-weight: 700; letter-spacing: 0.12em; text-indent: 0.12em; }
.splash-tag { margin: 8px 0 0; font-size: 16px; color: #aeb9c6; }
.splash-hint { margin: 36px 0 0; font-size: 12px; color: #7d8a99; }
.splash-name, .splash-tag, .splash-hint { opacity: 0; animation: float-in 0.5s ease-out forwards; }
.splash-name { animation-delay: 0.35s; }
.splash-tag { animation-delay: 0.6s; }
.splash-hint { animation-delay: 1.1s; }
@media (prefers-reduced-motion: reduce) {
  .splash, .splash * { animation: none !important; transition: none; }
  .splash-drop, .splash-line { stroke-dashoffset: 0; }
  .splash-name, .splash-tag, .splash-hint { opacity: 1; }
}
