:root {
  --bg: #f4f5f7; --card: #fff; --text: #1d2330; --muted: #667085; --line: #e3e6eb;
  --brand: #1f5fbf; --brand-dark: #174a96; --danger: #c0392b; --ok-bg: #e7f5ec; --ok: #1d7a43;
  --err-bg: #fdecea; --mark: #fff1a8;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171c; --card: #1d2128; --text: #e6e8eb; --muted: #9aa3ae; --line: #2e343d;
    --brand: #5b9bf0; --brand-dark: #7fb0f3; --ok-bg: #173323; --ok: #6fd39a; --err-bg: #3a1d1b; --mark: #5a4b00; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
mark { background: var(--mark); color: inherit; padding: 0 1px; border-radius: 2px; }

.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-inner { max-width: 1040px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 18px; color: var(--text); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--text); }
.nav a.on, .nav a:hover { background: var(--bg); text-decoration: none; }
.me { font-size: 14px; color: var(--muted); }
main { max-width: 1040px; margin: 0 auto; padding: 20px 16px 60px; }

h1 { font-size: 24px; margin: 4px 0 16px; }
h2 { font-size: 18px; margin: 24px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.item { display: block; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--text); }
.item:last-child { border-bottom: none; }
a.item:hover { background: var(--bg); text-decoration: none; }
.item .t { font-weight: 600; }
.item .m { font-size: 14px; color: var(--muted); }
.item .s { font-size: 14px; margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.empty { padding: 24px; text-align: center; color: var(--muted); }

.btn, button { display: inline-block; font: inherit; font-size: 15px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; }
.btn:hover, button:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary, button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover, button.primary:hover { background: var(--brand-dark); }
.btn.danger, button.danger { color: var(--danger); }
button.link { border: none; background: none; padding: 0; color: var(--brand); font-size: inherit; }

label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 4px; }
input[type=text], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text); }
textarea { min-height: 120px; resize: vertical; }
textarea.big { min-height: 320px; font-family: Consolas, monospace; font-size: 14px; }
input[type=file] { font: inherit; font-size: 14px; max-width: 100%; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; align-items: end; }
.filters { margin-bottom: 12px; }
.filters label { margin-top: 0; }
.actions { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--danger); }

.searchbar { display: flex; gap: 8px; }
.searchbar input { flex: 1; font-size: 17px; padding: 11px 14px; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 4px; }
.quick a { text-align: center; padding: 14px 8px; font-weight: 600; }
.stats { display: flex; gap: 16px; font-size: 14px; color: var(--muted); margin-top: 8px; }

dl.meta { display: grid; grid-template-columns: 90px 1fr; gap: 6px 12px; margin: 0; }
dl.meta dt { color: var(--muted); font-size: 14px; }
dl.meta dd { margin: 0; word-break: break-word; }
.content { white-space: pre-wrap; word-break: break-word; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.photos img { width: 100%; height: 150px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.filelist li { margin: 4px 0; }
pre.text { white-space: pre-wrap; word-break: break-word; font-size: 14px; max-height: 480px; overflow: auto;
  background: var(--bg); padding: 12px; border-radius: 8px; }
.hist { font-size: 14px; }
.hist li { margin-bottom: 6px; }
.hist .chg { color: var(--muted); }

table.users { width: 100%; border-collapse: collapse; font-size: 15px; }
table.users th, table.users td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.users form { display: inline; }
.authbox { max-width: 380px; margin: 8vh auto; }

/* 메모 사진 (단계별) */
.steps { display: grid; gap: 10px; margin-top: 8px; }
.step { display: grid; grid-template-columns: 200px 1fr; gap: 12px; align-items: start; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.step img { width: 100%; max-height: 260px; object-fit: contain; border-radius: 8px; background: var(--bg); }
.stepbody label { margin-top: 0; }
@media (max-width: 700px) { .step { grid-template-columns: 1fr; } }
a.item.withthumb { display: flex; gap: 12px; align-items: flex-start; }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); flex: none; }

/* 사진 표 */
.tablewrap { overflow-x: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; max-height: 70vh; overflow-y: auto; }
table.sheet { border-collapse: collapse; font-size: 14px; min-width: 100%; }
table.sheet th, table.sheet td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0; }
table.sheet thead th { position: sticky; top: 0; background: var(--bg); z-index: 1; white-space: nowrap; }
table.sheet input[type=text] { border: none; border-radius: 0; padding: 7px 8px; min-width: 90px; width: 100%; background: transparent; font-size: 14px; }
table.sheet thead input[type=text] { font-weight: 700; }
table.sheet input[type=text]:focus { outline: 2px solid var(--brand); outline-offset: -2px; background: var(--card); }
table.sheet .rn { color: var(--muted); font-size: 12px; text-align: center; padding: 0 6px; min-width: 28px; }
table.sheet th { display: table-cell; }
table.sheet th > input { display: inline-block; width: calc(100% - 26px); }
button.x { border: none; background: none; color: var(--muted); padding: 4px 6px; font-size: 13px; }
button.x:hover { color: var(--danger); }
.savebar { position: sticky; bottom: 0; background: var(--card); padding: 8px 0; align-items: center; }
.sheetphotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.sheetphotos img { width: 100%; height: 140px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

@media (max-width: 700px) {
  .grid2, .grid4 { grid-template-columns: 1fr; }
  .quick { grid-template-columns: 1fr 1fr !important; }
  .top-inner { gap: 6px; }
  .me { width: 100%; }
  h1 { font-size: 21px; }
  table.users thead { display: none; }
  table.users td { display: block; border: none; padding: 4px 0; }
  table.users tr { display: block; border-bottom: 1px solid var(--line); padding: 10px 0; }
}
