* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: #fafafa;
  color: #222;
}

.top-admin-link {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 50;
  padding: 8px 18px;
  background: #111;
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.top-admin-link:hover { background: #333; }

/* 관리자 페이지 */
.admin-wrap {
  max-width: 720px;
  margin: 40px auto;
  padding: 24px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}
#zonePicker {
  margin-top: 12px;
  padding: 14px;
  background: #f6f8fa;
  border-radius: 8px;
}
#zonePicker .hint {
  font-size: 12px;
  color: #555;
  margin: 0 0 10px;
  line-height: 1.5;
}
#zoneOpenBtn {
  width: 100%;
  padding: 10px;
  background: #0066cc;
  color: #fff;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
#zoneInfo {
  margin-top: 8px;
  font-size: 12px;
  color: #333;
  font-family: ui-monospace, monospace;
}

/* 영역 선택 모달 */
.zone-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.zone-modal-card {
  background: #fff;
  border-radius: 10px;
  width: min(98vw, 1340px);
  height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.zone-modal-header {
  padding: 12px 18px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
}
.zone-modal-header button {
  padding: 6px 14px;
  background: #eee;
  color: #333;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
#previewScroll {
  flex: 1;
  overflow: auto;
  background: #f5f5f5;
  display: flex;
  justify-content: center;
}
#previewWrap {
  position: relative;
  width: 1280px;
  height: 10000px;
  background: #fff;
  flex-shrink: 0;
}
#previewFrame {
  position: absolute;
  top: 0;
  left: 0;
  width: 1280px;
  height: 10000px;
  border: 0;
  pointer-events: none;
}
#previewOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 1280px;
  height: 10000px;
  cursor: crosshair;
  background: transparent;
  user-select: none;
}
#zoneSelectionBox {
  position: absolute;
  border: 2px solid #f00;
  background: rgba(255, 0, 0, 0.18);
  pointer-events: none;
}
.zone-modal-footer {
  padding: 12px 18px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}
#modalZoneInfo { color: #555; font-family: ui-monospace, monospace; }
.zone-modal-footer #zoneSave {
  padding: 8px 22px;
  background: #111;
  color: #fff;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.admin-wrap h1 { margin-top: 0; font-size: 22px; }
.admin-wrap label {
  display: block;
  margin-top: 14px;
  font-weight: 600;
  font-size: 13px;
  color: #555;
}
.admin-wrap input,
.admin-wrap select {
  width: 100%;
  padding: 10px 12px;
  margin-top: 6px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
}
.admin-wrap button {
  margin-top: 20px;
  width: 100%;
  padding: 12px;
  background: #111;
  color: #fff;
  border: 0;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.admin-wrap button:disabled { opacity: 0.5; cursor: not-allowed; }
.zone-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.result {
  margin-top: 20px;
  padding: 14px;
  background: #f0f8ff;
  border: 1px solid #bcdfff;
  border-radius: 8px;
  word-break: break-all;
}
.result.error { background: #fff0f0; border-color: #ffbcbc; }
.hide { display: none !important; }

/* 방문자 페이지 */
.gate {
  max-width: 360px;
  margin: 80px auto;
  padding: 28px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  text-align: center;
}
.gate input {
  width: 100%;
  padding: 12px;
  margin-top: 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
}
.gate button {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  background: #111;
  color: #fff;
  border: 0;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.gate .err { color: #c00; margin-top: 12px; font-size: 13px; min-height: 1em; }

.viewer-body {
  height: 100vh;
  overflow: hidden;
  background: #000;
}
.viewer-body.scroll-mode {
  height: auto;
  overflow: auto;
}
#viewer {
  width: 100vw;
  height: 100vh;
}
.frame-wrap {
  position: relative;
  width: 100%;
  height: 100%;
}
.frame-wrap iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* 관리자 대시보드 */
.dash-wrap {
  max-width: 1100px;
  margin: 24px auto;
  padding: 20px;
}
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #eee;
  padding-bottom: 12px;
  margin-bottom: 16px;
}
.dash-header h1 { margin: 0; font-size: 20px; }
#userBox button {
  padding: 8px 14px;
  background: #111;
  color: #fff;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
#userInfo { display: inline-flex; gap: 10px; align-items: center; font-size: 13px; }
#userEmail { color: #555; }
.status {
  padding: 10px 14px;
  margin: 10px 0;
  background: #f4f6f8;
  border-radius: 6px;
  font-size: 13px;
  min-height: 1em;
}
.status.error { background: #fff0f0; color: #c00; }
.status:empty { display: none; }
.dash-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 8px;
  font-size: 13px;
}
.dash-toolbar button,
.btn-link {
  padding: 6px 12px;
  background: #fff;
  color: #111;
  border: 1px solid #ccc;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
}
.dash-toolbar #count { margin-right: auto; color: #666; }
.links-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.links-table th,
.links-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
.links-table th { background: #fafafa; font-size: 12px; color: #666; }
.links-table .ellipsis {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.links-table .expired-row { opacity: 0.5; }
.links-table button {
  padding: 4px 10px;
  font-size: 12px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
}
.links-table .del { color: #c00; border-color: #f0c0c0; }

/* 방문자 페이지 - 관리 버튼/패널 */
.manage-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  padding: 8px 40px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  backdrop-filter: blur(4px);
}
.manage-btn:hover { background: rgba(0, 0, 0, 0.85); }

.manage-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.manage-panel .panel-card {
  background: #fff;
  padding: 24px 28px;
  border-radius: 12px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
.manage-panel h3 { margin: 0 0 8px; font-size: 17px; }
.manage-panel label {
  display: block;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 600;
  color: #555;
}
.manage-panel label small { font-weight: 400; color: #999; margin-left: 4px; }
.manage-panel input,
.manage-panel select {
  width: 100%;
  padding: 9px 11px;
  margin-top: 5px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}
.manage-panel .actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}
.manage-panel .actions button {
  flex: 1;
  padding: 10px;
  border: 0;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.manage-panel button.primary { background: #111; color: #fff; }
.manage-panel button.secondary { background: #eee; color: #333; }
.manage-panel button.danger { background: #c00; color: #fff; }
.manage-panel .err {
  color: #c00;
  font-size: 12px;
  margin-top: 10px;
  min-height: 1em;
}
.zone-open-mini {
  width: 100%;
  padding: 8px;
  background: #0066cc;
  color: #fff;
  border: 0;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.zone-mini-info {
  font-size: 11px;
  color: #666;
  margin-top: 6px;
  font-family: ui-monospace, monospace;
}
.blocker {
  position: absolute;
  background: transparent;
  pointer-events: auto;
}
