/* ==========================================================================
   To Do — scoped styles. Loaded only by /todo/.

   Structure: no sidebar. Views and Projects live in a "More" menu inside a
   sticky add bar pinned to the bottom, so the task list keeps full width at
   every size and the one persistent control sits in thumb reach.
   ========================================================================== */

:root {
    --faint: #9aa094;
    --rule-soft: #f0f0ec;
    --sunken: #fafaf8;
    --warn: #b4460f;
    --warn-soft: #fdf4ef;
    --task-card: #f8f8f6;

    /* Solid fills need their own ink: white on --accent is ~1.3:1 in dark
       mode. Flip the ink, not the fill. Never white text on --accent. */
    --accent-fill: #2f6b00;
    --accent-fill-hover: #234f00;
    --on-accent: #ffffff;

    --r-lg: 16px; --r-md: 11px; --r-sm: 8px; --r-pill: 999px;
    --row-pad: 13px;

    --shadow: 0 1px 2px rgba(20, 23, 15, .04), 0 8px 24px rgba(20, 23, 15, .05);
    --shadow-lift: 0 2px 4px rgba(20, 23, 15, .05), 0 14px 34px rgba(20, 23, 15, .09);
    --row-shadow: 0 1px 2px rgba(20, 23, 15, .06), 0 5px 14px rgba(20, 23, 15, .07);
    --shadow-sheet: 0 -8px 34px rgba(20, 23, 15, .16);

    color-scheme: light;
}

html[data-theme="dark"] {
    --faint: #767c70;
    --rule-soft: rgba(255, 255, 255, .07);
    --sunken: #0f110e;
    --warn: #ff9264;
    --warn-soft: rgba(255, 146, 100, .09);
    --task-card: #171a16;

    --accent-fill: #7cfc00;
    --accent-fill-hover: #9dff4d;
    --on-accent: #0b1400;

    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .32);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .35), 0 14px 34px rgba(0, 0, 0, .42);
    --row-shadow: 0 1px 2px rgba(0, 0, 0, .42), 0 6px 18px rgba(0, 0, 0, .38);
    --shadow-sheet: 0 -8px 34px rgba(0, 0, 0, .5);

    color-scheme: dark;
}

/* An explicit display beats [hidden], and most of this is flex/grid. */
[hidden] { display: none !important; }

.rt :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rt input::placeholder, .rt textarea::placeholder { color: var(--faint); }
.rt input, .rt textarea, .rt button { font-family: inherit; }

@keyframes td-pop { 0% { transform: scale(.7) } 55% { transform: scale(1.18) } 100% { transform: scale(1) } }
@keyframes td-spin { to { transform: rotate(360deg) } }
@keyframes td-shimmer { 0% { opacity: .55 } 50% { opacity: 1 } 100% { opacity: .55 } }
@keyframes td-rise { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: translateY(0) } }
@keyframes td-sheet { from { transform: translateY(100%) } to { transform: translateY(0) } }
@keyframes td-detail-enter { from { opacity: 0; transform: translateX(28px) } to { opacity: 1; transform: translateX(0) } }
@keyframes td-detail-exit { from { opacity: 1; transform: translateX(0) } to { opacity: 0; transform: translateX(28px) } }
@keyframes td-sheet-exit { from { opacity: 1; transform: translateY(0) } to { opacity: 0; transform: translateY(100%) } }
@keyframes td-scrim-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes td-scrim-out { from { opacity: 1 } to { opacity: 0 } }

/* styles.css clips .rt so the marketing pages' drifting shapes stay inside it.
   That makes .rt a scroll container, which stops `position: sticky; bottom` on
   the add bar from ever pinning to the viewport. The app clips per-section
   instead (see .td-signin), so release the clip here. */
.rt { overflow: visible; }

.td-shell { width: min(100%, 1440px); margin: 0 auto; padding: 0 28px; }

/* --- Header -------------------------------------------------------------- */

.td-brand img { width: 44px; height: 44px; object-fit: contain; }

/* Mobile three-slot bar, shown only ≤700px. */
.td-mobilebar {
    display: none; grid-template-columns: 44px 1fr 44px; align-items: center;
    gap: 8px; padding: 10px 14px; border-bottom: 2px solid var(--rule);
}
.td-burger {
    display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
    border: 1px solid var(--rule); border-radius: var(--r-md);
    background: transparent; color: var(--text); cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease, color .18s ease;
}
.td-burger svg { width: 19px; height: 19px; }
.td-burger[aria-expanded="true"] { border-color: var(--accent); background: var(--soft); color: var(--accent-ink); }
.td-mobilebar__logo { display: grid; place-items: center; }
.td-mobilebar__logo img { width: 41px; height: 41px; object-fit: contain; }

.td-drawer {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 90;
    max-height: calc(100vh - 66px); overflow-y: auto;
    padding: 10px 14px 16px; border-bottom: 1px solid var(--rule);
    background: var(--bg); box-shadow: var(--shadow-lift);
    animation: td-rise .18s ease;
}
.td-drawer a {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    min-height: 46px; padding: 0 12px; border-radius: var(--r-md);
    color: var(--text); font-size: .95rem; font-weight: 600;
}
.td-drawer a:hover { background: var(--soft); }
.td-drawer a[aria-current="page"] { color: var(--accent); background: var(--soft); }
.td-drawer .td-drawer__sub {
    min-height: 42px; margin-left: 12px; padding: 0 12px 0 14px;
    border-left: 2px solid var(--hl); border-radius: 0 var(--r-md) var(--r-md) 0;
    color: var(--muted); font-size: .88rem; font-weight: 400;
}
.td-drawer .td-drawer__sub span:last-child { color: var(--accent); }

/* Account menu, shared controls (.td-seg/.td-fill/.td-ghost), .td-kicker and
   .td-alert now live in styles.css: the signed-in nav is shared by every page. */


.td-iconbtn {
    display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
    border: 0; border-radius: var(--r-sm); background: transparent; color: var(--faint);
    cursor: pointer; transition: background-color .16s ease, color .16s ease;
}
.td-iconbtn svg { width: 15px; height: 15px; }
.td-iconbtn:hover { background: var(--sunken); color: var(--accent); }
.td-iconbtn--danger:hover { background: var(--warn-soft); color: var(--warn); }

.td-field { display: grid; gap: 7px; }
.td-field__label {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    color: var(--muted); font-size: .72rem; font-weight: 600;
    letter-spacing: .1em; text-transform: uppercase;
}
.td-input {
    width: 100%; min-height: 44px; padding: 10px 13px;
    border: 1px solid var(--rule); border-radius: var(--r-md);
    background: var(--field); color: var(--text); font: inherit; font-size: .95rem;
    transition: border-color .18s ease, box-shadow .18s ease;
}
.td-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--hl); outline: none; }
.td-input.is-invalid { border-color: var(--warn); }
.td-reveal {
    padding: 0; border: 0; background: transparent; color: var(--accent);
    font: inherit; font-size: .68rem; font-weight: 600;
    letter-spacing: .08em; text-transform: uppercase; cursor: pointer;
}
.td-textarea {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--rule); border-radius: var(--r-md);
    background: var(--sunken); color: var(--text);
    font: inherit; font-size: .91rem; line-height: 1.5; resize: vertical;
    transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}
.td-textarea:focus { border-color: var(--accent); background: var(--field); box-shadow: 0 0 0 3px var(--hl); outline: none; }


.td-spinner {
    display: inline-block; width: 13px; height: 13px; flex: 0 0 auto;
    border: 2px solid var(--rule); border-top-color: var(--accent);
    border-radius: 50%; animation: td-spin .7s linear infinite;
}
/* On a solid fill the spinner must track the ink, not the accent. */
.td-fill .td-spinner { width: 14px; height: 14px; border-color: rgba(127,127,127,.4); border-top-color: currentColor; }
.td-boot { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 80px 0; color: var(--muted); font-size: .9rem; }
.td-boot p { margin: 0; }

/* --- Sign in ------------------------------------------------------------- */

.td-signin { position: relative; overflow: hidden; }
.td-backdrop {
    position: absolute; inset: 0; pointer-events: none;
    background-image: radial-gradient(var(--grid-dot) 1.4px, transparent 1.4px);
    background-size: 26px 26px;
    -webkit-mask-image: radial-gradient(ellipse 80% 55% at 50% 0%, #000 15%, transparent 75%);
    mask-image: radial-gradient(ellipse 80% 55% at 50% 0%, #000 15%, transparent 75%);
}
.td-mark {
    position: absolute; top: 24%; left: 5%; width: 13px; height: 13px;
    border: 2px solid var(--dot); border-radius: 4px; opacity: .4; pointer-events: none;
}
.td-shell--signin { width: min(100%, 1000px); position: relative; }

/* Source order is head → card → copy; desktop only re-columns it. */
.td-signin__grid {
    display: grid; justify-items: start; gap: 0;
    width: min(100%, 470px); padding: 52px 0 84px;
}
.td-lede {
    display: flex; align-items: center; gap: 9px; margin: 0 0 20px;
    color: var(--muted); font-size: .76rem; font-weight: 600;
    letter-spacing: .13em; text-transform: uppercase;
}
.td-lede span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--dot); animation: breathe 2.6s ease-out infinite; }
.td-signin h1 { margin: 0 0 26px; font-size: clamp(2.4rem, 5.5vw, 3.4rem); font-weight: 600; line-height: 1.04; letter-spacing: -.035em; }

.td-card {
    width: 100%; padding: 28px; border: 1px solid var(--rule);
    border-radius: var(--r-lg); background: var(--card); box-shadow: var(--shadow);
}
.td-card .td-seg { margin: 0 0 22px; }
.td-authform { display: grid; gap: 16px; }
.td-submit { width: 100%; min-height: 46px; font-size: .92rem; }
.td-submit[disabled] { opacity: .7; cursor: wait; }
.td-footnote { margin: 2px 0 0; color: var(--faint); font-size: .79rem; }

.td-meter { display: grid; gap: 8px; padding: 12px 13px; border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--sunken); }
.td-meter__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.td-meter__top span:first-child { color: var(--muted); font-size: .78rem; }
.td-meter__state { font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.td-meter__track { height: 4px; border-radius: var(--r-pill); background: var(--rule); overflow: hidden; }
.td-meter__fill { width: 0; height: 100%; border-radius: var(--r-pill); background: var(--accent); transition: width .25s ease, background-color .25s ease; }

.td-copy { padding-top: 30px; }
.td-copy__lead { max-width: 30em; margin: 0 0 6px; font-size: 1.05rem; line-height: 1.55; }
.td-points { display: grid; gap: 0; padding: 0; margin: 0; list-style: none; max-width: 29em; }
.td-points li {
    display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: baseline;
    padding: 13px 0; border-top: 1px solid var(--rule-soft);
}
.td-points li:last-child { border-bottom: 1px solid var(--rule-soft); }
.td-points i { width: 6px; height: 6px; margin-top: 8px; border-radius: 50%; background: var(--dot); }
.td-points span { color: var(--muted); font-size: .93rem; }

.td-signin__footer {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 16px; padding: 0 0 56px; color: var(--muted); font-size: .82rem;
}
.td-signin__footer p { margin: 0; }
.td-themepill {
    display: inline-flex; align-items: center; gap: 9px; height: 34px; padding: 0 13px;
    border: 1px solid var(--rule); border-radius: var(--r-pill);
    background: transparent; color: var(--muted); font: inherit; font-size: .78rem;
    font-weight: 500; letter-spacing: .04em; text-transform: uppercase; cursor: pointer;
    transition: border-color .2s ease, color .2s ease;
}
.td-themepill:hover { border-color: var(--accent); color: var(--accent); }
.td-themepill i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--dot); }

/* --- Dashboard ----------------------------------------------------------- */

.td-dash { padding: 34px 20px 24px; }
.td-dash h1 { margin: 0 0 26px; font-size: clamp(1.75rem, 3.4vw, 2.3rem); font-weight: 600; line-height: 1.1; letter-spacing: -.03em; }

.td-body {
    display: grid; grid-template-columns: minmax(0, 1fr) 0px; gap: 38px;
    align-items: start; transition: grid-template-columns .22s ease;
}
.td-body.is-detail-open { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

.td-tasks { display: grid; gap: 34px; min-width: 0; }
.td-block { min-width: 0; }
.td-block--upcoming { margin-top: 20px; }
.td-blockhead { display: flex; align-items: center; gap: 12px; padding: 0 2px 11px; }
.td-blockhead h2 { margin: 0; color: var(--muted); font-size: .78rem; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; }
.td-badge {
    display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: var(--r-pill); background: var(--sunken); color: var(--muted);
    font-size: .72rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.td-blockhead .td-rule { flex: 1 1 auto; height: 1px; background: var(--rule-soft); }
.td-blockhead .td-note { color: var(--faint); font-size: .78rem; }
.td-block.is-overdue .td-blockhead h2 { color: var(--warn); }
.td-block.is-overdue .td-badge { background: var(--warn-soft); color: var(--warn); }

.td-list { display: grid; gap: 9px; padding: 0; margin: 0; list-style: none; }
.td-row {
    display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px;
    align-items: center; min-height: 60px; padding: var(--row-pad) 14px;
    border: 1px solid var(--rule); border-left: 3px solid transparent;
    border-radius: var(--r-md); background: var(--task-card); box-shadow: var(--row-shadow); cursor: pointer;
    transition: border-color .2s ease, background-color .2s ease, box-shadow .22s ease, transform .22s cubic-bezier(.22, .7, .25, 1);
}
.td-row:hover { background: var(--soft); box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.td-row.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--hl), var(--shadow-lift); transform: translateY(-1px); }
.td-row.is-overdue { border-color: var(--warn); border-left-color: var(--warn); }
.td-row.is-done { opacity: .62; border-color: var(--rule-soft); }

.td-check {
    display: grid; place-items: center; width: 23px; height: 23px; flex: 0 0 auto; padding: 0;
    border: 1.5px solid var(--rule); border-radius: 50%;
    background: transparent; color: transparent; cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease;
}
.td-check svg { width: 12px; height: 12px; }
.td-check:hover { border-color: var(--accent); }
.td-row.is-done .td-check { border-color: var(--accent-fill); background: var(--accent-fill); color: var(--on-accent); }
.td-check.is-popping svg { animation: td-pop .3s ease; }

.td-row__body { min-width: 0; }
.td-row__title {
    display: inline; margin: 0; color: var(--text); font-size: .97rem; font-weight: 500;
    line-height: 1.4; overflow-wrap: anywhere; cursor: text; border-radius: 4px;
    box-shadow: 0 0 0 4px transparent;
    transition: box-shadow .16s ease, background-color .16s ease;
}
.td-row__title:hover { background: var(--hl); box-shadow: 0 0 0 4px var(--hl); }
.td-row.is-done .td-row__title { color: var(--muted); text-decoration: line-through; }
.td-row__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 5px; }
.td-due { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .79rem; cursor: pointer; }
.td-due:hover { color: var(--accent-ink); }
.td-due svg { width: 12px; height: 12px; flex: 0 0 auto; }
.td-due.is-today { color: var(--accent); font-weight: 600; }
.td-due.is-late { color: var(--warn); font-weight: 600; }
.td-tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: var(--r-pill); background: var(--sunken); color: var(--muted); font-size: .76rem; }
.td-tag i { width: 6px; height: 6px; border-radius: 50%; }
.td-high { display: inline-flex; padding: 2px 9px; border-radius: var(--r-pill); background: var(--warn-soft); color: var(--warn); font-size: .73rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.td-notes { color: var(--faint); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 26em; }

.td-empty { display: grid; justify-items: center; gap: 7px; padding: 62px 24px; border: 1.5px dashed var(--rule); border-radius: var(--r-lg); background: var(--sunken); text-align: center; }
.td-empty__icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 6px; border-radius: var(--r-md); background: var(--soft); color: var(--accent); }
.td-empty__icon svg { width: 20px; height: 20px; }
.td-empty__title { margin: 0; font-size: 1.02rem; font-weight: 600; }
.td-empty__sub { max-width: 30em; margin: 0; color: var(--muted); font-size: .9rem; }

.td-skeletons { display: grid; gap: 9px; }
.td-skel { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; padding: var(--row-pad) 14px; border: 1px solid var(--rule-soft); border-radius: var(--r-md); background: var(--card); animation: td-shimmer 1.4s ease-in-out infinite; }
.td-skel i { width: 22px; height: 22px; border-radius: 50%; background: var(--rule); }
.td-skel span { display: grid; gap: 7px; }
.td-skel b { height: 9px; border-radius: var(--r-pill); background: var(--rule); }
.td-skel em { height: 7px; border-radius: var(--r-pill); background: var(--rule-soft); }
.td-loading { display: flex; align-items: center; gap: 9px; margin: 4px 0 0; color: var(--muted); font-size: .87rem; }

/* --- Add bar (sticky, bottom) + More menu -------------------------------- */

.td-compose-scrim { position: fixed; inset: 0; z-index: 50; background: rgba(10, 12, 8, .26); backdrop-filter: blur(4px); animation: td-rise .16s ease; }
.td-composewrap { position: sticky; bottom: 18px; z-index: 55; width: min(100%, 720px); margin: 26px auto 0; }
.td-compose {
    padding: 6px 6px 6px 7px; border: 1px solid var(--rule); border-radius: var(--r-lg);
    background: var(--card); box-shadow: var(--shadow);
    transition: border-color .2s ease, box-shadow .2s ease;
}
.td-compose.is-open { border-color: var(--rule); box-shadow: var(--shadow); }
.td-compose__row { display: flex; align-items: center; gap: 9px; }
.td-more {
    display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 11px;
    flex: 0 0 auto; border: 1px solid var(--rule); border-radius: var(--r-pill);
    background: var(--sunken); color: var(--muted); font: inherit; font-size: .82rem;
    font-weight: 600; cursor: pointer; transition: border-color .18s ease, background-color .18s ease, color .18s ease;
}
.td-more svg { width: 15px; height: 15px; flex: 0 0 auto; }
.td-more[aria-expanded="true"] { border-color: var(--accent); background: var(--soft); color: var(--accent-ink); }
.td-divider { width: 1px; height: 22px; flex: 0 0 auto; background: var(--rule-soft); }
.td-compose__title { flex: 1 1 auto; min-width: 0; min-height: 40px; padding: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 1rem; outline: none; }
.rt .td-compose__title:focus-visible { outline: none; }
.td-addbtn { height: 36px; padding: 0 16px; flex: 0 0 auto; border-radius: var(--r-sm); font-size: .85rem; }
.td-compose__notes { padding: 2px 2px 0 4px; animation: td-rise .18s ease; }
.td-compose__notes .td-textarea { min-height: 84px; }
.td-compose__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 2px 4px 4px; margin-top: 6px; border-top: 1px solid var(--rule-soft); animation: td-rise .18s ease; }
.td-pill { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px; border: 1px solid var(--rule); border-radius: var(--r-pill); background: var(--sunken); color: var(--muted); font-size: .8rem; cursor: pointer; }
.td-pill > span { color: var(--faint); font-size: .68rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.td-compose-date { padding: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: .8rem; outline: none; cursor: pointer; }

.td-filter {
    position: absolute; bottom: calc(100% + 9px); left: 0; right: 0;
    max-height: min(58vh, 440px); overflow-y: auto; padding: 7px;
    border: 1px solid var(--rule); border-radius: var(--r-lg);
    background: var(--bg); box-shadow: var(--shadow-lift); animation: td-rise .16s ease;
}
.td-filter__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.td-filter__col { padding: 4px 6px 6px; }
.td-filter__col + .td-filter__col { border-left: 1px solid var(--rule-soft); }
.td-view, .td-project {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px;
    padding: 0 10px; border: 0; border-radius: var(--r-md); background: transparent;
    color: var(--text); font: inherit; font-size: .91rem; text-align: left; cursor: pointer;
    transition: background-color .16s ease, color .16s ease;
}
.td-view span:first-child, .td-project__name { flex: 1 1 auto; min-width: 0; }
.td-view__count, .td-project__count { color: var(--faint); font-size: .8rem; font-variant-numeric: tabular-nums; }
.td-view:hover, .td-project:hover { background: var(--soft); }
.td-view.is-active, .td-project.is-active { background: var(--soft); color: var(--accent-ink); font-weight: 600; }
.td-view.is-active .td-view__count { color: var(--accent); }
.td-project { min-height: 38px; font-size: .89rem; gap: 9px; }
.td-project__dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; }
.td-project__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-newproject input {
    width: 100%; min-height: 36px; margin-top: 8px; padding: 8px 10px;
    border: 1px solid var(--rule); border-radius: var(--r-md);
    background: var(--field); color: var(--text); font: inherit; font-size: .87rem;
}
.td-newproject input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--hl); outline: none; }

/* --- Custom dropdowns (no native select) --------------------------------- */

.td-drop { position: relative; }
.td-drop__trigger {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid transparent; border-radius: var(--r-sm);
    background: transparent; color: var(--text); font: inherit; font-size: .8rem;
    cursor: pointer; transition: border-color .16s ease, background-color .16s ease;
}
.td-drop__trigger svg { width: 12px; height: 12px; transition: transform .18s ease; }
.td-drop__trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
.td-drop__trigger[aria-expanded="true"] { border-color: var(--accent); background: var(--soft); }
.td-drop__menu {
    position: absolute; z-index: 60; min-width: 160px; padding: 5px;
    border: 1px solid var(--rule); border-radius: var(--r-md);
    background: var(--bg); box-shadow: var(--shadow-lift); animation: td-rise .14s ease;
}
.td-drop__menu--up { bottom: calc(100% + 6px); left: 0; }
.td-drop__menu--down { top: calc(100% + 5px); left: 0; right: 0; }
.td-drop__opt {
    display: flex; align-items: center; gap: 8px; width: 100%; min-height: 34px;
    padding: 0 9px; border: 0; border-radius: var(--r-sm); background: transparent;
    color: var(--text); font: inherit; font-size: .85rem; text-align: left; cursor: pointer;
    transition: background-color .16s ease, color .16s ease;
}
.td-drop__opt:hover { background: var(--soft); }
.td-drop__opt[aria-selected="true"] { background: var(--soft); color: var(--accent-ink); font-weight: 600; }
.td-drop__opt i { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--rule); }
.td-drop__opt span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-drop__opt svg { width: 13px; height: 13px; flex: 0 0 auto; opacity: 0; }
.td-drop__opt[aria-selected="true"] svg { opacity: 1; }

/* --- Detail panel / sheet ------------------------------------------------ */

.td-detail {
    position: sticky; top: 118px; display: grid; align-content: start; gap: 0;
    border: 1px solid var(--rule); border-radius: var(--r-lg);
    max-height: calc(100vh - 138px); background: var(--card); box-shadow: var(--shadow); overflow-y: auto; overscroll-behavior: contain;
    animation: td-detail-enter .28s cubic-bezier(.22, .7, .25, 1); transition: height .22s ease, transform .2s ease;
}
.td-detail.is-closing { pointer-events: none; animation: td-detail-exit .22s ease forwards; }
.td-grabber { display: none; }
.td-detail__bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 10px 54px 10px 12px; border-bottom: 1px solid var(--rule-soft); background: var(--sunken); }
.td-donepill {
    display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px;
    border: 1px solid var(--rule); border-radius: var(--r-pill);
    background: transparent; color: var(--muted); font: inherit; font-size: .79rem;
    font-weight: 600; cursor: pointer; transition: border-color .18s ease, background-color .18s ease, color .18s ease;
}
.td-donepill svg { width: 13px; height: 13px; }
.td-donepill:hover { border-color: var(--accent); }
.td-donepill.is-done { border-color: var(--accent); background: var(--soft); color: var(--accent-ink); }
.td-detail__bar .td-iconbtn:first-of-type { margin-left: auto; }
.td-detail__bar [data-detail-close] { position: absolute; top: 10px; right: 12px; }
.td-detail__body { display: grid; gap: 13px; padding: 13px 14px 16px; }
.td-detail__title {
    margin: 0; padding: 6px 9px; border: 1px solid transparent; border-radius: var(--r-md);
    color: var(--text); font-size: 1.08rem; font-weight: 600; line-height: 1.3;
    letter-spacing: -.015em; overflow-wrap: anywhere; cursor: text;
    transition: background-color .16s ease, border-color .16s ease;
}
.td-detail__title:hover { background: var(--sunken); border-color: var(--rule); }
.td-detail__title.is-done { color: var(--muted); text-decoration: line-through; }
.td-titleinput {
    width: 100%; padding: 6px 9px; border: 1px solid var(--accent); border-radius: var(--r-md);
    background: var(--field); color: var(--text); font: inherit; font-size: 1.08rem;
    font-weight: 600; letter-spacing: -.015em; box-shadow: 0 0 0 3px var(--hl); outline: none;
}
.td-detail__body label { display: grid; gap: 7px; }
.td-detail__notes-preview,
.td-detail__textarea {
    min-height: 74px; padding: 9px 11px; border: 1px solid var(--rule); border-radius: var(--r-md);
    background: var(--field); color: var(--text); font: inherit; font-size: .9rem; line-height: 1.5;
}
.td-detail__notes-preview {
    white-space: pre-wrap; overflow-wrap: anywhere; cursor: text;
    transition: border-color .16s ease, background-color .16s ease;
}
.td-detail__notes-preview:hover { border-color: var(--rule); background: var(--sunken); }
.td-detail__notes-preview.is-empty { color: var(--faint); }
.td-detail__notes-preview a { color: var(--accent-ink); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 2px; }
.td-detail__notes-line + .td-detail__notes-line { margin-top: 4px; }
.td-detail__notes-list { display: grid; gap: 4px; margin: 0; padding-left: 20px; }
.td-detail__notes-line + .td-detail__notes-list,
.td-detail__notes-list + .td-detail__notes-line { margin-top: 6px; }
.td-detail__textarea { resize: none; overflow-y: auto; }
.td-detail__textarea:focus { border-color: var(--rule); background: var(--field); box-shadow: none; outline: none; }
.td-detail__textarea[contenteditable="true"] { overflow-wrap: anywhere; white-space: pre-wrap; cursor: text; }
.td-detail__textarea[contenteditable="true"]:empty::before { content: "Write a note, paste a link, or use - for bullets…"; color: var(--faint); }
.td-detail__textarea[contenteditable="true"] a { color: var(--accent-ink); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 2px; }
.td-metablock { display: grid; gap: 0; border: 1px solid var(--rule); border-radius: var(--r-md); overflow: visible; }
.td-metarow { display: grid; grid-template-columns: 66px minmax(0, 1fr); gap: 8px; align-items: center; padding: 6px 10px; background: var(--card); }
.td-metarow + .td-metarow { border-top: 1px solid var(--rule-soft); }
.td-metarow > span:first-child { color: var(--muted); font-size: .8rem; }
.td-date-trigger {
    width: 100%; padding: 5px 8px; border: 1px solid transparent; border-radius: var(--r-sm);
    background: transparent; color: var(--text); font: inherit; font-size: .86rem; text-align: left; cursor: pointer;
    transition: border-color .16s ease, background-color .16s ease;
}
.td-date-trigger:hover, .td-date-trigger[aria-expanded="true"] { border-color: var(--rule); background: var(--sunken); }
.td-calendar-popover { position: fixed; z-index: 85; max-height: calc(100vh - 24px); overflow-y: auto; padding: 11px; border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--sunken); box-shadow: var(--shadow-lift); animation: td-rise .16s ease; }
.td-calendar__head { display: grid; grid-template-columns: 32px 1fr 32px; align-items: center; gap: 7px; margin: -1px 0 10px; padding-bottom: 10px; border-bottom: 1px solid var(--rule-soft); }
.td-calendar__month { margin: 0; color: var(--text); font-size: .78rem; font-weight: 600; letter-spacing: .08em; text-align: center; text-transform: uppercase; }
.td-calendar__move {
    display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--rule);
    border-radius: var(--r-sm); background: var(--card); color: var(--muted); cursor: pointer;
}
.td-calendar__move:hover { border-color: var(--accent); background: var(--soft); color: var(--accent-ink); }
.td-calendar__move svg { width: 14px; height: 14px; }
.td-calendar__week, .td-calendar__days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.td-calendar__week { margin-bottom: 5px; color: var(--faint); font-size: .6rem; font-weight: 600; letter-spacing: .06em; text-align: center; }
.td-calendar__day {
    display: grid; place-items: center; aspect-ratio: 1; min-height: 30px; padding: 0; border: 1px solid transparent;
    border-radius: var(--r-sm); background: transparent; color: var(--text); font: inherit; font-size: .76rem; cursor: pointer;
    transition: border-color .16s ease, background-color .16s ease, color .16s ease;
}
.td-calendar__day:hover { border-color: var(--rule); background: var(--card); }
.td-calendar__day.is-today { border-color: var(--accent); background: var(--soft); color: var(--accent-ink); }
.td-calendar__day.is-selected { border-color: var(--accent-fill); background: var(--accent-fill); color: var(--on-accent); font-weight: 600; }
.td-calendar__blank { aspect-ratio: 1; }
.td-calendar__foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--rule-soft); }
.td-calendar__action { min-height: 28px; padding: 0 8px; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--muted); font: inherit; font-size: .7rem; font-weight: 600; cursor: pointer; }
.td-calendar__action:hover { border-color: var(--rule); background: var(--card); color: var(--accent-ink); }
.td-metarow .td-drop__trigger { width: 100%; justify-content: space-between; padding: 5px 8px; font-size: .86rem; }
.td-metarow .td-drop__trigger:hover { border-color: var(--rule); background: var(--sunken); }
.td-status { display: flex; align-items: center; gap: 8px; margin: -3px 0 0; color: var(--faint); font-size: .76rem; }
.td-status i { width: 6px; height: 6px; border-radius: 50%; background: var(--dot); }
.td-status.is-late i { background: var(--warn); }
.td-status.is-done i { background: var(--faint); }
.td-scrim { display: none; }

/* --- Responsive ---------------------------------------------------------- */

@media (min-width: 861px) {
    .td-signin__grid {
        width: min(100%, 1000px);
        grid-template-columns: minmax(0, 440px) minmax(0, 1fr);
        column-gap: 64px; row-gap: 0; align-items: start;
    }
    .td-copy { grid-column: 2; grid-row: 1 / span 2; align-self: center; padding-top: 0; }
}

@media (max-width: 1100px) {
    body.td-detail-scroll-lock { position: fixed; width: 100%; overflow: hidden; }
    .td-body, .td-body.is-detail-open { grid-template-columns: minmax(0, 1fr); }
    .td-detail {
        position: fixed; top: auto; bottom: 0; left: 0; right: 0; width: auto;
        max-height: 88%; overflow-y: auto; z-index: 70;
        border-radius: 20px 20px 0 0; box-shadow: var(--shadow-sheet);
        animation: td-sheet .28s cubic-bezier(.22, .7, .25, 1);
    }
    .td-detail.is-closing { animation: td-sheet-exit .22s ease forwards; }
    .td-grabber {
        position: relative; display: block; width: 76px; height: 28px; margin: 0 auto;
        touch-action: none; cursor: grab;
    }
    .td-grabber::after {
        position: absolute; top: 11px; right: 19px; left: 19px; height: 3px; border-radius: var(--r-pill);
        background: var(--rule); content: "";
    }
    .td-detail.is-dragging .td-grabber { cursor: grabbing; }
    .td-detail.is-dragging { transition: none; }
    .td-detail__bar { position: sticky; top: 0; z-index: 2; touch-action: none; }
    .td-body.is-detail-open .td-scrim { display: block; position: fixed; inset: 0; z-index: 69; background: rgba(10, 12, 8, .32); animation: td-scrim-in .2s ease; }
    .td-body.is-detail-closing .td-scrim { animation: td-scrim-out .22s ease forwards; }
}

@media (max-width: 860px) {
    .td-signin__grid { width: 100%; }
    .td-body, .td-body.is-detail-open { grid-template-columns: 1fr; gap: 24px; }
}

@media (max-width: 700px) {
    .rt .rt-bar, .rt .rt-panel { display: none; }
    .td-mobilebar { display: grid; }
    .rt .rt-header { position: relative; }
    .td-shell { padding: 0 16px; }
    .td-dash { padding: 22px 20px 24px; }
    .td-detail {
        height: 66dvh; min-height: 0; max-height: calc(100dvh - 8px);
        border-radius: 16px 16px 0 0;
    }
    .td-grabber { height: 24px; }
    .td-grabber::after { top: 9px; }
    .td-detail.is-expanded { height: calc(100dvh - 8px); }
    .td-detail__bar { padding-top: 6px; padding-bottom: 7px; }
    .td-detail__bar [data-detail-close] { top: 6px; }
    .rt input, .rt textarea, .rt select { font-size: 16px; }
    .td-calendar-popover { max-height: calc(100dvh - 24px); }
    .td-composewrap { bottom: 12px; width: auto; }
    .td-composewrap.is-compose-open {
        position: fixed; right: 16px; bottom: var(--td-compose-bottom, 12px); left: 16px;
        width: auto; max-height: var(--td-compose-max-height, calc(100dvh - 24px)); margin: 0;
        overflow-y: auto; overscroll-behavior: contain;
        transition: bottom .22s cubic-bezier(.22, .7, .25, 1), max-height .22s ease;
    }
    .td-detail .td-drop__menu--down { top: auto; bottom: calc(100% + 6px); }
    .td-filter__grid { grid-template-columns: 1fr; }
    .td-filter__col + .td-filter__col { border-left: 0; border-top: 1px solid var(--rule-soft); }
    .td-filterlabel { display: none; }
    .td-signin__grid { padding-top: 34px; }
}
