:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #1b1b1a;
  --muted: #76746e;
  --line: #e4e1da;
  --accent: #e8702a;
  --danger: #c63b2b;
  --warn: #b7791f;
  --ok: #2f8a4c;
  --chip: #efece6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161616;
    --card: #202020;
    --ink: #ecebe8;
    --muted: #9a978f;
    --line: #333;
    --accent: #f08a45;
    --danger: #ef6b5b;
    --warn: #d9a441;
    --ok: #5cba78;
    --chip: #2b2b2b;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--muted); font-size: 13px; }
.err { color: var(--danger); }

#login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
#login form { width: min(320px, 100%); display: grid; gap: 12px; }
#login h1 { margin: 0 0 8px; font-size: 22px; }
input, textarea {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; width: 100%;
}
button[type=submit], .btn {
  background: var(--ink); color: var(--bg); border: 0; border-radius: 10px; padding: 12px 16px; font-weight: 600;
}
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }

#app { max-width: 1100px; margin: 0 auto; padding: 0 16px 96px; }
header { display: flex; align-items: baseline; gap: 12px; padding: calc(env(safe-area-inset-top) + 16px) 0 8px; }
header h1 { margin: 0; font-size: 24px; }

nav#side {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav#side button { background: none; border: 0; padding: 12px 0; font-size: 13px; color: var(--muted); }
nav#side button.on { color: var(--ink); font-weight: 700; }

@media (min-width: 860px) {
  #app { display: grid; grid-template-columns: 160px 1fr; column-gap: 32px; padding-bottom: 48px; }
  header { grid-column: 1 / -1; }
  nav#side { position: sticky; top: 16px; align-self: start; display: flex; flex-direction: column; border: 0; background: none; padding: 0; }
  nav#side button { text-align: left; padding: 8px 12px; border-radius: 8px; font-size: 15px; }
  nav#side button.on { background: var(--chip); }
}

section.block { margin: 20px 0; }
section.block > h2 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 8px; letter-spacing: .02em; }
section.block > h2 .n { color: var(--ink); margin-left: 4px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.list > .item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-top: 1px solid var(--line); }
.list > .item:first-child { border-top: 0; }
.item .main { flex: 1; min-width: 0; }
.item .t { word-break: keep-all; overflow-wrap: anywhere; }
.item.done .t { text-decoration: line-through; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip { background: var(--chip); border-radius: 999px; padding: 1px 8px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.chip.late { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); font-weight: 600; }
.chip.soon { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); font-weight: 600; }
.chip.p2 { color: var(--danger); }
.chip.p1 { color: var(--accent); }

.check {
  flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%;
  border: 2px solid var(--line); background: none; padding: 0; display: grid; place-items: center;
}
.check.on { background: var(--ok); border-color: var(--ok); }
.check.on::after { content: ""; width: 6px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.date { flex: none; width: 52px; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); padding-top: 1px; }
.date b { display: block; color: var(--ink); font-size: 15px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.stat { padding: 12px 14px; }
.stat b { display: block; font-size: 22px; }
.stat.alert b { color: var(--danger); }

.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin: 12px 0; -webkit-overflow-scrolling: touch; }
.filters button { flex: none; background: var(--chip); border: 0; border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.filters button.on { background: var(--ink); color: var(--bg); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.pcard { padding: 14px 16px; }
.pcard h3 { margin: 0; font-size: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pcard .sum { color: var(--muted); font-size: 14px; margin: 4px 0 8px; }
.status { font-size: 12px; border-radius: 6px; padding: 1px 6px; font-weight: 600; background: var(--chip); }
.status.진행, .status.운영 { color: var(--ok); }
.status.실증, .status.제안 { color: var(--accent); }
.status.보류, .status.대기 { color: var(--muted); }
details > summary { cursor: pointer; color: var(--muted); font-size: 13px; list-style: none; margin-top: 8px; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { margin-bottom: 4px; }

.md { padding: 4px 16px 12px; overflow-x: auto; }
.md h1 { font-size: 18px; margin: 12px 0 4px; }
.md h2 { font-size: 15px; margin: 16px 0 4px; }
.md h3 { font-size: 14px; margin: 12px 0 4px; }
.md p, .md ul { margin: 6px 0; }
.md ul { padding-left: 18px; }
.md table { border-collapse: collapse; font-size: 13px; margin: 8px 0; min-width: 100%; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.md code { background: var(--chip); padding: 0 4px; border-radius: 4px; font-size: 12px; }
.md a { color: var(--accent); }
.search { margin: 12px 0; }
.empty { padding: 14px; color: var(--muted); font-size: 14px; }

#memo-btn {
  position: fixed; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 72px); z-index: 6;
  width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 28px; line-height: 1;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
@media (min-width: 860px) { #memo-btn { bottom: 24px; right: 24px; } }
dialog { border: 0; border-radius: 16px; padding: 0; width: min(420px, calc(100% - 32px)); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.35); }
#memo-form { padding: 20px; display: grid; gap: 10px; }
#memo-form h2 { margin: 0; font-size: 18px; }
.row { display: flex; gap: 8px; justify-content: flex-end; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 140px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 999px; font-size: 14px; z-index: 9; }
