/* ==========================================================================
   TaskNest styles
   Layout:  >= 992px  sidebar + content (scales from laptops to 27" monitors)
            <  992px  phone/tablet app layout with a bottom tab bar
   ========================================================================== */

:root {
  --tn-ink: #151A3D;
  --tn-ink-2: #20275A;
  --tn-canvas: #F1F3FA;
  --tn-surface: #FFFFFF;
  --tn-surface-2: #F6F7FC;
  --tn-line: #E1E5F2;
  --tn-text: #1A1F40;
  --tn-muted: #666E90;

  --tn-cobalt: #2F5BEA;
  --tn-cobalt-dark: #2348C4;
  --tn-coral: #FF5A6E;
  --tn-sun: #FFB21E;
  --tn-mint: #11B78A;
  --tn-violet: #8A5CF6;
  --tn-sky: #18A8F0;
  --tn-orange: #FF7A2F;

  --tn-radius: 1.25rem;
  --tn-radius-sm: .75rem;
  --tn-shadow: 0 1px 2px rgba(21, 26, 61, .05), 0 8px 24px -12px rgba(21, 26, 61, .18);
  --tn-display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif;
  --tn-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tn-tabbar: 4.25rem;
}

html[data-bs-theme="dark"] {
  --tn-ink: #0B0D20;
  --tn-ink-2: #1A1F47;
  --tn-canvas: #0F1228;
  --tn-surface: #191D3C;
  --tn-surface-2: #20254A;
  --tn-line: #2D3363;
  --tn-text: #ECEEFB;
  --tn-muted: #9DA4C8;
  --tn-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px -14px rgba(0, 0, 0, .6);
}

/* Bootstrap theme hooks */
html[data-bs-theme] {
  --bs-body-font-family: var(--tn-body);
  --bs-body-bg: var(--tn-canvas);
  --bs-body-color: var(--tn-text);
  --bs-secondary-color: var(--tn-muted);
  --bs-border-color: var(--tn-line);
  --bs-primary: var(--tn-cobalt);
  --bs-primary-rgb: 47, 91, 234;
  --bs-link-color: var(--tn-cobalt);
  --bs-link-color-rgb: 47, 91, 234;
  --bs-border-radius: .75rem;
  --bs-focus-ring-color: rgba(47, 91, 234, .28);
}

/* Type scales with the screen: 14px on small laptops up to 17.5px on 27" monitors.
   Everything is sized in rem, so the whole interface follows. */
html { font-size: 16px; }
@media (min-width: 992px) {
  html { font-size: clamp(14px, calc(0.42vw + 8.6px), 17.5px); }
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display { font-family: var(--tn-display); letter-spacing: -.01em; color: inherit; }
button { font-family: inherit; }
:focus-visible { outline: 3px solid rgba(47, 91, 234, .45); outline-offset: 2px; }

/* ---------- Bootstrap component tuning ---------- */
.btn { --bs-btn-font-weight: 600; --bs-btn-border-radius: .8rem; --bs-btn-padding-x: 1rem; --bs-btn-padding-y: .55rem; }
.btn-lg { --bs-btn-border-radius: 1rem; --bs-btn-padding-y: .8rem; --bs-btn-font-size: 1.05rem; }
.btn-sm { --bs-btn-border-radius: .6rem; --bs-btn-padding-y: .3rem; --bs-btn-padding-x: .7rem; }
.btn-primary {
  --bs-btn-bg: var(--tn-cobalt); --bs-btn-border-color: var(--tn-cobalt);
  --bs-btn-hover-bg: var(--tn-cobalt-dark); --bs-btn-hover-border-color: var(--tn-cobalt-dark);
  --bs-btn-active-bg: #1E3DA8; --bs-btn-active-border-color: #1E3DA8;
  --bs-btn-disabled-bg: var(--tn-cobalt); --bs-btn-disabled-border-color: var(--tn-cobalt);
}
.btn-light {
  --bs-btn-bg: var(--tn-surface-2); --bs-btn-border-color: var(--tn-line); --bs-btn-color: var(--tn-text);
  --bs-btn-hover-bg: var(--tn-line); --bs-btn-hover-border-color: var(--tn-line); --bs-btn-hover-color: var(--tn-text);
  --bs-btn-active-bg: var(--tn-line); --bs-btn-active-border-color: var(--tn-line); --bs-btn-active-color: var(--tn-text);
}
.btn-danger { --bs-btn-bg: #E8364F; --bs-btn-border-color: #E8364F; --bs-btn-hover-bg: #C92A41; --bs-btn-hover-border-color: #C92A41; }

.form-label { font-weight: 600; font-size: .875rem; margin-bottom: .35rem; color: var(--tn-text); }
.form-control, .form-select {
  background-color: var(--tn-surface-2);
  border-color: var(--tn-line);
  color: var(--tn-text);
  border-radius: .8rem;
  padding: .6rem .85rem;
}
.form-control:focus, .form-select:focus {
  background-color: var(--tn-surface);
  border-color: var(--tn-cobalt);
  box-shadow: 0 0 0 .22rem rgba(47, 91, 234, .18);
  color: var(--tn-text);
}
.form-control::placeholder { color: var(--tn-muted); opacity: .8; }
.form-control-lg { border-radius: 1rem; padding: .8rem 1rem; }

.modal { --bs-modal-bg: var(--tn-surface); --bs-modal-border-width: 0; --bs-modal-border-radius: 1.5rem; --bs-modal-inner-border-radius: 1.5rem;
  --bs-modal-header-border-width: 0; --bs-modal-footer-border-color: var(--tn-line); --bs-modal-padding: 1.25rem 1.5rem; --bs-modal-header-padding: 1.25rem 1.5rem .5rem; }
.modal-content { box-shadow: 0 30px 80px -20px rgba(11, 13, 32, .5); }
.modal-title { font-size: 1.3rem; font-weight: 700; }
.modal-footer { padding: .9rem 1.5rem; gap: .25rem; }
.modal-backdrop { --bs-backdrop-bg: #0B0D20; --bs-backdrop-opacity: .55; }
@media (min-width: 576px) { .modal-sm-wide { --bs-modal-width: 26rem; } }

.dropdown-menu {
  --bs-dropdown-bg: var(--tn-surface); --bs-dropdown-border-color: var(--tn-line); --bs-dropdown-border-radius: .9rem;
  --bs-dropdown-link-color: var(--tn-text); --bs-dropdown-link-hover-bg: var(--tn-surface-2); --bs-dropdown-link-hover-color: var(--tn-text);
  --bs-dropdown-link-active-bg: var(--tn-surface-2); --bs-dropdown-link-active-color: var(--tn-text);
  --bs-dropdown-padding-y: .4rem; --bs-dropdown-item-padding-y: .5rem; --bs-dropdown-min-width: 12.5rem;
  box-shadow: var(--tn-shadow);
}
.dropdown-item { display: flex; align-items: center; gap: .65rem; font-weight: 500; }
.dropdown-item i { color: var(--tn-muted); width: 1.1rem; text-align: center; }
.dropdown-item.text-danger i { color: inherit; }
.dropdown-header { color: var(--tn-muted); font-weight: 600; }

/* ---------- Shared bits ---------- */
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 2.5rem; height: 2.5rem; border-radius: .8rem;
  border: 0; background: transparent; color: var(--tn-muted); font-size: 1.15rem;
}
.icon-btn:hover { background: var(--tn-surface-2); color: var(--tn-text); }
.icon-btn-sm { width: 2rem; height: 2rem; font-size: 1rem; border-radius: .6rem; }
.icon-btn-dark { color: rgba(255, 255, 255, .8); }
.icon-btn-dark:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 2.6rem; height: 2.6rem; border-radius: .9rem;
  background: var(--c, var(--tn-cobalt)); color: #fff;
  font-family: var(--tn-display); font-weight: 700; font-size: 1.15rem; text-transform: uppercase;
}
.dot { width: .65rem; height: .65rem; border-radius: 50%; background: var(--c, var(--tn-muted)); flex: none; display: inline-block; }

.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .8rem; font-weight: 500; line-height: 1.2; white-space: nowrap;
  padding: .22rem .6rem; border-radius: 999px;
  background: var(--tn-surface-2); color: var(--tn-muted);
}
.chip i { font-size: .8rem; }
.chip-c { background: color-mix(in srgb, var(--c) 14%, transparent); color: color-mix(in srgb, var(--c) 78%, var(--tn-text)); font-weight: 600; }
.chip-overdue { background: color-mix(in srgb, var(--tn-coral) 16%, transparent); color: #D62C45; font-weight: 600; }
html[data-bs-theme="dark"] .chip-overdue { color: #FF8696; }
.chip-today { background: color-mix(in srgb, var(--tn-cobalt) 14%, transparent); color: var(--tn-cobalt); font-weight: 600; }
html[data-bs-theme="dark"] .chip-today { color: #8FA8FF; }

.empty { text-align: center; padding: 3rem 1.25rem; max-width: 28rem; margin: 0 auto; }
.empty h3 { font-size: 1.25rem; font-weight: 700; margin: 1rem 0 .35rem; }
.empty p { color: var(--tn-muted); margin-bottom: 1.25rem; }
.empty-icon {
  display: inline-grid; place-items: center; width: 4rem; height: 4rem; border-radius: 1.25rem;
  background: color-mix(in srgb, var(--c, var(--tn-cobalt)) 15%, transparent);
  color: var(--c, var(--tn-cobalt)); font-size: 1.7rem;
}
.spinner-wrap { display: grid; place-items: center; min-height: 40vh; color: var(--tn-muted); }

/* ==========================================================================
   Shell
   ========================================================================== */
.app { display: flex; min-height: 100dvh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Sidebar ---------- */
.sidebar { --bs-offcanvas-width: min(20rem, 86vw); --bs-offcanvas-bg: var(--tn-ink); --bs-offcanvas-border-width: 0; }
.sidebar-inner {
  background: var(--tn-ink); color: #fff;
  display: flex; flex-direction: column; gap: .9rem;
  height: 100%; width: 100%;
  padding: 1.1rem .9rem calc(.9rem + env(safe-area-inset-bottom));
}
@media (min-width: 992px) {
  .sidebar { flex: none; width: clamp(15rem, 17vw, 18.5rem); position: sticky; top: 0; height: 100dvh; }
}
.brand { display: flex; align-items: center; gap: .7rem; padding: .15rem .45rem; }
.brand-mark { width: 2.2rem; height: 2.2rem; flex: none; }
.brand-name { font-family: var(--tn-display); font-weight: 700; font-size: 1.35rem; letter-spacing: -.02em; }

.ws-switch {
  display: flex; align-items: center; gap: .75rem; width: 100%; text-align: left;
  padding: .6rem .7rem; border-radius: 1rem; border: 1px solid rgba(255, 255, 255, .1);
  background: var(--tn-ink-2); color: #fff;
}
.ws-switch:hover { border-color: rgba(255, 255, 255, .28); }
.ws-switch-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.ws-switch-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-switch-hint { font-size: .78rem; color: rgba(255, 255, 255, .6); }
.ws-switch > i { color: rgba(255, 255, 255, .6); }

.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -.3rem; padding: 0 .3rem; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.side-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .78rem; font-weight: 600; color: rgba(255, 255, 255, .5);
  padding: .9rem .75rem .35rem;
}
.side-label .icon-btn { width: 1.7rem; height: 1.7rem; font-size: .95rem; }
.side-link {
  display: flex; align-items: center; gap: .75rem; width: 100%; text-align: left;
  padding: .55rem .75rem; border-radius: .8rem; border: 0;
  background: transparent; color: rgba(255, 255, 255, .78); font-weight: 500;
}
.side-link > i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.side-link > span:not(.count):not(.dot) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-link .dot { margin: 0 .28rem; }
.side-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.side-link.active { background: var(--tn-cobalt); color: #fff; font-weight: 600; }
.side-link .count { font-size: .78rem; font-weight: 600; color: rgba(255, 255, 255, .6); min-width: 1.5rem; text-align: right; }
.side-link.active .count { color: #fff; }
.side-link .count.hot { background: var(--tn-coral); color: #fff; border-radius: 999px; padding: .05rem .45rem; text-align: center; }
.side-row { display: flex; align-items: center; }
.side-row .side-link { flex: 1; min-width: 0; }
.side-row .edit { opacity: 0; }
.side-row:hover .edit, .side-row .edit:focus-visible { opacity: 1; }
@media (hover: none) { .side-row .edit { opacity: .7; } }
.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .1); padding-top: .6rem; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; gap: .6rem;
  padding: .8rem clamp(1rem, 2.2vw, 2.25rem);
  padding-top: calc(.8rem + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--tn-canvas) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 1.45rem; font-weight: 700; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-title p { margin: 0; font-size: .85rem; color: var(--tn-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search {
  display: flex; align-items: center; gap: .55rem; margin: 0;
  width: clamp(14rem, 24vw, 26rem); padding: 0 .85rem; height: 2.7rem;
  background: var(--tn-surface); border: 1px solid var(--tn-line); border-radius: .9rem; color: var(--tn-muted);
}
.search:focus-within { border-color: var(--tn-cobalt); box-shadow: 0 0 0 .22rem rgba(47, 91, 234, .16); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--tn-text); font-size: 1rem; }
.search kbd { background: var(--tn-surface-2); color: var(--tn-muted); border: 1px solid var(--tn-line); border-radius: .4rem; font-size: .72rem; padding: .1rem .4rem; }
.btn-ai {
  display: inline-flex; align-items: center; gap: .45rem;
  --bs-btn-bg: var(--tn-violet); --bs-btn-border-color: var(--tn-violet); --bs-btn-color: #fff;
  --bs-btn-hover-bg: #7443E8; --bs-btn-hover-border-color: #7443E8; --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: #6335D6; --bs-btn-active-border-color: #6335D6; --bs-btn-active-color: #fff;
}

.view { flex: 1; padding: .5rem clamp(1rem, 2.2vw, 2.25rem) 2.5rem; }

/* ---------- Phone layout ---------- */
.tabbar { display: none; }
@media (max-width: 991.98px) {
  .topbar { gap: .25rem; padding-left: .6rem; padding-right: .75rem; flex-wrap: wrap; }
  .topbar-title h1 { font-size: 1.3rem; }
  .topbar .search { display: none; order: 10; width: 100%; margin-top: .5rem; }
  .topbar.searching .search { display: flex; }
  .btn-ai { padding: 0; width: 2.5rem; height: 2.5rem; justify-content: center; border-radius: .8rem; }
  .btn-ai span { display: none; }
  .view { padding-bottom: calc(var(--tn-tabbar) + 2.75rem + env(safe-area-inset-bottom)); }

  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    display: grid; grid-template-columns: 1fr 1fr 4.6rem 1fr 1fr; align-items: center;
    height: calc(var(--tn-tabbar) + env(safe-area-inset-bottom));
    padding: 0 .4rem env(safe-area-inset-bottom);
    background: var(--tn-surface); border-top: 1px solid var(--tn-line);
    box-shadow: 0 -10px 30px -18px rgba(21, 26, 61, .35);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
    height: 100%; border: 0; background: none; color: var(--tn-muted); font-size: .72rem; font-weight: 600;
  }
  .tab i { font-size: 1.35rem; line-height: 1; padding: .2rem 1.05rem; border-radius: 999px; }
  .tab.active { color: var(--tn-cobalt); }
  .tab.active i { background: color-mix(in srgb, var(--tn-cobalt) 14%, transparent); }
  html[data-bs-theme="dark"] .tab.active { color: #8FA8FF; }
  .fab {
    justify-self: center; width: 3.75rem; height: 3.75rem; border-radius: 1.35rem; border: 4px solid var(--tn-canvas);
    background: var(--tn-cobalt); color: #fff; font-size: 1.5rem; display: grid; place-items: center;
    transform: translateY(-1.1rem); box-shadow: 0 12px 22px -8px rgba(47, 91, 234, .7);
  }
  .fab:active { transform: translateY(-1.1rem) scale(.94); }
}
@media (min-width: 576px) and (max-width: 991.98px) {
  .view { max-width: 46rem; margin: 0 auto; width: 100%; }
}

/* ==========================================================================
   Smart add (natural-language quick add)
   ========================================================================== */
.smart-add {
  background: var(--tn-surface); border: 2px solid var(--tn-line); border-radius: var(--tn-radius);
  padding: .55rem .6rem .55rem .7rem; box-shadow: var(--tn-shadow);
}
.smart-add:focus-within { border-color: var(--tn-violet); }
.smart-add-row { display: flex; align-items: center; gap: .65rem; }
.smart-add-icon { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: .85rem; background: var(--tn-violet); color: #fff; font-size: 1.15rem; flex: none; }
.smart-add input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--tn-text); font-size: 1.08rem; padding: .4rem 0; }
.smart-add input::placeholder { color: var(--tn-muted); }
.smart-preview { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; padding: .5rem .2rem .15rem 3.25rem; font-size: .82rem; color: var(--tn-muted); }
.smart-preview:empty { display: none; }
.smart-preview code { background: var(--tn-surface-2); color: var(--tn-text); border-radius: .4rem; padding: .1rem .4rem; font-family: inherit; font-weight: 600; }
@media (max-width: 575.98px) {
  .smart-preview { padding-left: .2rem; }
  .smart-add .btn span { display: none; }
}

/* ==========================================================================
   Dashboard
   ========================================================================== */
.dash { display: flex; flex-direction: column; gap: 1.25rem; max-width: 118rem; }
.greeting h2 { font-size: clamp(1.7rem, 2.4vw, 2.4rem); font-weight: 700; margin: 0; letter-spacing: -.025em; line-height: 1.1; }
.greeting p { color: var(--tn-muted); margin: .3rem 0 0; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.tile {
  position: relative; overflow: hidden; text-align: left; border: 0;
  border-radius: var(--tn-radius); padding: 1.1rem 1.2rem; min-height: 8rem;
  display: flex; flex-direction: column; justify-content: space-between;
  background: var(--c); color: #fff; transition: transform .15s ease;
}
.tile:hover { transform: translateY(-2px); }
.tile::after { /* quarter-circle cut into the corner */
  content: ""; position: absolute; right: -2.2rem; bottom: -2.2rem; width: 7rem; height: 7rem; border-radius: 50%;
  background: rgba(255, 255, 255, .16);
}
.tile-top { display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: .95rem; }
.tile-top i { font-size: 1.25rem; opacity: .9; }
.tile-num { font-family: var(--tn-display); font-weight: 700; font-size: 2.9rem; line-height: 1; letter-spacing: -.03em; }
.tile-note { font-size: .82rem; opacity: .9; margin-left: .5rem; font-weight: 500; }
.tile.on-light { color: #3D2A00; }
.tile.on-light::after { background: rgba(255, 255, 255, .3); }

.dash-grid { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); align-items: start; }
.dash-side { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
@media (min-width: 1750px) {
  .dash-grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 1fr); }
  .dash-side { display: contents; }
}
@media (max-width: 991.98px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  .tile { min-height: 7rem; padding: .9rem 1rem; }
  .tile-num { font-size: 2.4rem; }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}

.panel { background: var(--tn-surface); border-radius: var(--tn-radius); padding: 1.25rem; box-shadow: var(--tn-shadow); }
.panel-head { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.panel-head h3 { font-size: 1.15rem; font-weight: 700; margin: 0; flex: 1; }

/* Focus plan (AI) */
.focus { background: var(--tn-ink); color: #fff; box-shadow: none; }
.focus .panel-head h3 { display: flex; align-items: center; gap: .55rem; }
.focus .panel-head h3 i { color: var(--tn-sun); }
.focus-source { font-size: .75rem; font-weight: 600; padding: .2rem .6rem; border-radius: 999px; background: rgba(255, 255, 255, .12); color: rgba(255, 255, 255, .85); }
.focus-summary { font-size: 1.05rem; line-height: 1.45; color: rgba(255, 255, 255, .92); margin-bottom: 1rem; }
.focus-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.focus-item { display: flex; align-items: center; gap: .8rem; padding: .7rem .8rem; border-radius: 1rem; background: var(--tn-ink-2); cursor: pointer; }
.focus-item:hover { background: #2A3270; }
.focus-rank { font-family: var(--tn-display); font-weight: 700; font-size: 1.05rem; width: 2rem; height: 2rem; border-radius: .7rem; display: grid; place-items: center; background: var(--c); color: #fff; flex: none; }
.focus-text { flex: 1; min-width: 0; }
.focus-text b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.focus-text span { font-size: .84rem; color: rgba(255, 255, 255, .68); }
.focus .check { border-color: rgba(255, 255, 255, .45); }
.focus-tip { display: flex; gap: .6rem; font-size: .9rem; color: rgba(255, 255, 255, .8); margin-top: .9rem; }
.focus-tip i { color: var(--tn-sun); }
.focus-stale { margin-top: .9rem; font-size: .85rem; color: rgba(255, 255, 255, .7); }
.focus .btn-refresh { border: 0; background: rgba(255, 255, 255, .12); color: #fff; border-radius: .7rem; padding: .35rem .7rem; font-weight: 600; font-size: .85rem; display: inline-flex; gap: .4rem; align-items: center; }
.focus .btn-refresh:hover { background: rgba(255, 255, 255, .22); }
.spin { animation: tn-spin 1s linear infinite; display: inline-block; }
@keyframes tn-spin { to { transform: rotate(360deg); } }

/* Week ahead */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .45rem; align-items: end; }
.week-day { border: 0; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: .35rem; color: var(--tn-muted); }
.week-count { font-family: var(--tn-display); font-weight: 700; color: var(--tn-text); font-size: .95rem; }
.week-bar { width: 100%; height: 6.5rem; border-radius: .7rem; background: var(--tn-surface-2); display: flex; align-items: flex-end; overflow: hidden; }
.week-bar span { display: block; width: 100%; border-radius: .7rem; background: var(--tn-cobalt); min-height: 0; }
.week-day.is-today .week-bar span { background: var(--tn-sun); }
.week-day.is-today .week-name { color: var(--tn-text); font-weight: 700; }
.week-day:hover .week-bar { outline: 2px solid var(--tn-line); }
.week-name { font-size: .78rem; font-weight: 600; line-height: 1.15; text-align: center; }
.week-name small { display: block; font-size: .95rem; color: var(--tn-text); font-family: var(--tn-display); font-weight: 700; }

/* Projects progress */
.proj-list { display: flex; flex-direction: column; gap: .2rem; }
.proj-row { display: block; width: 100%; text-align: left; border: 0; background: none; padding: .55rem .5rem; border-radius: .8rem; color: var(--tn-text); }
.proj-row:hover { background: var(--tn-surface-2); }
.proj-row-top { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; font-weight: 600; }
.proj-row-top span.name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-row-top small { color: var(--tn-muted); font-weight: 500; }
.bar { display: block; height: .5rem; border-radius: 999px; background: var(--tn-surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 999px; background: var(--c, var(--tn-cobalt)); }

/* ==========================================================================
   Task list
   ========================================================================== */
.list-wrap { max-width: 78rem; display: flex; flex-direction: column; gap: 1rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.toolbar .form-select { width: auto; background-color: var(--tn-surface); padding: .45rem 2.2rem .45rem .8rem; font-weight: 500; font-size: .92rem; }
.toolbar .spacer { flex: 1; }
@media (max-width: 575.98px) {
  .toolbar { flex-wrap: nowrap; overflow-x: auto; margin: 0 -1rem; padding: 0 1rem .15rem; scrollbar-width: none; }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar > * { flex: none; }
  .toolbar .spacer { display: none; }
}

.group-head {
  display: flex; align-items: center; gap: .55rem; width: 100%; text-align: left;
  border: 0; background: none; padding: .35rem .25rem .5rem; color: var(--tn-text);
  font-family: var(--tn-display); font-weight: 700; font-size: 1.05rem;
}
.group-head .count { font-family: var(--tn-body); font-size: .8rem; font-weight: 600; color: var(--tn-muted); background: var(--tn-surface); border-radius: 999px; padding: .1rem .55rem; }
.group-head .bi-chevron-down { font-size: .8rem; color: var(--tn-muted); transition: transform .2s; }
.group.collapsed .bi-chevron-down { transform: rotate(-90deg); }
.group.collapsed .group-body { display: none; }
.group-body { background: var(--tn-surface); border-radius: var(--tn-radius); box-shadow: var(--tn-shadow); }
.group-body > .task-row:first-child { border-radius: var(--tn-radius) var(--tn-radius) 0 0; }
.group-body > .task-row:last-child { border-radius: 0 0 var(--tn-radius) var(--tn-radius); }
.group-body > .task-row:only-child { border-radius: var(--tn-radius); }

.task-row {
  display: flex; align-items: center; gap: .7rem;
  padding: .75rem .6rem .75rem 0; position: relative;
  border-bottom: 1px solid var(--tn-line);
}
.task-row:last-child { border-bottom: 0; }
.task-row::before { content: ""; align-self: stretch; width: .28rem; border-radius: 0 .3rem .3rem 0; background: var(--p); flex: none; margin: .1rem 0; }
.task-row:hover { background: color-mix(in srgb, var(--tn-surface-2) 70%, transparent); }
.check {
  flex: none; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  border: 2px solid var(--p, var(--tn-muted)); background: transparent; color: transparent;
  display: grid; place-items: center; font-size: .95rem; padding: 0; transition: background .15s, transform .15s;
}
.check:hover { background: color-mix(in srgb, var(--p, var(--tn-mint)) 20%, transparent); color: var(--p, var(--tn-mint)); }
.check:active { transform: scale(.88); }
.is-done > .check, .check.on { background: var(--tn-mint); border-color: var(--tn-mint); color: #fff; }
.task-main { flex: 1; min-width: 0; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .75rem; }
.task-title { font-weight: 600; font-size: 1rem; line-height: 1.3; min-width: 0; overflow-wrap: anywhere; flex: 1 1 16rem; }
.task-meta { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.is-done .task-title { text-decoration: line-through; color: var(--tn-muted); font-weight: 500; }
.is-done::before { opacity: .35; }
.star { border: 0; background: none; color: var(--tn-line); font-size: 1.1rem; width: 2.2rem; height: 2.2rem; border-radius: .6rem; flex: none; }
.star:hover { color: var(--tn-sun); }
.star.on { color: var(--tn-sun); }
html[data-bs-theme="dark"] .star { color: #454C82; }
html[data-bs-theme="dark"] .star.on { color: var(--tn-sun); }
@media (max-width: 575.98px) {
  .task-row { align-items: flex-start; padding-top: .85rem; padding-bottom: .85rem; }
  .task-row .check { margin-top: .05rem; }
  .task-title { flex-basis: 100%; }
}

/* ==========================================================================
   Board
   ========================================================================== */
.board { display: grid; grid-template-columns: repeat(4, minmax(15.5rem, 1fr)); gap: 1rem; align-items: start; }
.board-col { background: color-mix(in srgb, var(--s) 9%, var(--tn-surface)); border-radius: var(--tn-radius); padding: .7rem; border-top: .35rem solid var(--s); }
.board-col.over { outline: 2px dashed var(--s); outline-offset: 2px; }
.board-head { display: flex; align-items: center; gap: .5rem; padding: .25rem .35rem .7rem; font-family: var(--tn-display); font-weight: 700; font-size: 1.05rem; }
.board-head .count { font-family: var(--tn-body); font-size: .8rem; font-weight: 700; background: var(--s); color: #fff; border-radius: 999px; padding: .08rem .55rem; }
.board-head .icon-btn { margin-left: auto; width: 2rem; height: 2rem; }
.board-list { display: flex; flex-direction: column; gap: .6rem; min-height: 5rem; }
.board-empty { border: 2px dashed color-mix(in srgb, var(--s) 35%, transparent); border-radius: 1rem; padding: 1.1rem .75rem; text-align: center; color: var(--tn-muted); font-size: .9rem; }
.card-task {
  background: var(--tn-surface); border-radius: 1rem; padding: .8rem .85rem .8rem 1rem; position: relative;
  box-shadow: var(--tn-shadow); cursor: pointer;
}
.card-task::before { content: ""; position: absolute; left: 0; top: .7rem; bottom: .7rem; width: .28rem; border-radius: 0 .3rem .3rem 0; background: var(--p); }
.card-task[draggable="true"] { cursor: grab; }
.card-task.dragging { opacity: .45; }
.card-top { display: flex; align-items: flex-start; gap: .4rem; }
.card-title { flex: 1; min-width: 0; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.card-task.is-done .card-title { text-decoration: line-through; color: var(--tn-muted); }
.card-top .icon-btn { margin: -.3rem -.4rem 0 0; }
.card-meta { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .55rem; }
.card-task .bar { margin-top: .65rem; height: .35rem; }
@media (max-width: 991.98px) {
  .board {
    display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: .75rem;
    margin: 0 -1rem; padding: 0 1rem 1rem; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .board::-webkit-scrollbar { display: none; }
  .board-col { flex: 0 0 min(84vw, 21rem); scroll-snap-align: center; }
}

/* ==========================================================================
   Calendar
   ========================================================================== */
.cal-wrap { display: grid; grid-template-columns: minmax(0, 1fr) clamp(19rem, 25vw, 25rem); gap: 1.25rem; align-items: start; }
@media (max-width: 1199.98px) { .cal-wrap { grid-template-columns: minmax(0, 1fr); } }
.cal-head { display: flex; align-items: center; gap: .4rem; margin-bottom: .9rem; }
.cal-head h3 { font-size: 1.3rem; font-weight: 700; margin: 0 auto 0 .25rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .35rem; }
.cal-dow { text-align: center; font-size: .78rem; font-weight: 600; color: var(--tn-muted); padding-bottom: .2rem; }
.cal-day {
  display: flex; flex-direction: column; gap: .2rem; text-align: left; overflow: hidden;
  min-height: clamp(3.4rem, 11.5vh, 8rem); padding: .35rem .4rem;
  border: 2px solid transparent; border-radius: .8rem; background: var(--tn-surface-2); color: var(--tn-text);
}
.cal-day:hover { border-color: var(--tn-line); }
.cal-day.other { background: transparent; }
.cal-day.other .cal-num { color: var(--tn-muted); opacity: .6; }
.cal-day.selected { border-color: var(--tn-cobalt); background: color-mix(in srgb, var(--tn-cobalt) 7%, var(--tn-surface)); }
.cal-num { font-family: var(--tn-display); font-weight: 700; font-size: .92rem; width: 1.75rem; height: 1.75rem; display: grid; place-items: center; border-radius: 50%; flex: none; }
.cal-day.today .cal-num { background: var(--tn-cobalt); color: #fff; }
.cal-chip {
  font-size: .74rem; font-weight: 600; line-height: 1.35; padding: .05rem .35rem; border-radius: .35rem;
  background: color-mix(in srgb, var(--p) 16%, transparent); border-left: .2rem solid var(--p);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%;
}
.cal-chip.done { text-decoration: line-through; opacity: .55; }
.cal-more { font-size: .72rem; color: var(--tn-muted); font-weight: 600; padding-left: .2rem; }
.cal-dots { display: none; gap: .18rem; flex-wrap: wrap; }
.cal-dots i { width: .4rem; height: .4rem; border-radius: 50%; background: var(--p); display: block; }
.day-panel .panel-head h3 small { display: block; font-family: var(--tn-body); font-size: .85rem; font-weight: 500; color: var(--tn-muted); }
.day-panel .group-body { box-shadow: none; border: 1px solid var(--tn-line); }
@media (max-width: 767.98px) {
  .cal.panel { padding: .9rem .6rem; }
  .cal-day { min-height: 3.3rem; align-items: center; padding: .25rem .1rem; }
  .cal-chip, .cal-more { display: none; }
  .cal-dots { display: flex; justify-content: center; }
}

/* ==========================================================================
   Workspace modal
   ========================================================================== */
body.no-ws { background: var(--tn-ink); }
body.no-ws .modal-backdrop { opacity: 0; }
.ws-modal { overflow: hidden; }
.ws-hero { position: relative; overflow: hidden; background: var(--tn-ink); color: #fff; padding: 1.75rem 1.5rem 1.5rem; flex: none; }
.ws-hero .brand-mark { width: 3rem; height: 3rem; position: relative; }
.ws-hero h2 { font-size: 1.75rem; font-weight: 700; margin: 1rem 0 .4rem; letter-spacing: -.02em; position: relative; }
.ws-hero p { margin: 0; color: rgba(255, 255, 255, .78); max-width: 26rem; position: relative; }
.ws-hero-shape { position: absolute; border-radius: 50%; }
.ws-hero-shape.s1 { width: 9rem; height: 9rem; background: var(--tn-cobalt); right: -2.5rem; top: -3rem; }
.ws-hero-shape.s2 { width: 4.2rem; height: 4.2rem; background: var(--tn-coral); right: 4.6rem; top: 1.1rem; }
.ws-hero-shape.s3 { width: 2.4rem; height: 2.4rem; background: var(--tn-mint); right: 1.4rem; top: 5.4rem; }
.ws-close { position: absolute; right: 1rem; top: 1rem; z-index: 2; }
.ws-form { display: flex; gap: .6rem; }
.ws-form .form-control { flex: 1; min-width: 0; }
.ws-form .btn { white-space: nowrap; }
@media (max-width: 575.98px) { .ws-form { flex-direction: column; } .ws-hero { padding-top: calc(2rem + env(safe-area-inset-top)); } }
.ws-list-label { font-weight: 600; font-size: .875rem; color: var(--tn-muted); margin: 1.4rem 0 .5rem; }
.ws-item { display: flex; align-items: center; gap: .25rem; border-radius: 1rem; }
.ws-item + .ws-item { margin-top: .3rem; }
.ws-open {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: .85rem; text-align: left;
  padding: .6rem .7rem; border: 0; border-radius: 1rem; background: var(--tn-surface-2); color: var(--tn-text);
}
.ws-open:hover { background: color-mix(in srgb, var(--tn-cobalt) 10%, var(--tn-surface-2)); }
.ws-open .text { flex: 1; min-width: 0; line-height: 1.3; }
.ws-open b { display: block; font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-open small { color: var(--tn-muted); }
.ws-open > i { color: var(--tn-muted); }
.ws-inline { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .6rem .7rem; border-radius: 1rem; background: var(--tn-surface-2); }
.ws-inline p { margin: 0; flex: 1 1 12rem; font-weight: 500; }
.ws-inline .form-control { flex: 1 1 10rem; background: var(--tn-surface); }

/* ==========================================================================
   Task modal
   ========================================================================== */
.title-input { font-family: var(--tn-display); font-size: 1.45rem; font-weight: 700; padding: .65rem .9rem; letter-spacing: -.01em; }
.ai-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0 1.1rem; }
.btn-ai-soft {
  display: inline-flex; align-items: center; gap: .45rem; font-weight: 600; font-size: .9rem;
  padding: .45rem .85rem; border-radius: 999px; border: 0;
  background: color-mix(in srgb, var(--tn-violet) 14%, transparent); color: #6B3FE0;
}
html[data-bs-theme="dark"] .btn-ai-soft { color: #C3ADFF; }
.btn-ai-soft:hover { background: color-mix(in srgb, var(--tn-violet) 24%, transparent); }
.btn-ai-soft:disabled { opacity: .6; }
.star-toggle { border: 0; background: var(--tn-surface-2); color: var(--tn-muted); width: 2.4rem; height: 2.4rem; border-radius: .8rem; font-size: 1.1rem; }
.star-toggle.on { background: color-mix(in srgb, var(--tn-sun) 22%, transparent); color: #E69A00; }

.priority-pills { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.pill {
  display: flex; align-items: center; justify-content: center; gap: .4rem; cursor: pointer;
  padding: .55rem .4rem; border-radius: .8rem; border: 2px solid var(--tn-line); font-weight: 600; font-size: .92rem;
  background: var(--tn-surface-2); color: var(--tn-text);
}
.pill i { color: var(--c); }
.btn-check:checked + .pill { background: var(--c); border-color: var(--c); color: #fff; }
.btn-check:checked + .pill i { color: #fff; }
.btn-check:focus-visible + .pill { outline: 3px solid rgba(47, 91, 234, .45); outline-offset: 2px; }
@media (max-width: 400px) { .pill i { display: none; } }

.sub-section { border-top: 1px solid var(--tn-line); padding-top: 1rem; margin-top: 1.1rem; }
.sub-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.sub-head h3 { font-size: 1.05rem; font-weight: 700; margin: 0; flex: 1; }
.sub-count { font-size: .82rem; color: var(--tn-muted); font-weight: 600; }
.sub-progress { height: .35rem; border-radius: 999px; background: var(--tn-surface-2); overflow: hidden; margin-bottom: .6rem; }
.sub-progress span { display: block; height: 100%; width: 0; background: var(--tn-mint); border-radius: 999px; transition: width .25s; }
.sub-item { display: flex; align-items: center; gap: .6rem; padding: .2rem 0; }
.sub-item .check { width: 1.4rem; height: 1.4rem; font-size: .85rem; --p: var(--tn-muted); }
.sub-item input[type="text"] { flex: 1; min-width: 0; border: 0; border-bottom: 1px solid transparent; background: transparent; color: var(--tn-text); padding: .3rem 0; outline: 0; }
.sub-item input[type="text"]:focus { border-bottom-color: var(--tn-cobalt); }
.sub-item.done input[type="text"] { text-decoration: line-through; color: var(--tn-muted); }
.sub-add { display: flex; align-items: center; gap: .6rem; margin-top: .4rem; padding: .25rem .4rem .25rem .7rem; border-radius: .8rem; background: var(--tn-surface-2); color: var(--tn-muted); }
.sub-add input { flex: 1; min-width: 0; border: 0; background: transparent; outline: 0; color: var(--tn-text); padding: .4rem 0; }
.comment { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem .7rem; border-radius: .8rem; background: var(--tn-surface-2); margin-bottom: .4rem; }
.comment p { margin: 0; flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.comment small { display: block; color: var(--tn-muted); font-size: .76rem; margin-top: .15rem; }
.muted-note { color: var(--tn-muted); font-size: .9rem; margin: 0 0 .4rem; }

.swatches { display: flex; flex-wrap: wrap; gap: .55rem; }
.swatch { width: 2.3rem; height: 2.3rem; border-radius: .8rem; border: 3px solid transparent; background: var(--c); cursor: pointer; padding: 0; }
.swatch.on { border-color: var(--tn-surface); box-shadow: 0 0 0 3px var(--c); }

.confirm-body { text-align: center; padding: 1.75rem 1.5rem 1.5rem; }
.confirm-body h2 { font-size: 1.3rem; font-weight: 700; margin: 1rem 0 .35rem; }
.confirm-body p { color: var(--tn-muted); margin-bottom: 1.25rem; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }

/* Phones: small modals become bottom sheets, the task editor goes full screen */
@media (max-width: 575.98px) {
  .modal-sheet .modal-dialog { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; max-width: none; min-height: 0; align-items: flex-end; }
  .modal-sheet.fade .modal-dialog { transform: translateY(100%); }
  .modal-sheet.show .modal-dialog { transform: none; }
  .modal-sheet .modal-content { border-radius: 1.6rem 1.6rem 0 0; max-height: 92dvh; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom); }
  .modal-sheet .modal-content::before { content: ""; width: 2.6rem; height: .3rem; border-radius: 999px; background: var(--tn-line); margin: .6rem auto 0; flex: none; }
}
@media (max-width: 767.98px) {
  #taskModal .modal-header { padding-top: calc(1rem + env(safe-area-inset-top)); }
  #taskModal .modal-footer { padding-bottom: calc(.9rem + env(safe-area-inset-bottom)); }
  .modal { --bs-modal-padding: 1rem 1.1rem; --bs-modal-header-padding: 1rem 1.1rem .5rem; }
  .modal-footer { padding-left: 1.1rem; padding-right: 1.1rem; }
}

/* ==========================================================================
   Assistant panel
   ========================================================================== */
.ai-panel { --bs-offcanvas-width: min(27rem, 100vw); --bs-offcanvas-bg: var(--tn-surface); --bs-offcanvas-border-width: 0; }
.ai-panel .offcanvas-header { gap: .75rem; border-bottom: 1px solid var(--tn-line); padding-top: calc(1rem + env(safe-area-inset-top)); }
.ai-panel .offcanvas-title { font-size: 1.2rem; font-weight: 700; line-height: 1.2; }
.ai-badge { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: .9rem; background: var(--tn-violet); color: #fff; font-size: 1.15rem; }
.ai-mode { margin: 0; font-size: .8rem; color: var(--tn-muted); }
#aiMessages { display: flex; flex-direction: column; gap: .6rem; }
.msg { max-width: 88%; padding: .65rem .9rem; border-radius: 1.1rem; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.msg.user { align-self: flex-end; background: var(--tn-cobalt); color: #fff; border-bottom-right-radius: .35rem; }
.msg.bot { align-self: flex-start; background: var(--tn-surface-2); color: var(--tn-text); border-bottom-left-radius: .35rem; }
.msg.typing { color: var(--tn-muted); }
.ai-foot { border-top: 1px solid var(--tn-line); padding: .75rem 1rem calc(.9rem + env(safe-area-inset-bottom)); }
.ai-chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .65rem; scrollbar-width: none; }
.ai-chips::-webkit-scrollbar { display: none; }
.ai-chips button { flex: none; border: 1px solid var(--tn-line); background: var(--tn-surface); color: var(--tn-text); border-radius: 999px; padding: .35rem .8rem; font-size: .86rem; font-weight: 500; }
.ai-chips button:hover { border-color: var(--tn-violet); color: var(--tn-violet); }
.ai-form { display: flex; gap: .5rem; }

/* ==========================================================================
   Tailwind toasts: small helpers Tailwind's disabled reset would have provided
   ========================================================================== */
:where(#toasts) *, :where(#toasts) *::before, :where(#toasts) *::after { border-width: 0; border-style: solid; }
#toasts { margin-top: env(safe-area-inset-top); font-family: var(--tn-body); }
.toast-bar { width: 100%; transition: width linear; }

/* Fallback look for the alerts if the Tailwind CDN cannot be reached */
.no-tw #toasts { position: fixed; top: 1rem; right: 1rem; z-index: 2000; width: 27rem; max-width: calc(100vw - 2rem); display: flex; flex-direction: column; gap: .75rem; }
.no-tw #toasts > div { position: relative; overflow: hidden; display: flex; align-items: flex-start; gap: 1rem; padding: 1rem; border-radius: 1rem; border: 1px solid var(--tn-line); background: var(--tn-surface); color: var(--tn-text); box-shadow: var(--tn-shadow); font-size: 1.05rem; }
.no-tw #toasts > div > div:first-child { font-size: 1.5rem; color: var(--tn-cobalt); }
.no-tw #toasts > div > div:nth-child(2) { flex: 1; min-width: 0; }
.no-tw #toasts > div > div:nth-child(2) > div:first-child { font-weight: 700; }
.no-tw #toasts button { background: none; color: var(--tn-muted); }
.no-tw .toast-bar { position: absolute; left: 0; bottom: 0; height: .25rem; background: var(--tn-cobalt); }

/* Boot error */
.boot-error { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; }
.boot-error-card { background: var(--tn-surface); border-radius: 1.5rem; padding: 2rem; max-width: 34rem; text-align: center; }
.boot-error-card h2 { font-size: 1.4rem; font-weight: 700; margin: 1rem 0 .5rem; }
.boot-error-card p { color: var(--tn-muted); overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
