/* =========================================================
   Tokens
   ========================================================= */
:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f1f1ef;
  --text: #1c1c1e;
  --muted: #8a8a8e;
  --line: #ebebe8;
  --hover: #f3f3f1;
  --accent: #3b5bdb;
  --accent-soft: #e8edff;
  --danger: #e03131;
  --sun: #e03131;
  --sat: #1c7ed6;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --radius: 16px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214;
    --surface: #1b1b1e;
    --surface-2: #232327;
    --text: #ececef;
    --muted: #85858c;
    --line: #2a2a2e;
    --hover: #242428;
    --accent: #748ffc;
    --accent-soft: #262d4a;
    --danger: #ff6b6b;
    --sun: #ff6b6b;
    --sat: #4dabf7;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

/* =========================================================
   Base
   ========================================================= */
* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo",
    "Noto Sans KR", "Segoe UI", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

/* =========================================================
   Buttons & fields
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 11px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.icon { width: 38px; padding: 0; }
.btn.icon svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary svg { width: 16px; height: 16px; }
.btn.danger { color: var(--danger); background: var(--surface); }
.btn.block { width: 100%; height: 46px; font-size: 15px; }

.link-btn {
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 16px;
  padding: 8px 4px;
  min-width: 44px;
}
.link-btn.strong { font-weight: 700; }

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.field span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input {
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 16px; /* >=16px prevents iOS zoom on focus */
  outline: none;
}
.field input:focus { border-color: var(--accent); background: var(--surface); }

.form-error { color: var(--danger); font-size: 14px; min-height: 1em; }
.form-error:empty { display: none; }

/* =========================================================
   Login
   ========================================================= */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px calc(24px + var(--safe-b));
}
.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
}
.login-logo { margin: 0 auto 4px; border-radius: 16px; }
.login-card h1 { font-size: 24px; letter-spacing: -0.02em; }
.login-sub { color: var(--muted); margin-top: -8px; margin-bottom: 8px; }

/* =========================================================
   Shell — mobile first: bottom tab bar
   ========================================================= */
.shell { min-height: 100dvh; }

.nav {
  position: fixed;
  z-index: 20;
  left: 0; right: 0; bottom: 0;
  display: flex;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--line);
}
.nav-brand { display: none; }
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.nav-item svg { width: 24px; height: 24px; stroke-width: 1.8; }
.nav-item[aria-current="page"] { color: var(--accent); }

.main {
  padding-top: var(--safe-t);
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  background: var(--bg);
}
.topbar-actions { display: flex; gap: 6px; }
.title-btn {
  display: flex;
  align-items: baseline;
  gap: 8px;
  border: 0;
  background: none;
  padding: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.title-btn .year { font-size: 17px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.page-title { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; }

.desktop-only { display: none; }

.fab {
  position: fixed;
  z-index: 15;
  right: 18px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 18px);
  width: 56px;
  height: 56px;
  border-radius: 18px;
  border: 0;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform .15s;
}
.fab:active { transform: scale(.94); }
.fab svg { width: 26px; height: 26px; stroke-width: 2.4; }
.shell:not([data-view="calendar"]):not([data-view="todos"]) .fab { display: none; }

/* =========================================================
   Calendar grid
   ========================================================= */
.cal {
  margin: 0 8px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px 4px 6px;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); }
.weekdays div {
  padding: 8px 0 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.weekdays .sun { color: var(--sun); }
.weekdays .sat { color: var(--sat); }

.grid { display: flex; flex-direction: column; }
.grid.slide-next { animation: slide-next .22s ease; }
.grid.slide-prev { animation: slide-prev .22s ease; }
@keyframes slide-next { from { opacity: 0; transform: translateX(24px); } }
@keyframes slide-prev { from { opacity: 0; transform: translateX(-24px); } }

.day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 4px 2px;
  border: 0;
  border-radius: 12px;
  background: none;
  transition: background .12s;
}
.day .num {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 500;
  flex: none;
}
.day.sun .num { color: var(--sun); }
.day.sat .num { color: var(--sat); }
.day.other { opacity: .32; }
.day.today .num { background: var(--accent); color: #fff; font-weight: 700; }
.day.selected:not(.today) .num { background: var(--text); color: var(--bg); font-weight: 700; }

/* Week rows: day cells underneath, an overlay grid of event bars on top.
   Lanes start at --bar-top; a bar spans grid columns, so multi-day events read as one band. */
.week {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  height: 58px;
}
.week-bars {
  position: absolute;
  left: 0; right: 0; top: 37px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: 4px;
  row-gap: 2px;
  pointer-events: none;
}
/* Mobile: thin coloured lines, taps fall through to the day cell */
.ev-bar {
  min-width: 0;
  height: 4px;
  margin: 0 3px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: var(--c);
  font-size: 0;
  overflow: hidden;
  pointer-events: none;
}
.ev-bar.timed { margin: 0 9px; }
.ev-bar.cont-left { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.ev-bar.cont-right { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.ev-bar.private { background: transparent; box-shadow: inset 0 0 0 1px var(--c); }
.week-bars .more { display: none; }

/* =========================================================
   Agenda / event lists
   ========================================================= */
.agenda { padding: 20px 16px 24px; }
.agenda-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.agenda-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }

.event-list { display: flex; flex-direction: column; gap: 8px; }
.event {
  display: flex;
  align-items: stretch;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  transition: transform .1s;
}
.event:active { transform: scale(.985); }
.event-bar { width: 4px; border-radius: 4px; background: var(--c); flex: none; }
.event-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.event-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-meta { display: flex; gap: 8px; font-size: 13px; color: var(--muted); }
.event-who { display: inline-flex; align-items: center; gap: 5px; }
.event-who::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

.empty-state {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  border: 1.5px dashed var(--line);
  border-radius: 14px;
}
.empty-state .btn { margin-top: 12px; }

.upcoming { padding: 4px 16px 24px; display: flex; flex-direction: column; gap: 20px; }

/* =========================================================
   Members
   ========================================================= */
.members-body { padding: 4px 16px 24px; display: flex; flex-direction: column; gap: 14px; max-width: 560px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.section-label { font-size: 13px; font-weight: 700; color: var(--muted); margin: 8px 4px -4px; }
.member-list { padding: 4px 16px; }
.member { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.member + .member { border-top: 1px solid var(--line); }
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--c);
  color: #fff;
  font-weight: 700;
  flex: none;
}
.avatar.lg { width: 52px; height: 52px; font-size: 20px; }
.me { display: flex; align-items: center; gap: 14px; }
.me strong { font-size: 18px; display: block; }
.install-card { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

/* =========================================================
   Editor — bottom sheet on mobile, modal on desktop
   ========================================================= */
.sheet {
  border: 0;
  padding: 0;
  margin: auto auto 0;
  width: 100%;
  max-width: 100%;
  max-height: calc(100dvh - var(--safe-t) - 24px);
  border-radius: 20px 20px 0 0;
  background: var(--bg);
  color: var(--text);
  padding-bottom: var(--safe-b);
  overflow: auto;
}
.sheet[open] { animation: sheet-up .28s cubic-bezier(.2,.9,.3,1); }
.sheet::backdrop { background: rgba(0,0,0,.35); animation: fade .2s; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.sheet-grip { width: 36px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; }
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
}
.sheet-head h2 { font-size: 16px; font-weight: 700; }
.sheet-body { padding: 8px 16px 20px; display: flex; flex-direction: column; gap: 14px; }

.title-input, .note, .group {
  width: 100%;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  outline: none;
}
.title-input { height: 52px; padding: 0 16px; font-size: 18px; font-weight: 600; }
.note { padding: 14px 16px; font-size: 16px; resize: vertical; min-height: 88px; }
.group { padding: 0 16px; }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
}
.row + .row { border-top: 1px solid var(--line); }
.row > span { white-space: nowrap; flex: none; }
.row-inputs { display: flex; gap: 6px; min-width: 0; justify-content: flex-end; }
.row-inputs input {
  min-width: 0;
  height: 36px;
  border: 0;
  border-radius: 9px;
  background: var(--surface-2);
  padding: 0 10px;
  font-size: 16px;
  outline: none;
}
.row-inputs input:focus { box-shadow: 0 0 0 2px var(--accent); }
.row-inputs input[type="date"] { flex: 1 1 0; }
.row-inputs input[type="time"] { flex: none; padding: 0 6px; }
.all-day .time { display: none; }

.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 51px;
  height: 31px;
  border-radius: 31px;
  background: var(--line);
  position: relative;
  margin: 0;
  transition: background .2s;
  cursor: pointer;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
  transition: transform .2s;
}
.switch:checked { background: #34c759; }
.switch:checked::after { transform: translateX(20px); }

/* =========================================================
   Toast
   ========================================================= */
.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 90px);
  transform: translate(-50%, 20px);
  padding: 10px 18px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* =========================================================
   Tablet / desktop (≥ 900px): left rail + calendar + side agenda
   ========================================================= */
@media (min-width: 900px) {
  .shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    height: 100dvh;
  }

  .nav {
    position: static;
    flex-direction: column;
    height: auto;
    padding: 20px 12px;
    gap: 4px;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-top: 0;
  }
  .nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px 20px;
    font-weight: 800;
    font-size: 16px;
  }
  .nav-brand img { border-radius: 9px; }
  .nav-item {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    height: 44px;
    padding: 0 12px;
    border-radius: 11px;
    font-size: 15px;
    color: var(--text);
  }
  .nav-item svg { width: 20px; height: 20px; color: var(--muted); }
  .nav-item:hover { background: var(--hover); }
  .nav-item[aria-current="page"] { background: var(--surface); box-shadow: var(--shadow); color: var(--text); }
  .nav-item[aria-current="page"] svg { color: var(--accent); }

  .main { padding: 0; min-width: 0; overflow: auto; }
  .desktop-only { display: inline-flex; }
  .fab { display: none; }
  .toast { bottom: 32px; }

  .topbar { padding: 22px 24px 16px; }
  .title-btn { font-size: 30px; }

  .view-calendar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100dvh;
  }
  .view-calendar .topbar { grid-column: 1 / -1; }
  .cal {
    margin: 0 0 24px 24px;
    display: flex;
    flex-direction: column;
    padding: 4px 10px 10px;
  }
  .weekdays div { text-align: left; padding: 10px 10px 8px; }
  .grid { flex: 1; min-height: 0; }
  .week { flex: 1; min-height: 0; height: auto; border-top: 1px solid var(--line); }
  .week-bars { top: 34px; grid-auto-rows: 20px; }

  .day {
    min-height: 0;
    align-items: stretch;
    padding: 6px;
    overflow: hidden;
    border-radius: 0;
  }
  .day:hover { background: var(--hover); }
  .day.selected { background: var(--accent-soft); }
  .day .num { width: 28px; height: 28px; font-size: 14px; }
  .day.selected:not(.today) .num { background: none; color: inherit; }

  /* Desktop: titled bars; clicking one opens the event */
  .ev-bar {
    height: 20px;
    margin: 0 4px;
    padding: 0 7px;
    border-radius: 5px;
    font-size: 12px;
    line-height: 20px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    text-overflow: ellipsis;
    background: color-mix(in srgb, var(--c) 18%, var(--surface));
    color: color-mix(in srgb, var(--c) 72%, var(--text));
    pointer-events: auto;
    cursor: pointer;
  }
  .ev-bar:hover { background: color-mix(in srgb, var(--c) 28%, var(--surface)); }
  .ev-bar.span { border-left: 3px solid var(--c); }
  .ev-bar.span.cont-left { border-left: 0; }
  .ev-bar.timed { margin: 0 4px; background: none; padding-left: 14px; position: relative; color: var(--text); font-weight: 500; }
  .ev-bar.timed:hover { background: var(--hover); }
  .ev-bar.timed::before {
    content: "";
    position: absolute;
    left: 4px; top: 7px;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--c);
  }
  .ev-bar.private.span { box-shadow: none; background: color-mix(in srgb, var(--c) 7%, var(--surface)); border: 1px dashed color-mix(in srgb, var(--c) 60%, transparent); }
  .ev-bar.private.timed { box-shadow: none; }
  .week-bars .more {
    display: block;
    height: 16px;
    margin: 0 4px;
    padding: 0 6px;
    border: 0;
    background: none;
    font-size: 11px;
    line-height: 16px;
    color: var(--muted);
    text-align: left;
    pointer-events: auto;
    cursor: pointer;
  }
  .week-bars .more:hover { color: var(--text); }

  .agenda { padding: 0 24px 24px; overflow: auto; }
  .agenda-head { flex-direction: column; gap: 2px; padding-top: 6px; }
  .agenda-head h2 { font-size: 22px; }

  .members-body { padding: 4px 24px 24px; }

  .sheet {
    margin: auto;
    width: 480px;
    border-radius: 20px;
    padding-bottom: 0;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
  }
  .sheet[open] { animation: pop .2s ease; }
  .sheet-grip { display: none; }
  .sheet-head { padding: 12px 12px 4px; }
  @keyframes pop { from { opacity: 0; transform: scale(.96); } }
}

@media (min-width: 1300px) {
  .view-calendar { grid-template-columns: minmax(0, 1fr) 360px; }
}

/* =========================================================
   Selects, settings rows, reminder bell
   ========================================================= */
.select {
  height: 36px;
  max-width: 60%;
  border: 0;
  border-radius: 9px;
  background: var(--surface-2);
  padding: 0 10px;
  font-size: 16px;
  outline: none;
}
.select:focus { box-shadow: 0 0 0 2px var(--accent); }
.row small { font-size: 12px; margin-left: 4px; }

.settings { display: flex; flex-direction: column; gap: 4px; padding: 6px 16px 14px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; }
.setting + .setting { border-top: 1px solid var(--line); }
.setting strong { font-weight: 600; }
.setting .switch { flex: none; }
.setting .switch:disabled { opacity: .4; cursor: default; }
.settings .btn { align-self: flex-start; margin-top: 4px; }

.bell { width: 13px; height: 13px; stroke-width: 2.2; color: var(--accent); vertical-align: -2px; }

/* =========================================================
   Categories, todos, checklist
   ========================================================= */
.cat-chip {
  display: inline-flex;
  align-items: center;
  height: 19px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  background: color-mix(in srgb, var(--c) 15%, transparent);
  color: color-mix(in srgb, var(--c) 80%, var(--text));
}
.event-meta { flex-wrap: wrap; align-items: center; row-gap: 2px; }
.progress { font-weight: 600; }
.progress.complete { color: #2b8a3e; }

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 11px;
  background: var(--surface-2);
}
.segmented button {
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.filter-chips {
  display: flex;
  gap: 6px;
  padding: 2px 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
}
.filter-chip .dot, .todo-group h3 .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.filter-chip .count { font-size: 12px; color: var(--muted); }
.filter-chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.filter-chip[aria-pressed="true"] .count { color: inherit; opacity: .7; }

.todo-groups { padding: 0 16px; display: flex; flex-direction: column; gap: 18px; }
.todo-group h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 4px 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}
.todo-group h3.overdue { color: var(--danger); }
.todo-group h3 .count { font-weight: 600; opacity: .7; }
.todo-list { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }

.todo { display: flex; align-items: flex-start; gap: 4px; padding: 4px 6px 4px 4px; }
.todo + .todo { border-top: 1px solid var(--line); }
.todo-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 6px;
  border: 0;
  background: none;
  text-align: left;
}
.todo-title { font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.todo-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.todo-meta .due.soon { color: var(--accent); font-weight: 600; }
.todo-meta .due.overdue { color: var(--danger); font-weight: 600; }
.todo-meta .linked { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-meta .assignee { display: inline-flex; align-items: center; gap: 4px; }
.todo-meta .assignee::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.todo.done .todo-title { color: var(--muted); text-decoration: line-through; }

.check {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  background: none;
  display: grid;
  place-items: center;
  padding: 0;
}
.check::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--muted) 70%, transparent);
  transition: background .15s, border-color .15s;
}
.check[aria-pressed="true"]::before {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E") center / 14px no-repeat;
}

.show-done {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 20px 16px 28px;
  color: var(--muted);
  font-size: 14px;
}
.show-done input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Checklist inside the event editor */
.checklist-box { background: var(--surface); border-radius: 14px; padding: 6px 6px 10px; }
.checklist-head { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 10px 4px; font-weight: 600; }
.checklist li { display: flex; align-items: center; }
.checklist li.done .checklist-title { color: var(--muted); text-decoration: line-through; }
.checklist-title {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  text-align: left;
  padding: 8px 2px;
  font-size: 15px;
  overflow-wrap: anywhere;
}
.checklist-input {
  width: calc(100% - 12px);
  margin: 4px 6px 0;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-2);
  padding: 0 12px;
  font-size: 16px;
  outline: none;
}
.checklist-input:focus { box-shadow: 0 0 0 2px var(--accent); }
.icon-x {
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}
.icon-x:hover { color: var(--danger); }
.event-link { font-size: 15px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Category management */
.category-card { padding: 6px 12px 12px; }
.category-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.category-row + .category-row { border-top: 1px solid var(--line); }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 0; background: var(--c); flex: none; margin: 0 4px; }
.category-name { flex: 1; text-align: left; border: 0; background: none; padding: 10px 4px; font-size: 15px; font-weight: 500; }
.category-empty { padding: 12px 4px; }
.inline-add { display: flex; gap: 8px; margin-top: 8px; }
.inline-add input {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 0 12px;
  font-size: 16px;
  outline: none;
}
.inline-add input:focus { border-color: var(--accent); }

@media (min-width: 900px) {
  .filter-chips { padding: 2px 24px 14px; }
  .todo-groups { padding: 0 24px; max-width: 760px; }
  .show-done { justify-content: flex-start; padding-left: 28px; }
}

/* =========================================================
   Upcoming timeline, side panels, settings grid
   ========================================================= */
.month-sep { font-size: 13px; font-weight: 700; color: var(--muted); margin: 6px 4px -8px; }
.day-head { display: flex; align-items: baseline; gap: 6px; margin: 0 4px 8px; }
.day-num { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.day-info { display: inline-flex; align-items: baseline; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.day-head.sun .day-num { color: var(--sun); }
.day-head.sat .day-num { color: var(--sat); }
.day-block.is-today .day-num { color: var(--accent); }
.rel { color: var(--accent); font-weight: 700; }

.todo-toolbar { display: flex; flex-direction: column; }
.todo-toolbar .show-done { justify-content: flex-start; padding: 0 20px 12px; font-size: 13px; }

/* Side panels only exist on wide screens */
.side-panel { display: none; }
.panel-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.panel-card h3 { margin: 0 0 12px; font-size: 13px; font-weight: 700; color: var(--muted); }
.big-stat { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.big-stat strong { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar span { display: block; height: 100%; width: var(--p); background: var(--c); border-radius: 3px; transition: width .3s; }
.stat-pills { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.pill { font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.stat-list { display: flex; flex-direction: column; gap: 10px; }
.stat-list li { display: flex; flex-direction: column; gap: 6px; }
.stat-list li.stat-row { flex-direction: row; }
.stat-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; background: none; padding: 0; font-size: 14px; text-align: left;
}
.stat-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.stat-row .name { flex: 1; font-weight: 600; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat-grid div { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-radius: 12px; background: var(--surface-2); }
.stat-grid strong { font-size: 24px; font-weight: 800; }
.stat-grid span { font-size: 12px; }
.prep-list { display: flex; flex-direction: column; gap: 6px; }
.prep-item {
  width: 100%; display: flex; flex-direction: column; gap: 3px; text-align: left;
  border: 0; border-left: 3px solid var(--c); border-radius: 6px; background: var(--surface-2); padding: 8px 10px;
}
.prep-title { font-weight: 600; font-size: 14px; }
.prep-meta { display: flex; gap: 8px; font-size: 12.5px; color: var(--muted); }
.prep-meta .dday { font-weight: 700; color: var(--accent); }

.settings-section { display: flex; flex-direction: column; gap: 14px; }

@media (min-width: 900px) {
  .side-panel {
    display: flex; flex-direction: column; gap: 14px;
    overflow-y: auto; padding: 0 24px 24px 0; min-height: 0;
  }

  /* ----- Todos: board columns + progress panel ----- */
  .view-todos {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    grid-template-rows: auto auto minmax(0, 1fr);
    height: 100dvh;
  }
  .view-todos .topbar { grid-column: 1 / -1; }
  .todo-toolbar {
    grid-column: 1; flex-direction: row; align-items: center; justify-content: space-between;
    gap: 12px; padding: 0 24px 14px; min-width: 0;
  }
  .todo-toolbar .filter-chips { padding: 0; min-width: 0; }
  .todo-toolbar .show-done { padding: 0; flex: none; }
  .view-todos .side-panel { grid-column: 2; grid-row: 2 / 4; }

  .todo-groups {
    grid-column: 1; grid-row: 3;
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr);
    gap: 14px; align-items: start;
    max-width: none; min-height: 0;
    overflow-x: auto; padding: 0 24px 24px;
  }
  .todo-groups > .empty-state { grid-column: 1 / -1; }
  .todo-group {
    display: flex; flex-direction: column; max-height: 100%; min-height: 0;
    background: var(--surface-2); border-radius: 16px; padding: 12px 10px 10px;
  }
  .todo-group h3 { margin: 0 6px 10px; flex: none; }
  .todo-group .todo-list { overflow-y: auto; min-height: 0; box-shadow: none; }
  .todo-group .todo { background: var(--surface); }
  .todo-group .todo-list { background: none; display: flex; flex-direction: column; gap: 6px; }
  .todo-group .todo { border-radius: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
  .todo-group .todo + .todo { border-top: 0; }

  /* ----- Upcoming: date column timeline + summary panel ----- */
  .view-upcoming {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100dvh;
  }
  .view-upcoming .topbar { grid-column: 1 / -1; }
  .view-upcoming .upcoming { overflow-y: auto; max-width: none; padding: 0 24px 24px; gap: 12px; }
  .view-upcoming .side-panel { grid-column: 2; grid-row: 2; }
  .month-sep { font-size: 15px; color: var(--text); margin: 12px 0 0; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .day-block { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 16px; align-items: start; }
  .day-head { flex-direction: column; gap: 2px; margin: 4px 0 0; }
  .day-num { font-size: 30px; line-height: 1; }
  .day-info { flex-direction: column; gap: 2px; }
  .day-block .event-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }

  /* ----- Settings: two columns ----- */
  .members-body {
    max-width: 1080px;
    display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; row-gap: 14px;
    grid-template-areas:
      "me categories"
      "members categories"
      "account push";
    align-items: start;
  }
  .settings-section[data-area="me"] { grid-area: me; }
  .settings-section[data-area="members"] { grid-area: members; }
  .settings-section[data-area="categories"] { grid-area: categories; }
  .settings-section[data-area="push"] { grid-area: push; }
  .settings-section[data-area="account"] { grid-area: account; }
  .settings-section .section-label { margin-top: 0; }
}

/* =========================================================
   Folders & files
   ========================================================= */
.view-folders { position: relative; }
.btn-label { display: none; }
.btn:disabled.primary { filter: grayscale(.6); }

.breadcrumb {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  padding: 0 12px 10px; font-size: 14px;
}
.crumb {
  border: 0; background: none; padding: 6px 6px; border-radius: 8px;
  color: var(--muted); font-weight: 600; max-width: 180px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crumb:hover { background: var(--hover); }
.crumb[aria-current="page"] { color: var(--text); }
.crumb-sep { color: var(--muted); opacity: .6; }

.folder-tree { display: none; }
.file-area { padding: 0 16px 24px; min-height: 40vh; }
.file-list { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.file-list > .empty-state { background: var(--bg); box-shadow: none; margin: 0; }
.file-row { display: flex; align-items: center; transition: background .12s; }
.file-row + .file-row { border-top: 1px solid var(--line); }
.file-row.drop-hover { background: var(--accent-soft); }
.file-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px;
  padding: 12px 6px 12px 14px; border: 0; background: none; text-align: left;
}
.file-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.file-name {
  display: flex; align-items: center; gap: 6px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-meta { font-size: 12.5px; color: var(--muted); }
.cat-tag { font-size: 10.5px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
.more-btn {
  flex: none; width: 44px; height: 44px; border: 0; background: none;
  color: var(--muted); font-size: 20px; border-radius: 10px;
}
.more-btn:hover { background: var(--hover); color: var(--text); }

.folder-icon { width: 34px; height: 34px; flex: none; stroke: none; fill: var(--c, #fab005); }
.ftype {
  flex: none; width: 34px; height: 40px; border-radius: 6px;
  display: grid; place-items: end center; padding-bottom: 5px;
  font-size: 9.5px; font-weight: 800; letter-spacing: .02em; color: #fff;
  background: var(--c);
  clip-path: polygon(0 0, 70% 0, 100% 22%, 100% 100%, 0 100%);
}

.drop-hint { text-align: center; padding: 14px 0 0; }
.drop-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 3px dashed var(--accent);
  pointer-events: none;
}
.drop-overlay div {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 18px 28px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow);
}
.drop-overlay strong { font-size: 18px; }

/* Upload dialog */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 28px 16px; border: 2px dashed var(--line); border-radius: 16px;
  background: var(--surface); text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone svg { width: 30px; height: 30px; color: var(--accent); }
.dropzone:hover, .dropzone.drop-hover { border-color: var(--accent); background: var(--accent-soft); }
.upload-list { display: flex; flex-direction: column; gap: 8px; }
.upload-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: 12px; padding: 10px 12px; }
.upload-row .ftype { width: 28px; height: 34px; font-size: 8.5px; }
.upload-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.upload-status { flex: none; min-width: 54px; text-align: right; }
.upload-row.done .upload-status { color: #2b8a3e; font-weight: 600; }
.upload-row.failed .upload-status { color: var(--danger); font-weight: 600; }
.upload-row.failed .bar span { background: var(--danger); }

/* Action sheet */
.action-sheet { padding: 0 12px calc(12px + var(--safe-b)); }
.action-title { text-align: center; color: var(--muted); font-size: 13px; padding: 10px 16px 8px; overflow-wrap: anywhere; }
.action-list { display: flex; flex-direction: column; background: var(--surface); border-radius: 14px; overflow: hidden; }
.action {
  height: 52px; border: 0; background: var(--surface); font-size: 16px; font-weight: 500; color: var(--accent);
}
.action + .action { border-top: 1px solid var(--line); }
.action.danger { color: var(--danger); }
.action.cancel { width: 100%; margin-top: 8px; border-radius: 14px; font-weight: 700; color: var(--text); }

@media (min-width: 900px) {
  .btn-label { display: inline; }
  .view-folders {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    height: 100dvh;
  }
  .view-folders .topbar { grid-column: 1 / -1; }
  .breadcrumb { grid-column: 2; padding: 0 24px 12px 20px; }
  .folder-tree {
    display: block; grid-column: 1; grid-row: 2 / 4;
    overflow-y: auto; padding: 0 8px 24px 24px;
  }
  .file-area { grid-column: 2; grid-row: 3; overflow-y: auto; padding: 0 24px 24px 20px; }
  .file-list { max-width: 1100px; }
  .drop-hint { max-width: 1100px; }

  .tree { list-style: none; }
  .tree-item {
    width: 100%; display: flex; align-items: center; gap: 8px;
    height: 36px; padding: 0 10px 0 calc(10px + var(--depth, 0) * 16px);
    border: 0; background: none; border-radius: 9px; text-align: left; font-size: 14px;
  }
  .tree-item:hover { background: var(--hover); }
  .tree-item[aria-current="page"] { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
  .tree-item.drop-hover { background: var(--accent-soft); }
  .tree-item.root { font-weight: 700; color: var(--muted); margin-bottom: 4px; }
  .tree-item .folder-icon { width: 18px; height: 18px; }
  .tree-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tree-count { font-size: 12px; color: var(--muted); }

  .action-sheet { width: 360px; padding-bottom: 12px; }
}

.label-long { display: none; }
@media (hover: none) { .drop-hint { display: none; } }
@media (min-width: 900px) {
  .label-long { display: inline; }
  .label-short { display: none; }
}

/* =========================================================
   Private (나만 보기) items
   ========================================================= */
.lock { font-size: .85em; margin-right: 4px; }
.checklist-title.private::before { content: "🔒 "; font-size: .85em; }

.todo-toolbar .visibility { align-self: flex-start; margin: 0 16px 10px; }
@media (min-width: 900px) {
  .todo-toolbar .visibility { margin: 0; flex: none; }
}

/* =========================================================
   HWP/HWPX viewer
   ========================================================= */
.viewer {
  border: 0; padding: 0; margin: 0;
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  background: #e9e9e6; color: var(--text);
  display: flex; flex-direction: column;
}
.viewer:not([open]) { display: none; }
.viewer::backdrop { background: rgba(0,0,0,.4); }
@media (prefers-color-scheme: dark) { .viewer { background: #0d0d0f; } }
.viewer-bar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + var(--safe-t)) 10px 8px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.viewer-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.viewer-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.viewer-tools { display: flex; gap: 4px; }
.viewer-tools .btn.icon { font-size: 18px; }
.zoom-label { padding: 0 8px; min-width: 58px; font-variant-numeric: tabular-nums; }
.viewer-scroll { flex: 1; overflow: auto; padding: 16px 12px calc(24px + var(--safe-b)); }
.viewer-status { text-align: center; color: var(--muted); padding: 40px 0; }
.hwp-pages {
  width: var(--zoom, 100%); max-width: none; margin: 0 auto;
  display: flex; flex-direction: column; gap: 14px;
}
.hwp-holder {
  width: 100%; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.15);
  display: grid; place-items: center;
}
.hwp-holder.loaded { aspect-ratio: auto !important; }
.hwp-page { display: block; width: 100%; height: auto; }
.hwp-page-error { color: #868e96; padding: 24px; }
.hwp-fail { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 16px; text-align: center; }
@media (max-width: 899px) { .zoom-label { display: none; } }
@media (min-width: 900px) {
  .hwp-pages { width: calc(820px * var(--zoom-n, 1)); }
  .viewer-scroll { padding: 24px; }
}

/* =========================================================
   Folder selection, bulk actions, drag & drop moves
   ========================================================= */
.list-head {
  display: flex; align-items: center; gap: 6px;
  padding: 0 6px 6px; font-size: 13px; font-weight: 600; color: var(--muted);
}
.sel-wrap { display: none; align-items: center; justify-content: center; width: 40px; flex: none; align-self: stretch; cursor: pointer; }
.sel { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.selecting .sel-wrap { display: flex; }
.selecting .list-head { display: flex; }
.list-head { display: none; }
.file-row.selected { background: var(--accent-soft); }
.file-row[draggable="true"] { -webkit-user-drag: element; }
.selecting .file-row .file-main { padding-left: 4px; }

.bulk-bar {
  position: fixed; z-index: 30;
  left: 12px; right: 12px; bottom: calc(var(--nav-h) + var(--safe-b) + 10px);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; border-radius: 16px;
  background: var(--surface); box-shadow: 0 8px 28px rgba(0,0,0,.18); border: 1px solid var(--line);
}
.bulk-bar strong { font-size: 14px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bulk-actions { display: flex; gap: 6px; width: 100%; }
.bulk-actions .btn { flex: 1; height: 36px; padding: 0 6px; font-size: 13px; }
.view-folders.selecting .file-area { padding-bottom: 120px; }
.shell:not([data-view="folders"]) .bulk-bar { display: none; }

.drag-ghost {
  position: fixed; top: -100px; left: -100px; padding: 6px 12px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; pointer-events: none;
}
.crumb.drop-hover, .tree-item.drop-hover, .file-row.drop-hover {
  background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent);
}

/* Move/copy target picker */
.target-list { display: flex; flex-direction: column; background: var(--surface); border-radius: 14px; padding: 6px; max-height: 55dvh; overflow-y: auto; }
.target-item {
  width: 100%; display: flex; align-items: center; gap: 8px; text-align: left;
  height: 42px; padding: 0 10px 0 calc(10px + var(--depth, 0) * 16px);
  border: 0; border-radius: 10px; background: none; font-size: 15px;
}
.target-item .folder-icon { width: 20px; height: 20px; }
.target-item:hover:not(:disabled) { background: var(--hover); }
.target-item[aria-pressed="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); font-weight: 600; }
.target-item:disabled { opacity: .35; cursor: not-allowed; }

@media (min-width: 900px) {
  /* Desktop: checkboxes are always there; the 선택 toggle is only for touch */
  .select-toggle { display: none; }
  .sel-wrap, .list-head { display: flex; }
  .list-head { max-width: 1100px; }
  .file-row .file-main { padding-left: 4px; }
  .bulk-bar {
    position: sticky; bottom: 16px; left: auto; right: auto;
    margin: 14px 0 0; max-width: 1100px; flex-wrap: nowrap;
  }
  .bulk-actions { width: auto; }
  .bulk-actions .btn { flex: none; padding: 0 14px; }
  .view-folders.selecting .file-area { padding-bottom: 24px; }
}

/* Office viewer: the library owns scrolling inside a bounded-height host */
.office-host { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.office-surface { flex: 1; min-height: 0; width: 100%; height: 100%; }
#office-viewer .viewer-status { flex: none; }
@media (min-width: 900px) {
  /* "맞춤" fits the page to this width: readable pages instead of edge-to-edge on big monitors */
  .office-host[data-kind="docx"] .office-surface { max-width: 960px; margin: 0 auto; }
  .office-host[data-kind="pptx"] .office-surface { max-width: 1200px; margin: 0 auto; }
}
