:root {
  --bg: #0f1520;
  --panel: #161e2b;
  --raised: #1c2636;
  --line: #2a3546;
  --text: #e6e9ef;
  --muted: #8d98aa;
  --accent: #3b82f6;
  --accent-text: #fff;
  --glyph: #7aa2f7;
  --danger: #f87171;
  --ok: #34d399;
  --warn: #fbbf24;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --panel: #f6f7f9;
  --raised: #e9edf3;
  --line: #c5cdd8;
  --text: #182131;
  --muted: #526075;
  --accent: #1d5fd1;
  --danger: #b42332;
  --ok: #146c43;
  --warn: #8b6200;
  --glyph: var(--accent);
  color-scheme: light;
}
:root[data-theme="gray"] {
  --bg: #d1d3d6;
  --panel: #dfe1e4;
  --raised: #c3c7cd;
  --line: #949ba5;
  --text: #20252d;
  --muted: #48515e;
  --accent: #164fae;
  --danger: #a51d2b;
  --ok: #11603a;
  --warn: #775200;
  --glyph: var(--accent);
  color-scheme: light;
}
.theme-picker { margin-left: auto; width: auto; flex: none; }
.topbar .menu-button { white-space: nowrap; }
@media (max-width: 420px) {
  .topbar { gap: .4rem; padding-inline: .6rem; }
  .topbar .mark { display: none; }
  .topbar .menu-button, .theme-picker { font-size: .85rem; padding: .45rem; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }

input, button {
  font: inherit;
  color: inherit;
  border-radius: 6px;
}
input {
  width: 100%;
  padding: .55rem .7rem;
  background: var(--bg);
  border: 1px solid var(--line);
}
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  padding: .5rem .9rem;
  background: var(--raised);
  border: 1px solid var(--line);
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: progress; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.field { display: grid; gap: .3rem; margin-bottom: .9rem; flex: 1; }
.field label { color: var(--muted); font-size: .9rem; }
.field-error, .error { color: var(--danger); margin: 0; font-size: .9rem; min-height: 0; }
.error:empty, .field-error:empty { display: none; }
.notice { color: var(--ok); }
.notice:empty { display: none; }
.row { display: flex; gap: .5rem; align-items: end; }
.row .field { margin-bottom: 0; }

/* sign-in screens */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1.75rem; }
.brand { font-size: 1.25rem; letter-spacing: .02em; margin-bottom: .25rem; }
.card form button.primary { width: 100%; margin-top: .25rem; }

/* signed-in layout, after Superthread: left sidebar, content on the right */
.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100vh; }
.topbar { display: flex; grid-column: 1 / -1; align-items: center; gap: .75rem; padding: .55rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.layout.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); }
.sidebar-collapsed .sidebar { display: none; }
.overview-link { display: block; padding: .3rem .45rem; font-size: .9rem; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: .9rem .7rem; display: flex; flex-direction: column; gap: .75rem;
  position: sticky; top: 56px; height: calc(100dvh - 56px); overflow-y: auto; }
.workspace { display: flex; align-items: center; gap: .6rem; font-weight: 600; padding: 0 .25rem; color: var(--text); text-decoration: none; }
.mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 6px; background: var(--raised); }
.sidebar a { color: var(--text); text-decoration: none; border-radius: 6px; }
.sidebar a:hover, .sidebar a.active { background: var(--raised); }
.sidebar-foot { margin-top: auto; display: grid; gap: .35rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.sidebar-foot > a { padding: .35rem .5rem; }
.whoami { display: grid; font-size: .9rem; padding: .35rem .5rem; }
.content { padding: clamp(1rem, 2vw, 2rem); min-width: 0; width: 100%; }
.content:focus { outline: none; }
.stack { display: grid; gap: 1.25rem; min-width: 0; align-content: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; }
.created { margin: .75rem 0; padding: .75rem; border: 1px dashed var(--accent); border-radius: 8px; }
.small-text { font-size: .85rem; }
.muted-link { color: var(--muted); }

button.small { padding: .3rem .65rem; font-size: .88rem; }
button.icon { padding: .2rem .5rem; line-height: 1.2; }
button.more { background: none; border: 0; color: var(--muted); font-size: .85rem; padding: .25rem .5rem; text-align: left; }
button.more:hover { color: var(--text); }
textarea { font: inherit; color: inherit; width: 100%; padding: .6rem .7rem; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; resize: vertical; }
textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
select { font: inherit; color: inherit; width: 100%; padding: .5rem .6rem; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }

/* title search */
.search { position: relative; }
.search input { padding: .45rem .6rem; font-size: .92rem; }
.search-results { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: .3rem; list-style: none;
  background: var(--raised); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgb(0 0 0 / .35); max-height: 60vh; overflow-y: auto; }
.search-results li { padding: .1rem 0; }
.search-results li.muted, .search-results li.error { padding: .4rem .5rem; font-size: .88rem; }
.search-results a { display: flex; gap: .5rem; align-items: baseline; padding: .4rem .5rem; }
.search-results a:focus, .search-results a:hover { background: var(--panel); }
.kind { color: var(--muted); font-size: .78rem; min-width: 3.2rem; }

/* + 새로 만들기 */
.new { position: relative; }
.new-button { width: 100%; text-align: left; }
.menu { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); display: grid; padding: .3rem;
  background: var(--raised); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgb(0 0 0 / .35); }
.menu button { background: none; border: 0; text-align: left; }
.menu button:hover, .menu button:focus { background: var(--panel); }

/* Space tree */
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree .spaces { display: grid; gap: .35rem; }
.row-item { display: flex; align-items: center; gap: .1rem; }
.row-item a { flex: 1; min-width: 0; padding: .3rem .45rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-link { font-weight: 600; }
.twisty { background: none; border: 0; color: var(--muted); width: 1.5rem; padding: .1rem; font-size: .8rem; flex: none; }
.twisty-space { width: 1.5rem; flex: none; }
.space-children { padding-left: 1rem; display: grid; gap: .1rem; }
.boards a, .pages a { font-size: .92rem; }
.boards li a { display: flex; gap: .45rem; padding: .28rem .45rem .28rem 1.95rem; }
.glyph { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; color: var(--muted); }
.glyph.board { color: var(--glyph); }
.row-item a, .boards li a, .board-name { display: flex; align-items: center; gap: .45rem; }
.indent { padding-left: 1rem; }

/* screens */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; overflow-wrap: anywhere; }
.tools { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.google-settings { display: grid; gap: .75rem; }
.google-settings label { display: grid; gap: .3rem; }
.google-login { display: grid; gap: .5rem; margin-top: 1rem; }
.card-google { display: grid; gap: .45rem; border-top: 1px solid var(--line); padding-top: .75rem; }
.card-google .google-check { display: flex; align-items: center; gap: .5rem; }
.google-check input { width: auto; flex: none; }
.section { display: grid; gap: .6rem; min-width: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; }
.section-head h2 { margin: 0; font-size: .95rem; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.empty { margin: 0; padding: 1rem; border: 1px dashed var(--line); border-radius: 8px; }
.empty-state { display: grid; gap: .75rem; justify-items: start; padding: 2rem 0; }
.empty-state h1, .empty-state p { margin: 0; }
.board-list, .page-grid, .chips { list-style: none; margin: 0; padding: 0; }
.board-list { display: grid; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.board-row { display: grid; grid-template-columns: minmax(10rem, 1fr) auto auto; align-items: center; gap: 1rem; padding: .7rem .9rem; background: var(--panel); }
.board-row + .board-row { border-top: 1px solid var(--line); }
/* Reserve both arrow slots even on the first/last board so counts stay aligned. */
.board-row > .tools { display: grid; grid-template-columns: repeat(2, 2rem); }
.board-row > .tools .order-up { grid-column: 1; }
.board-row > .tools .order-down { grid-column: 2; }
.board-name { color: var(--text); text-decoration: none; font-weight: 600; overflow-wrap: anywhere; }
.board-name:hover { color: var(--accent); }
.counts { display: flex; gap: .35rem; flex-wrap: wrap; }
.count { font-size: .8rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: .1rem .55rem; white-space: nowrap; }
.count strong { color: var(--text); font-weight: 600; }
.count.doing strong { color: var(--warn); }
.count.done strong { color: var(--ok); }
.page-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: .75rem; }
.page-card { display: grid; gap: .35rem; min-height: 5.5rem; align-content: start; padding: .9rem 1rem; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; }
.page-card:hover { border-color: var(--muted); }
.page-title { font-weight: 600; overflow-wrap: anywhere; }
.crumbs { display: flex; gap: .45rem; flex-wrap: wrap; color: var(--muted); font-size: .88rem; }
.crumbs a { color: var(--muted); }
.content:has(.board-screen) { max-width: none; }
.columns { display: grid; grid-template-columns: repeat(5, minmax(14rem, 1fr)); gap: .75rem; overflow-x: auto; align-items: start; padding-bottom: .25rem; }
.column { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .75rem; min-height: 8rem; display: grid; gap: .5rem; }
.column h2 { display: flex; justify-content: space-between; font-size: .92rem; margin: 0; }
.card-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.card-tile { display: grid; gap: .2rem; padding: .55rem .65rem; background: var(--raised); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); text-decoration: none; }
.card-tile:hover { border-color: var(--muted); }
.column-tools { display: flex; gap: .25rem; margin: .3rem 0; align-items: center; }
.column-tools { margin-bottom: .6rem; }
.board-filters, .history-filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; }
.board-filters label, .history-filters label { display: grid; gap: .3rem; }
.history-filters input, .history-filters select { max-width: 100%; }
.board-history { padding: 1rem; border: 1px solid var(--line); border-radius: 8px; }
.history-list { padding: 0; list-style: none; }
.history-list li { display: grid; gap: .3rem; padding: .7rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.members-dialog { width: min(650px, calc(100vw - 2rem)); }
.member-list { padding: 0; list-style: none; }
.member-list li, .member-add { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: .7rem 0; }
.member-list li span { flex: 1; min-width: 8rem; overflow-wrap: anywhere; }
.card-list .drop-before { border-top: 3px solid var(--accent, #739fff); }
.column.drop-end { outline: 2px dashed var(--accent, #739fff); outline-offset: -2px; }
.card-title { overflow-wrap: anywhere; }
.card-meta { font-size: .78rem; }
.add-form { display: grid; gap: .4rem; }
.add-form .actions { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-block; padding: .25rem .7rem; border: 1px solid var(--line); border-radius: 999px; color: var(--text); text-decoration: none; font-size: .9rem; }
.chip:hover { border-color: var(--muted); }
.chip-row { display: inline-flex; align-items: center; gap: .1rem; }
.page-cell { position: relative; }
.page-cell .tools { position: absolute; right: .5rem; bottom: .5rem; }
.pick-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; max-height: 16rem; overflow-y: auto; }
.pick-list button { width: 100%; text-align: left; }
/* References (M6): a chip per [[card:N]] / [[page:N]] with the current title; deleted or missing ones are not links. */
.ref-chip { display: inline-flex; align-items: center; gap: .3rem; max-width: 100%; padding: 0 .45rem; border: 1px solid var(--line); border-radius: 6px;
  background: var(--raised); color: var(--text); text-decoration: none; font-size: .92em; line-height: 1.6; vertical-align: baseline; overflow-wrap: anywhere; }
a.ref-chip:hover { border-color: var(--accent); }
.ref-chip.gone { color: var(--muted); border-style: dashed; background: none; }
.ref-kind { color: var(--muted); font-size: .85em; font-weight: 600; }
.ref-retry { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.card-refs { display: grid; gap: .3rem; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 8px; }
.card-refs > p { margin: 0; }
.plain-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.ref-suggest { list-style: none; margin: -.25rem 0 0; padding: .25rem; display: grid; gap: .15rem; max-height: 14rem; overflow-y: auto;
  border: 1px solid var(--accent); border-radius: 8px; background: var(--panel); }
.ref-suggest li { padding: .35rem .5rem; border-radius: 6px; overflow-wrap: anywhere; }
.ref-suggest [role=option] { cursor: pointer; }
.ref-suggest [aria-selected=true], .ref-suggest [role=option]:hover { background: var(--raised); }
.backlinks { display: grid; gap: .5rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.backlinks h3 { margin: 0; font-size: .95rem; }
.backlinks p { margin: 0; }
.backlink-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.backlink-list:empty { display: none; }
/* Card tags (M6c) */
.card-tags { display: grid; gap: .35rem; }
.card-tags .label { color: var(--muted); font-size: .88rem; }
.tag-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem; }
.tag-chip { display: inline-flex; align-items: center; gap: .2rem; max-width: 100%; padding: 0 .5rem; border-radius: 8px;
  background: var(--raised); border: 1px solid var(--line); font-size: .82rem; line-height: 1.7; overflow-wrap: anywhere; }
.tag-chip button.icon { padding: 0 .2rem; border: 0; background: none; line-height: 1; }
.card-tags .row { align-items: center; }
.card-tags .row input { min-width: 0; }
.card-tags .row button { flex: none; white-space: nowrap; }
.card-tags .tag-results { padding:.35rem; border:1px solid var(--line); border-radius:8px; background:var(--panel); }
.tile-tags { display: flex; flex-wrap: wrap; gap: .25rem; }
.tile-tags .tag-chip { font-size: .75rem; }

/* dialogs */
.dialog { width: min(420px, calc(100vw - 2rem)); background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem; }
.dialog::backdrop { background: rgb(0 0 0 / .55); }
.dialog h2 { margin-top: 0; }
.actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; }

/* page body: sanitized Markdown and its editor */
.markdown-body { line-height: 1.7; overflow-wrap: anywhere; min-width: 0; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 1.4em 0 .5em; line-height: 1.3; }
.markdown-body h1 { font-size: 1.45rem; }
.markdown-body h2 { font-size: 1.2rem; border-bottom: 1px solid var(--line); padding-bottom: .25rem; }
.markdown-body h3 { font-size: 1.05rem; }
.markdown-body p, .markdown-body ul, .markdown-body ol, .markdown-body blockquote, .markdown-body pre, .markdown-body table { margin: 0 0 1em; }
.markdown-body ul, .markdown-body ol { padding-left: 1.5rem; }
/* Ordered-list depth is shared by the rich editor and rendered Markdown. */
.markdown-body ol { list-style-type: decimal; padding-left: 2.5rem; }
.markdown-body ol ol { list-style-type: lower-alpha; }
.markdown-body ol ol ol { list-style-type: lower-roman; }
.markdown-body li.task-item { list-style: none; margin-left: -1.3rem; }
.markdown-body li.task-item input { width: auto; padding: 0; margin: 0 .45rem 0 0; vertical-align: -.1em; }
.markdown-body code { font: .9em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--raised); padding: .1em .35em; border-radius: 4px; }
.markdown-body pre { background: var(--raised); border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; overflow-x: auto; }
.markdown-body pre code { background: none; padding: 0; }
.markdown-body blockquote { margin-left: 0; padding: .2rem 1rem; border-left: 3px solid var(--line); color: var(--muted); }
.markdown-body hr { border: 0; border-top: 1px solid var(--line); margin: 1.5em 0; }
.markdown-body table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.markdown-body th, .markdown-body td { border: 1px solid var(--line); padding: .4rem .7rem; min-width: 4rem; }
.markdown-body th { background: var(--raised); }
.markdown-body .align-left { text-align: left; }
.markdown-body .align-center { text-align: center; }
.markdown-body .align-right { text-align: right; }
.page-editor { display: grid; gap: .6rem; }
.page-title-input { font-size: 1.15rem; font-weight: 600; }
.page-source { min-height: 24rem; font: .92rem/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
.preview { min-height: 24rem; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 6px; }
.tabs { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.tab { padding: .3rem .8rem; font-size: .88rem; }
.tab[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

/* card popup */
.card-dialog { width: min(900px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; }
.card-dialog > p { margin: 1.25rem; }
.card-head { display: flex; align-items: center; gap: .75rem; padding: .75rem 1.25rem; border-bottom: 1px solid var(--line); }
.card-head .close { margin-left: auto; }
.card-number { font-weight: 600; color: var(--muted); }
.card-layout { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; }
.card-main { display: grid; gap: .6rem; padding: 1.25rem; align-content: start; }
.card-title-input { font-size: 1.15rem; font-weight: 600; }
.card-body { min-height: 12rem; }
.card-editor .rich-page, .card-editor .card-body {
  min-height: min(12rem, 40dvh);
  max-height: min(28rem, 50dvh);
  overflow: auto;
  overscroll-behavior: auto;
  scrollbar-gutter: stable;
}
.card-editor .rich-page .ProseMirror { min-height: min(12rem, 40dvh); }
.save-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.save-status { margin: 0; color: var(--muted); font-size: .88rem; }
.save-status.dirty { color: var(--warn); }
.card-props { display: grid; gap: .8rem; align-content: start; padding: 1.25rem; border-left: 1px solid var(--line); }
.card-props label { display: grid; gap: .3rem; color: var(--muted); font-size: .88rem; }
.card-time { display: flex; align-items: end; gap: .5rem; }
.card-time label { flex: 1; min-width: 0; }
.card-time input { width: 100%; min-width: 0; }
.card-time button { flex-shrink: 0; }
.conflict { display: grid; gap: .45rem; padding: .8rem; border: 1px solid var(--warn); border-radius: 8px; }
.conflict h3 { margin: 0; font-size: .95rem; color: var(--warn); }
.conflict p { margin: 0; }
.conflict-title { font-weight: 600; overflow-wrap: anywhere; }
.conflict-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; background: var(--bg); padding: .6rem; border-radius: 6px; max-height: 14rem; overflow: auto; }

table { width: 100%; border-collapse: collapse; margin-top: .75rem; }
th, td { text-align: left; padding: .5rem; border-bottom: 1px solid var(--line); font-size: .92rem; }
th { color: var(--muted); font-weight: 500; }
.trash-table th, .trash-table td { white-space: nowrap; }
.trash-table .trash-title { white-space: normal; overflow-wrap: anywhere; min-width: 10rem; }
.restore-info p { margin: 0 0 .4rem; }
.badge { padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; border: 1px solid var(--line); }
.badge.pending { color: var(--warn); }
.badge.used { color: var(--ok); }
.badge.revoked, .badge.expired { color: var(--muted); }

@media (max-width: 720px) {
  .layout, .layout.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); align-content: start; } /* short screens must not stretch the top bar */
  .topbar { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10; font-weight: 600; }
  .sidebar { display: none; position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .menu-open .sidebar, .sidebar-collapsed.menu-open .sidebar { display: flex; }
  .sidebar .workspace { display: none; }
  .menu-open .content { display: none; }
  .content { padding: 1rem; }
  .row { flex-direction: column; align-items: stretch; }
  table { display: block; overflow-x: auto; }
  .board-row { grid-template-columns: 1fr auto; }
  .board-row .counts { grid-column: 1 / -1; grid-row: 2; }
  .page-grid { grid-template-columns: 1fr; }
  .columns { grid-template-columns: repeat(5, minmax(14rem, 80vw)); }
  .card-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; border: 0; border-radius: 0; }
  .card-layout { grid-template-columns: 1fr; }
  .card-props { border-left: 0; border-top: 1px solid var(--line); }
}

/* Card relationships/comments: retain the existing popup layout and text-only rendering. */
.card-extras { display: grid; gap: 1.5rem; margin-top: 1.5rem; }
.card-props .card-family { margin-top: 0; min-width: 0; }
.card-family .family-list > li > *, .card-family .card-parent > * { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.card-extras section { border-top: 1px solid var(--line); padding-top: .75rem; }
.card-extras form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin: .75rem 0; }
.card-extras form label { flex: 1 1 100%; }
.card-extras input, .card-extras textarea { width: 100%; min-width: 0; }
.family-list, .comment-list { list-style: none; padding: 0; margin: .75rem 0; }
.family-list li { display: flex; flex-wrap: wrap; gap: .5rem; padding: .35rem 0; overflow-wrap: anywhere; }
.card-parent { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.comment-list li { border-bottom: 1px solid var(--line); padding: .75rem 0; }
.comment-body { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Dashboard responds to available content width, including a collapsed sidebar. */
.content { container-type: inline-size; }
@container (max-width: 780px) {
  .board-row { grid-template-columns: minmax(0, 1fr) auto; }
  .board-row .counts { grid-column: 1 / -1; grid-row: 2; }
}
.view-switch, .gantt-tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.view-switch button[aria-pressed=true] { background: var(--accent); color: var(--accent-text); }
.gantt { display: grid; gap: .75rem; min-width: 0; }
.gantt-tools select, .gantt-tools input { width: auto; max-width: 100%; }
.gantt-scroll { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.gantt-table { width: max-content; min-width: 100%; }
.gantt-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); min-height: 52px; }
.gantt-row svg { flex: none; display: block; }
.gantt-heading { position: sticky; top: 0; z-index: 3; min-height: 40px; background: var(--panel); }
.gantt-label { position: sticky; left: 0; z-index: 2; background: var(--panel); width: 200px; flex: 0 0 200px; padding: .35rem .65rem; display: grid; align-content: center; text-decoration: none; color: var(--text); border-right: 1px solid var(--line); }
.gantt-label strong { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-label small { font-size: .7rem; }
.gantt text { fill: var(--muted); font: 11px system-ui; }
.gantt-grid { stroke: var(--line); stroke-width: 1; }
.gantt-today { stroke: var(--warn); stroke-width: 2; }
.gantt-bar { fill: var(--accent); cursor: grab; touch-action: none; }
.gantt-bar.done { fill: #25896d; }
.gantt-bar.cancelled { fill: #637084; }
.gantt-bar:focus { outline: none; stroke: var(--text); stroke-width: 2; }
.gantt[aria-busy=true] .gantt-bar { cursor: wait; opacity: .6; }
.gantt-undated h3 { font-size: 1rem; }
@media (max-width: 720px) { .gantt-label { width: 145px; flex-basis: 145px; } }
/* Space overview is an optional section; wide dashboards put Pages to the right. */
.space-dashboard { display: grid; gap: 1.5rem; min-width: 0; align-items: start; }
.space-overview { min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.space-overview > summary { cursor: pointer; padding: .8rem 1rem; font-weight: 600; }
.space-overview-content { padding: 0 1rem 1rem; min-width: 0; }
.space-overview .page-head h3 { margin: 0; font-size: 1rem; }
@container (min-width: 1100px) {
  .space-dashboard { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
  .space-boards .board-row { grid-template-columns: minmax(0, 1fr) auto; }
  .space-boards .board-row .counts { grid-column: 1 / -1; grid-row: 2; }
  .space-pages .page-grid { grid-template-columns: 1fr; }
}
.gantt-handle { fill: #dae6fa; fill-opacity: .8; stroke: var(--panel); stroke-width: 1; cursor: ew-resize; touch-action: none; }
.gantt-handle:focus { stroke: var(--warn); stroke-width: 2; outline: none; }
.gantt[aria-busy=true] .gantt-handle { cursor: wait; }

/* Keep the calendar opt-in above card content, including narrow screens. */
.card-dialog > .card-google { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
.card-dialog > .card-google .google-check { margin: 0; }

/* Uploaded images remain within the document/card at narrow widths. */
.markdown-body img, .plain-body img { max-width: 100%; height: auto; border-radius: 6px; vertical-align: middle; }
.attachments { border-top: 1px solid var(--line); padding-top: 12px; }
.attachments h3 { margin: 0; font-size: 1rem; }
.attachment-list { list-style: none; padding: 0; margin: 10px 0; }
.attachment-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0; }
.attachment-list a { overflow-wrap: anywhere; min-width: 0; }

.messenger-link { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 6px; }
.chat-badge { display: inline-block; background: var(--accent); color: var(--accent-text); border-radius: 12px; padding: 1px 7px; font-size: .75rem; }
.chat-screen { min-width: 0; }
.chat-layout { display: grid; grid-template-columns: 210px minmax(0,1fr); gap: 16px; }
.chat-rooms { display: flex; flex-direction: column; gap: 5px; max-height: 78vh; overflow: auto; }
.chat-rooms h3 { font-size: .8rem; color: var(--muted); margin: 12px 6px 4px; }
.chat-rooms button, .chat-rooms a { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left; padding: 9px; border-radius: 6px; overflow-wrap: anywhere; }
.chat-rooms .active { background: var(--panel); border: 1px solid var(--accent); }
.chat-pane { min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: var(--panel); }
.chat-room-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chat-room-head h2 { font-size: 1.1rem; margin: 0 0 12px; overflow-wrap: anywhere; }
.chat-messages { height: min(52vh,620px); min-height: 180px; overflow: auto; overflow-anchor: none; padding: 8px 4px; }
.chat-message { margin: 0 0 12px; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; max-width: 94%; width: fit-content; background: var(--bg); }
.chat-message.own { margin-left: auto; border-color: var(--accent); }
.chat-message header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; font-size: .8rem; margin-bottom: 6px; }
.chat-message time { color: var(--muted); font-size: .7rem; }
.chat-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-mention { color: var(--accent); font-weight: 600; }
.chat-file { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; overflow-wrap: anywhere; }
.chat-file img { max-width: 100%; max-height: 300px; object-fit: contain; border-radius: 6px; }
.chat-composer { position: relative; border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 8px; }
.chat-composer > .ref-suggest { position: absolute; bottom: 100%; left: 0; right: 0; z-index: 2; margin: 0 0 4px; max-height: min(14rem,40dvh); }
.chat-input { width: 100%; resize: vertical; min-height: 70px; }
.chat-staged { list-style: none; margin: 0; padding: 0; }
.chat-staged li { display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; padding: 3px 0; }
.chat-mentions, .chat-people { display: flex; flex-wrap: wrap; gap: 6px; max-height: 180px; overflow: auto; }
.chat-mentions[hidden] { display: none; }
.notification-list { display: grid; gap: 8px; max-height: 65vh; overflow: auto; }
.notification-item { display: grid; gap: 5px; text-align: left; overflow-wrap: anywhere; }
.notification-item.unread { border-color: var(--accent); }
.notification-item small { color: var(--muted); }
@media(max-width:900px) { .chat-layout { grid-template-columns: 160px minmax(0,1fr); gap: 10px; } }
@media(max-width:720px) {
  .chat-layout { grid-template-columns: minmax(0,1fr); }
  .chat-rooms { max-height: 140px; flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .chat-rooms h3 { flex-basis: 100%; margin-top: 4px; }
  .chat-rooms button,.chat-rooms a { max-width: 100%; padding: 6px 8px; font-size: .8rem; }
  .chat-pane { padding: 10px; }.chat-message { max-width: 97%; }
  .chat-alert { padding: .3rem .4rem; white-space: nowrap; }
}

/* Right-side chat stays mounted independently of the page/card router. */
:root { --chat-width: 420px; --topbar-height: 58px; }
.topbar { z-index: 70; }
.chat-toggle { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.chat-drawer { position: fixed; right: 0; top: var(--topbar-height); bottom: 0; width: min(var(--chat-width),100vw); background: var(--panel); border-left: 1px solid var(--line); z-index: 60; overflow: auto; box-shadow: -8px 0 24px rgb(0 0 0 / .15); }
.chat-drawer[hidden] { display: none; }
.chat-drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.chat-drawer-content { padding: 12px; }
.chat-drawer .chat-screen > .page-head { margin-bottom: 10px; justify-content: flex-end; }
.chat-drawer .chat-screen > .page-head h1 { display: none; }
.chat-drawer .chat-layout { display: flex; flex-direction: column; gap: 10px; }
.chat-room-picker summary { cursor: pointer; color: var(--muted); padding: 6px 0; }
.chat-drawer .chat-rooms { max-height: 220px; }
.chat-drawer .chat-pane { padding: 10px; }
.chat-drawer .chat-messages { height: max(160px,calc(100dvh - var(--topbar-height) - 360px)); min-height: 160px; }
.chat-drawer .chat-composer .tools { flex-wrap: wrap; }
.card-backdrop { position: fixed; inset: var(--topbar-height) 0 0; background: rgb(0 0 0 / .4); z-index: 40; }
.card-dialog { position: fixed; top: calc(var(--topbar-height) + 12px); left: 12px; right: 12px; margin: 0 auto; max-height: calc(100dvh - var(--topbar-height) - 24px); overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; z-index: 50; }
@media(min-width:1100px) {
  body.chat-open .content { width: calc(100% - var(--chat-width)); margin-right: var(--chat-width); }
  body.chat-open .card-dialog { right: calc(var(--chat-width) + 12px); width: min(900px,calc(100vw - var(--chat-width) - 24px)); }
  body.chat-open .card-backdrop { right: var(--chat-width); }
}
@media(max-width:720px) {
  .chat-drawer { width: 100vw; }
  .topbar { flex-wrap: wrap; gap: .35rem; padding: .5rem .6rem; }
  .chat-toggle,.chat-alert { font-size: .8rem; padding: .4rem; }
  .card-dialog { top: var(--topbar-height); left: 0; right: 0; width: 100vw; height: calc(100dvh - var(--topbar-height)); max-height: calc(100dvh - var(--topbar-height)); }
}

/* Monthly calendar shares the board's cards and history filter. */
.calendar-toolbar{display:flex;align-items:center;gap:12px;margin-bottom:12px}
.calendar-toolbar strong{min-width:130px;text-align:center}
.calendar-scroll{overflow-x:auto;border:1px solid var(--line);border-radius:8px}
.calendar-weekdays,.calendar-days,.calendar-lane{display:grid;grid-template-columns:repeat(7,minmax(0,1fr))}
.calendar-weekdays,.calendar-grid{min-width:630px}
.calendar-week{position:relative;min-height:110px;border-top:1px solid var(--line)}
.calendar-days{position:absolute;inset:0}
.calendar-events{pointer-events:none;position:relative;padding:44px 0 8px;display:grid;gap:4px}
.calendar-lane{min-width:0}
.calendar-lane .calendar-card{pointer-events:auto;grid-row:1;min-width:0;margin:0 3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.calendar-card.continues-before{border-top-left-radius:0;border-bottom-left-radius:0;border-left-width:1px}
.calendar-card.continues-after{border-top-right-radius:0;border-bottom-right-radius:0}
.calendar-weekdays span{text-align:center;padding:8px;background:var(--panel)}
.calendar-day{padding:6px;border-right:1px solid var(--line);min-width:0}
.calendar-day:nth-child(7n){border-right:0}
.calendar-day time{display:block;font-size:12px;color:var(--muted);margin-bottom:6px}
.calendar-day-heading{display:flex;align-items:center;justify-content:space-between;gap:4px}
.calendar-day-heading time{margin:0}
.calendar-add{padding:0;min-width:30px;height:30px;font-size:20px;line-height:1}
.calendar-day.today time{font-weight:700;color:var(--accent)}
.calendar-day.outside{background:var(--panel)}
.calendar-card{display:block;overflow-wrap:anywhere;font-size:13px;padding:5px 7px;margin-bottom:4px;border:1px solid var(--line);border-left:3px solid var(--accent);border-radius:4px;background:var(--raised);color:var(--text);text-decoration:none}
.calendar-start-1{grid-column-start:1}
.calendar-span-1{grid-column-end:span 1}
.calendar-start-2{grid-column-start:2}
.calendar-span-2{grid-column-end:span 2}
.calendar-start-3{grid-column-start:3}
.calendar-span-3{grid-column-end:span 3}
.calendar-start-4{grid-column-start:4}
.calendar-span-4{grid-column-end:span 4}
.calendar-start-5{grid-column-start:5}
.calendar-span-5{grid-column-end:span 5}
.calendar-start-6{grid-column-start:6}
.calendar-span-6{grid-column-end:span 6}
.calendar-start-7{grid-column-start:7}
.calendar-span-7{grid-column-end:span 7}
.calendar-card.done{border-left-color:var(--ok)}
.calendar-card.cancelled{border-left-color:var(--muted)}
.calendar-undated{margin-top:16px}.calendar-undated h2{font-size:15px}

.calendar-host,.calendar-view,.calendar-scroll { min-width:0; max-width:100%; }

/* Page title and body are editable in place from the moment the page opens. */
.page-title-heading { flex: 1 1 18rem; min-width: 0; margin: 0; }
.page-title-heading .page-title-input { width: 100%; min-width: 0; font: inherit; font-weight: inherit; padding: .2rem 0; border: 1px solid transparent; border-radius: 4px; background: transparent; }
.page-title-heading .page-title-input:focus { border-color: var(--accent); outline: none; }
.page-editor .rich-page { border: 0; background: transparent; }
.page-editor .rich-page .ProseMirror { padding: .5rem 0; }
.member-list li { display: grid; grid-template-columns: minmax(8rem,1fr) minmax(0,auto); }
.member-list li > span { min-width: 0; }
.member-permissions { display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: .4rem; min-width: 0; }
.member-permissions select { width: 100%; min-width: 0; }
.member-permissions button { white-space: nowrap; }
.member-add { display: grid; grid-template-columns: minmax(8rem,1fr) minmax(0,auto); }
.member-add > select { min-width: 0; }
.member-new-role { grid-template-columns: minmax(0,1fr) auto; }
@media(max-width:600px) {
  .member-list li,.member-add { grid-template-columns: minmax(0,1fr); }
}
.search-context { display: block; font-size: .75rem; font-weight: 400; overflow-wrap: anywhere; }

.signature-preview { width: min(100%, 320px); height: auto; border: 1px solid var(--line); background: white; border-radius: 6px; }
.review-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding-block: .6rem; }
.review-controls .review-status { font-size: .88rem; }
.review-selection { max-height: 45vh; overflow: auto; display: grid; gap: .5rem; }
.review-selection label { display: flex; gap: .5rem; align-items: baseline; }
.review-selection input { width: auto; }

/* Quoted comments remain in the existing card comment stream. */
.comment-quote, .comment-quote-preview { width: 100%; min-width: 0; }
.comment-quote blockquote, .comment-quote-preview blockquote { margin: .4rem 0; padding: .4rem .7rem; border-left: 3px solid var(--accent); background: var(--bg); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 10rem; overflow: auto; }
.quote-location-status { margin-left: .5rem; }

/* Card workspace expansion retains the same editor and draft. */
.card-window-actions { display:flex; align-items:center; gap:.5rem; margin-left:auto; }
.card-window-actions .close { margin-left:0; }
body .card-dialog.card-expanded { left:var(--card-expanded-left,0px); right:var(--card-expanded-right,0px); top:var(--topbar-height); bottom:0; width:auto; height:calc(100dvh - var(--topbar-height)); max-width:none; max-height:none; margin:0; border-radius:0; container-type:inline-size; }
.card-expanded[hidden] { display:none; }
.card-expanded .card-head { position:sticky; top:0; background:var(--panel); z-index:2; }
@container (max-width:700px) {
  .card-expanded .card-layout { grid-template-columns:minmax(0,1fr); }
  .card-expanded .card-props { border-left:0; border-top:1px solid var(--line); }
}
.board-list-table { table-layout:fixed; }
.board-list-table th:first-child { width:36%; }
.board-list-table td { overflow-wrap:anywhere; }
.board-list-table tbody tr:hover { background:var(--panel); }
@media(max-width:720px) {
  .board-list-table,.board-list-table tbody { display:block; }
  .board-list-table thead { display:none; }
  .board-list-table tr { display:grid; gap:.4rem; padding:.8rem; margin:.7rem 0; border:1px solid var(--line); border-radius:8px; }
  .board-list-table td { display:grid; grid-template-columns:4rem minmax(0,1fr); gap:.6rem; padding:0; border:0; }
  .board-list-table td::before { content:attr(data-label); color:var(--muted); }
  .board-list-table td:first-child { font-weight:600; }
}

.quote-popover { position:fixed; z-index:65; box-shadow:0 3px 12px rgb(0 0 0 / .25); white-space:nowrap; }
.page-tree-row { cursor:grab; }
.page-tree-row[data-drop="before"] { box-shadow:inset 0 2px var(--accent); }
.page-tree-row[data-drop="after"] { box-shadow:inset 0 -2px var(--accent); }
.page-tree-row[data-drop="inside"] { outline:2px solid var(--accent); outline-offset:-2px; background:var(--panel); }

.pdf-preview { width:min(1000px,calc(100vw - 2rem)); height:calc(100dvh - 2rem); max-width:none; max-height:none; padding:1rem; }
.pdf-preview[open] { display:flex; flex-direction:column; gap:.6rem; }
.pdf-heading { display:flex; align-items:center; gap:.5rem; flex-wrap:wrap; }
.pdf-heading h2 { flex:1; min-width:0; overflow-wrap:anywhere; font-size:1.1rem; margin:0; }
.pdf-tools { display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; }
.pdf-tools input { width:5rem; }
.pdf-status { margin:0; }
.pdf-surface { flex:1; min-height:0; overflow:auto; background:#52565c; padding:12px; }
.pdf-surface canvas { display:block; background:white; margin:0 auto; }
@media(max-width:720px) { .pdf-preview { width:100vw; height:100dvh; margin:0; border-radius:0; padding:.6rem; } }

/* M23 board summaries, editable columns and page child navigation. */
.attachment-mark { display:inline-flex; vertical-align:middle; margin-left:.35em; color:var(--muted); }
.attachment-mark .glyph { width:1em; height:1em; }
.column-heading { display:flex; align-items:center; gap:.3rem; min-width:0; }
.column-heading h2 { flex:1; min-width:0; align-items:center; gap:.25rem; }
.column-name { width:100%; min-width:0; padding:.25rem .1rem; border:1px solid transparent; background:transparent; font:inherit; font-weight:700; color:var(--column-color,var(--text)); }
.column-name:hover,.column-name:focus { border-color:var(--line); }
.column-grip { cursor:grab; padding:.2rem; background:transparent; border-color:transparent; }
.column-grip:active { cursor:grabbing; }
.column-color-picker { position:fixed; inset:auto; margin:0; width:min(264px,calc(100vw - 16px)); box-sizing:border-box; grid-template-columns:repeat(9,minmax(0,1fr)); gap:.25rem; align-items:center; padding:.65rem; border:1px solid var(--line); border-radius:10px; background:var(--panel); box-shadow:0 5px 18px rgb(0 0 0 / .25); }
.card-status-field { display:grid; gap:.3rem; }
.board-view-adder { width:100%; max-width:34rem; }
.card-status-value,.card-status-option { display:flex; justify-content:space-between; align-items:center; gap:.7rem; width:100%; text-align:left; color:var(--column-color,var(--text)); }
.card-status-menu { position:fixed; inset:auto; margin:0; box-sizing:border-box; max-height:min(320px,calc(100dvh - 16px)); overflow-y:auto; padding:.3rem; border:1px solid var(--line); border-radius:8px; background:var(--panel); box-shadow:0 5px 18px rgb(0 0 0 / .25); }
.card-status-option { border-color:transparent; background:transparent; }
.card-status-option:hover,.card-status-option:focus-visible { background:var(--bg); outline:2px solid var(--line); outline-offset:-2px; }
.column-color-picker:popover-open { display:grid; }
.column-color-picker:not(:popover-open) { display:none; }
.column-heading .column-color-toggle { flex:none; width:1.35rem; }
.column-color-swatch { width:100%; max-width:1.5rem; aspect-ratio:1; min-height:0; padding:0; border-radius:50%; border:2px solid transparent; background:var(--column-color); color:var(--bg); display:grid; place-items:center; font-size:.8rem; line-height:1; }
.column-color-swatch[aria-pressed="true"] { outline:2px solid var(--text); outline-offset:2px; }
.column-color-swatch:focus-visible { outline:2px dashed var(--text); outline-offset:3px; }
.column-color-swatch:hover { border-color:var(--text); }
.column-color-default { --column-color:var(--panel); border-color:var(--muted); color:var(--text); background:linear-gradient(135deg,transparent 46%,var(--muted) 47%,var(--muted) 53%,transparent 54%); }
.column-color-default[aria-pressed="true"] { background:var(--panel); }
.column[class*="column-color-"] { border-color:var(--column-color); }
.overview-screen .column h2 { color:var(--column-color,var(--text)); }
.count[class*="column-color-"] strong { color:var(--column-color); }
.column-drop-before { box-shadow:inset 4px 0 var(--accent); }
.column-drop-after { box-shadow:inset -4px 0 var(--accent); }
.column-color-red { --column-color:#ed7878; }
.column-color-orange { --column-color:#eea35f; }
.column-color-yellow { --column-color:#cfbd59; }
.column-color-green { --column-color:#76bd87; }
.column-color-teal { --column-color:#63c1b8; }
.column-color-blue { --column-color:#82a9ef; }
.column-color-purple { --column-color:#b297e8; }
.column-color-pink { --column-color:#e591bc; }
[data-theme="light"] .column-color-red, [data-theme="gray"] .column-color-red { --column-color:#b92e38; }
[data-theme="light"] .column-color-orange, [data-theme="gray"] .column-color-orange { --column-color:#a6530b; }
[data-theme="light"] .column-color-yellow, [data-theme="gray"] .column-color-yellow { --column-color:#806300; }
[data-theme="light"] .column-color-green, [data-theme="gray"] .column-color-green { --column-color:#26743b; }
[data-theme="light"] .column-color-teal, [data-theme="gray"] .column-color-teal { --column-color:#16766b; }
[data-theme="light"] .column-color-blue, [data-theme="gray"] .column-color-blue { --column-color:#345fc0; }
[data-theme="light"] .column-color-purple, [data-theme="gray"] .column-color-purple { --column-color:#7744ad; }
[data-theme="light"] .column-color-pink, [data-theme="gray"] .column-color-pink { --column-color:#ad3677; }
.page-body-layout { display:grid; grid-template-columns:minmax(11rem,15rem) minmax(0,1fr); gap:1.25rem; align-items:start; }
.page-body-layout:not(:has(.page-children)) { grid-template-columns:minmax(0,1fr); }
.page-body-main { min-width:0; }
.page-children { position:sticky; top:1rem; min-width:0; border-right:1px solid var(--line); padding-right:1rem; max-height:calc(100vh - 7rem); overflow:auto; }
.page-children summary { cursor:pointer; font-size:.95rem; font-weight:600; padding:.25rem 0; }
.page-children details[open] > summary { margin-bottom:.7rem; }
.page-child-list { display:flex; flex-direction:column; list-style:none; padding:0; margin:0; gap:.5rem; }
.page-child-list .chip-row { display:flex; align-items:center; min-width:0; }
.page-child-list .chip { min-width:0; flex:1; white-space:normal; overflow-wrap:anywhere; }
@media(max-width:800px) {
 .page-body-layout { grid-template-columns:minmax(0,1fr); }
 .page-children { position:static; border-right:0; border-bottom:1px solid var(--line); padding:0 0 1rem; max-height:18rem; }
}
.dialog.members-dialog { width:min(650px,calc(100vw - 2rem)); }
.page-screen { container-type:inline-size; }
@container(max-width:760px) {
 .page-body-layout { grid-template-columns:minmax(0,1fr); }
 .page-children { position:static; border-right:0; border-bottom:1px solid var(--line); padding:0 0 1rem; max-height:18rem; }
}

.copy-link-control { position:relative; display:inline-flex; align-items:center; }
.copy-link { display:inline-flex; align-items:center; justify-content:center; }
.copy-link-notice { position:absolute; right:0; top:calc(100% + 6px); z-index:20; width:max-content; max-width:min(280px,70vw); padding:8px 12px; border:1px solid var(--line); border-radius:8px; background:var(--panel); color:var(--text); box-shadow:0 4px 12px #0003; font-size:13px; }
.copy-link-notice:empty { display:none; }
.push-settings .row { flex-wrap:wrap; }
.push-settings .push-chat-option { display:flex; align-items:center; gap:8px; min-width:0; max-width:100%; }
.push-settings .push-chat-option input { width:auto; flex:0 0 auto; padding:0; margin:0; }
.push-settings .push-chat-option span { min-width:0; word-break:keep-all; overflow-wrap:anywhere; }

.member-mention { display:inline; padding:1px 4px; border-radius:4px; background:var(--raised); color:var(--glyph); font-weight:600; white-space:pre-wrap; }
.mention-suggest { max-height:220px; overflow:auto; }
.page-comments { border-top:1px solid var(--line); padding-top:16px; }
.page-comments form { display:grid; gap:8px; }
.page-comments textarea { width:100%; }

/* Calendar period editing: only actual endpoints receive handles, not week cuts. */
.calendar-card.calendar-editable{position:relative;padding-left:14px;padding-right:14px;cursor:grab;touch-action:none;user-select:none}
.calendar-handle{position:absolute;top:0;bottom:0;width:10px;cursor:ew-resize;touch-action:none}
.calendar-handle::after{content:"";position:absolute;top:25%;bottom:25%;left:4px;border-left:2px solid var(--muted)}
.calendar-handle-start{left:0}.calendar-handle-due{right:0}
.calendar-handle:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}
.calendar-day.calendar-date-preview{box-shadow:inset 0 0 0 2px var(--accent);background:var(--raised)}
.calendar-card.calendar-dragging{opacity:.6}

.page-research-settings .row{flex-wrap:wrap}
.page-research-settings label{display:flex;align-items:center;gap:8px;max-width:100%;word-break:keep-all}
.page-research-settings input{width:auto;flex:none;padding:0;margin:0}

/* Shared document tags and body hashtags. */
.hashtag { color: var(--accent, #6c9de8); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.tag-search-link { display: inline-block; padding: .45rem .6rem; }
.tag-search-results { list-style: none; padding: 0; }
.tag-search-results li { display: flex; flex-wrap: wrap; gap: .5rem 1rem; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.hashtag-suggest button { width: 100%; text-align: left; }
.hashtag-suggest button[aria-selected="true"] { outline: 2px solid var(--accent, #6c9de8); }

/* M36: consistent navigation buttons and document/file links. Anchors retain native link behavior. */
a.link-button,
.page-screen .crumbs a,
.page-child-list a.chip,
a.ref-chip,
.plain-body a.ref {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  max-width: 100%; padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--raised); color: var(--text); font: inherit; line-height: 1.4;
  text-decoration: none; overflow-wrap: anywhere; vertical-align: middle;
}
a.link-button.small, .page-screen .crumbs a { font-size: .85rem; padding: .35rem .6rem; }
a.link-button:hover, .page-screen .crumbs a:hover, .page-child-list a.chip:hover,
a.ref-chip:hover, .plain-body a.ref:hover { border-color: var(--glyph); background: var(--panel); }
a.link-button .glyph, a.ref-chip .glyph { flex: none; }
.space-tag-button { white-space: nowrap; }
.page-screen .crumbs { align-items: center; }
.page-child-list a.chip, a.family-link { justify-content: flex-start; text-align: left; }
.card-parent a.ref-chip, .backlink-list a.ref-chip { font-size: .85rem; }
.markdown-body a:not(.ref-chip):not(.ref), .plain-body a:not(.ref-chip):not(.ref) {
  border: 1px solid var(--line); border-radius: 6px; padding: .1em .35em;
  background: var(--raised); color: var(--glyph); text-decoration: none;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
  overflow-wrap: anywhere; line-height: 1.8;
}
.markdown-body a:not(.ref-chip):not(.ref):hover { border-color: var(--glyph); }
.markdown-body a[href^="http"]::after { content: ' ↗'; font-size: .8em; opacity: .7; }
.markdown-body a[href^="/api/attachments/"] { color: var(--text); padding: .2em .5em; }
.markdown-body a[href^="/api/attachments/"]::before { content: '↧ '; color: var(--glyph); }
.markdown-body .hashtag { text-decoration: none; border-radius: 5px; background: var(--raised); color: var(--glyph); }
.markdown-body img, .plain-body img { border: 1px solid var(--line); border-radius: 10px; }
.pdf-inline-preview { border-radius: 6px; margin-inline-start: .35rem; padding: .2rem .5rem; font-size: .78rem; background: var(--raised); }
.attachment-list { display: grid; gap: .55rem; }
.attachment-list li.attachment-item {
  display: flex; align-items: center; flex-wrap: wrap; gap: .55rem 1rem;
  padding: .65rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
}
.attachment-file { display: flex; flex: 1 1 15rem; align-items: center; gap: .7rem; color: var(--text); text-decoration: none; border-radius: 6px; }
.attachment-file:hover .attachment-name { color: var(--glyph); }
.attachment-art { width: 44px; height: 48px; flex: none; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 7px; background: var(--raised); color: var(--glyph); overflow: hidden; }
.attachment-art img { width: 100%; height: 100%; object-fit: cover; }
.attachment-art .glyph { width: 22px; height: 22px; }
.attachment-info { display: grid; min-width: 0; gap: .12rem; }
.attachment-name { font-size: .9rem; font-weight: 600; overflow-wrap: anywhere; }
.attachment-meta { color: var(--muted); font-size: .75rem; }
.attachment-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.attachment-actions .attachment-delete { color: var(--muted); background: transparent; }
.attachment-actions .attachment-delete:hover { color: var(--danger); border-color: var(--danger); }
@media(max-width:600px) {
  .attachment-actions { width: 100%; }
  .attachment-actions > * { flex: 1 1 auto; text-align: center; }
  .space-screen .page-head .tools { flex-wrap: wrap; }
}
