/* 하루한판 - 디자인 토큰 + 화면 스타일 (라이트/다크) */
:root {
  --bg: #f4f5f7; --panel: #fff; --text: #1f2328; --muted: #6b7280; --line: #e3e5e8;
  --accent: #2563eb; --accent-soft: #e8efff;
  --danger: #dc2626; --warn: #d97706; --ok: #16a34a;
  --sun: #dc2626; --sat: #2563eb; --today: #fff7d6;
  --shadow: 0 1px 2px rgba(0,0,0,.06);
  /* SQL 강조: 키워드 함수 문자열 숫자 주석 힌트 바인드변수 따옴표식별자 */
  --sk: #1d4ed8; --sf: #7c3aed; --ss: #b45309; --sn: #0f766e; --sc: #6b7280; --sh: #15803d; --sb: #be185d; --si: #0e7490;
  --code-bg: #f7f8fa;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #15171a; --panel: #1e2125; --text: #e6e8eb; --muted: #9aa1a9; --line: #2e3238;
  --accent: #5b8cff; --accent-soft: #233150;
  --danger: #f87171; --warn: #fbbf24; --ok: #4ade80;
  --sun: #f87171; --sat: #7aa2ff; --today: #3a3420;
  --shadow: none;
  --sk: #7aa2ff; --sf: #c4a5ff; --ss: #fbbf77; --sn: #5eead4; --sc: #8b949e; --sh: #86efac; --sb: #f9a8d4; --si: #67e8f9;
  --code-bg: #181a1e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 700; }
h2 { font-size: 15px; }
code, pre, .mono { font-family: Consolas, "D2Coding", ui-monospace, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ───────── 입력·버튼 ───────── */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=date], input[type=time], input[type=password], select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; width: 100%; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--ok); margin: 0; cursor: pointer; flex: none; }

button {
  background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: 6px;
  padding: 6px 12px; cursor: pointer; white-space: nowrap;
}
button:hover { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button.ghost:hover { border-color: var(--accent); color: var(--accent); filter: none; }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.icon { background: transparent; color: var(--muted); border: 0; padding: 2px 6px; }
button.icon:hover { color: var(--accent); filter: none; }
button.small { padding: 3px 8px; font-size: 12px; }

/* ───────── 상단 바 ───────── */
.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 8px 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { font-weight: 800; font-size: 16px; letter-spacing: -.3px; white-space: nowrap; }
.brand span { color: var(--accent); }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.tabs a {
  text-decoration: none; color: var(--muted); padding: 6px 11px; border-radius: 6px; white-space: nowrap;
}
.tabs a:hover { color: var(--text); background: var(--bg); }
.tabs a.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.tools { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.save-state {
  font-size: 12px; color: var(--muted); margin-right: 4px; white-space: nowrap;
  max-width: 240px; overflow: hidden; text-overflow: ellipsis;
}
.save-state.err { color: var(--danger); font-weight: 700; }

main { max-width: 1280px; margin: 0 auto; padding: 20px; }

/* ───────── 공통 패널·카드 ───────── */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; box-shadow: var(--shadow);
}
.panel > h2, .panel-head { margin-bottom: 10px; }
.panel-head { display: flex; align-items: center; gap: 8px; }
.panel-head h2 { margin: 0; }
.panel-head .grow { flex: 1; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.empty { color: var(--muted); padding: 12px 0; text-align: center; font-size: 13px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--panel);
  border-radius: 16px; padding: 3px 11px; cursor: pointer; color: var(--muted); font-size: 13px;
}
.chip:hover { color: var(--text); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.chip .n { font-size: 11px; opacity: .8; }
.tag {
  display: inline-block; background: var(--accent-soft); color: var(--accent); border-radius: 10px;
  padding: 0 8px; font-size: 12px; line-height: 20px; white-space: nowrap;
}
.badge { display: inline-block; border-radius: 10px; padding: 0 7px; font-size: 11px; line-height: 18px; font-weight: 700; }
.badge.doing { color: var(--warn); border: 1px solid var(--warn); }
.badge.lang { color: var(--muted); border: 1px solid var(--line); font-weight: 400; }
.pri { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--line); }
.pri.high { background: var(--danger); }
.pri.mid { background: var(--warn); }
.due { font-size: 12px; color: var(--muted); white-space: nowrap; }
.due.over { color: var(--danger); font-weight: 700; }
.due.today { color: var(--warn); font-weight: 700; }

/* ───────── 홈 ───────── */
.hello { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.hello h1 { font-size: 22px; letter-spacing: -.5px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { cursor: default; }
.stat.link { cursor: pointer; }
.stat.link:hover { border-color: var(--accent); }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 26px; font-weight: 800; line-height: 1.2; }
.stat .value small { font-size: 13px; font-weight: 400; color: var(--muted); }
.stat.danger .value { color: var(--danger); }
.stat.warn .value { color: var(--warn); }
.bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--ok); }
.home-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; }
.day-group + .day-group { margin-top: 8px; }
.day-group .d { font-size: 12px; color: var(--muted); font-weight: 700; }
.day-group .d.today { color: var(--accent); }
.ev-line { display: flex; gap: 8px; align-items: center; padding: 2px 0; }
.ev-dot { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.dday-row { display: flex; justify-content: space-between; padding: 4px 0; gap: 8px; }
.dday-row b { color: var(--accent); white-space: nowrap; }
.note-card { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.note-card + .note-card { margin-top: 8px; }
.note-card:hover { border-color: var(--accent); }
.note-card .body { color: var(--muted); font-size: 12px; white-space: pre-wrap; max-height: 3.2em; overflow: hidden; }

/* ───────── 할 일 ───────── */
.quick-add { display: grid; grid-template-columns: minmax(0, 1fr) 150px 100px 140px auto; gap: 8px; margin-bottom: 12px; }
.quick-add.team { grid-template-columns: minmax(0, 1fr) 150px 100px 120px 120px auto; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters .grow { flex: 1; }
.filters input[type=search] { width: 200px; }
.todo-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line);
}
.todo-row:last-child { border-bottom: 0; }
.todo-row .main { flex: 1; min-width: 0; cursor: pointer; }
.todo-row .title { overflow-wrap: anywhere; }
.todo-row.done .title { text-decoration: line-through; color: var(--muted); }
.todo-row .meta { display: flex; gap: 6px; align-items: center; margin-top: 1px; flex-wrap: wrap; }
.todo-row .meta:empty { display: none; }
.todo-row .acts { display: flex; gap: 2px; visibility: hidden; }
.todo-row:hover .acts { visibility: visible; }

/* ───────── 보드 ───────── */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.col { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.col-head { display: flex; align-items: center; gap: 6px; font-weight: 700; margin-bottom: 8px; }
.col-head .n { color: var(--muted); font-weight: 400; font-size: 12px; }
.col-head .dot { width: 8px; height: 8px; border-radius: 50%; }
.col input[type=text] { width: 100%; margin-bottom: 8px; }
.col-list { min-height: 60px; display: flex; flex-direction: column; gap: 6px; }
.col.over .col-list { outline: 2px dashed var(--accent); outline-offset: 2px; border-radius: 8px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: grab;
  box-shadow: var(--shadow);
}
.card:hover { border-color: var(--accent); }
.card.dragging { opacity: .4; }
.card .title { display: flex; gap: 6px; align-items: center; overflow-wrap: anywhere; }
.card .title .t { min-width: 0; }
.card.done .title .t { text-decoration: line-through; color: var(--muted); }
.card .meta { display: flex; gap: 6px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.col-note { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ───────── 달력 ───────── */
.cal-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-head h2 { font-size: 18px; min-width: 120px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal .wd { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal .wd.sun, .cal .day.sun .num, .cal .day.hol .num { color: var(--sun); }
.cal .wd.sat, .cal .day.sat .num { color: var(--sat); }
.cal .day {
  min-height: 92px; padding: 3px 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  cursor: pointer; overflow: hidden; min-width: 0;
}
.cal .day:hover { background: var(--bg); }
.cal .day.other { opacity: .45; }
.cal .day.today { background: var(--today); }
.cal .day.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal .num { font-size: 12px; font-weight: 700; }
.cal .hname { font-size: 11px; color: var(--sun); margin-left: 4px; }
.cal .ev {
  font-size: 11px; line-height: 17px; border-radius: 3px; padding: 0 4px; margin-top: 2px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal .td { font-size: 11px; line-height: 17px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .td.over { color: var(--danger); }
.cal .more { font-size: 11px; color: var(--muted); }
.side-item { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.side-item:last-child { border-bottom: 0; }
.side-item .ev-dot { margin-top: 6px; }
.palette { display: flex; gap: 6px; flex-wrap: wrap; }
.palette label { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.palette input { display: none; }
.palette input:checked + label { border-color: var(--text); }

/* ───────── 루틴 ───────── */
.routine-item { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.routine-item:last-child { border-bottom: 0; }
.routine-item .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.routine-item.checked .grow { color: var(--muted); text-decoration: line-through; }
.log-wrap { overflow-x: auto; }
/* 최근 기록: 행=루틴, 열=날짜(오른쪽 끝이 오늘). 루틴 이름 열은 가로 스크롤해도 고정 */
.log { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; }
.log th, .log td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: center; white-space: nowrap; }
.log thead th { border-top: 1px solid var(--line); }
.log th.r {
  position: sticky; left: 0; z-index: 1; background: var(--panel); border-left: 1px solid var(--line);
  text-align: left; font-weight: 400; max-width: 200px; overflow: hidden; text-overflow: ellipsis;
}
.log th.d { font-weight: 700; font-size: 12px; min-width: 44px; line-height: 1.25; }
.log th.d small { display: block; font-weight: 400; color: var(--muted); }
.log th.d.sun { color: var(--sun); }
.log th.d.sat { color: var(--sat); }
.log .today { background: var(--accent-soft); }
.log th.d.today { color: var(--accent); }
.log td.c { cursor: pointer; }
.log td.c:hover { background: var(--bg); }
.log td.c.on { color: var(--ok); font-weight: 800; }
.log tfoot th.r { font-weight: 700; }
.log td.cnt { font-size: 12px; color: var(--muted); }
.log td.cnt.full { color: var(--ok); font-weight: 700; }

/* ───────── 메모 ───────── */
.notes { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.note-list { display: flex; flex-direction: column; gap: 2px; max-height: calc(100vh - 220px); overflow-y: auto; }
.note-item { padding: 8px 10px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.note-item:hover { background: var(--bg); }
.note-item.on { background: var(--accent-soft); border-color: var(--accent); }
.note-item .t { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item .s { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor { display: flex; flex-direction: column; gap: 10px; }
.editor .title-in { font-size: 18px; font-weight: 700; border: 0; padding: 4px 0; background: transparent; width: 100%; }
.editor .title-in:focus { outline: 0; }
.editor textarea { min-height: calc(100vh - 300px); border: 0; padding: 0; background: transparent; line-height: 1.7; }
.editor textarea:focus { outline: 0; }

/* ───────── 스니펫 ───────── */
.snips { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr)); gap: 12px; }
.snip { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.snip-head { display: flex; align-items: center; gap: 6px; }
.snip-head .t { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snip pre {
  margin: 0; background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px;
  font-size: 12.5px; line-height: 1.55; overflow: auto; max-height: 320px; white-space: pre;
  user-select: text; -webkit-user-select: text; cursor: text;
}
.snip .memo { font-size: 12px; color: var(--muted); white-space: pre-wrap; }
.sk { color: var(--sk); font-weight: 700; } .sf { color: var(--sf); } .ss { color: var(--ss); } .sn { color: var(--sn); }
.sc { color: var(--sc); font-style: italic; } .sh { color: var(--sh); font-style: italic; } .sb { color: var(--sb); } .si { color: var(--si); }

/* highlight.js 토큰 → 같은 색 토큰 (라이트/다크 자동) */
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-section, .hljs-doctag, .hljs-name { color: var(--sk); font-weight: 700; }
.hljs-built_in, .hljs-title, .hljs-title.function_, .hljs-function .hljs-title { color: var(--sf); }
.hljs-string, .hljs-regexp, .hljs-template-string, .hljs-char.escape_ { color: var(--ss); }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-link { color: var(--sn); }
.hljs-comment, .hljs-quote { color: var(--sc); font-style: italic; }
.hljs-meta, .hljs-meta .hljs-keyword { color: var(--sh); }
.hljs-variable, .hljs-template-variable, .hljs-subst { color: var(--sb); }
.hljs-attr, .hljs-attribute, .hljs-property, .hljs-type, .hljs-title.class_, .hljs-selector-class, .hljs-selector-id { color: var(--si); }
.hljs-emphasis { font-style: italic; } .hljs-strong { font-weight: 700; }
.hljs-addition { color: var(--ok); } .hljs-deletion { color: var(--danger); }

/* ───────── 공간·팀 ───────── */
.space-pick { display: flex; align-items: center; gap: 2px; }
.space-pick select {
  border: 1px solid var(--line); border-left: 4px solid var(--c, var(--accent)); font-weight: 700; max-width: 200px; padding: 5px 8px;
}
.av {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: #fff; flex: none;
  font-size: 10.5px; font-weight: 700; letter-spacing: -.3px; line-height: 1;
}
.av.sm { width: 20px; height: 20px; font-size: 9.5px; }
.space-tag {
  display: inline-block; font-size: 11px; line-height: 18px; padding: 0 7px; border-radius: 9px; white-space: nowrap;
  color: var(--c, var(--muted)); border: 1px solid var(--c, var(--line)); background: transparent; font-weight: 700;
}
.group-label { font-size: 12px; color: var(--muted); font-weight: 700; margin-top: 6px; }
.team-panel { border-top: 3px solid var(--c); }
.team-members { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }
.tm { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.tm > div { min-width: 0; }
.acts-list { border-top: 1px solid var(--line); padding-top: 6px; }
.act-line { display: flex; gap: 8px; align-items: center; padding: 3px 0; font-size: 13px; }
.act-line > span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-line .t { color: var(--muted); }
.member-list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
.member { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.member:last-child { border-bottom: 0; }
.member select { padding: 3px 6px; font-size: 13px; }
.pending-user { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.pending-user:last-child { border-bottom: 0; }
.pending-user select { padding: 3px 6px; font-size: 13px; }
#btn-pending { background: var(--warn); border-color: var(--warn); }
.invite-box { background: var(--bg); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.invite-box select { padding: 3px 6px; font-size: 13px; }
/* 같이 보기: 저장 위치 표시, 공간 색 띠 */
#target-sel { border: 1px solid var(--line); border-left: 4px solid var(--c, var(--accent)); padding: 5px 8px; font-size: 13px; max-width: 180px; }
.save-to {
  display: inline-flex; align-items: center; font-size: 12px; white-space: nowrap; padding: 2px 8px; border-radius: 10px;
  color: var(--c); border: 1px dashed var(--c); align-self: center;
}
.card.mixed { border-left: 4px solid var(--c); }
.cal .ev.team-ev { outline: 1px solid rgba(255,255,255,.6); outline-offset: -2px; }
.quick-add.mixed { grid-template-columns: minmax(0, 1fr) 150px 100px 140px auto auto; }
.quick-add.mixed.team { grid-template-columns: minmax(0, 1fr) 150px 100px 120px 120px auto auto; }
.log td.c .who { display: block; font-size: 10px; color: var(--muted); font-weight: 400; line-height: 1.2; }
.card .meta .grow { flex: 1; }

/* ───────── 대화상자 ───────── */
dialog {
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text);
  padding: 0; width: min(520px, calc(100vw - 24px)); box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog form { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
dialog h3 { font-size: 16px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.full { grid-column: 1 / -1; }
.field > span { font-size: 12px; color: var(--muted); }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.field.check > span { font-size: 14px; color: var(--text); }
.dlg-acts { display: flex; gap: 8px; justify-content: flex-end; }
.dlg-acts .grow { flex: 1; }

/* ───────── 로그인 ───────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(360px, 92vw); display: flex; flex-direction: column; gap: 12px; padding: 24px; }
.login h1 { font-size: 20px; text-align: center; }
.login input { width: 100%; }
.login button { width: 100%; padding: 8px; }
.login .err { color: var(--danger); font-size: 12px; min-height: 18px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.or::before, .or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 8px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text);
  text-decoration: none; font-weight: 700; cursor: pointer; font: inherit;
}
.google-btn:hover { border-color: var(--accent); }
.account-google { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 8px; background: var(--bg); }

/* ───────── 반응형 ───────── */
/* 상단 바가 좁아지면 탭은 아래 줄 전체 폭으로 (넘치면 가로 스크롤) */
@media (max-width: 1100px) {
  .brand { order: 1; }
  .space-pick { order: 2; }
  .tools { order: 3; }
  .tabs { order: 4; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; min-width: 0; }
  .tabs::-webkit-scrollbar { display: none; }
}
@media (max-width: 900px) {
  .cal-wrap, .notes, .board, .home-grid, .cols-2, .cols-3 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-add, .quick-add.team, .quick-add.mixed, .quick-add.mixed.team { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-add input[name=title] { grid-column: 1 / -1; }
  .note-list { max-height: 260px; }
  .editor textarea { min-height: 50vh; }
}
@media (max-width: 600px) {
  .topbar-inner { padding: 8px 16px; gap: 8px; }
  .brand { order: 1; }
  .space-pick { order: 2; flex: 1; min-width: 0; }
  .space-pick select { max-width: 100%; flex: 1; min-width: 0; }
  .space-pick { flex-wrap: wrap; }
  .tools { order: 4; flex: 0 0 100%; justify-content: flex-end; flex-wrap: wrap; }
  .tabs { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  main { padding: 16px; }
  .filters input[type=search] { width: 100%; }
  .cal .day { min-height: 64px; }
  .cal .ev, .cal .td, .cal .hname { font-size: 10px; }
  .fields { grid-template-columns: minmax(0, 1fr); }
  .tools .label-text { display: none; }
}
@media (hover: none) {
  .todo-row .acts { visibility: visible; }
}
