:root {
  color-scheme: light dark;
  --bg: #f7f7f8;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #666;
  --border: #e2e2e5;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --warn-bg: #fff7e6;
  --warn-border: #f0c36d;
  --ok: #16a34a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181c;
    --card: #212227;
    --text: #eaeaea;
    --muted: #9a9a9a;
    --border: #34353b;
    --accent: #3b82f6;
    --accent-text: #ffffff;
    --danger: #f87171;
    --warn-bg: #2a230f;
    --warn-border: #6b5321;
    --ok: #4ade80;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 16px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  max-width: 720px;
  margin-inline: auto;
}

h1 { font-size: 1.3rem; margin-bottom: 4px; }
.subtitle { color: var(--muted); font-size: 0.85rem; margin-bottom: 20px; }

nav.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
nav.tabs a {
  padding: 6px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}
nav.tabs a.active { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }

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

.item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.item.disputed { border-color: var(--warn-border); background: var(--warn-bg); }
.item-title { font-weight: 600; }
.item-meta { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}
.badge.confirmed { background: rgba(22,163,74,0.15); color: var(--ok); }
.badge.disputed { background: rgba(240,195,109,0.25); color: #a5720b; }

label { display: block; font-size: 0.85rem; margin: 10px 0 4px; color: var(--muted); }
input[type=text], input[type=date], input[type=password], input[type=file], select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}
.checkbox-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 0.85rem; }
.checkbox-row input { width: auto; }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-text);
  margin-top: 12px;
}
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.danger { background: var(--danger); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.small { padding: 4px 10px; font-size: 0.8rem; margin-top: 0; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }

.hint { font-size: 0.78rem; color: var(--muted); margin-top: 6px; }
.msg { font-size: 0.85rem; margin-top: 8px; padding: 8px 10px; border-radius: 8px; }
.msg.ok { background: rgba(22,163,74,0.12); color: var(--ok); }
.msg.err { background: rgba(220,38,38,0.12); color: var(--danger); }

.dispute-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.dispute-actions { display: flex; gap: 8px; margin-top: 10px; }

.view-toggle { display: flex; gap: 6px; margin-bottom: 12px; }
.view-toggle button { margin-top: 0; }
.view-toggle button.inactive { background: transparent; color: var(--accent); border: 1px solid var(--accent); }

.pin-row { display: flex; gap: 6px; align-items: center; }
.pin-row input { flex: 1; min-width: 0; }
.pin-row button { white-space: nowrap; }

.cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cal-title { font-weight: 600; }
.cal-nav { display: flex; gap: 6px; }
.cal-nav button { margin-top: 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: 0.68rem; color: var(--muted); text-align: center; padding: 2px 0 6px; }
.cal-cell {
  min-height: 58px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  font-size: 0.68rem;
  overflow: hidden;
}
.cal-cell.outside { opacity: 0.35; }
.cal-cell.today { border-color: var(--accent); border-width: 2px; }
.cal-date { font-weight: 600; margin-bottom: 2px; font-size: 0.72rem; }
.cal-chip {
  display: block;
  width: 100%;
  text-align: left;
  background: rgba(22,163,74,0.15);
  color: var(--ok);
  border: none;
  border-radius: 4px;
  padding: 1px 4px;
  margin: 0 0 2px;
  font-size: 0.65rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: inherit;
}
.cal-chip.disputed { background: rgba(240,195,109,0.25); color: #a5720b; }
.cal-chip.selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-more { font-size: 0.62rem; color: var(--muted); }

.cal-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; font-size: 0.72rem; color: var(--muted); margin-bottom: 8px; }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.legend-dot.confirmed { background: var(--ok); }
.legend-dot.disputed { background: #a5720b; }

.cal-detail-row { grid-column: 1 / -1; margin: 2px 0 6px; }
.cal-detail-row .item { position: relative; font-size: 0.85rem; }
.cal-detail-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0 6px;
  margin: 0;
  font-size: 1rem;
  line-height: 1.4;
}

.attach-section { margin-top: 10px; }
.attach-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.attach-thumb {
  position: relative;
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  padding: 0;
  margin: 0;
  background: none;
  cursor: pointer;
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-file {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.78rem;
  text-decoration: none;
  color: var(--text);
  background: var(--bg);
}
.attach-cat {
  font-size: 0.6rem;
  color: var(--accent-text);
  background: rgba(37,99,235,0.75);
  padding: 1px 5px;
  border-radius: 999px;
}
.attach-thumb .attach-cat { position: absolute; bottom: 3px; right: 3px; }
.attach-form { margin-top: 8px; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 1000;
  padding: 24px;
}
.lightbox[hidden] { display: none; }
.lightbox-scroll {
  max-width: 100%;
  max-height: 75vh;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.lightbox-scroll.zoomed { justify-content: flex-start; }
.lightbox img { max-width: 100%; max-height: 75vh; border-radius: 8px; cursor: zoom-in; }
.lightbox-scroll.zoomed img { cursor: zoom-out; }
.lightbox-zoom-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.15);
  padding: 6px 14px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.8rem;
}
.lightbox-zoom-controls button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: none;
  padding: 0;
  margin: 0;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
#lightbox-zoom-level { min-width: 3.2em; text-align: center; }
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0;
  margin: 0;
  cursor: pointer;
}
.lightbox-original { color: #fff; font-size: 0.8rem; text-decoration: underline; margin-top: 0; }
