:root {
  --bg: #F6F7FB;
  --dot: #D5DCE8;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #FFFFFF;
  --border: #E2E8F0;
  --text: #0F172A;
  --text-sub: #475569;
  --text-muted: #64748B;
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-soft: #EFF6FF;
  --danger: #DC2626;
  --danger-soft: #FEF2F2;
  --snap: #059669;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 18px 44px rgba(15, 23, 42, 0.16);
  --font: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', 'Segoe UI', sans-serif;
  --topbar-h: 56px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea {
  font-family: inherit;
}

[hidden] {
  display: none !important;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ==================== 상단 슬림 바 ==================== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0 10px;
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.topbar-left {
  flex: 1 1 auto;
}

.topbar-right {
  flex: 0 0 auto;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.14s, color 0.14s, opacity 0.14s;
}

.icon-btn:hover:not(:disabled) {
  background: #EEF2F7;
}

.icon-btn:active:not(:disabled) {
  background: #E2E8F0;
}

.icon-btn:disabled {
  opacity: 0.32;
  cursor: default;
}

.title-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.14s, border-color 0.14s;
}

.title-btn:hover {
  background: #EEF2F7;
}

.map-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.save-badge {
  font-size: 11px;
  font-weight: 600;
  color: #059669;
  background: #ECFDF5;
  padding: 3px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.undo-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.pill-btn {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-solid);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s, border-color 0.14s, transform 0.1s;
}

.pill-btn:hover {
  background: #F1F5F9;
  border-color: #CBD5E1;
}

.pill-btn:active {
  transform: scale(0.97);
}

/* ==================== 배너 & 힌트 ==================== */
.banner-wrap {
  position: fixed;
  top: calc(var(--topbar-h) + env(safe-area-inset-top) + 12px);
  left: 12px;
  right: 12px;
  z-index: 35;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.mode-banner {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  padding: 9px 14px;
  border-radius: 999px;
  background: #1E3A8A;
  color: #FFFFFF;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
}

.banner-cancel-btn {
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.hint-chip {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #DBEAFE;
  color: #1E3A8A;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}

.hint-chip strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 13px;
  margin: 0 2px;
}

.hint-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}

/* ==================== 캔버스 ==================== */
.canvas-stage {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--dot) 1.35px, transparent 1.35px);
  background-size: 26px 26px;
  outline: none;
}

.canvas-stage.panning {
  cursor: grabbing;
}

.canvas-stage.connecting {
  cursor: crosshair;
}

.canvas-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.edges-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
  pointer-events: none;
}

.edge-group {
  pointer-events: auto;
  cursor: pointer;
}

.edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 24;
  stroke-linecap: round;
}

.edge-line {
  fill: none;
  stroke: #64748B;
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke 0.12s, stroke-width 0.12s;
}

.edge-group:hover .edge-line {
  stroke: #334155;
  stroke-width: 3.2;
}

.edge-group.selected .edge-line {
  stroke: var(--primary);
  stroke-width: 3.6;
}

.preview-arrow {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2.8;
  stroke-dasharray: 7 5;
  stroke-linecap: round;
  pointer-events: none;
}

.preview-arrow.snapped {
  stroke: var(--snap);
  stroke-dasharray: none;
  stroke-width: 3.4;
}

.preview-ghost {
  fill: rgba(37, 99, 235, 0.10);
  stroke: var(--primary);
  stroke-width: 2;
  stroke-dasharray: 6 4;
  pointer-events: none;
}

/* ==================== 동그란 노드 ==================== */
.nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
}

.goal-node {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14px;
  cursor: grab;
  border: 2.5px solid var(--node-border, #2563EB);
  background: var(--node-bg, #FFFFFF);
  color: var(--node-fg, #0F172A);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: box-shadow 0.15s ease, transform 0.12s ease, border-color 0.15s ease;
  touch-action: none;
}

.goal-node:hover {
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.13);
}

.goal-node.selected {
  box-shadow: 0 0 0 5px var(--node-halo, rgba(37, 99, 235, 0.22)), 0 14px 32px rgba(15, 23, 42, 0.14);
  z-index: 10;
}

.goal-node.dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.04);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
  z-index: 20;
  transition: none;
}

.goal-node.snap-target {
  box-shadow: 0 0 0 7px rgba(5, 150, 105, 0.28), 0 12px 30px rgba(5, 150, 105, 0.22);
  border-color: var(--snap) !important;
  transform: translate(-50%, -50%) scale(1.06);
  z-index: 15;
}

.node-label {
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  word-break: keep-all;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  pointer-events: none;
}

.goal-node[data-size="lg"] { padding: 14px; }
.goal-node[data-size="md"] { padding: 12px; }
.goal-node[data-size="sm"] { padding: 9px; }
.goal-node[data-size="lg"] .node-label { font-size: 15.5px; }
.goal-node[data-size="md"] .node-label { font-size: 13.5px; }
.goal-node[data-size="sm"] .node-label { font-size: 11.5px; line-height: 1.24; }

.node-memo-dot {
  margin-top: 5px;
  font-size: 10.5px;
  font-weight: 600;
  opacity: 0.72;
  max-width: 82%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* 드래그-드롭 + 핸들 (선택 시 표시, PC는 호버 시에도 즉시 드래그 가능) */
.node-handle {
  position: absolute;
  right: -19px;
  top: 50%;
  transform: translateY(-50%) scale(0.86);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2.5px solid #FFFFFF;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: crosshair;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.40);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease, background 0.14s ease;
  touch-action: none;
  z-index: 12;
}

.goal-node.selected .node-handle {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

@media (hover: hover) {
  .goal-node:hover .node-handle {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-50%) scale(1);
  }
}

.goal-node.dragging .node-handle {
  opacity: 0 !important;
  pointer-events: none !important;
}

.node-handle::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
}

.node-handle:hover {
  transform: translateY(-50%) scale(1.12);
  background: var(--primary-hover);
}

.node-handle:active {
  transform: translateY(-50%) scale(0.95);
}

/* ==================== 줌 컨트롤 ==================== */
.zoom-controls {
  position: fixed;
  right: 14px;
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 30;
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.zoom-btn, .zoom-pct {
  height: 38px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.zoom-btn {
  width: 36px;
  font-size: 18px;
  font-weight: 600;
}

.zoom-pct {
  min-width: 50px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.zoom-btn:hover, .zoom-pct:hover {
  background: #EEF2F7;
}

/* ==================== 하단 플로팅 도크 ==================== */
.dock-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 38;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  pointer-events: none;
}

.dock {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 6px;
  border-radius: 20px;
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.dock-btn {
  height: 44px;
  padding: 0 14px;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s, transform 0.1s;
}

.dock-btn:hover {
  background: #EEF2F7;
}

.dock-btn:active {
  transform: scale(0.96);
}

.dock-primary {
  background: var(--primary);
  color: #FFFFFF;
}

.dock-primary:hover {
  background: var(--primary-hover);
}

.dock-danger {
  color: var(--danger);
}

.dock-danger:hover {
  background: var(--danger-soft);
}

.color-dot-preview {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #FFFFFF;
  box-shadow: 0 0 0 1.5px rgba(15, 23, 42, 0.2);
}

.color-popover {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

/* ==================== 내 지도 드로어 ==================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.36);
  display: flex;
  justify-content: flex-start;
}

.drawer {
  width: min(340px, 88vw);
  height: 100%;
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 12px 18px;
  border-bottom: 1px solid var(--border);
}

.drawer-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

.drawer-sub {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.drawer-actions {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.btn-primary-full, .btn-secondary-full {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-primary-full {
  background: var(--primary);
  color: #FFFFFF;
}

.btn-primary-full:hover {
  background: var(--primary-hover);
}

.btn-secondary-full {
  background: #F1F5F9;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary-full:hover {
  background: #E2E8F0;
}

.map-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1.5px solid transparent;
  background: #F8FAFC;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s;
}

.map-item:hover {
  background: #F1F5F9;
}

.map-item.active {
  background: var(--primary-soft);
  border-color: #93C5FD;
}

.map-item-main {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: inherit;
}

.map-item-title {
  display: block;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-item-meta {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-muted);
}

.map-item-btns {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.mini-icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.mini-icon-btn:hover {
  background: rgba(15, 23, 42, 0.08);
  color: var(--text);
}

.mini-icon-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.drawer-footer {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  background: #F8FAFC;
}

.help-mini {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-sub);
}

/* ==================== 모달 / 편집 시트 ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(15, 23, 42, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

/* 모바일에서 키보드가 올라와도 가려지지 않게 상단 정렬 */
.modal-backdrop.modal-top {
  align-items: flex-start;
  padding-top: calc(max(18px, 6vh) + env(safe-area-inset-top));
}

.modal-card {
  width: min(460px, 100%);
  background: var(--surface-solid);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-card.modal-sm {
  width: min(400px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 12px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 800;
}

.editor-form {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 5px;
}

/* iOS 자동확대 방지를 위해 모든 입력칸 16px 고정 */
.text-input {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid #CBD5E1;
  border-radius: 13px;
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  background: #FFFFFF;
  resize: none;
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}

.text-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.text-input-memo {
  font-size: 16px;
}

.text-input-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px;
}

.editor-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.palette-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.swatch-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2.5px solid #FFFFFF;
  cursor: pointer;
  box-shadow: 0 0 0 1.5px rgba(15, 23, 42, 0.15);
  transition: transform 0.12s;
}

.swatch-btn:hover {
  transform: scale(1.1);
}

.swatch-btn.active {
  box-shadow: 0 0 0 2.5px var(--text);
  transform: scale(1.12);
}

.size-row {
  display: inline-flex;
  background: #F1F5F9;
  padding: 3px;
  border-radius: 11px;
  gap: 3px;
}

.size-chip {
  height: 34px;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-sub);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.size-chip.active {
  background: #FFFFFF;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.btn-ghost, .btn-solid {
  height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-ghost {
  background: #F1F5F9;
  color: var(--text-sub);
}

.btn-ghost:hover {
  background: #E2E8F0;
}

.btn-solid {
  background: var(--primary);
  color: #FFFFFF;
}

.btn-solid:hover {
  background: var(--primary-hover);
}

/* 저장 / 불러오기 시트 */
.action-sheet-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sheet-item, .file-pick-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: 15px;
  background: #FFFFFF;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.14s, border-color 0.14s;
}

.sheet-item:hover, .file-pick-btn:hover {
  background: #F8FAFC;
  border-color: #93C5FD;
}

.file-pick-btn {
  position: relative;
  border-style: dashed;
  border-color: #93C5FD;
  background: var(--primary-soft);
}

.file-pick-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.sheet-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.sheet-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sheet-text strong {
  font-size: 14.5px;
  font-weight: 700;
}

.sheet-text small {
  font-size: 12px;
  color: var(--text-muted);
}

.load-sheet-body {
  padding: 14px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.load-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-sub);
}

.divider-or {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.divider-or::before, .divider-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ==================== 토스트 ==================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(78px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 90;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  color: #FFFFFF;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  text-align: center;
  pointer-events: none;
}

/* ==================== 모바일 반응형 ==================== */
@media (max-width: 640px) {
  .topbar {
    padding-left: 6px;
    padding-right: 8px;
    gap: 4px;
  }

  .save-badge {
    display: none;
  }

  .pill-btn {
    padding: 0 10px;
    font-size: 13px;
    gap: 4px;
  }

  .undo-group .icon-btn {
    width: 36px;
    height: 36px;
  }

  .dock {
    padding: 5px;
    gap: 3px;
  }

  .dock-btn {
    padding: 0 11px;
    font-size: 13px;
    gap: 4px;
  }

  .zoom-controls {
    right: 10px;
    bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .zoom-pct {
    display: none;
  }

  .zoom-btn {
    width: 38px;
    height: 38px;
  }

  .hint-chip {
    font-size: 12px;
    padding: 7px 12px;
  }
}

@media (max-width: 350px) {
  .pill-btn span {
    display: none;
  }

  .pill-btn {
    width: 40px;
    padding: 0;
    justify-content: center;
  }

  .dock-btn {
    padding: 0 9px;
    font-size: 12.5px;
  }
}

/* 가로 모드(짧은 화면) 대응 */
@media (max-height: 460px) {
  .zoom-controls {
    bottom: calc(68px + env(safe-area-inset-bottom));
  }

  .dock-wrap {
    bottom: calc(8px + env(safe-area-inset-bottom));
  }
}
