:root {
  --bg: #F1F4F7;
  --surface: #FFFFFF;
  --surface-2: #E8ECF1;
  --ink: #1B2430;
  --muted: #67707C;
  --line: #DBE1E8;
  --accent: #E1531F;
  --accent-strong: #C64315;
  --accent-contrast: #FFFFFF;
  --danger: #D5473F;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow: 0 1px 2px rgba(20, 26, 33, 0.06), 0 8px 24px -12px rgba(20, 26, 33, 0.18);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161B;
    --surface: #1B2129;
    --surface-2: #232A33;
    --ink: #E9EDF1;
    --muted: #97A2AD;
    --line: #2C333D;
    --accent: #FF7B44;
    --accent-strong: #FF8F5E;
    --accent-contrast: #1B1206;
    --danger: #FF6B63;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --bg: #12161B;
  --surface: #1B2129;
  --surface-2: #232A33;
  --ink: #E9EDF1;
  --muted: #97A2AD;
  --line: #2C333D;
  --accent: #FF7B44;
  --accent-strong: #FF8F5E;
  --accent-contrast: #1B1206;
  --danger: #FF6B63;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', sans-serif;
  min-height: 100dvh;
  padding-bottom: 96px;
}
h1, h2 { text-wrap: balance; margin: 0; }
button, input, textarea { font-family: inherit; }
a { color: inherit; }

/* ---------- 상단바 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-title h1 { font-size: 1.15rem; font-weight: 900; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-meta { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.count { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; font-size: 0.9rem; }
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #B7BEC6;
  flex-shrink: 0;
  transition: background-color .2s;
}
.dot.live { background: #33B27A; box-shadow: 0 0 0 3px rgba(51,178,122,0.18); }
.dot.down { background: var(--danger); }
.link-btn {
  background: none; border: none; color: var(--muted); font-size: 0.88rem;
  font-weight: 500; cursor: pointer; padding: 6px 4px;
}
.link-btn:hover { color: var(--ink); }
.link-btn.danger-link { color: var(--danger); }
.link-btn.danger-link:hover { color: var(--danger); opacity: 0.75; }
.link-btn:disabled { opacity: 0.6; cursor: default; }
.back-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%; margin-left: -6px;
  color: var(--ink);
}
.back-btn:hover { background: var(--surface-2); }

/* ---------- 목록 ---------- */
.list { display: flex; flex-direction: column; gap: 1px; background: var(--line); }
.row {
  display: flex;
  gap: 16px;
  padding: 16px 20px;
  background: var(--surface);
  text-decoration: none;
  color: var(--ink);
}
.row:hover, .row:active { background: var(--surface-2); }
.thumb {
  position: relative;
  flex-shrink: 0;
  width: 128px;
  height: 128px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb svg { opacity: 0.55; }
.more-badge {
  position: absolute; right: 6px; bottom: 6px;
  background: rgba(20,26,33,0.72);
  color: #fff;
  font-size: 0.72rem; font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.row-body { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 6px; flex: 1; }
.row-location {
  margin: 0; font-size: 1.2rem; font-weight: 900; letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
}
.row-content {
  margin: 0; font-size: 0.92rem; color: var(--muted); line-height: 1.45;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.row-time { margin: 2px 0 0; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 64px 24px;
  line-height: 1.7;
}

.fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  text-decoration: none;
}
.fab:hover { background: var(--accent-strong); }

/* ---------- 로그인 ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh; padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px 28px;
}
.eyebrow {
  margin: 0 0 6px; font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.08em; color: var(--accent); text-transform: uppercase;
}
.login-card h1 { font-size: 1.5rem; font-weight: 900; margin-bottom: 8px; }
.lead { color: var(--muted); font-size: 0.92rem; margin: 0 0 22px; line-height: 1.5; }
.login-card form { display: flex; flex-direction: column; gap: 8px; }
.login-card label { font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.login-card input {
  padding: 13px 14px; font-size: 1.05rem; border-radius: var(--radius-md);
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  margin-bottom: 6px;
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-card button {
  margin-top: 8px; padding: 13px; border: none; border-radius: var(--radius-md);
  background: var(--accent); color: var(--accent-contrast); font-size: 1rem; font-weight: 700;
  cursor: pointer;
}
.login-card button:hover { background: var(--accent-strong); }
.login-card button:disabled { opacity: 0.6; cursor: default; }

/* ---------- 등록/수정 폼 ---------- */
.form-wrap { max-width: 560px; margin: 0 auto; padding: 20px; }
.field { margin-bottom: 26px; }
.field > label { display: block; font-size: 0.95rem; font-weight: 700; margin-bottom: 10px; }
.hint { font-weight: 500; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
#location {
  width: 100%; padding: 14px 16px; font-size: 1.1rem; font-weight: 500;
  border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface); color: var(--ink);
}
#content {
  width: 100%; padding: 14px 16px; font-size: 0.98rem; line-height: 1.6;
  border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface); color: var(--ink); resize: vertical;
}
#location:focus, #content:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.photo-tile, .add-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  overflow: hidden;
}
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile .remove-btn {
  position: absolute; top: 5px; right: 5px;
  width: 26px; height: 26px; border-radius: 50%;
  border: none; background: rgba(20,26,33,0.72); color: #fff;
  font-size: 1.05rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.add-tile {
  border: 1.5px dashed var(--line);
  background: var(--surface-2);
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.add-tile:hover { border-color: var(--accent); color: var(--accent); }

.form-actions { display: flex; gap: 12px; margin-top: 32px; }
.btn-primary, .btn-secondary {
  flex: 1; text-align: center; padding: 15px; border-radius: var(--radius-md);
  font-size: 1.02rem; font-weight: 700; border: none; cursor: pointer; text-decoration: none;
}
.btn-primary {
  background: var(--accent); color: var(--accent-contrast);
  display: flex; align-items: center; justify-content: center; gap: 9px;
}
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:disabled { opacity: 0.85; cursor: default; }
.btn-secondary { background: var(--surface-2); color: var(--ink); }
.btn-secondary:hover { background: var(--line); }

.spinner {
  width: 18px; height: 18px; flex-shrink: 0;
  border: 2.5px solid color-mix(in srgb, var(--accent-contrast) 35%, transparent);
  border-top-color: var(--accent-contrast);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.4s; }
}

.error {
  color: var(--danger); font-size: 0.9rem; font-weight: 600;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  padding: 10px 14px; border-radius: var(--radius-md); margin: 4px 0 0;
}

@media (max-width: 420px) {
  .thumb { width: 104px; height: 104px; }
  .row { padding: 14px 16px; gap: 12px; }
  .topbar { padding: 12px 16px; }
}
