:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #6b7280;
  --border: #e2e4e9;
  --accent: #2563eb;
  --accent-active: #1d4ed8;
  --danger: #dc2626;
}

* { box-sizing: border-box; }

/* viewport-fit=cover 로 화면 가장자리까지 쓰게 되면서, body(최대 480px) 바깥이
   브라우저 기본 흰색으로 드러난다. html 에도 같은 배경을 깔아 전체를 덮는다. */
html {
  background: var(--bg);
  min-height: 100%;
}

body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

h1 {
  font-size: 20px;
  margin: 0 0 16px;
}

h2 {
  font-size: 16px;
  margin: 0 0 12px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.game-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--card);
  overflow-y: auto;
  padding: 16px;
}

.game-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.game-overlay-header span {
  font-weight: 700;
  font-size: 1.1em;
}

.ladder-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
}

.ladder-top {
  display: flex;
}

.ladder-pick, .ladder-slot {
  flex: none;
  text-align: center;
  padding: 6px 0;
  font-size: 13px;
}

.ladder-pick {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  margin: 0 2px;
}

.ladder-pick.mine {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.ladder-pick:disabled {
  opacity: 0.6;
}

.ladder-slot {
  font-weight: 700;
}

.ladder-slot.loss { color: var(--danger); }
.ladder-slot.pass { color: var(--accent); }

.ladder-svg { display: block; }
.ladder-line { stroke: var(--border); stroke-width: 2; }
.ladder-rung { stroke: var(--muted); stroke-width: 2; }
.ladder-trace { stroke: var(--accent); stroke-width: 3; fill: none; opacity: 0.5; }
.ladder-token { fill: var(--accent); }

.ladder-result {
  font-weight: 700;
  margin-top: 8px;
}

.ladder-result.loss { color: var(--danger); }
.ladder-result.pass { color: var(--accent); }

.ladder-loser-wrap {
  position: relative;
  overflow: visible;
  margin: 16px 0;
}

.ladder-loser-banner {
  padding: 20px 12px;
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  color: var(--danger);
  border: 2px solid var(--danger);
  border-radius: 12px;
  background: #fef2f2;
  animation: ladder-pop 0.4s ease-out;
}

.ladder-loser-banner.is-me {
  color: #fff;
  background: var(--danger);
}

@keyframes ladder-pop {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.ladder-confetti {
  position: absolute;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.ladder-confetti span {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 14px;
  opacity: 0.9;
  animation-name: ladder-confetti-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}

@keyframes ladder-confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(220px) rotate(var(--rot)); opacity: 0; }
}

.rps-round { margin-bottom: 8px; }

.rps-match { font-size: 14px; padding: 2px 0; }

.rps-match-exempt { color: #94a3b8; text-decoration: line-through; }

.rps-match-survivor { font-weight: 700; color: #ea580c; }

.rps-callout-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0; /* narrowed by JS (positionRpsCallout) to stop above the choice buttons */
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.15);
}

.rps-callout-text {
  padding: 0 16px;
  font-size: clamp(64px, 22vw, 180px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 6px 28px rgba(0, 0, 0, 0.45);
}

.rps-callout-text:empty { display: none; }

.rps-callout-text.rps-pop { animation: ladder-pop 0.3s ease-out; }

.rps-callout-confetti {
  position: fixed;
  inset: 0;
  z-index: 1001;
  pointer-events: none;
}

.rps-callout-confetti span {
  position: absolute;
  top: -12px;
  width: 10px;
  height: 16px;
  opacity: 0.9;
  animation-name: rps-callout-confetti-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}

@keyframes rps-callout-confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(var(--rot)); opacity: 0; }
}

.nunchi-avatars { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.nunchi-avatar { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); }
.nunchi-figure { font-size: 28px; display: inline-block; }
.nunchi-avatar.sit .nunchi-figure { transform: translateY(6px) scale(0.9); }
.nunchi-avatar.stand .nunchi-figure { animation: nunchi-standup 0.4s ease-out; }
.nunchi-avatar.out .nunchi-figure { animation: nunchi-fall 0.4s ease-out forwards; }

@keyframes nunchi-standup {
  0% { transform: translateY(6px) scale(0.9); }
  60% { transform: translateY(-4px) scale(1.05); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes nunchi-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(10px) rotate(90deg); opacity: 0.4; }
}

.nunchi-pool { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.nunchi-num {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-weight: 700;
}

.nunchi-collision { font-weight: 700; color: var(--danger); }

.nunchi-results { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.nunchi-result.pass { color: var(--accent); }
.nunchi-result.loss { color: var(--danger); font-weight: 700; animation: ladder-pop 0.4s ease-out; }

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}

input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
}

input:focus {
  outline: none;
  border-color: var(--accent);
}

select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
}

select:focus {
  outline: none;
  border-color: var(--accent);
}

input[type="checkbox"] {
  display: inline-block;
  width: auto;
  padding: 0;
  margin: 0;
  accent-color: var(--accent);
}

.top-actions label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0;
  width: auto;
}

button, .btn, .btn-link, .btn-danger {
  transition: filter 0.15s ease;
}

button:hover, .btn:hover, .btn-link:hover, .btn-danger:hover {
  filter: brightness(0.93);
}

button, .btn {
  display: block;
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  margin-bottom: 10px;
}

button:active, .btn:active {
  background: var(--accent-active);
}

button.secondary {
  background: var(--card);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.error {
  color: var(--danger);
  font-size: 14px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.report-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.report-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.report-list li:last-child {
  border-bottom: none;
}

.report-list a {
  font-weight: 600;
}

img.photo {
  width: 100%;
  max-width: 100%;
  border-radius: 8px;
  margin-bottom: 10px;
  display: block;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.photo-thumb-link {
  display: block;
}

.photo-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.attachment-list {
  margin-top: 12px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.attachment-item:last-child {
  border-bottom: none;
}

.attachment-icon {
  flex: none;
}

.attachment-item a {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-date {
  flex: none;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.btn-link {
  display: inline-block;
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  background: #eef2ff;
  color: var(--accent);
  text-decoration: none;
}

.btn-link-admin {
  background: #f3e8ff;
  color: #7c3aed;
}

.btn-danger {
  display: inline-block;
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: #fee2e2;
  color: var(--danger);
  cursor: pointer;
  white-space: nowrap;
}

.crop-wrap {
  position: relative;
  margin-bottom: 12px;
  width: fit-content;
  max-width: 100%;
}

.crop-wrap img {
  width: auto;
  max-width: 100%;
  max-height: 65vh;
  height: auto;
  display: block;
  border-radius: 0;
}

.badge {
  display: inline-block;
  width: auto;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
}

.badge-ok {
  background: #dcfce7;
  color: #166534;
}

.badge-org {
  background: #e5e7eb;
  color: #374151;
}

.badge-org[data-org="ARC"] { background: #dbeafe; color: #1d4ed8; }
.badge-org[data-org="Blood Bank"] { background: #fee2e2; color: #b91c1c; }
.badge-org[data-org="Vitalant"] { background: #fef3c7; color: #92400e; }
.badge-org[data-org="Hospital"] { background: #dcfce7; color: #166534; }
.badge-org[data-org="Institution"] { background: #ede9fe; color: #6d28d9; }

.data-table {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.data-row {
  display: grid;
  grid-template-columns: 24px 1.3fr 1.3fr 0.9fr 1fr 0.9fr 0.7fr auto;
  gap: 10px;
  align-items: center;
  min-width: 680px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.data-row-templates {
  grid-template-columns: 24px 1.3fr 1fr 1fr auto;
  min-width: 360px;
}

.data-row-users {
  grid-template-columns: 0.8fr 0.6fr 0.8fr 0.9fr 0.5fr 0.5fr auto;
  min-width: 420px;
  font-size: 12px;
  gap: 6px;
}

.data-row-users .btn-link,
.data-row-users .btn-danger,
.data-row-users button {
  padding: 5px 8px;
  font-size: 12px;
  margin-bottom: 0;
}

.row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.data-row-spec {
  grid-template-columns: 1fr 1.5fr;
  min-width: auto;
}

.data-row-spec span:first-child {
  color: var(--muted);
  font-weight: 600;
}

.legacy-geo-btn {
  display: none;
}

.cell-sn {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.cell-sn a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge.badge-spec-toggle {
  border: none;
  cursor: pointer;
  font: inherit;
  margin: 0;
  flex: none;
}

.badge.badge-spec-toggle.badge-spec-open {
  background: #fde68a;
}

.data-row-spec-panel {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

body.home {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-top: 24px;
}

.home-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.home-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  text-align: center;
  padding-bottom: 15vh;
}

.home-logo {
  width: 80%;
  max-width: 320px;
  height: auto;
}

.home-search {
  width: 100%;
  max-width: 400px;
}

.home-search input {
  border-radius: 24px;
  padding: 14px 20px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
}

.home-search-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.home-search-actions button {
  flex: 1;
  margin-bottom: 0;
}

.home-action-btn {
  height: 44px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
}

.home-search-actions .home-action-btn {
  flex: 1;
  margin-bottom: 0;
}

.home-chat-rooms {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(50vw - 20px);
}

.chat-room-link {
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.home-welcome {
  position: fixed;
  right: 12px;
  bottom: 38px;   /* 아래 접속 중 줄 자리 확보 */
  z-index: 30;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.85);
  padding: 6px 10px;
  border-radius: 8px;
}

@media (max-width: 480px) {
  .home-chat-rooms {
    max-width: calc(60vw - 20px);
  }
  .chat-room-link {
    font-size: 12px;
    height: 38px;
    padding: 0 12px;
  }
}

.chat-box {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.chat-messages {
  max-height: 60vh;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg-meta {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.chat-msg-body {
  font-size: 14px;
  word-break: break-word;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.chat-input-row input {
  flex: 1;
  margin-top: 0;
}

.chat-input-row button {
  width: auto;
  margin-bottom: 0;
  padding: 12px 20px;
}

.birthday-banner {
  background: linear-gradient(135deg, #fde68a, #fbcfe8);
  border-radius: 12px;
  padding: 12px 16px;
  margin: 0 0 12px;
  text-align: center;
  font-weight: 600;
  color: #7c2d12;
}

.birthday-banner p {
  margin: 4px 0;
}

.firework-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}

.firework-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  animation: firework-burst 1s ease-out forwards;
}

@keyframes firework-burst {
  0% {
    transform: translate(0, 0);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy));
    opacity: 0;
  }
}

.tarot-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

@media (min-width: 768px) {
  .tarot-grid {
    gap: 14px;
  }
}

.tarot-card {
  aspect-ratio: 2 / 3;
  perspective: 600px;
  cursor: pointer;
}

.tarot-card.disabled {
  cursor: default;
  opacity: 0.4;
  pointer-events: none;
}

.tarot-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s;
  transform-style: preserve-3d;
}

.tarot-card.flipped .tarot-card-inner {
  transform: rotateY(180deg);
}

.tarot-card-front,
.tarot-card-back {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: 8px;
  backface-visibility: hidden;
  padding: 4px;
  font-size: 11px;
  font-weight: 600;
}

.tarot-card-front {
  background: linear-gradient(135deg, #4338ca, #7c3aed);
  color: #fff;
}

.tarot-back-svg {
  width: 72%;
  height: 72%;
  color: #fff;
}

.tarot-card-back {
  flex-direction: column;
  gap: 2px;
  background: #fff7ed;
  color: #7c2d12;
  border: 1px solid var(--border);
  transform: rotateY(180deg);
  overflow: hidden;
}

.tarot-frame-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: currentColor;
  pointer-events: none;
}

.tarot-card-symbol {
  font-size: clamp(18px, 5vw, 30px);
  line-height: 1;
  z-index: 1;
}

.tarot-card-name {
  font-size: clamp(8px, 2vw, 11px);
  z-index: 1;
  padding: 0 4px;
}

.tarot-card-orientation {
  font-size: clamp(7px, 1.6vw, 9px);
  z-index: 1;
  opacity: 0.75;
}

.tarot-card-back[data-category="start"] { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.tarot-card-back[data-category="power"] { background: linear-gradient(135deg, #fecaca, #fca5a5); color: #991b1b; }
.tarot-card-back[data-category="calm"] { background: linear-gradient(135deg, #cffafe, #a5f3fc); color: #155e75; }
.tarot-card-back[data-category="caution"] { background: linear-gradient(135deg, #e9d5ff, #d8b4fe); color: #6b21a8; }

@keyframes tarot-deal {
  from {
    transform: translateY(30px) scale(0.8);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.tarot-card.dealing {
  animation: tarot-deal 0.4s ease-out backwards;
}

.tarot-reading {
  margin-top: 16px;
}

.tarot-screen {
  transition: opacity 0.3s ease;
}

.tarot-screen-hidden {
  display: none;
}

.tarot-picked-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tarot-picked-summary span {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}

.tarot-reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.tarot-reveal.tarot-reveal-visible {
  opacity: 1;
  transform: translateY(0);
}

.geo-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 20;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.geo-suggestion-item {
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.geo-suggestion-item:last-child {
  border-bottom: none;
}

.geo-suggestion-item:hover {
  background: var(--bg);
}

.data-row:last-child {
  border-bottom: none;
}

.card.bulk-row[data-href] {
  cursor: pointer;
  transition: background 0.15s ease;
}

.card.bulk-row[data-href]:hover {
  background: var(--bg);
}

.data-row[data-href] {
  cursor: pointer;
  transition: background 0.15s ease;
}

.data-row[data-href]:hover {
  background: var(--bg);
}

.photo-thumb-wrap {
  position: relative;
}

.photo-delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 2px 8px;
  font-size: 11px;
  margin-bottom: 0;
  border-radius: 6px;
}

.schedule-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.schedule-title {
  font-size: 16px;
  font-weight: 600;
}

.schedule-row-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.schedule-row-actions {
  display: flex;
  gap: 4px;
  flex: none;
}

.data-row-head {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  background: var(--bg);
}

.data-row a {
  font-weight: 600;
}

.crop-wrap .crop-dot {
  position: absolute; width: 44px; height: 44px; padding: 0; margin: -22px 0 0 -22px;
  border: 0; border-radius: 50%; background: transparent; touch-action: none; z-index: 3;
  cursor: grab;
}
.crop-wrap .crop-dot::after {
  content: ""; display: block; width: 18px; height: 18px; margin: auto;
  border: 3px solid #fff; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 2px #111;
}
.crop-wrap .crop-dot:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.crop-guides { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.crop-shade { fill: rgba(0,0,0,.55); }
.crop-line-back, .crop-line-front { fill: none; vector-effect: non-scaling-stroke; }
.crop-line-back { stroke: #111; stroke-width: 3; }
.crop-line-front { stroke: #fff; stroke-width: 1.5; stroke-dasharray: 6 5; }
.crop-loupe {
  position: fixed; right: 12px; width: 110px; height: 110px; border: 3px solid #fff;
  border-radius: 50%; box-shadow: 0 0 0 2px #111; pointer-events: none; z-index: 2000;
}
.crop-loupe[hidden] { display: none; }

@media (min-width: 768px) {
  body {
    max-width: 960px;
    padding: 0 32px 48px;
  }

  .top-actions {
    flex-wrap: nowrap;
    gap: 4px;
    margin: 0 -32px 24px;
    padding: 14px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--card);
    position: sticky;
    top: 0;
    z-index: 10;
  }

  h1 {
    margin-top: 24px;
  }
}

.dm-online-line {
  position: fixed;
  right: 12px;
  bottom: 12px;      /* 환영 문구 바로 밑 */
  z-index: 30;
  margin: 0;
  max-width: 55vw;
  text-align: right;
  font-size: 11px;
  line-height: 1.4;
  color: #888;
  background: rgba(255, 255, 255, 0.85);
  padding: 4px 10px;
  border-radius: 8px;
  word-break: keep-all;
  pointer-events: none;
}

/* 카톡식 안읽음 뱃지 (홈 DM 버튼) */
.dm-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* 데이터 보기 / A4 PDF 탭 */
.view-tabs { display: flex; gap: 6px; margin: 0 0 14px; }
.view-tabs a {
  flex: 1; text-align: center; padding: 10px 8px; border-radius: 8px;
  border: 1px solid #d7dbe0; background: #fff; color: #555;
  font-size: 14px; font-weight: 600; text-decoration: none;
}
.view-tabs a.active { background: #eef2ff; border-color: #c7d2fe; color: var(--accent); }

/* A4 PDF 목록 / 페이지 */
.a4-item { display: flex; align-items: center; gap: 10px; padding: 12px 6px; border-bottom: 1px solid #eee; text-decoration: none; color: inherit; }
.a4-item:last-child { border-bottom: none; }
.a4-title { flex: 1; font-weight: 600; word-break: break-all; }
.a4-sub { display: block; font-size: 12px; color: #888; font-weight: 400; margin-top: 2px; }
.a4-count { background: #eef2ff; color: var(--accent); border-radius: 10px; padding: 2px 9px; font-size: 12px; font-weight: 700; }
.a4-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.a4-page { position: relative; border: 1px solid #ddd; border-radius: 6px; overflow: hidden; background: #fafafa; }
.a4-page img { width: 100%; display: block; aspect-ratio: 1/1.414; object-fit: cover; }
.a4-page .no { position: absolute; top: 4px; left: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 8px; }
.a4-page .del { position: absolute; top: 4px; right: 4px; border: none; background: rgba(239,68,68,.9); color: #fff; border-radius: 8px; font-size: 11px; padding: 2px 7px; cursor: pointer; }

/* 홈 화면 앱(PWA)으로 실행될 때 아이폰 노치·하단 바 영역 보정 */
html { background: var(--bg); }
body { padding-bottom: calc(48px + env(safe-area-inset-bottom)); }
body.home { padding-top: calc(24px + env(safe-area-inset-top)); }
.home-chat-rooms { bottom: calc(12px + env(safe-area-inset-bottom)); left: calc(12px + env(safe-area-inset-left)); }
.home-welcome { bottom: calc(38px + env(safe-area-inset-bottom)); right: calc(12px + env(safe-area-inset-right)); }
.dm-online-line { bottom: calc(12px + env(safe-area-inset-bottom)); right: calc(12px + env(safe-area-inset-right)); }
