/* =====================================================
   TODAY view
   The stream is the signature: one ranked column where every row carries
   its project's colour as a left spine. Colour does the grouping work so
   the rows themselves can stay quiet and uniform, and the eye can run
   straight down the titles without re-reading a header for each project.
   ===================================================== */

.tw {
  --c-overdue: #dc2626;
  --c-today: #ea580c;
  --c-doing: #2563eb;
  --c-soon: #64748b;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 268px;
  gap: 28px;
  align-items: start;
  max-width: 1180px;
  margin: 0 auto;
  padding: 4px 4px 64px;
}
.tw-loading { padding: 48px; color: var(--text-muted); }

/* ---------- Head ---------- */
.tw-head { padding: 4px 2px 18px; }
.tw-date {
  font-size: 28px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.3;
}
.tw-summary {
  margin-top: 7px;
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.tw-summary b { font-weight: 600; color: var(--text); }
.tw-summary b.c-overdue { color: var(--c-overdue); }
.tw-summary b.c-today { color: var(--c-today); }
.tw-summary b.c-doing { color: var(--c-doing); }

/* ---------- Quick add ---------- */
.tw-add {
  display: flex;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow);
}
.tw-add:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, .12); }
.tw-add-project {
  border: none;
  background: #eef0f4;
  border-radius: 7px;
  padding: 0 8px;
  max-width: 168px;
  color: var(--text);
  font-size: 13px;
}
.tw-add input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  padding: 9px 4px;
  font-size: 15px;
  background: transparent;
  color: var(--text);
}
.tw-add-hint {
  padding: 8px 4px 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.7;
}
.tw-add-hint b { font-weight: 600; color: #4b5563; }
.tw-add-hint.is-preview { color: var(--primary-dark); }
.tw-add-hint.is-preview b { color: var(--primary-dark); }

/* ---------- Sections ---------- */
.tw-sec { margin-top: 30px; }
.tw-sec-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 2px 9px;
}
.tw-sec-title::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.tw-sec-count {
  font-weight: 600;
  letter-spacing: 0;
  color: #9aa2b1;
  font-variant-numeric: tabular-nums;
}
.tw-sec-overdue .tw-sec-title { color: var(--c-overdue); }
.tw-sec-today   .tw-sec-title { color: var(--c-today); }
.tw-sec-doing   .tw-sec-title { color: var(--c-doing); }
.tw-sec-soon    .tw-sec-title { color: var(--c-soon); }

.tw-rows {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

/* ---------- Row ---------- */
.tw-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 14px 0 0;
  min-height: 46px;
  border-bottom: 1px solid #eef0f3;
  transition: background .12s ease;
}
.tw-row:last-child { border-bottom: none; }
.tw-row:hover { background: #fafbfc; }
.tw-row.is-clearing { opacity: .35; }

.tw-spine {
  width: 3px;
  align-self: stretch;
  flex-shrink: 0;
  order: -1;
}

.tw-check {
  width: 18px; height: 18px;
  flex-shrink: 0;
  margin-left: 13px;
  border: 1.5px solid #c3c9d4;
  border-radius: 50%;
  background: transparent;
  position: relative;
  transition: border-color .12s ease, background .12s ease;
}
.tw-check::after {
  content: "";
  position: absolute;
  left: 5px; top: 2px;
  width: 4px; height: 8px;
  border: solid #fff;
  border-width: 0 1.8px 1.8px 0;
  transform: rotate(45deg) scale(.5);
  opacity: 0;
  transition: opacity .12s ease, transform .12s ease;
}
.tw-check:hover { border-color: var(--ok); background: var(--ok); }
.tw-check:hover::after { opacity: 1; transform: rotate(45deg) scale(1); }
.tw-check:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.tw-title {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: none;
  background: none;
  padding: 12px 0;
  font-size: 14.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tw-title:hover { color: var(--primary-dark); text-decoration: underline; text-underline-offset: 2px; }
.tw-title:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 3px; }

.tw-prio {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 2px 7px;
  border-radius: 20px;
}
.tw-prio.p-urgent { background: #fee2e2; color: #b91c1c; }
.tw-prio.p-high   { background: #ffedd5; color: #c2410c; }
.tw-prio.p-low    { background: #f1f5f9; color: #64748b; }

.tw-proj {
  flex-shrink: 0;
  max-width: 140px;
  font-size: 12px;
  color: #98a0ae;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tw-due {
  flex-shrink: 0;
  min-width: 78px;
  text-align: right;
  font-size: 12px;
  color: #98a0ae;
  font-variant-numeric: tabular-nums;
}
.tw-due.is-overdue { color: var(--c-overdue); font-weight: 600; }
.tw-due.is-today   { color: var(--c-today); font-weight: 600; }
.tw-due.is-soon    { color: #64748b; }

.tw-more {
  width: 100%;
  margin-top: 8px;
  padding: 9px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
}
.tw-more:hover { border-color: var(--primary); color: var(--primary-dark); background: #f8f8ff; }

/* ---------- Nothing left ---------- */
.tw-clear { text-align: center; padding: 72px 20px; color: var(--text-muted); }
.tw-clear-mark {
  width: 52px; height: 52px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: #e8f7f1;
  color: var(--ok);
  font-size: 26px;
  line-height: 52px;
}
.tw-clear h2 { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.tw-clear p { font-size: 13px; }

/* ---------- Project rail ---------- */
.tw-rail { position: sticky; top: 4px; }
.tw-rail-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 2px 9px;
  padding-top: 4px;
}
.tw-rail-empty { font-size: 13px; color: var(--text-muted); padding: 0 2px; }
.tw-projrow {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 11px;
  margin-bottom: 7px;
  transition: border-color .12s ease, transform .12s ease;
}
.tw-projrow:hover { border-color: #c7cbd6; transform: translateX(-2px); }
.tw-projrow:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tw-projrow-top { display: flex; align-items: center; gap: 7px; }
.tw-projrow .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tw-projrow-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tw-projrow-alert {
  flex-shrink: 0;
  min-width: 17px;
  text-align: center;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 20px;
  background: #fee2e2;
  color: #b91c1c;
}
.tw-projrow-count {
  flex-shrink: 0;
  font-size: 11px;
  color: #98a0ae;
  font-variant-numeric: tabular-nums;
}
.tw-bar {
  display: block;
  height: 3px;
  margin-top: 8px;
  border-radius: 3px;
  background: #edeff3;
  overflow: hidden;
}
.tw-bar-fill { display: block; height: 100%; border-radius: 3px; opacity: .85; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .tw { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .tw-rail { position: static; margin-top: 30px; }
  .tw-proj { display: none; }
}
@media (max-width: 560px) {
  .tw-date { font-size: 22px; }
  .tw-add { flex-wrap: wrap; }
  .tw-add-project { max-width: none; flex: 1 0 100%; padding: 7px 8px; }
  .tw-prio { display: none; }
  .tw-due { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .tw-row, .tw-check, .tw-check::after, .tw-projrow { transition: none; }
}

/* Sidebar: Today badge — only shows when something is actually due */
#today-badge.urgent {
  background: #dc2626;
  color: #fff;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  font-variant-numeric: tabular-nums;
}

/* =====================================================
   Chrome adjustments
   ===================================================== */

/* Today writes its own header, so the app topbar would only repeat it.
   Kept on small screens because it carries the sidebar toggle. */
@media (min-width: 961px) {
  body.today-mode .topbar { display: none; }
}
body.today-mode .view-container { padding-top: 18px; }

/* Left-align the stream instead of centring it — centring left a dead
   gutter next to the sidebar and pushed the first task off the eye's path. */
.tw { margin: 0; max-width: 1240px; padding-left: 6px; }

/* Sidebar folders are wayfinding, not controls: quiet until you reach for them. */
.sidebar-group-header { opacity: .62; transition: opacity .12s ease; }
.sidebar-group-header:hover { opacity: 1; }
.sidebar-group-header .count { opacity: 0; transition: opacity .12s ease; }
.sidebar-group-header:hover .count { opacity: .8; }
.group-actions { opacity: 0; transition: opacity .12s ease; }
.sidebar-group-header:hover .group-actions { opacity: 1; }
.sidebar-group-header:focus-within .group-actions,
.sidebar-group-header:focus-within .count { opacity: 1; }

/* A project with nothing open shouldn't compete with one that needs work. */
.tw-projrow.is-clear { opacity: .5; }
.tw-projrow.is-clear:hover { opacity: 1; }
