:root {
  color-scheme: light dark;
  --bg: #f4f4f6;
  --surface: #ffffff;
  --surface-2: #ececf0;
  --border: #dcdce2;
  --text: #1c1c1e;
  --text-2: #6b6b73;
  --text-3: #9a9aa2;
  --accent: #0a6fdc;
  --pro: #0a6fdc;
  --perso: #23a047;
  --error: #d93025;
  --warning: #a35f00;
  --claude: #b8613f;
  --dim: rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214;
    --surface: #1c1c1f;
    --surface-2: #2a2a2f;
    --border: #313137;
    --text: #ececf0;
    --text-2: #a2a2ab;
    --text-3: #6c6c74;
    --accent: #3d8fff;
    --pro: #3d8fff;
    --perso: #34c759;
    --error: #ff5c52;
    --warning: #f0a848;
    --claude: #e08a66;
    --dim: rgba(0, 0, 0, 0.55);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

button,
input {
  font: inherit;
  color: inherit;
}

#app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 20px 40px;
}

/* Header: the view switch only */
.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.seg button {
  padding: 5px 16px;
  border: 0;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
}

.seg button + button {
  border-left: 1px solid var(--border);
}

.seg button.on {
  background: var(--accent);
  color: #fff;
}

/* Split: two profile columns */
.cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}

.colh {
  margin: 0;
  padding-bottom: 5px;
  border-bottom: 2px solid var(--border);
  font-size: 15px;
  font-weight: 700;
}

.colh.pro {
  border-color: var(--pro);
}

.colh.perso {
  border-color: var(--perso);
}

.tabs {
  display: none;
}

.gh {
  margin: 14px 0 5px;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.gh.overdue {
  color: var(--error);
}

/* Quick add */
.newtask {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 2px;
  padding: 6px 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.newtask:focus-within {
  border-style: solid;
  border-color: var(--accent);
}

.newtask .title {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  outline: none;
}

.title::placeholder {
  color: var(--text-3);
}

.cal {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  padding: 1px 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 11.5px;
  white-space: nowrap;
}

.cal:focus-within {
  border-color: var(--accent);
}

/* The native date input sits invisibly over the button face. */
.cal input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.newtask.bad,
.sheet .title.bad,
.cal.bad,
.login input.bad {
  border-style: solid;
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}

/* Rows */
.row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 5px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.row.open {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.row.over {
  padding-left: 7px;
  border-left: 3px solid var(--error);
}

.row:focus {
  outline: none;
}

.row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.row > .date {
  flex: none;
  width: 46px;
  padding-top: 1px;
  color: var(--text-2);
  font-size: 12px;
}

.row.over > .date {
  color: var(--error);
  font-weight: 600;
}

.main {
  flex: 1;
  min-width: 0;
}

.row .title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.next,
.block {
  margin-top: 2px;
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.next {
  color: var(--text-2);
}

.block {
  color: var(--warning);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.chip {
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11px;
  text-decoration: none;
}

.chip:hover {
  color: var(--text);
}

/* A Claude desktop session: opens that session in the app. */
.lk.claude .chip {
  background: color-mix(in srgb, var(--claude) 18%, transparent);
  color: var(--claude);
  font-weight: 600;
}

.exp {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.exp .grow {
  flex: 1;
}

.id {
  color: var(--text-3);
  font-size: 11px;
  font-style: italic;
}

.exp .done,
.exp .tog,
.exp .drop {
  display: none;
}

.act {
  display: none;
  flex: none;
  gap: 4px;
  margin: -2px 0; /* keeps the row height when the buttons appear */
}

/* With the focus anywhere in the row, so the keyboard can reach them. */
.row:hover .act,
.row.open .act,
.row:focus-within .act {
  display: flex;
}

.btn {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 11.5px;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--text-3);
  color: var(--text);
}

/* Profile dot: the task's profile color; a click moves it to the other one. */
.dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  padding: 0;
}

.dot::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--pro);
}

.dot.perso::before {
  background: var(--perso);
}

.exp .dot {
  display: none;
}

/* Inline edits */
.row .f {
  cursor: text;
}

.row .f:focus {
  outline: none;
}

.row .f:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: 3px;
}

/* Same text position and line height as the field it replaces. */
.edit {
  display: block;
  width: calc(100% + 12px);
  margin: -2px -6px;
  padding: 1px 5px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--bg);
  outline: none;
}

.row > .date.editing {
  width: auto;
  padding-top: 0;
}

.date .edit {
  width: auto;
  margin: -1px 0;
  font-size: 12px;
}

.edit.bad,
.btn.bad,
.lk.bad .chip {
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}

.add {
  padding: 1px 7px;
  border: 1px dashed var(--border);
  border-radius: 4px;
  background: none;
  color: var(--text-3);
  font-size: 11px;
  cursor: pointer;
}

.add:hover,
.add:focus-visible {
  border-color: var(--text-3);
  color: var(--text);
}

.links .add {
  visibility: hidden;
}

.row:hover .links .add,
.row:focus-within .links .add,
.row.open .links .add {
  visibility: visible;
}

.newlink {
  flex: 1 1 200px;
}

.newlink .edit {
  width: 100%;
  margin: 0;
  font-size: 12px;
}

/* × on a link chip shows on hover, over the chip's corner. */
.lk {
  position: relative;
  display: inline-flex;
}

.x {
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.x:hover {
  color: var(--error);
}

.lk .x {
  position: absolute;
  top: -6px;
  right: -6px;
  display: none;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  font-size: 11px;
}

.lk:hover .x,
.lk:focus-within .x {
  display: inline-flex;
}

/* Blocked-by: blockers with ×, a filter, and the matching tasks. */
.blockers {
  color: var(--text);
}

.bchips {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin-bottom: 5px;
}

.bchips:empty {
  display: none;
}

.bchip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--warning);
}

.pick {
  margin-top: 4px;
  padding: 3px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.opt {
  padding: 3px 8px;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.opt:hover,
.opt.on {
  background: var(--surface-2);
}

/* Week: ‹ › in the header, the grid, and the side panel beside it */
.nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.nav .btn {
  padding: 3px 11px;
  font-size: 13px;
}

.wk {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px; /* the panel's place is kept: no reflow on select */
  gap: 14px;
  align-items: start;
}

/* Column by column: a head, then the pro and perso cells. */
.grid {
  display: grid;
  grid-template-rows: auto minmax(84px, auto) minmax(84px, auto);
  grid-template-columns: 22px;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 5px;
}

.wh {
  padding: 2px 4px;
  overflow: hidden;
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.wh.over {
  color: var(--error);
}

.wh.today {
  color: var(--accent);
}

.lane {
  border-radius: 6px;
}

.lane.pro {
  background: color-mix(in srgb, var(--pro) 40%, transparent);
}

.lane.perso {
  background: color-mix(in srgb, var(--perso) 40%, transparent);
}

.cell {
  min-width: 0;
  padding: 5px;
  border-radius: 6px;
  background: var(--surface-2);
}

.cell.over {
  background: color-mix(in srgb, var(--error) 10%, var(--surface-2));
}

.cell.today {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.cell.drop {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-2));
}

.card {
  margin-bottom: 4px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  font-size: 12.5px;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.card:last-child {
  margin-bottom: 0;
}

.card:focus {
  outline: none;
}

.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.card.sel {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.card.bad {
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}

.card.dragging {
  opacity: 0.45;
}

.bl {
  margin-left: 4px;
  color: var(--warning);
}

.panel {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.panel:focus {
  outline: none;
}

.panel .title {
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.panel .f {
  cursor: text;
}

.when {
  margin-top: 2px;
  color: var(--text-2);
  font-size: 12.5px;
}

.when.over {
  color: var(--error);
  font-weight: 600;
}

.when .edit {
  width: auto;
  margin: 0 -6px;
}

.panel .f:focus {
  outline: none;
}

.panel .f:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: 3px;
}

.panel .links {
  margin-top: 8px;
}

.panel .links .add {
  visibility: visible;
}

.panel .block,
.blocks {
  margin-top: 8px;
}

.blocks {
  color: var(--warning);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

/* + next step and + blocker sit where their line goes. */
.panel > div > .add {
  display: block;
  margin-top: 6px;
}

.panel .foot {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.foot .grow {
  flex: 1;
}

/* Active: the tasks in progress as cards, newest first */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  align-items: start;
}

.acard {
  padding: 10px 12px 8px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--pro);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.acard.perso {
  border-left-color: var(--perso);
}

.acard.open {
  border-top-color: var(--accent);
  border-right-color: var(--accent);
  border-bottom-color: var(--accent);
}

.acard:focus {
  outline: none;
}

.acard:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.acard .head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.acard .title {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.due {
  flex: none;
  color: var(--text-2);
  font-size: 11.5px;
}

.due.over {
  color: var(--error);
  font-weight: 600;
}

.due .edit {
  width: auto;
  margin: -2px -6px;
  font-size: 12px;
}

.acard .next,
.acard .block {
  margin-top: 4px;
  font-size: 12px;
}

.acard .foot {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin-top: 8px;
}

.acard .links {
  flex: 1;
  margin-top: 0;
}

.acard .act {
  display: flex;
  visibility: hidden;
  margin: 0;
}

/* With the focus anywhere in the card, so the keyboard can reach them. */
.acard:hover .act,
.acard.open .act,
.acard:focus-within .act {
  visibility: visible;
}

.acard:hover .links .add,
.acard:focus-within .links .add,
.acard.open .links .add {
  visibility: visible;
}

.acard .f {
  cursor: text;
}

.acard .f:focus {
  outline: none;
}

.acard .f:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: 3px;
}

/* + next step and + blocker open their line under the title. */
.acard > .next.editing,
.acard > .block.editing {
  margin-top: 6px;
}

/* The phone's day list: hidden on desktop */
.days {
  display: none;
}

/* Mobile quick add: hidden on desktop */
.quick {
  display: none;
}

/* Login */
.login {
  display: flex;
  justify-content: center;
  padding-top: 30vh;
}

.login input {
  width: min(280px, 100%);
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 16px;
  outline: none;
}

.login input:focus {
  border-color: var(--accent);
}

@media (max-width: 699px) {
  #app {
    padding: 12px 12px calc(88px + env(safe-area-inset-bottom));
  }

  .seg {
    flex: 1;
  }

  .seg button {
    flex: 1;
    padding: 6px 0;
  }

  .nav .btn {
    padding: 5px 13px;
  }

  /* Week: a day-by-day list, both profiles mixed, a colored dot per task. */
  .wk {
    display: none;
  }

  .days {
    display: block;
  }

  .dayh {
    margin: 12px 0 5px;
    color: var(--text-2);
    font-size: 11.5px;
    font-weight: 700;
  }

  .dayh.over {
    color: var(--error);
  }

  .dayh.today {
    color: var(--accent);
  }

  .item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    padding: 8px 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .item:focus {
    outline: none;
  }

  .item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
  }

  .item .name {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .pdot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--pro);
  }

  .pdot.perso {
    background: var(--perso);
  }

  .tabs {
    display: flex;
    margin-bottom: 2px;
  }

  .tab {
    flex: 1;
    padding: 6px 0;
    border: 0;
    border-bottom: 2px solid var(--border);
    background: none;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
  }

  .tab.on {
    color: var(--text);
  }

  .tab.on.pro {
    border-color: var(--pro);
  }

  .tab.on.perso {
    border-color: var(--perso);
  }

  .cols {
    display: block;
  }

  .colh,
  .newtask,
  .split[data-tab='pro'] .col.perso,
  .split[data-tab='perso'] .col.pro {
    display: none;
  }

  /* No hover on a phone, and no resume before phase 2. */
  .act {
    display: none !important;
  }

  .row > .date {
    width: 40px;
    font-size: 11.5px;
  }

  .row:not(.open) .links {
    display: none;
  }

  .exp .done,
  .exp .tog,
  .exp .drop {
    display: inline-block;
    padding: 4px 12px;
    font-size: 12px;
  }

  /* A Claude session opens only on the computer where it lives. */
  .lk.claude {
    display: none;
  }

  /* Active: one column; a tap expands a card, which shows ✓ and ×. */
  .cards {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .acard:not(.open) .foot {
    display: none;
  }

  .exp .dot {
    display: inline-flex;
    align-self: stretch;
    width: 32px;
  }

  /* No hover: in the expanded row or card, × sits inline after each chip. */
  .row.open .lk .x,
  .acard.open .lk .x {
    position: static;
    display: inline-flex;
    width: auto;
    height: auto;
    padding: 0 7px;
    border: 0;
    background: none;
    font-size: 14px;
  }

  /* 16 px keeps iOS from zooming into the input. */
  .row .edit,
  .acard .edit {
    font-size: 16px;
  }

  .quick {
    display: block;
  }

  .fab {
    position: fixed;
    right: 16px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    padding: 0 0 3px;
    border: 0;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    cursor: pointer;
  }

  .sheet-wrap {
    position: fixed;
    inset: 0;
    z-index: 20;
  }

  .dim {
    position: absolute;
    inset: 0;
    background: var(--dim);
  }

  .sheet {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    border-radius: 14px 14px 0 0;
    background: var(--surface);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.2);
  }

  .sheet .title {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--bg);
    font-size: 16px;
    outline: none;
  }

  .sheet-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
  }

  .pick {
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-2);
    font-size: 13px;
    cursor: pointer;
  }

  .pick.on.pro {
    border-color: var(--pro);
    color: var(--pro);
  }

  .pick.on.perso {
    border-color: var(--perso);
    color: var(--perso);
  }

  .sheet .cal {
    margin-left: auto;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 13px;
  }
}
