:root {
  --bg: #191919;
  --sidebar: #202020;
  --raised: #252525;
  --hover: rgba(255, 255, 255, 0.055);
  --active: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.09);
  --text: rgba(255, 255, 255, 0.9);
  --muted: rgba(255, 255, 255, 0.5);
  --faint: rgba(255, 255, 255, 0.34);
  --blue: #2383e2;
  --blue-hover: #1b74c9;
  --danger: #e16259;
  --shadow: 0 16px 50px rgba(0, 0, 0, 0.45);
  --font: "Inter", "Segoe UI", sans-serif;
  --sidebar-w: 252px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { background: transparent; border: 0; }
textarea { resize: none; overflow: hidden; }
::selection { background: rgba(35, 131, 226, 0.45); }
:focus { outline: none; }
:focus-visible {
  outline: 2px solid rgba(35, 131, 226, 0.9);
  outline-offset: 1px;
}
#app, .app { height: 100%; }
.app { display: flex; min-height: 100dvh; background: var(--bg); }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  height: 100%;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  user-select: none;
  transition: width 0.16s ease, transform 0.16s ease;
}
.sidebar input, .sidebar textarea { user-select: text; }
.app.sidebar-collapsed .sidebar { width: 0; overflow: hidden; border-right-color: transparent; }
.sidebar-top {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 44px;
  padding: 0 8px;
  flex: none;
}
.side-scroll { flex: 1; overflow: auto; padding: 0 8px 16px; }
.sidebar-bottom {
  flex: none;
  padding: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.search-btn, .side-item, .side-link, .side-add, .bottom-link {
  width: 100%;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  color: rgba(255, 255, 255, 0.72);
  text-align: left;
}
.search-btn { margin: 0 8px 8px; width: calc(100% - 16px); background: rgba(255, 255, 255, 0.055); color: var(--muted); }
.search-btn span { flex: 1; }
.search-btn kbd, .hint kbd {
  font-family: inherit;
  font-size: 11px;
  color: var(--faint);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
  line-height: 16px;
}
.sidebar svg, .topbar svg, .btn svg, .mini-btn svg, .side-add svg, .icon-btn svg, .search-btn svg, .palette svg, .menu svg {
  width: 16px;
  height: 16px;
  min-width: 16px;
  flex: none;
}
.side-add { height: 30px; min-height: 30px; max-height: 30px; overflow: hidden; }
.side-link:hover, .side-item:hover, .side-add:hover, .bottom-link:hover, .search-btn:hover { background: var(--hover); color: var(--text); }
.side-link.is-active, .side-item.is-active { background: var(--active); color: #fff; }
.side-link { position: relative; }
.side-section { margin-top: 14px; }
.side-label {
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--faint);
}
.side-emoji { width: 18px; text-align: center; flex: none; font-size: 15px; line-height: 1; }
.side-label-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item { cursor: pointer; }
.side-item-actions { display: none; gap: 1px; margin-left: auto; }
.side-item:hover .side-item-actions, .side-item:focus-within .side-item-actions { display: flex; }
.mini-btn {
  width: 20px; height: 20px; border-radius: 4px;
  color: var(--muted); display: grid; place-items: center; font-size: 14px;
}
.mini-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.mini-star { color: #e3b341; font-size: 11px; }
.badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 11px;
  display: inline-grid;
  place-items: center;
}
.badge.warn { background: rgba(225, 98, 89, 0.18); color: #f0a8a2; }
.side-add { color: var(--muted); }

.scrim { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.topbar {
  height: 45px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px 0 8px;
  user-select: none;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 6px; min-width: 0; }
.topbar-right { flex: none; }
.crumb { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--muted); font-size: 14px; }
.crumb-emoji { font-size: 15px; }
.crumb-parent, .crumb-current { background: none; color: var(--muted); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb-current { color: var(--text); }
.crumb-parent:hover { color: var(--text); }
.edited { color: var(--faint); font-size: 13px; padding-right: 4px; }

.btn {
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}
.btn.outline { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); }
.btn.outline:hover, .btn.quiet:hover { background: var(--hover); }
.btn.quiet { color: var(--muted); font-weight: 400; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-hover); }
.btn.danger, .danger-text { color: var(--danger); }
.icon-btn {
  width: 28px; height: 28px; border-radius: 6px;
  display: grid; place-items: center; color: var(--muted);
}
.icon-btn:hover { background: var(--hover); color: #fff; }
.icon-btn.is-on { color: #e3b341; }

.content { flex: 1; overflow: auto; scrollbar-gutter: stable; }
.page-inner { max-width: 1080px; margin: 0 auto; padding: 28px 56px 96px; }
.cover { height: 30vh; min-height: 180px; max-height: 280px; }
.has-cover .page-inner { margin-top: -52px; position: relative; }
.page-head { position: relative; }
.quick-row { display: flex; gap: 2px; min-height: 28px; margin-bottom: 2px; }
.page-icon {
  font-size: 72px;
  line-height: 1;
  margin: 0 0 6px;
  padding: 0;
  background: none;
  cursor: pointer;
  border-radius: 8px;
}
.page-icon:hover { background: rgba(255, 255, 255, 0.04); }
.page-title, .static-title {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.8px;
  line-height: 1.15;
  color: #fff;
  background: transparent;
}
.page-title::placeholder { color: rgba(255, 255, 255, 0.28); }
.page-desc {
  width: 100%;
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  max-height: 140px;
}
.page-desc::placeholder { color: var(--faint); }
.lede { margin: 8px 0 0; color: var(--muted); font-size: 15px; }

.composer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
}
.composer-label { color: var(--faint); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; margin-right: 2px; }
.composer-btn, .chip-btn {
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.composer-btn:hover, .chip-btn:hover { background: rgba(255, 255, 255, 0.08); }
.dot, .swatch { width: 8px; height: 8px; border-radius: 99px; background: var(--c); flex: none; }
.swatch { border-radius: 2px; }

.section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section h2 { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: rgba(255, 255, 255, 0.78); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.item-line {
  width: 100%;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 7px 8px;
  border-radius: 6px;
  text-align: left;
  color: var(--text);
}
.item-line:hover { background: var(--hover); }
.item-line b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty {
  padding: 10px 8px;
  color: var(--faint);
}

.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.subject-card {
  text-align: left;
  min-height: 108px;
  padding: 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.subject-card:hover { background: rgba(255, 255, 255, 0.055); }
.subject-card-icon { font-size: 22px; line-height: 1; }
.subject-card-title { font-weight: 600; }

.props { margin-top: 18px; display: flex; flex-direction: column; gap: 2px; }
.prop { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px; align-items: center; min-height: 32px; }
.prop-label { color: var(--muted); }
.prop input { width: 100%; height: 28px; padding: 0 6px; border-radius: 4px; }
.prop input:hover, .prop input:focus { background: rgba(255, 255, 255, 0.05); }
.prop input::placeholder { color: var(--faint); }

.db { margin-top: 22px; }
.db-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.views, .filters { display: flex; gap: 2px; flex-wrap: wrap; }
.views { padding: 2px; border-radius: 8px; background: rgba(255, 255, 255, 0.03); }
.view-btn, .filter-btn {
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.view-btn svg { width: 15px; height: 15px; }
.view-btn.is-on, .filter-btn.is-on { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.view-btn:hover, .filter-btn:hover { color: var(--text); }
.db-toolbar .btn { margin-left: auto; }
.db-head, .db-row {
  display: grid;
  grid-template-columns: var(--cols);
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 0 8px;
}
.db-head { color: var(--faint); font-size: 12px; border-bottom: 1px solid var(--line); }
.db-row { border-bottom: 1px solid rgba(255, 255, 255, 0.045); border-radius: 4px; cursor: pointer; }
.db-row:hover { background: rgba(255, 255, 255, 0.04); }
.cell-title { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 500; }
.cell-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.date.warn { color: #f0a8a2; }
.add-row {
  width: 100%;
  text-align: left;
  color: var(--faint);
  padding: 8px;
  border-radius: 6px;
}
.add-row:hover { background: var(--hover); color: var(--muted); }

.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  background: color-mix(in srgb, var(--c) 24%, transparent);
  color: color-mix(in srgb, var(--c) 28%, white);
  max-width: 100%;
}
.pill:hover { filter: brightness(1.08); }
.pill-btn { cursor: pointer; }

.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.board-col {
  width: 270px;
  flex: none;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 8px;
  min-height: 160px;
}
.board-col.drop-hot { background: rgba(35, 131, 226, 0.14); }
.board-col-head { display: flex; align-items: center; gap: 8px; padding: 4px 4px 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.board-col-head .count { color: var(--faint); font-weight: 500; }
.board-col-head .mini-btn { margin-left: auto; }
.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 10px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: #2a2a2a;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  cursor: grab;
}
.card:hover { background: #303030; }
.card.is-done { opacity: 0.55; }
.card-title { font-weight: 600; }
.card-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }

.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; margin-top: 18px; }
.cal-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-toolbar h2 { margin: 0; font-size: 18px; font-weight: 600; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.dow { color: var(--faint); font-size: 12px; padding: 0 6px 4px; }
.day {
  min-height: 108px;
  border-radius: 8px;
  padding: 6px;
  text-align: left;
  background: rgba(255, 255, 255, 0.02);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.045);
  cursor: pointer;
}
.day:hover { background: rgba(255, 255, 255, 0.045); }
.day.is-empty { background: transparent; box-shadow: none; cursor: default; min-height: 108px; }
.day.is-selected { background: rgba(255, 255, 255, 0.05); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16); }
.day-num {
  width: 24px; height: 24px; display: grid; place-items: center;
  border-radius: 50%; font-size: 12px; margin-bottom: 4px;
}
.is-today .day-num { background: var(--blue); color: #fff; font-weight: 600; }
.chip {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  font-size: 11px;
  line-height: 1.35;
  padding: 2px 4px;
  border-radius: 3px;
  margin-top: 3px;
  color: color-mix(in srgb, var(--c) 22%, white);
  background: color-mix(in srgb, var(--c) 30%, transparent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip:hover { filter: brightness(1.1); }
.more-count { display: block; color: var(--faint); font-size: 11px; padding: 2px 4px; }
.day-panel {
  position: sticky;
  top: 8px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 12px;
}
.day-panel h3 { margin: 0 0 4px; font-size: 16px; }
.day-panel .item-line { grid-template-columns: 10px minmax(0, 1fr); }

.filters.feed-filters { margin-top: 16px; }
.feed { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.feed-card {
  text-align: left;
  padding: 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  color: var(--text);
}
.feed-card:hover { background: rgba(255, 255, 255, 0.05); }
.feed-top, .feed-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.feed-card h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.2px; }
.feed-card p { margin: 0; color: var(--muted); white-space: pre-wrap; }
.text-link { color: var(--muted); }
.text-link:hover { color: var(--text); }

.blocks { margin-top: 8px; display: flex; flex-direction: column; }
.block { display: flex; gap: 8px; align-items: flex-start; position: relative; padding: 3px 0; border-radius: 6px; }
.block:hover { background: rgba(255, 255, 255, 0.025); }
.block textarea { width: 100%; padding: 2px 4px; line-height: 1.55; }
.block-h textarea { font-size: 24px; font-weight: 700; letter-spacing: -0.4px; color: #fff; }
.callout {
  width: 100%;
  background: rgba(35, 131, 226, 0.1);
  border-radius: 8px;
  padding: 8px 10px;
}
.check { width: 16px; height: 16px; margin-top: 6px; accent-color: var(--blue); flex: none; }
.block.is-checked textarea { color: var(--faint); text-decoration: line-through; }
.block-x {
  opacity: 0;
  width: 22px; height: 22px; border-radius: 4px; color: var(--faint); flex: none; margin-top: 4px;
}
.block:hover .block-x { opacity: 1; }
.block-x:hover { background: var(--hover); color: var(--text); }
.block-types { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }

.popover, .menu, .settings-pop {
  background: var(--raised);
  border-radius: 12px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.popover { position: absolute; z-index: 5; top: 36px; left: 0; padding: 10px; }
.icon-grid { display: grid; grid-template-columns: repeat(8, 32px); gap: 4px; }
.icon-grid button { width: 32px; height: 32px; border-radius: 6px; font-size: 18px; }
.icon-grid button:hover, .cover-swatch:hover { background: var(--hover); }
.cover-grid { display: grid; grid-template-columns: repeat(3, 96px); gap: 8px; }
.cover-swatch { height: 52px; border-radius: 8px; width: 100%; }
.cover-swatch.is-on { outline: 2px solid #fff; outline-offset: 2px; }
.popover .quiet { margin-top: 8px; }

.menu, .settings-pop { position: fixed; z-index: 70; padding: 6px; min-width: 220px; }
.settings-pop { width: 300px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.settings-pop label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; }
.settings-pop input[type="text"] {
  height: 32px;
  border-radius: 6px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 14px;
}
.check-row { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--text) !important; font-size: 14px !important; }
.hint { margin: 0; color: var(--faint); font-size: 12px; line-height: 1.45; }
.menu button, .settings-pop .menu-btn {
  width: 100%;
  text-align: left;
  padding: 7px 8px;
  border-radius: 6px;
  color: var(--text);
}
.menu button:hover, .settings-pop .menu-btn:hover { background: var(--hover); }
.menu-sep { height: 1px; background: var(--line); margin: 4px 2px; }

.palette-layer, .peek-layer { position: fixed; inset: 0; z-index: 80; }
.peek-layer { z-index: 60; }
.palette-scrim, .peek-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.peek-scrim { background: rgba(0, 0, 0, 0.35); }
.palette {
  position: relative;
  z-index: 1;
  width: min(640px, calc(100% - 24px));
  margin: 12vh auto 0;
  background: var(--raised);
  border-radius: 12px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  overflow: hidden;
  max-height: min(70vh, 640px);
  display: flex;
  flex-direction: column;
  animation: pop 0.12s ease;
}
.palette-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}
.palette-search svg { width: 16px; height: 16px; color: var(--muted); }
.palette-search input { flex: 1; height: 48px; font-size: 16px; outline: none; }
.palette-list { overflow: auto; padding: 6px; }
.palette-label { padding: 8px 8px 4px; color: var(--faint); font-size: 12px; }
.palette-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 4px 8px;
  border-radius: 6px;
  text-align: left;
  color: var(--text);
}
.palette-row.is-active, .palette-row:hover { background: rgba(255, 255, 255, 0.08); }
.palette-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-quick { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px; border-top: 1px solid var(--line); }

.peek {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(520px, 100%);
  background: #202020;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 1;
  display: flex;
  flex-direction: column;
  animation: slide 0.16s ease;
}
.peek-bar { display: flex; align-items: center; gap: 8px; padding: 8px; flex: none; }
.peek-bar .spacer { flex: 1; }
.peek-body { flex: 1; overflow: auto; padding: 8px 28px 48px; }
.peek-type { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.peek-title {
  width: 100%;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #fff;
  line-height: 1.2;
  margin-bottom: 16px;
}
.peek-title::placeholder { color: rgba(255, 255, 255, 0.28); }
.peek-prop { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px; align-items: center; min-height: 34px; }
.peek-k { color: var(--muted); }
.peek-prop input, .peek-prop select {
  height: 30px;
  border-radius: 4px;
  padding: 0 6px;
  width: 100%;
  color-scheme: dark;
}
.peek-prop input:hover, .peek-prop input:focus, .peek-prop select:hover, .peek-prop select:focus { background: rgba(255, 255, 255, 0.05); }
.peek-desc {
  width: 100%;
  margin-top: 18px;
  min-height: 120px;
  max-height: 320px;
  line-height: 1.55;
  color: var(--text);
}
.peek-desc::placeholder { color: var(--faint); }
.status-row { display: flex; flex-wrap: wrap; gap: 4px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 90;
  background: #2c2c2c;
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  font-size: 13px;
}

* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.18) transparent; }

@keyframes slide { from { transform: translateX(12px); opacity: 0.4; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media (max-width: 980px) {
  .cal-layout { grid-template-columns: 1fr; }
  .day-panel { position: static; }
  .page-inner { padding: 24px 28px 80px; }
  .page-title, .static-title { font-size: 32px; }
}

@media (max-width: 800px) {
  .sidebar {
    position: fixed;
    z-index: 40;
    transform: translateX(0);
    width: min(86vw, 300px);
  }
  .app.sidebar-collapsed .sidebar { transform: translateX(-105%); width: min(86vw, 300px); }
  .app:not(.sidebar-collapsed) .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 35; }
  .edited, .crumb-parent, .crumb-sep { display: none; }
  .page-inner { padding: 20px 16px 72px; }
  .item-line { grid-template-columns: 10px minmax(0, 1fr) auto; }
  .item-line .hide-sm { display: none; }
  .prop { grid-template-columns: 1fr; gap: 2px; }
  .db-head { display: none; }
  .db-toolbar .btn { margin-left: 0; }
  .db-row { grid-template-columns: 1fr !important; gap: 4px; padding: 8px; align-items: start; }
  .db-row .pill, .db-row .muted, .db-row .date { justify-self: start; width: auto; }
  .day, .day.is-empty { min-height: 64px; }
  .chip { font-size: 10px; }
  .me-chip span span { max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .peek-prop { grid-template-columns: 96px minmax(0, 1fr); }
  .topbar-right .me-chip, .topbar-right .btn.outline { display: none; }
}

.who {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  background: #2a2a2a;
}
.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}
.me-chip, .me-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.me-chip {
  height: 28px;
  padding: 0 8px 0 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
}
.me-row { justify-content: space-between; padding: 4px 8px 8px; }
.cell-stack, .line-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.line-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.subject-pick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.peek-subject, .peek-files { align-items: start; }
.subject-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.subject-chip.is-on { background: rgba(35, 131, 226, 0.2); box-shadow: inset 0 0 0 1px rgba(35, 131, 226, 0.75); }
.subject-chip .side-emoji { font-size: 14px; }
.peek-people { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.upload-btn { cursor: pointer; }
.shot, .shot-wrap { position: relative; }
.shot {
  width: 84px;
  height: 60px;
  padding: 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.shot-sm { width: 64px; height: 44px; }
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot-x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  line-height: 16px;
}

.date-groups { display: flex; flex-direction: column; gap: 18px; }
.date-group h3 { margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.date-group.is-today h3 { color: var(--blue, #2383e2); }
.date-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.date-card {
  text-align: left;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
}
.date-card:hover { background: rgba(255, 255, 255, 0.05); }
.date-card.is-done { opacity: 0.55; }

.lightbox { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 16px; }
.lightbox-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.72); }
.lightbox-card { position: relative; z-index: 1; max-width: min(920px, 100%); display: flex; flex-direction: column; gap: 10px; }
.lightbox-card img { max-height: 78vh; max-width: 100%; width: auto; border-radius: 10px; background: #111; }
.lightbox-bar { display: flex; gap: 8px; justify-content: flex-end; }

.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.gate-card {
  width: min(420px, 100%);
  background: var(--sidebar);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.gate-mark { font-size: 36px; }
.gate-card h1 { margin: 8px 0 6px; font-size: 22px; }
.gate-card p { margin: 0; color: var(--muted); line-height: 1.5; }
.gate-dev { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.gate-dev label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; }
.gate-dev input {
  height: 36px;
  border-radius: 8px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  font-size: 14px;
}
.gate-error { min-height: 0; color: #e16259; font-size: 13px; }
.gate-error:empty { display: none; }
#tg-login { margin-top: 16px; }

.file-box { display: flex; flex-direction: column; align-items: stretch; gap: 8px; width: 100%; }
.attach { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; width: 100%; }
.shot { width: 100%; height: 88px; }
.shot-sm { width: 100%; height: 68px; }
.docs { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.doc-wrap { position: relative; display: flex; }
.doc {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 4px 28px 4px 8px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.doc:hover { background: rgba(255, 255, 255, 0.07); }
.doc-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; color: #8eb7ef; }
.doc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-wrap .shot-x { top: 8px; right: 6px; }
.peek-foot {
  flex: none;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.peek-status { align-items: start; }
.pop-label { font-size: 11px; color: var(--faint); padding: 2px 4px 6px; }
.mark { display: inline-flex; width: 18px; height: 18px; align-items: center; justify-content: center; flex: none; color: #ececec; }
.mark svg { width: 16px; height: 16px; }
.page-icon .mark, .page-icon .mark svg { width: 64px; height: 64px; }
.subject-card-icon .mark, .subject-card-icon .mark svg { width: 22px; height: 22px; }
.mark-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #eee;
}
.mark-btn:hover, .mark-btn:focus { background: var(--hover); }
.icon-grid.marks { margin-bottom: 8px; }
.palette-row .mark { margin-right: 8px; }
