:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --line: #e3e6eb;
  --text: #1c2330;
  --muted: #6b7482;
  --accent: #2f6ad9;
  --accent-soft: #e6eefc;
  --rent: #2f6ad9;
  --jeonse: #0f9d76;
  --purchase: #b06a00;
  --sale: #d1435b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171a20;
    --card: #20242c;
    --line: #2f3540;
    --text: #e8ebf0;
    --muted: #98a1b0;
    --accent: #6f9dff;
    --accent-soft: #263553;
    --rent: #6f9dff;
    --jeonse: #3fcaa0;
    --purchase: #e0a040;
    --sale: #ff7d92;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  user-select: none;
}

#app {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 10px 10px;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
button:hover { background: var(--line); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.bar {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 42px;
  -webkit-app-region: drag;
}
.bar button { -webkit-app-region: no-drag; }
.bar h1 {
  margin: 0 2px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.spacer { flex: 1; }
.icon { width: 26px; height: 26px; font-size: 16px; line-height: 1; padding: 0; }
.text { padding: 3px 8px; color: var(--accent); font-weight: 600; }
#pin { font-size: 12px; opacity: 0.35; }
#pin.on { opacity: 1; }
#refresh.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
body:not(.desktop) .desktop-only { display: none; }

.dow, .grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.dow span {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding-bottom: 3px;
}
.dow span:first-child, .day.sun .num { color: var(--sale); }
.dow span:last-child, .day.sat .num { color: var(--rent); }

.day {
  height: 50px;
  padding: 4px 0 0;
  background: var(--card);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.day:hover { background: var(--card); border-color: var(--accent); }
.day .num { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.day.other { opacity: 0.4; }
.day.today .num {
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 0 6px;
}
.day.selected { border-color: var(--accent); background: var(--accent-soft); }
.dots { display: flex; gap: 2px; height: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; }
.count { font-size: 10px; line-height: 1; color: var(--muted); font-variant-numeric: tabular-nums; }

.rent { --c: var(--rent); }
.jeonse { --c: var(--jeonse); }
.purchase { --c: var(--purchase); }
.sale { --c: var(--sale); }
.dot { background: var(--c); }

.grid.week .day { height: 92px; gap: 2px; }
.tag {
  display: flex;
  justify-content: space-between;
  gap: 2px;
  width: calc(100% - 4px);
  padding: 0 3px;
  border-radius: 3px;
  font-size: 10px;
  line-height: 15px;
  letter-spacing: -0.5px;
  white-space: nowrap;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 13%, transparent);
}
.tag b { font-variant-numeric: tabular-nums; }

.legend {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}
.legend[hidden] { display: none; }
.legend span { display: flex; align-items: center; gap: 3px; }

.agenda { margin-top: 8px; }
.agenda-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 2px 5px;
}
#status { font-size: 11px; color: var(--muted); }
.list {
  height: 292px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.list::-webkit-scrollbar { width: 6px; }
.list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.group {
  font-size: 11px;
  font-weight: 700;
  color: var(--c);
  padding: 4px 2px 0;
}
.card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--c);
  border-radius: 6px;
  padding: 6px 8px;
}
.card:hover { background: var(--card); border-color: var(--c); }
.card .top {
  display: flex;
  gap: 5px;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
}
.badge {
  color: var(--c);
  border: 1px solid var(--c);
  border-radius: 4px;
  padding: 0 4px;
  font-weight: 700;
  white-space: nowrap;
}
.card .where { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .name { font-weight: 700; margin: 2px 0 1px; overflow-wrap: anywhere; }
.card .when { font-variant-numeric: tabular-nums; }
.card .when b { color: var(--c); }
.card .more { display: none; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.card.open .more { display: block; }
.more .sub { color: var(--muted); font-size: 11px; margin-bottom: 4px; overflow-wrap: anywhere; }
.more table { border-collapse: collapse; width: 100%; font-size: 12px; }
.more td { padding: 1px 0; vertical-align: top; font-variant-numeric: tabular-nums; }
.more td:last-child { text-align: right; white-space: nowrap; padding-left: 8px; }
.more tr.now td { color: var(--c); font-weight: 700; }
.more .link { display: inline-block; margin-top: 5px; color: var(--accent); font-weight: 600; }

.empty { color: var(--muted); text-align: center; padding: 28px 0; }

.panel {
  position: absolute;
  inset: 0;
  background: var(--bg);
  padding: 0 10px 10px;
  display: flex;
  flex-direction: column;
}
.panel[hidden] { display: none; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 42px;
  font-size: 14px;
  -webkit-app-region: drag;
}
.panel-head button { -webkit-app-region: no-drag; }
.panel-body { overflow-y: auto; }
.panel h2 { font-size: 12px; margin: 10px 0 6px; }
.panel h2 small { font-weight: 400; color: var(--muted); margin-left: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

@media (min-width: 420px) {
  body:not(.desktop) .list { height: auto; max-height: none; }
}
body:not(.desktop) .list { height: auto; min-height: 200px; }

/* 웹·모바일(홈 화면에 추가한 앱 포함) */
body:not(.desktop) { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body:not(.desktop) #app {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
body:not(.desktop) .bar { height: 48px; position: sticky; top: 0; z-index: 2; background: var(--bg); }
body:not(.desktop) .icon { width: 36px; height: 36px; font-size: 19px; }
body:not(.desktop) .text { padding: 7px 10px; }
body:not(.desktop) .chip { padding: 8px 14px; }
body:not(.desktop) .panel { position: fixed; z-index: 3; padding-top: env(safe-area-inset-top); }
body:not(.desktop) .card { padding: 9px 10px; }
@media (max-width: 430px) {
  body:not(.desktop) .dow, body:not(.desktop) .grid { gap: 2px; }
  body:not(.desktop) .tag { font-size: 9.5px; letter-spacing: -0.8px; padding: 0 2px; width: calc(100% - 2px); }
  body:not(.desktop) .tag b { letter-spacing: -0.3px; }
}
@media (hover: none) { button:hover { background: none; } }
