/* orgacom: sober interface, square corners everywhere (same family as Kit-Keeper, blue accent). */
:root {
  --bg: #f2f2f0; --surface: #fff; --surface-2: #ebebe8; --text: #1a1a1a; --muted: #666;
  --line: #cfcfca; --line-strong: #1a1a1a;
  --accent: #10069f; --accent-ink: #fff; --accent-soft: #e8e7f6;
  --danger: #b71c1c; --warn: #d84315; --soon: #e0a100; --ok: #007b46;
  --todo: #b71c1c; --doing: #e0a100; --done: #007b46;
  --header-h: 52px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.4; color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #121212; --surface: #1a1a1a; --surface-2: #242424; --text: #e8e8e6; --muted: #9a9a96;
  --line: #363636; --line-strong: #e8e8e6;
  --accent: #8c86ff; --accent-ink: #0b0830; --accent-soft: #1a1745;
  --danger: #ef5350; --warn: #ff8a3d; --soon: #f2c230; --ok: #34b87a;
  --todo: #ef5350; --doing: #f2c230; --done: #34b87a;
  color-scheme: dark;
}
* { box-sizing: border-box; border-radius: 0 !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; overflow-x: hidden; }
#app { min-height: 100vh; display: flex; flex-direction: column; }
#app > main { flex: 1 0 auto; width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: .04em; } h3 { font-size: 1rem; }
a { color: var(--accent); }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; } .grow { flex: 1 1 auto; min-width: 0; }
.spacer { height: 1rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header ---------- */
header.top { position: sticky; top: 0; z-index: 40; background: var(--surface); border-bottom: 2px solid var(--line-strong); }
.top-in { display: flex; align-items: center; gap: 1rem; padding: .35rem 1rem; max-width: 1600px; margin: 0 auto; min-height: var(--header-h); }
.brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--text); font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.brand .logo { width: 28px; height: 28px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-family: ui-monospace, Menlo, monospace; font-size: .95rem; }
.brand .word { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .01em; }
nav.main { display: flex; gap: 0; }
nav.main a { padding: .55rem .75rem; text-decoration: none; color: var(--text); border-bottom: 3px solid transparent; white-space: nowrap; }
nav.main a:hover { background: var(--surface-2); }
nav.main a.on { border-bottom-color: var(--accent); font-weight: 600; }
.search { position: relative; flex: 1 1 240px; max-width: 380px; margin-left: auto; }
.search input { width: 100%; }
.search-res { position: absolute; left: 0; right: 0; top: 100%; background: var(--surface); border: 1px solid var(--line-strong); border-top: 0; max-height: 60vh; overflow: auto; z-index: 45; }
.search-res a { display: block; padding: .45rem .6rem; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.search-res a:hover, .search-res a.sel { background: var(--accent-soft); }
.search-res .ex { display: block; font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; }
.search-res mark { background: none; color: var(--accent); font-weight: 700; }
.top-tools { display: flex; gap: .35rem; align-items: center; }
.bell { position: relative; }
.bell .count { position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; padding: 0 .3rem; line-height: 1.3; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 2px); min-width: 220px; background: var(--surface); border: 1px solid var(--line-strong); z-index: 45; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.menu-pop.left { left: 0; right: auto; }
.menu-pop a, .menu-pop button { display: flex; width: 100%; text-align: left; padding: .5rem .8rem; border: 0; background: none; color: var(--text); text-decoration: none; justify-content: flex-start; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--accent-soft); }
.menu-pop .who { padding: .5rem .8rem; border-bottom: 1px solid var(--line); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
.notif-pop { width: min(420px, 92vw); max-height: 70vh; overflow: auto; }
.notif-pop .nh { display: flex; align-items: center; gap: .5rem; padding: .5rem .8rem; border-bottom: 1px solid var(--line-strong); background: var(--surface-2); position: sticky; top: 0; }
.notif-pop .nh b { margin-right: auto; }
.notif { display: block; padding: .5rem .8rem; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.notif:hover { background: var(--accent-soft); }
.notif.unread { box-shadow: inset 4px 0 0 var(--accent); background: color-mix(in srgb, var(--accent) 5%, transparent); }
.notif .when { display: block; font-size: .78rem; color: var(--muted); }
.live-dot { width: .6rem; height: .6rem; background: var(--muted); display: inline-block; }
.live-dot.on { background: var(--ok); }

main { max-width: 1600px; margin: 0 auto; padding: 1rem; }
.page-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .9rem; }
.page-head h1 { margin-right: auto; }
.intro { margin: -.3rem 0 1rem; color: var(--muted); max-width: 75ch; }

/* ---------- buttons & fields ---------- */
button, .btn { font: inherit; cursor: pointer; padding: .42rem .85rem; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: .4rem; line-height: 1.2; }
button:hover, .btn:hover { background: var(--surface-2); }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover, .btn.primary:hover { filter: brightness(1.12); background: var(--accent); }
button.danger, .btn.danger { color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: var(--danger); color: #fff; }
button.ghost { border-color: transparent; background: none; } button.ghost:hover { background: var(--surface-2); }
button.small, .btn.small { padding: .22rem .55rem; font-size: .85rem; }
button.icon { padding: .3rem .5rem; min-width: 2rem; justify-content: center; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
button.linklike { border: 0; background: none; color: var(--accent); padding: 0; font-weight: 600; }
button.linklike:hover { text-decoration: underline; background: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
select { max-width: 100%; text-overflow: ellipsis; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); padding: .4rem .55rem; min-width: 0; }
input[type=checkbox], input[type=radio] { width: 1.05rem; height: 1.05rem; padding: 0; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
textarea { width: 100%; resize: vertical; }
label { display: block; }
.field { display: flex; flex-direction: column; gap: .2rem; margin-bottom: .7rem; min-width: 0; }
.field > span.lbl { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.field .hint { font-size: .8rem; color: var(--muted); }
.check { display: flex; gap: .45rem; align-items: center; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8rem; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 .8rem; }
.grid2 > *, .grid3 > * { min-width: 0; }
.err { color: var(--danger); margin: .3rem 0 .6rem; font-weight: 600; } .err:empty { display: none; }
.seg { display: inline-flex; }
.seg > button { border-right-width: 0; }
.seg > button:last-child { border-right-width: 1px; }
.seg > button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--line-strong); font-weight: 600; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line-strong); }
.panel > .ph { display: flex; align-items: center; gap: .6rem; padding: .5rem .8rem; border-bottom: 1px solid var(--line-strong); background: var(--surface-2); flex-wrap: wrap; }
.panel > .ph h2 { margin-right: auto; }
.panel > .pb { padding: .8rem; } .panel > .pb.flush { padding: 0; }
.panel + .panel { margin-top: 1rem; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 1rem; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0; border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
.stat { padding: .7rem .8rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.empty { padding: 1.4rem; text-align: center; color: var(--muted); }
.notice { border: 1px solid var(--warn); border-left-width: 5px; background: color-mix(in srgb, var(--warn) 10%, var(--surface)); padding: .6rem .8rem; margin-bottom: 1rem; }
.notice.info { border-color: var(--accent); background: var(--accent-soft); }
.notice p { margin: .2rem 0; }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line-strong); margin-bottom: .8rem; overflow-x: auto; }
.tabs a, .tabs button { padding: .5rem .85rem; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--text); text-decoration: none; white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover, .tabs button:hover { background: var(--surface-2); }
.tabs a.on, .tabs button.on { border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- tables ---------- */
.tw { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .42rem .6rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line-strong); white-space: nowrap; user-select: none; }
th.sortable { cursor: pointer; } th.sortable:hover { color: var(--text); }
th .arr { color: var(--accent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.chk, th.chk { width: 2rem; padding-right: 0; }
tbody tr:hover { background: var(--accent-soft); }
tr.clickable { cursor: pointer; }
tr.sel { background: var(--accent-soft); }
tr.grp td { background: var(--surface-2); font-weight: 700; border-bottom: 1px solid var(--line-strong); text-transform: uppercase; font-size: .8rem; letter-spacing: .04em; }
tr.grp:hover { background: var(--surface-2); }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; letter-spacing: .03em; white-space: nowrap; }
.badge { display: inline-block; padding: .05rem .4rem; font-size: .75rem; font-weight: 700; border: 1px solid currentColor; white-space: nowrap; }
.badge.ok { color: var(--ok); } .badge.warn { color: var(--warn); } .badge.bad { color: var(--danger); } .badge.gris { color: var(--muted); } .badge.acc { color: var(--accent); }
.bulk { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; padding: .5rem .8rem; background: var(--accent); color: var(--accent-ink); position: sticky; top: calc(var(--header-h) + 2px); z-index: 6; }
.bulk button, .bulk select { background: var(--surface); color: var(--text); }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .7rem; }

/* ---------- chips, states, avatars ---------- */
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .05rem .45rem; font-size: .82rem; border: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; color: var(--text); text-decoration: none; }
.chip i { width: .6rem; height: .6rem; flex: none; background: var(--c, var(--muted)); }
.chip.x { padding-right: 0; }
.chip.x button { border: 0; background: none; padding: 0 .35rem; font-size: .8rem; color: var(--muted); }
.chip.x button:hover { color: var(--danger); }
.chips { display: flex; gap: .25rem; flex-wrap: wrap; }
.state { display: inline-flex; align-items: center; gap: .35rem; padding: .08rem .5rem; font-size: .8rem; font-weight: 700; border: 1px solid var(--c, var(--muted)); color: var(--c, var(--muted)); background: color-mix(in srgb, var(--c, var(--muted)) 10%, transparent); white-space: nowrap; }
.prio { font-size: .8rem; font-weight: 700; white-space: nowrap; }
.prio.p2 { color: var(--danger); } .prio.p0 { color: var(--muted); }
.av { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; flex: none; background: var(--c, var(--accent)); color: #fff; font-size: .7rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.av.sm { width: 1.3rem; height: 1.3rem; font-size: .62rem; }
.avs { display: inline-flex; gap: 2px; }
.who { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.lock { font-size: .78rem; color: var(--muted); border: 1px solid var(--line); padding: 0 .3rem; }

/* ---------- multi-select popover ---------- */
.ms { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; min-height: 2.1rem; padding: .2rem .3rem; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; position: relative; }
.ms.ro { cursor: default; border-color: transparent; background: none; padding-left: 0; }
.ms .ph { color: var(--muted); font-size: .9rem; padding: 0 .2rem; }
.ms:focus-visible { outline: 2px solid var(--accent); }
.pop { position: absolute; z-index: 60; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: 0 6px 18px rgba(0,0,0,.22); min-width: 240px; max-width: min(420px, 94vw); }
.pop input.q { width: 100%; border: 0; border-bottom: 1px solid var(--line); outline: none; }
.pop .opts { max-height: 300px; overflow: auto; }
.pop .opt { display: flex; gap: .5rem; align-items: center; padding: .38rem .6rem; cursor: pointer; border-bottom: 1px solid var(--line); }
.pop .opt:hover, .pop .opt.hi { background: var(--accent-soft); }
.pop .opt i { width: .65rem; height: .65rem; background: var(--c, var(--muted)); flex: none; }
.pop .opt .sub { color: var(--muted); font-size: .8rem; margin-left: auto; }
.pop .opt.create { color: var(--accent); font-weight: 600; }
.pop .grp { padding: .3rem .6rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); }

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: .7rem; }
.filters > input[type=search] { flex: 1 1 200px; max-width: 320px; }
.fbtn { display: inline-flex; gap: .35rem; align-items: center; }
.fbtn.set { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.fcount { color: var(--muted); font-size: .85rem; margin-left: auto; }
.f-toggle { display: none !important; }

/* ---------- windows ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; z-index: 70; overflow: auto; }
.modal { background: var(--surface); border: 2px solid var(--line-strong); width: min(560px, 100%); }
.modal.wide { width: min(800px, 100%); }
.modal.xwide { width: min(1100px, 100%); }
.modal > .mh { display: flex; align-items: center; padding: .6rem .9rem; border-bottom: 1px solid var(--line-strong); background: var(--surface-2); gap: .5rem; }
.modal > .mh h2 { margin-right: auto; text-transform: none; letter-spacing: 0; font-size: 1.1rem; }
.modal > .mb { padding: .9rem; }
.modal > .mf { padding: .7rem .9rem; border-top: 1px solid var(--line); display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: .6rem 0; }
.kv dt { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; } .kv dd { margin: 0; }
.conflict { border: 1px solid var(--line); padding: .6rem; margin-bottom: .6rem; }
.conflict h3 { margin-bottom: .4rem; }
.conflict label { display: flex; gap: .5rem; align-items: flex-start; padding: .3rem; cursor: pointer; }
.conflict label:hover { background: var(--accent-soft); }
.conflict pre { margin: .2rem 0 0; white-space: pre-wrap; max-height: 180px; overflow: auto; font-size: .85rem; background: var(--surface-2); padding: .4rem; flex: 1; }
.idbox { display: block; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; word-break: break-all; padding: .6rem .7rem; background: var(--surface-2); border: 1px solid var(--line-strong); user-select: all; }

#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .4rem; z-index: 100; max-width: min(420px, calc(100vw - 2rem)); }
.toast { background: var(--text); color: var(--bg); padding: .6rem .9rem; border-left: 5px solid var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.toast.error { border-left-color: var(--danger); }
.toast a { color: inherit; font-weight: 700; }

/* ---------- sign-in ---------- */
.login { flex: 1 0 auto; width: 100%; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login .panel { width: min(380px, 100%); }
.login .brand { justify-content: center; font-size: 1.6rem; margin-bottom: 1rem; }
.login .brand .logo { width: 40px; height: 40px; font-size: 1.3rem; }
.login input { width: 100%; }

/* ---------- Markdown ---------- */
.md { overflow-wrap: anywhere; line-height: 1.5; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { text-transform: none; letter-spacing: 0; margin: 1.1rem 0 .4rem; }
.md h1 { font-size: 1.3rem; } .md h2 { font-size: 1.15rem; } .md h3 { font-size: 1.02rem; } .md h4 { font-size: .95rem; }
.md p { margin: .5rem 0; }
.md ul, .md ol { margin: .4rem 0; padding-left: 1.4rem; }
.md li { margin: .15rem 0; }
.md li.task { list-style: none; margin-left: -1.3rem; display: flex; gap: .45rem; align-items: flex-start; }
.md li.task input { margin-top: .2rem; flex: none; }
.md blockquote { margin: .5rem 0; padding: .3rem .8rem; border-left: 4px solid var(--accent); background: var(--accent-soft); }
.md code { background: var(--surface-2); padding: 0 .25rem; font-size: .9em; }
.md pre { background: var(--surface-2); padding: .6rem; overflow: auto; border: 1px solid var(--line); }
.md pre code { background: none; padding: 0; }
.md hr { border: 0; border-top: 1px solid var(--line-strong); margin: 1rem 0; }
.md table { width: auto; margin: .5rem 0; }
.md th, .md td { border: 1px solid var(--line); }
.md .mention { color: var(--accent); font-weight: 600; background: var(--accent-soft); padding: 0 .15rem; }
.md .img { display: inline-block; border: 1px dashed var(--line); padding: .1rem .4rem; color: var(--muted); font-size: .85rem; }
.md-tools { display: flex; gap: 0; flex-wrap: wrap; border: 1px solid var(--line-strong); border-bottom: 0; background: var(--surface-2); }
.md-tools button { border: 0; border-right: 1px solid var(--line); background: none; padding: .3rem .6rem; font-size: .88rem; }
.md-tools button:hover { background: var(--accent-soft); }
.md-tools .sp { margin-left: auto; }
.md-edit { min-height: 280px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .9rem; line-height: 1.45; }
.md-split { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.md-split .md { border: 1px solid var(--line); padding: .6rem; max-height: 70vh; overflow: auto; }
.mention-pop { position: fixed; }

@media (max-width: 1280px) {
  .top-in { flex-wrap: wrap; gap: .3rem .8rem; }
  nav.main { order: 5; width: calc(100% + 2rem); overflow-x: auto; margin: 0 -1rem; padding: 0 1rem; border-top: 1px solid var(--line); }
  .brand { order: 1; } .search { order: 2; max-width: none; flex: 1 1 200px; margin-left: 0; } .top-tools { order: 3; margin-left: auto; }
  .bulk { top: 0; position: static; }
}
@media (max-width: 900px) {
  .search { order: 4; flex-basis: 100%; }
  .cols { grid-template-columns: 1fr; }
  .grid2, .grid3, .md-split { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  html { font-size: 16px; }
  .f-toggle { display: inline-flex !important; }
  .filters:not(.open) > :not(input[type=search]):not(.f-toggle):not(.fcount) { display: none; }
  .filters > input[type=search] { flex: 1 1 140px; }
  main { padding: .7rem; }
  .top-in { padding: .4rem .7rem; }
  nav.main { margin: 0 -.7rem; padding: 0 .7rem; width: calc(100% + 1.4rem); }
  button, .btn, input, select { min-height: 40px; }
  button.small, .btn.small { min-height: 32px; }
  .overlay { padding: 0; }
  .modal, .modal.wide, .modal.xwide { width: 100%; min-height: 100vh; border-width: 0; }
  .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: .5rem; }
}
@media print {
  header.top, .toolbar, .bulk, #toasts, .no-print, .filters { display: none !important; }
  body { background: #fff; color: #000; } main { padding: 0; }
}
