:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --line: #e4e7ec;
  --accent: #1c58d9;
  --accent-soft: #e8efff;
  --mention: #b45309;
  --mention-bg: #fef3c7;
  --code-bg: #f1f3f5;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --card: #1c2027;
    --text: #e6e8eb;
    --muted: #9aa3ae;
    --line: #2c323b;
    --accent: #6ea0ff;
    --accent-soft: #1e2a44;
    --mention: #fbbf24;
    --mention-bg: #3a2f12;
    --code-bg: #252a32;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.btn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 34px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .5; cursor: default; }

/* ── header ── */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 860px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { font-size: 26px; line-height: 1; }
.title h1 { font-size: 18px; margin: 0; line-height: 1.3; }
.channel-header { font-size: 12.5px; color: var(--muted); }
.channel-header p { margin: 0; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.actions form { margin: 0; }
#search input {
  height: 34px; width: 200px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 14px;
}
#search input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* ── layout ── */
.wrap { max-width: 860px; margin: 0 auto; padding: 12px 16px 48px; }
.readonly-note { font-size: 12.5px; color: var(--muted); margin: 4px 0 12px; }
.feed { display: flex; flex-direction: column; gap: 10px; }
.day-sep {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); font-size: 12.5px; font-weight: 600; margin: 14px 0 2px;
}
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ── post ── */
.post {
  display: flex; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; box-shadow: var(--shadow);
}
.post.flash { animation: flash 2s ease-out; }
@keyframes flash { from { border-color: var(--accent); background: var(--accent-soft); } }
.post.compact { border: 0; border-radius: 0; box-shadow: none; padding: 10px 0; border-top: 1px solid var(--line); background: transparent; }
.avatar {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.avatar.bot { background: var(--code-bg); color: var(--muted); }
.body { min-width: 0; flex: 1; }
.meta { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.name { font-weight: 700; }
.tag { font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 4px; background: var(--code-bg); color: var(--muted); }
time { color: var(--muted); font-size: 12.5px; }
.permalink { margin-left: auto; color: var(--muted); font-size: 13px; opacity: 0; transition: opacity .15s; }
.post:hover .permalink, .permalink:focus { opacity: 1; }
@media (hover: none) { .permalink { opacity: .6; } }

.msg { overflow-wrap: anywhere; }
.msg > :first-child { margin-top: 2px; }
.msg > :last-child { margin-bottom: 0; }
.msg p { margin: 0 0 6px; }
.msg ul, .msg ol { margin: 4px 0 6px; padding-left: 22px; }
.msg blockquote { margin: 6px 0; padding: 2px 12px; border-left: 3px solid var(--line); color: var(--muted); }
.msg code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.msg pre { background: var(--code-bg); padding: 10px 12px; border-radius: 8px; overflow-x: auto; }
.msg pre code { padding: 0; background: none; }
.msg table { border-collapse: collapse; margin: 6px 0; display: block; overflow-x: auto; }
.msg th, .msg td { border: 1px solid var(--line); padding: 4px 10px; }
.msg h1, .msg h2, .msg h3, .msg h4 { margin: 8px 0 4px; line-height: 1.35; }
.msg h1 { font-size: 20px; } .msg h2 { font-size: 18px; } .msg h3 { font-size: 16px; }
.msg img { max-width: 100%; }
.mention { color: var(--mention); background: var(--mention-bg); border-radius: 4px; padding: 0 3px; font-weight: 600; }

.attach { margin-top: 8px; padding: 6px 12px; border-left: 4px solid var(--line); border-radius: 4px; background: var(--bg); }
.attach-title { font-weight: 700; }
.fields { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 6px 0 0; }
.fields > div { flex: 1 1 100%; }
.fields > div.short { flex: 1 1 calc(50% - 20px); }
.fields dt { font-weight: 700; font-size: 13px; }
.fields dd { margin: 0; }

.images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.images img {
  display: block; max-width: 240px; max-height: 180px; border-radius: 8px;
  border: 1px solid var(--line); object-fit: cover; background: var(--bg);
}
.file {
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); max-width: 520px;
}
.file .ext {
  flex: none; font-size: 10.5px; font-weight: 800; letter-spacing: .02em;
  padding: 4px 6px; border-radius: 6px; background: #e5484d; color: #fff; min-width: 38px; text-align: center;
}
.file .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file .dl { font-size: 16px; }
.reactions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.reactions span { font-size: 13px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); }
.replies-btn { margin-top: 8px; border: 0; background: none; color: var(--accent); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 0; }
.thread { margin-top: 6px; padding-left: 10px; border-left: 2px solid var(--line); }

.pinned { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; margin-bottom: 12px; }
.pinned summary { cursor: pointer; font-weight: 700; }
.pinned .count { color: var(--muted); font-weight: 400; }
.search-result { margin-bottom: 16px; }
.search-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 700; }
.new-banner { position: sticky; top: 70px; z-index: 5; display: flex; justify-content: center; margin-bottom: 8px; }
.new-banner button {
  border: 0; border-radius: 999px; padding: 6px 16px; background: var(--accent); color: #fff;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.more { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 18px; }
.empty { text-align: center; color: var(--muted); padding: 32px 0; }

/* ── calendar ── */
:root { --sat: #2563eb; --red: #dc2626; --vac: #0f766e; --vac-bg: #dcf5ef; --late: #b45309; --late-bg: #fdf0d5; --today: #1c58d9; }
@media (prefers-color-scheme: dark) {
  :root { --sat: #7aa7ff; --red: #ff7b72; --vac: #5eead4; --vac-bg: #12352f; --late: #fbbf24; --late-bg: #3a2c10; --today: #6ea0ff; }
}
.calendar {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px 14px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.cal-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.cal-title { font-size: 17px; margin: 0 6px; min-width: 104px; text-align: center; }
.cal-nav { height: 30px; padding: 0 10px; }
.small-btn { font-size: 13px; }
.cal-legend { margin-left: auto; display: flex; gap: 6px; }
.cal-error { margin: 0 0 8px; font-size: 13px; color: var(--late); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-dow { text-align: center; font-size: 12.5px; font-weight: 700; padding: 4px 0; color: var(--muted); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--bg); }
.cal-dow.sun { color: var(--red); }
.cal-dow.sat { color: var(--sat); }
.cal-day {
  position: relative; min-height: 92px; padding: 4px 5px 6px; min-width: 0;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px; cursor: pointer; outline: none;
}
.cal-day:hover { background: var(--bg); }
.cal-day:focus-visible, .cal-day.selected { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day.out { opacity: .45; }
.cal-num { font-size: 13px; font-weight: 700; line-height: 1.4; }
.cal-day.blue .cal-num { color: var(--sat); }
.cal-day.red .cal-num { color: var(--red); }
.cal-day.today .cal-num {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--today); color: #fff;
}
.cal-hol { font-size: 11px; color: var(--red); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-hol.inline { font-size: 12.5px; margin-left: 4px; }
.chip {
  display: block; font-size: 11.5px; line-height: 1.35; padding: 1px 5px; border-radius: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--code-bg); color: var(--text);
}
.cal-legend .chip, .detail-list .chip { display: inline-block; font-weight: 700; }
.chip.vac { background: var(--vac-bg); color: var(--vac); }
.chip.late { background: var(--late-bg); color: var(--late); }
.chip b { font-weight: 700; color: var(--text); }
.chip-type { font-weight: 600; }
.chip-reason { display: block; color: var(--muted); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; }
.cal-more { font-size: 11px; color: var(--muted); }
.cal-count { display: none; }
.cal-detail-panel:empty { display: none; }
.cal-detail-panel { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg); }
.detail-title { font-weight: 700; margin-bottom: 6px; }
.detail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.detail-reason { margin: 2px 0 0 4px; font-size: 13.5px; color: var(--muted); }
.detail-empty { margin: 0; font-size: 13.5px; }

/* ── login ── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow);
}
.brand { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.login-card p { margin: 0; font-size: 13.5px; }
.login-card input[type=password] {
  height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit;
}
.login-card button {
  height: 42px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font: inherit; font-weight: 700; cursor: pointer;
}
.remember { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.error { color: #e5484d; }

@media (max-width: 600px) {
  .top-inner { padding: 8px 12px; }
  .actions { width: 100%; }
  #search { flex: 1; }
  #search input { width: 100%; }
  .wrap { padding: 10px 10px 40px; }
  .post { padding: 12px; gap: 10px; }
  .avatar { width: 32px; height: 32px; font-size: 14px; }
  .images img { max-width: 100%; }
  .new-banner { top: 110px; }
  /* 폰: 칸에는 숫자·인원수만, 내용은 아래 상세 패널에서 */
  .calendar { padding: 10px 8px 12px; }
  .cal-legend { width: 100%; margin-left: 0; justify-content: flex-end; }
  .cal-day { min-height: 54px; padding: 3px; align-items: center; }
  .cal-day .chip, .cal-day .cal-hol, .cal-more { display: none; }
  .cal-day .cal-count {
    display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
    font-size: 11px; font-weight: 700; background: var(--accent-soft); color: var(--accent);
  }
}
