/* todo — app styles on top of base.css (design-system). */

/* Phones: no pull-to-refresh fighting a drag, and no rubber-banding of the whole page. */
html { overscroll-behavior-y: none; }
body { overscroll-behavior-y: contain; }

.brand-mark { width: 16px; height: 16px; }
.faint { color: var(--faint); }
.link { color: var(--muted); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.link:hover { color: var(--text); text-decoration-color: var(--muted); }
@media (min-width: 900px) { .only-phone { display: none !important; } }

.list-k { margin: 20px 0 6px; }
.search { margin: 0 0 4px; min-height: 34px; font-size: 16px; }
@media (min-width: 900px) { .search { font-size: 13px; } }
.page-h .btn { align-self: center; }

/* ---------- board and note lists ---------- */
.prow {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: baseline;
  min-height: 44px; padding: 10px 6px; border-bottom: 1px solid var(--border);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.prow:hover { background: var(--surface); }
.pname { font-size: 14.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcount { font-size: 12px; color: var(--faint); }
.pdesc { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.new-page { margin-top: 12px; }
.new-page input { border-color: transparent; background: transparent; padding-left: 6px; }
.new-page input:focus { border-color: var(--border-strong); background: var(--bg); }
.plist.sorting .prow:not(.dragging) { transition: none; }
.prow.dragging { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border-strong); border-radius: var(--r); }

.srow { display: flex; justify-content: space-between; gap: 12px; padding: 9px 6px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.srow:hover { background: var(--surface); }
.srow.done .stitle { text-decoration: line-through; color: var(--faint); }

/* ---------- desktop split: list beside the open board ---------- */
@media (min-width: 900px) {
  body[data-route="b"] main, body[data-route="home"] main { max-width: 1040px; margin-left: max(208px, calc(50vw - 520px)); }
  .split { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 40px; align-items: start; }
  .side { position: sticky; top: 76px; max-height: calc(100dvh - 100px); overflow: auto; padding-right: 4px; }
  .side .list-k:first-of-type { margin-top: 14px; }
  .side .prow { min-height: 36px; padding: 7px 8px; border-bottom: 0; border-radius: var(--r); }
  .side .pname { font-size: 13.5px; font-weight: 400; color: var(--muted); }
  .side .pdesc { display: none; }
  .side .prow[aria-current="page"] { background: var(--surface-2); }
  .side .prow[aria-current="page"] .pname { color: var(--text); }
  .side .new-page input { font-size: 13px; min-height: 32px; }
}

/* ---------- board ---------- */
.board-h { display: flex; align-items: flex-start; gap: 12px; margin: 4px 0 10px; }
.board-title { flex: 1; min-width: 0; }
.board-title h1 { font-size: 22px; overflow-wrap: anywhere; }
.pdesc-h { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.board-h .icon { flex: none; margin-top: 2px; }
.menu { margin: 0 0 12px; }
.menu .btn-row { margin-top: 2px; }

.items { list-style: none; margin: 0; padding: 0; }
.item { border-bottom: 1px solid var(--border); }
.irow {
  display: grid; grid-template-columns: 18px 20px minmax(0, 1fr) auto; column-gap: 10px; align-items: start;
  min-height: 44px; padding: 11px 4px 11px 0;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.grip {
  align-self: stretch; margin: -11px 0; display: grid; place-items: center;
  color: var(--faint); font-size: 11px; letter-spacing: -3px; cursor: grab; touch-action: none; opacity: 0.5;
}
.tasks .grip, .archive .grip { visibility: hidden; }
@media (hover: hover) {
  .grip { opacity: 0; }
  .item:hover .grip { opacity: 0.8; }
  .irow:hover { background: var(--surface); }
}
.check {
  position: relative; width: 18px; height: 18px; margin-top: 1.5px; padding: 0;
  border: 1.5px solid var(--border-strong); border-radius: 3px; background: none;
}
.check::before { content: ""; position: absolute; inset: -13px; } /* 44px tap target */
.check:hover { border-color: var(--muted); }
.prog .check::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: var(--warn); }
.done .check { border-color: #2c4a3a; }
.done .check::after {
  content: ""; position: absolute; left: 5px; top: 1.5px; width: 4px; height: 8px;
  border: solid var(--up); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.ititle { font-size: 14.5px; line-height: 21px; overflow-wrap: anywhere; cursor: pointer; }
.ititle:focus-visible { outline-offset: 3px; }
.done .ititle { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--faint); }
.has-notes { margin-left: 6px; color: var(--faint); font-size: 12px; }
.imeta { font-size: 12px; line-height: 21px; color: var(--muted); white-space: nowrap; }
.done .imeta { color: var(--faint); }
.item.dragging { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border-strong); border-radius: var(--r); }
.item.dragging .grip { opacity: 1; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }
.item.open > .irow { background: var(--surface); }

/* Expanded item */
.ipanel { display: grid; gap: 8px; padding: 2px 4px 14px 28px; animation: slide 0.16s ease-out; }
@keyframes slide { from { opacity: 0; transform: translateY(-4px); } }
.ipanel textarea { resize: none; overflow: hidden; }
.t-title { font-size: 16px; }
.t-notes { min-height: 60px; }
.links-line { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; }
.links-line:empty { display: none; }
.ifields { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ifields .seg button { min-height: 30px; }
.deadline { display: flex; align-items: center; gap: 2px; }
.deadline input { width: 150px; min-height: 34px; }
.ifields select { width: auto; max-width: 220px; min-height: 34px; font-size: 13px; }
.ifoot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 11.5px; }

.archive .item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.arch-tools { display: flex; }

/* Add field: right under the last item, and kept above the tab bar on long boards. */
.add {
  position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); z-index: 5;
  padding: 8px 0; background: var(--bg);
}
.add input { padding-left: 34px; background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M6 1v10M1 6h10' stroke='%235d6169' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat 12px 50%; }
@media (min-width: 900px) { .add { bottom: 0; } }
.board-foot { margin-top: 6px; }
.items + .empty { padding-bottom: 4px; }

/* ---------- notes ---------- */
.note-title { flex: 1; font-size: 22px; font-weight: 500; letter-spacing: -0.02em; border-color: transparent; background: transparent; padding: 2px 4px; min-height: 40px; }
.note-body { min-height: 50dvh; resize: none; overflow: hidden; border-color: transparent; background: transparent; padding: 6px 4px; line-height: 1.6; }
.note-title:focus, .note-body:focus { border-color: transparent; }
.note-meta { font-size: 11.5px; margin: 16px 4px 0; }

/* ---------- sign in ---------- */
body.gate .tabs, body.gate .status { display: none; }
@media (min-width: 900px) { body.gate main { margin-left: auto; } }
.login .seg { justify-self: center; }
.login .hint { text-align: center; margin: 0; }

/* ---------- sharing ---------- */
.spaces { margin: 12px 0 2px; }
.pmeta { margin: 4px 0 0; font-size: 11.5px; color: var(--faint); }
.note-orgs { margin: -6px 4px 8px; }
.new-page.with-space { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.new-page select { width: auto; max-width: 150px; min-height: 32px; font-size: 12.5px; border-color: transparent; background-color: transparent; color: var(--muted); }
.hidden-toggle { margin-top: 8px; }
.share { display: grid; gap: 10px; padding: 8px 0 4px; border-top: 1px solid var(--border); margin-top: 4px; }
.share-row { display: grid; gap: 6px; }
.share-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13.5px; }
.share-h .chip[aria-pressed="true"] { color: var(--up); }
.chip:disabled { opacity: 0.4; cursor: default; }
.add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.share-toggle {
  min-height: 36px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r);
  background: none; color: var(--faint); font-size: 11.5px; white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis;
}
.share-toggle[aria-pressed="true"] { color: var(--text); border-color: #45474d; background: var(--surface-2); }
.vis-hint { margin: -2px 0 0; }
.ifields select[data-f="assignee_id"] { max-width: 240px; }
.seg button:disabled { cursor: default; }
.seg button:disabled:not([aria-pressed="true"]) { opacity: 0.4; }
.people { margin: 0 0 4px; }

/* organisations */
.org summary { justify-content: space-between; }
.org summary > span:first-child { font-weight: 500; }
.members { display: grid; }
.member { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; min-height: 40px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.member-tools { display: flex; }
.org-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.org-forms { display: grid; gap: 20px; margin-top: 16px; }
@media (min-width: 640px) { .org-forms { grid-template-columns: 1fr 1fr; } }
.org-forms .btn { justify-self: start; }

/* note conflicts */
.conflicts { display: grid; gap: 6px; margin-top: 12px; padding: 10px 12px; border: 1px solid #4a4230; border-radius: var(--r); background: rgba(214, 168, 71, 0.06); }
.conflict-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.conflict-body { margin: 0; white-space: pre-wrap; font: 13px/1.5 var(--sans); color: var(--muted); padding: 8px; background: var(--bg); border-radius: var(--r); }
.conflicts .hint { margin: 0; }

.tag { color: var(--muted); }
