/* =========================================================================
   ClawCalendar — "Tide Table"
   A warm-harbor identity: deep teal water, a sand-paper calendar floating on
   it, and a single lobster-coral accent. The live "tide ripple" on a changed
   event is the signature — see .tt-event.is-rippling.
   ========================================================================= */

:root {
    --harbor:   #0F2E2E;  /* deep teal canvas (the water) */
    --harbor-2: #12393A;  /* raised panels on the canvas */
    --harbor-3: #19474A;  /* hover / borders on canvas */
    --paper:    #F1E7D6;  /* warm sand calendar surface */
    --paper-2:  #E9DCC6;  /* paper, slightly deeper (gridless areas) */
    --ink:      #20312E;  /* primary text on paper */
    --ink-soft: #5C6B64;  /* muted text on paper */
    --coral:    #E8542F;  /* lobster-shell vermilion — the ONLY action accent */
    --coral-deep: #C53F1E;
    --coral-wash: rgba(232, 84, 47, 0.14);
    --brass:    #C99A4B;  /* secondary / all-day chips */
    --seafoam:  #8FB8B0;  /* muted text/lines on harbor */
    --seafoam-dim: #6B948D;
    --tideline: rgba(15, 46, 46, 0.10); /* hairlines on paper */
    --danger:   #B23A2E;

    --hour-h: 52px;                  /* one hour of grid height (JS reads this) */
    --grid-h: calc(var(--hour-h) * 24);
    --gutter-w: 56px;

    --font-display: "Bricolage Grotesque", "Public Sans", system-ui, sans-serif;
    --font-body: "Public Sans", system-ui, -apple-system, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;

    --shadow-float: 0 18px 40px -22px rgba(0, 0, 0, 0.65);
}

/* ---- App shell ---------------------------------------------------------- */
body.tt-fullbleed {
    margin: 0;
    background: var(--harbor);
    color: var(--paper);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
}

/* =========================================================================
   Sign-in screen — the harbor at rest before you cast off
   ========================================================================= */
.tt-signin {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(120% 90% at 100% 0%, #15403F 0%, var(--harbor) 60%) fixed;
}

.tt-signin-card {
    width: min(420px, 100%);
    padding: 2.6rem 2.2rem 2.2rem;
    text-align: center;
    background: var(--paper);
    color: var(--ink);
    border-radius: 20px;
    box-shadow: var(--shadow-float);
    /* a thin coral keel along the bottom, echoing the event accent */
    border-bottom: 4px solid var(--coral);
    animation: tt-detail-in .25s ease-out;
}

.tt-signin-mark {
    font-size: 3.2rem;
    line-height: 1;
    margin-bottom: 0.6rem;
    /* gentle bob, like a buoy on the tide */
    animation: tt-bob 4s ease-in-out infinite;
}
@keyframes tt-bob {
    0%, 100% { transform: translateY(0) rotate(-3deg); }
    50%      { transform: translateY(-6px) rotate(3deg); }
}

.tt-signin-brand {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 2rem;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin: 0 0 0.35rem;
}

.tt-signin-tagline {
    font-size: 0.98rem;
    line-height: 1.5;
    color: var(--ink-soft);
    margin: 0 auto 1.6rem;
    max-width: 30ch;
}

.tt-signin-error {
    margin: 0 0 1.1rem;
    padding: 0.55rem 0.8rem;
    border-radius: 10px;
    background: rgba(178, 58, 46, 0.12);
    border: 1px solid rgba(178, 58, 46, 0.45);
    color: var(--danger);
    font-size: 0.85rem;
}

.tt-signin-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.95rem;
    color: #fff;
    background: var(--coral);
    border-radius: 11px;
    text-decoration: none;
    transition: background .15s, transform .05s;
}
.tt-signin-btn:hover { background: var(--coral-deep); color: #fff; }
.tt-signin-btn:active { transform: translateY(1px); }

.tt-signin-glogo {
    flex: 0 0 auto;
    background: #fff;
    border-radius: 3px;
    padding: 2px;
}

.tt-signin-note {
    margin: 1.2rem 0 0;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--ink-soft);
}

.tt-signin :focus-visible {
    outline: 2px solid var(--coral);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .tt-signin-mark { animation: none; }
}

.tt-app {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(120% 80% at 100% 0%, #15403F 0%, var(--harbor) 60%) fixed;
    overflow: hidden;
}

/* ---- Top bar ------------------------------------------------------------ */
.tt-topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.85rem 1.4rem;
    border-bottom: 1px solid var(--harbor-3);
}

.tt-brand {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
    color: var(--paper);
    white-space: nowrap;
}
.tt-claw { font-family: initial; }

.tt-weeknav {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tt-nav-btn,
.tt-nav-now {
    font-family: var(--font-mono);
    background: transparent;
    color: var(--seafoam);
    border: 1px solid var(--harbor-3);
    border-radius: 8px;
    cursor: pointer;
    line-height: 1;
    transition: color .15s, border-color .15s, background .15s;
}
.tt-nav-btn {
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
}
.tt-nav-now {
    height: 32px;
    padding: 0 0.7rem;
    font-size: 0.8rem;
    text-transform: lowercase;
}
.tt-nav-btn:hover,
.tt-nav-now:hover {
    color: var(--paper);
    border-color: var(--seafoam-dim);
    background: var(--harbor-2);
}

.tt-weeklabel {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--paper);
    margin-left: 0.4rem;
    white-space: nowrap;
}

.tt-topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.tt-add-btn {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.85rem;
    color: #fff;
    background: var(--coral);
    border: none;
    border-radius: 9px;
    padding: 0.45rem 0.9rem;
    cursor: pointer;
    transition: background .15s, transform .05s;
}
.tt-add-btn:hover { background: var(--coral-deep); }
.tt-add-btn:active { transform: translateY(1px); }

.tt-rand-btn {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--seafoam);
    background: transparent;
    border: 1px solid var(--harbor-3);
    border-radius: 9px;
    padding: 0.45rem 0.8rem;
    cursor: pointer;
    transition: color .15s, border-color .15s, transform .05s;
}
.tt-rand-btn:hover { color: var(--paper); border-color: var(--seafoam-dim); }
.tt-rand-btn:active { transform: translateY(1px); }
.tt-rand-btn.is-loading { opacity: 0.6; cursor: progress; }

.tt-calpick-select {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--paper);
    background: var(--harbor-2);
    border: 1px solid var(--harbor-3);
    border-radius: 9px;
    padding: 0.42rem 0.6rem;
    max-width: 200px;
    cursor: pointer;
}
.tt-calpick { position: relative; }
.tt-calpick::before {
    content: "";
    position: absolute;
    left: 0.55rem;
    top: 50%;
    transform: translateY(-50%);
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--tt-active, var(--coral));
    pointer-events: none;
    z-index: 1;
}
.tt-calpick-select { padding-left: 1.4rem; }

.tt-signout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}
.tt-user {
    font-size: 0.8rem;
    color: var(--seafoam);
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tt-signout-btn {
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--seafoam);
    background: transparent;
    border: 1px solid var(--harbor-3);
    border-radius: 8px;
    padding: 0.38rem 0.7rem;
    cursor: pointer;
}
.tt-signout-btn:hover { color: var(--paper); border-color: var(--seafoam-dim); }

.tt-banner {
    margin: 0.6rem 1.4rem 0;
    padding: 0.6rem 0.9rem;
    border-radius: 10px;
    background: rgba(178, 58, 46, 0.18);
    border: 1px solid rgba(178, 58, 46, 0.5);
    color: #F4D7D1;
    font-size: 0.88rem;
}

/* ---- Body split: calendars + chat dock ----------------------------------- */
.tt-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    gap: 1rem;
    padding: 1rem 1.4rem 1.4rem;
}

/* Container that holds one .tt-calendar per visible user (active + the selected read-only user).
   Side-by-side on desktop; flips to a vertical stack at <=900px (see media query below) so the
   two grids read top-and-bottom on tablet/phone instead of being crushed into half-width. */
.tt-calendars {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: row;
    gap: 1rem;
}

.tt-calendar {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Per-calendar header strip: color dot + name + tag (active / read-only). The user color comes
   from the inline --tt-user-color set on the element in the view. */
.tt-calendar-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.7rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--harbor-3);
    color: var(--paper);
    font-family: var(--font-display);
    font-size: 0.85rem;
}
.tt-calendar-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--tt-user-color, var(--coral));
    flex: 0 0 auto;
}
.tt-calendar-name {
    font-weight: 600;
    letter-spacing: -0.005em;
}
.tt-calendar-tag {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    text-transform: lowercase;
    letter-spacing: 0.04em;
    color: var(--seafoam);
    padding: 0.12rem 0.45rem;
    border: 1px solid var(--harbor-3);
    border-radius: 6px;
    opacity: 0.85;
    white-space: nowrap;
}
.tt-calendar-tag.is-active {
    color: var(--paper);
    border-color: var(--tt-user-color, var(--coral));
    background: color-mix(in srgb, var(--tt-user-color, var(--coral)) 18%, transparent);
}

/* Read-only calendar picker: the compact select in the side calendar's head strip that chooses
   which non-active user that grid shows. Blends into the dark strip; the head's color dot (from
   --tt-user-color) re-colors to the picked user after the reload. */
.tt-otherpick {
    display: inline-flex;
    min-width: 0;
}
.tt-otherpick-select {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: -0.005em;
    color: var(--paper);
    background: var(--harbor-2);
    border: 1px solid var(--harbor-3);
    border-radius: 7px;
    padding: 0.18rem 0.45rem;
    max-width: 140px;
    cursor: pointer;
}

/* ---- The week grid (floats on the harbor) ------------------------------- */
.tt-grid {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    color: var(--ink);
    border-radius: 16px;
    box-shadow: var(--shadow-float);
    overflow: hidden;
}

.tt-grid-loading,
.tt-grid-error {
    margin: auto;
    padding: 2rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--ink-soft);
}
.tt-grid-error { color: var(--danger); }

/* header row */
.tt-grid-head {
    display: grid;
    grid-template-columns: var(--gutter-w) repeat(7, 1fr);
    border-bottom: 1px solid var(--tideline);
    flex: 0 0 auto;
}
.tt-corner { border-right: 1px solid var(--tideline); }

.tt-dayhead {
    text-align: center;
    padding: 0.5rem 0.25rem 0.45rem;
    border-left: 1px solid var(--tideline);
}
.tt-dayhead-dow {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.tt-dayhead-num {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.25rem;
    line-height: 1.1;
    color: var(--ink);
}
.tt-dayhead.is-today .tt-dayhead-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.9rem;
    height: 1.9rem;
    border-radius: 50%;
    background: var(--coral);
    color: #fff;
}
.tt-dayhead.is-today .tt-dayhead-dow { color: var(--coral-deep); }

/* all-day strip */
.tt-allday {
    display: grid;
    grid-template-columns: var(--gutter-w) repeat(7, 1fr);
    border-bottom: 1px solid var(--tideline);
    background: var(--paper-2);
    flex: 0 0 auto;
    min-height: 1.7rem;
}
.tt-allday-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
    text-align: right;
    padding: 0.35rem 0.5rem 0 0;
    border-right: 1px solid var(--tideline);
}
.tt-allday-cell {
    border-left: 1px solid var(--tideline);
    padding: 0.25rem 0.3rem;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.tt-allday-chip {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--ink);
    background: rgba(201, 154, 75, 0.28);
    border-left: 3px solid var(--brass);
    border-radius: 4px;
    padding: 1px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

/* scrollable hours */
.tt-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: var(--gutter-w) 1fr;
    scrollbar-width: thin;
}
.tt-gutter {
    position: relative;
    height: var(--grid-h);
    border-right: 1px solid var(--tideline);
}
.tt-hour-label {
    position: absolute;
    right: 0.5rem;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--ink-soft);
}
.tt-cols {
    position: relative;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    height: var(--grid-h);
}
.tt-daycol {
    position: relative;
    border-left: 1px solid var(--tideline);
    background-image: linear-gradient(var(--tideline) 1px, transparent 1px);
    background-size: 100% var(--hour-h);
}
.tt-daycol.is-today { background-color: rgba(232, 84, 47, 0.035); }

/* timed event block */
.tt-event {
    position: absolute;
    left: 2px;
    right: 2px;
    background: var(--coral-wash);
    border-left: 3px solid var(--coral);
    border-radius: 7px;
    padding: 3px 6px;
    overflow: hidden;
    cursor: pointer;
    transition: background .15s;
}
.tt-event:hover { background: rgba(232, 84, 47, 0.24); z-index: 5; }
/* An event currently involved in an open conflict thread — derived server-side per page load. */
.tt-event.is-conflicted {
    border-left: 3px dashed var(--coral-deep);
    box-shadow: inset 0 0 0 1px var(--coral);
}
.tt-event.is-conflicted::after {
    content: "⚠";
    position: absolute;
    top: 2px;
    right: 3px;
    font-size: 0.7rem;
    color: var(--coral-deep);
    line-height: 1;
    pointer-events: none;
}
.tt-event.is-conflicted:hover { background: rgba(232, 84, 47, 0.28); }
.tt-event-time {
    font-family: var(--font-mono);
    font-size: 0.64rem;
    color: var(--coral-deep);
    line-height: 1.1;
}
.tt-event-title {
    font-weight: 600;
    font-size: 0.76rem;
    color: var(--ink);
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Short events (< 45 min): collapse the two-line layout into a single row so
   the time and title remain readable instead of being clipped. */
.tt-event.is-short {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    padding: 2px 6px;
}
.tt-event.is-short .tt-event-title-row {
    flex: 0 0 auto;
    gap: 0.2rem;
}
.tt-event.is-short .tt-event-title {
    flex: 1 1 auto;
    min-width: 0;
    display: block;
    white-space: nowrap;
    -webkit-line-clamp: unset;
    -webkit-box-orient: unset;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* event details popover — opens on click, floats above the grid */
.tt-detail {
    position: fixed;
    z-index: 100;
    width: min(300px, 90vw);
    max-height: 70vh;
    overflow-y: auto;
    padding: 0.95rem 1rem 1rem;
    background: var(--paper);
    color: var(--ink);
    border-radius: 12px;
    border-left: 4px solid var(--coral);
    box-shadow: var(--shadow-float);
    scrollbar-width: thin;
    animation: tt-detail-in .12s ease-out;
}
@keyframes tt-detail-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.tt-detail-close {
    position: absolute;
    top: 0.45rem;
    right: 0.5rem;
    width: 24px;
    height: 24px;
    line-height: 1;
    font-size: 1.2rem;
    color: var(--ink-soft);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
.tt-detail-close:hover { background: var(--tideline); color: var(--ink); }
.tt-detail-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.25;
    color: var(--ink);
    padding-right: 1.6rem;
    margin-bottom: 0.35rem;
}
.tt-detail-when {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--coral-deep);
    margin-bottom: 0.55rem;
}
.tt-detail-row {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    font-size: 0.84rem;
    color: var(--ink);
    margin-bottom: 0.45rem;
}
.tt-detail-icon { flex: 0 0 auto; }
.tt-detail-text { word-break: break-word; }
.tt-detail-desc {
    font-size: 0.84rem;
    line-height: 1.45;
    color: var(--ink);
    white-space: pre-wrap;
    word-wrap: break-word;
    border-top: 1px solid var(--tideline);
    padding-top: 0.5rem;
}
.tt-detail-empty {
    font-size: 0.8rem;
    color: var(--ink-soft);
    font-style: italic;
}

/* meeting events — distinct from solo events so participants can be spotted at a glance */
.tt-event.is-meeting {
    border-left: 3px double var(--brass);
    background: rgba(201, 154, 75, 0.16);
}
.tt-event.is-meeting:hover { background: rgba(201, 154, 75, 0.28); }
.tt-event.is-meeting.is-conflicted {
    /* keep the conflict treatment dominant when both apply */
    border-left: 3px dashed var(--coral-deep);
}
.tt-event-title-row {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}
.tt-event-chip {
    font-size: 0.6rem;
    line-height: 1;
    color: var(--brass);
}
.tt-event-title.is-meeting { color: var(--ink); }

/* participants section inside the details popover */
.tt-detail-participants {
    margin-top: 0.6rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--tideline);
}
.tt-detail-participants-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}
.tt-detail-participants-label {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
}
.tt-detail-participants-list {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-bottom: 0.45rem;
}
.tt-detail-participant {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.84rem;
    color: var(--ink);
    padding: 0.2rem 0.25rem;
    border-radius: 6px;
}
.tt-detail-participant:hover { background: var(--tideline); }
.tt-detail-participant-dot {
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--tt-dot, var(--coral));
    box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--tideline);
}
.tt-detail-participant-name {
    flex: 1 1 auto;
    word-break: break-word;
}
.tt-detail-participant-remove {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    line-height: 1;
    font-size: 1rem;
    color: var(--ink-soft);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    transition: color .12s, border-color .12s, background .12s;
}
.tt-detail-participant-remove:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(178, 58, 46, 0.08);
}
.tt-detail-add {
    display: flex;
    align-items: stretch;
    gap: 0.35rem;
    margin-top: 0.2rem;
}
.tt-detail-add-select {
    flex: 1 1 auto;
    font-family: var(--font-body);
    font-size: 0.82rem;
    color: var(--ink);
    background: var(--paper-2);
    border: 1px solid var(--tideline);
    border-radius: 6px;
    padding: 0.3rem 0.4rem;
    cursor: pointer;
}
.tt-detail-add-select:focus-visible {
    outline: 2px solid var(--coral);
    outline-offset: 1px;
}
.tt-detail-add-btn {
    flex: 0 0 auto;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--paper);
    background: var(--coral);
    border: none;
    border-radius: 6px;
    padding: 0.3rem 0.7rem;
    cursor: pointer;
    transition: background .12s;
}
.tt-detail-add-btn:hover:not(:disabled) { background: var(--coral-deep); }
.tt-detail-add-btn:disabled { opacity: 0.55; cursor: default; }
.tt-detail-add-empty {
    flex: 1 1 auto;
    font-size: 0.8rem;
    color: var(--ink-soft);
    font-style: italic;
}
.tt-detail-loading {
    font-size: 0.8rem;
    color: var(--ink-soft);
    font-style: italic;
    padding: 0.2rem 0.25rem;
}
.tt-detail-error {
    font-size: 0.8rem;
    color: var(--danger);
    background: rgba(178, 58, 46, 0.08);
    border-radius: 6px;
    padding: 0.35rem 0.45rem;
    margin-top: 0.4rem;
}

/* now-line — the live coral tideline */
.tt-nowline {
    position: absolute;
    left: 0;
    right: 0;
    height: 0;
    border-top: 2px solid var(--coral);
    z-index: 6;
    pointer-events: none;
}
.tt-nowline::before {
    content: "";
    position: absolute;
    left: -4px;
    top: -4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--coral);
    box-shadow: 0 0 0 3px rgba(232, 84, 47, 0.25);
}

/* signature: tide ripple when an event is created/moved/cleared */
.tt-event.is-rippling {
    animation: tt-ripple 1.1s ease-out 1;
}
@keyframes tt-ripple {
    0%   { box-shadow: 0 0 0 0 rgba(232, 84, 47, 0.55); background: rgba(232, 84, 47, 0.42); }
    70%  { box-shadow: 0 0 0 14px rgba(232, 84, 47, 0); }
    100% { box-shadow: 0 0 0 0 rgba(232, 84, 47, 0); background: var(--coral-wash); }
}

/* =========================================================================
   Chat dock — "the claw"
   ========================================================================= */
.tt-chat {
    flex: 0 0 360px;
    display: flex;
    flex-direction: column;
    background: var(--harbor-2);
    border: 1px solid var(--harbor-3);
    border-radius: 16px;
    box-shadow: var(--shadow-float);
    overflow: hidden;
}
.tt-chat-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--harbor-3);
}
.tt-chat-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--paper);
}
.tt-chat-head-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.tt-chat-new,
.tt-chat-close {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--seafoam);
    background: transparent;
    border: 1px solid var(--harbor-3);
    border-radius: 7px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
}
.tt-chat-new:hover,
.tt-chat-close:hover { color: var(--paper); border-color: var(--seafoam-dim); }
.tt-chat-close { display: none; } /* shown only on mobile */

.tt-chat-log {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    scrollbar-width: thin;
}
.tt-chat-empty {
    margin: auto;
    text-align: center;
    max-width: 24ch;
    font-size: 0.82rem;
    color: var(--seafoam);
    line-height: 1.5;
}
.tt-msg {
    max-width: 85%;
    padding: 0.5rem 0.7rem;
    border-radius: 12px;
    font-size: 0.86rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.tt-msg-user {
    align-self: flex-end;
    background: var(--coral);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.tt-msg-claw {
    align-self: flex-start;
    background: var(--harbor-3);
    color: var(--paper);
    border-bottom-left-radius: 4px;
}
.tt-msg-error {
    align-self: flex-start;
    background: rgba(178, 58, 46, 0.22);
    border: 1px solid rgba(178, 58, 46, 0.55);
    color: #F4D7D1;
}

/* --- Rendered markdown inside claw / agent bubbles (parsed by marked, sanitized by DOMPurify) ---
   Markdown owns its own whitespace, so we drop the bubble's pre-wrap here and
   tighten the first/last child margins so a single-paragraph reply still looks like a chat line. */
.tt-md { white-space: normal; word-wrap: break-word; overflow-wrap: anywhere; }
.tt-md > *:first-child { margin-top: 0; }
.tt-md > *:last-child { margin-bottom: 0; }
.tt-md p { margin: 0.35rem 0; }
.tt-md h1, .tt-md h2, .tt-md h3, .tt-md h4, .tt-md h5, .tt-md h6 {
    margin: 0.6rem 0 0.3rem;
    line-height: 1.25;
    font-family: var(--font-display);
    font-weight: 600;
}
.tt-md h1 { font-size: 1.05rem; }
.tt-md h2 { font-size: 1rem; }
.tt-md h3, .tt-md h4 { font-size: 0.92rem; }
.tt-md h5, .tt-md h6 { font-size: 0.84rem; color: var(--seafoam); }
.tt-md ul, .tt-md ol { margin: 0.35rem 0; padding-left: 1.25rem; }
.tt-md li { margin: 0.15rem 0; }
.tt-md li::marker { color: var(--seafoam); }
.tt-md a {
    color: var(--coral);
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
}
.tt-md a:hover { color: var(--paper); }
.tt-md strong { font-weight: 600; }
.tt-md em { font-style: italic; }
.tt-md del { opacity: 0.7; }
.tt-md hr {
    border: none;
    border-top: 1px solid var(--harbor-3);
    margin: 0.6rem 0;
}
.tt-md blockquote {
    margin: 0.4rem 0;
    padding: 0.2rem 0 0.2rem 0.65rem;
    border-left: 3px solid var(--seafoam-dim);
    color: var(--seafoam);
}
.tt-md blockquote > *:first-child { margin-top: 0; }
.tt-md blockquote > *:last-child { margin-bottom: 0; }
.tt-md code {
    font-family: var(--font-mono);
    font-size: 0.82em;
    background: rgba(15, 46, 46, 0.55);
    border: 1px solid var(--harbor-3);
    border-radius: 4px;
    padding: 0.05rem 0.3rem;
}
.tt-md pre {
    margin: 0.45rem 0;
    padding: 0.5rem 0.6rem;
    background: rgba(15, 46, 46, 0.75);
    border: 1px solid var(--harbor-3);
    border-radius: 8px;
    overflow-x: auto;
}
.tt-md pre code {
    background: transparent;
    border: none;
    padding: 0;
    font-size: 0.8em;
    color: inherit;
}
.tt-md table {
    border-collapse: collapse;
    margin: 0.45rem 0;
    font-size: 0.82em;
    width: max-content;
    max-width: 100%;
}
.tt-md th, .tt-md td {
    border: 1px solid var(--harbor-3);
    padding: 0.25rem 0.5rem;
    text-align: left;
    vertical-align: top;
}
.tt-md th { background: rgba(143, 184, 176, 0.12); font-weight: 600; }
.tt-md sup { font-size: 0.7em; vertical-align: super; }
.tt-md sub { font-size: 0.7em; vertical-align: sub; }

/* typing indicator */
.tt-typing { display: inline-flex; gap: 4px; align-items: center; }
.tt-typing span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--seafoam);
    animation: tt-bounce 1.2s infinite ease-in-out both;
}
.tt-typing span:nth-child(2) { animation-delay: 0.15s; }
.tt-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes tt-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40% { transform: translateY(-4px); opacity: 1; }
}

.tt-chat-compose {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.7rem;
    border-top: 1px solid var(--harbor-3);
}
.tt-chat-compose textarea {
    flex: 1 1 auto;
    resize: none;
    max-height: 140px;
    /* JS auto-resizes the textarea up to max-height; hide the native scrollbar
       (which on some browsers shows persistent up/down arrow buttons even when
       the content fits) so the compose row stays clean. */
    overflow: hidden;
    font-family: var(--font-body);
    font-size: 0.88rem;
    color: var(--paper);
    background: var(--harbor);
    border: 1px solid var(--harbor-3);
    border-radius: 10px;
    padding: 0.5rem 0.7rem;
    line-height: 1.35;
}
.tt-chat-compose textarea::placeholder { color: var(--seafoam-dim); }
.tt-chat-compose textarea:focus { outline: none; border-color: var(--coral); }
.tt-chat-send {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 10px;
    background: var(--coral);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background .15s;
}
.tt-chat-send:hover { background: var(--coral-deep); }
.tt-chat-send:disabled { opacity: 0.5; cursor: default; }

/* voice dictation mic — injected by voice-input.js beside the send button */
.tt-voice-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--harbor-3);
    border-radius: 10px;
    background: var(--harbor-2);
    color: var(--seafoam);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.tt-voice-btn:hover { background: var(--harbor-3); color: var(--paper); }
.tt-voice-btn.is-listening {
    background: var(--coral);
    border-color: var(--coral-deep);
    color: #fff;
    animation: tt-voice-pulse 1.3s ease-in-out infinite;
}
@keyframes tt-voice-pulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--coral-wash); }
    50% { box-shadow: 0 0 0 6px var(--coral-wash); }
}
@media (prefers-reduced-motion: reduce) {
    .tt-voice-btn.is-listening { animation: none; }
}

/* mobile FAB — hidden on desktop */
.tt-chat-fab {
    display: none;
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: var(--coral);
    font-size: 1.7rem;
    cursor: pointer;
    box-shadow: var(--shadow-float);
    z-index: 50;
}

/* =========================================================================
   Add-event dialog
   ========================================================================= */
.tt-dialog {
    border: 1px solid var(--harbor-3);
    border-radius: 16px;
    padding: 0;
    background: var(--harbor-2);
    color: var(--paper);
    width: min(440px, 92vw);
    box-shadow: var(--shadow-float);
}
.tt-dialog::backdrop { background: rgba(8, 22, 22, 0.55); }
.tt-dialog-form { padding: 1.3rem; display: flex; flex-direction: column; gap: 0.7rem; }
.tt-dialog-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.2rem;
    margin: 0 0 0.2rem;
}
.tt-dialog-error {
    margin: 0;
    padding: 0.5rem 0.7rem;
    border-radius: 8px;
    background: rgba(178, 58, 46, 0.22);
    border: 1px solid rgba(178, 58, 46, 0.55);
    color: #F4D7D1;
    font-size: 0.83rem;
}
.tt-field { display: flex; flex-direction: column; gap: 0.25rem; }
.tt-field > span {
    font-size: 0.78rem;
    color: var(--seafoam);
    font-weight: 500;
}
.tt-field > span em { color: var(--seafoam-dim); font-style: normal; }
.tt-field input,
.tt-field textarea,
.tt-field select {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--paper);
    background: var(--harbor);
    border: 1px solid var(--harbor-3);
    border-radius: 9px;
    padding: 0.5rem 0.65rem;
}
.tt-field input:focus,
.tt-field textarea:focus,
.tt-field select:focus { outline: none; border-color: var(--coral); }
.tt-event-repeat { font-size: 0.7em; opacity: 0.85; }
.tt-field-row { display: flex; gap: 0.7rem; }
.tt-field-row .tt-field { flex: 1; min-width: 0; }
.tt-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 0.4rem;
}
.tt-btn-ghost {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--seafoam);
    background: transparent;
    border: 1px solid var(--harbor-3);
    border-radius: 9px;
    padding: 0.5rem 0.9rem;
    cursor: pointer;
}
.tt-btn-ghost:hover { color: var(--paper); }
.tt-btn-coral {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.85rem;
    color: #fff;
    background: var(--coral);
    border: none;
    border-radius: 9px;
    padding: 0.5rem 1rem;
    cursor: pointer;
}
.tt-btn-coral:hover { background: var(--coral-deep); }
.tt-btn-coral:disabled { opacity: 0.5; cursor: default; }

/* =========================================================================
   Focus + motion + responsive
   ========================================================================= */
.tt-app :focus-visible,
.tt-dialog :focus-visible,
.tt-chat-fab:focus-visible {
    outline: 2px solid var(--coral);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .tt-event.is-rippling,
    .tt-typing span { animation: none; }
    .tt-event.is-rippling { background: rgba(232, 84, 47, 0.42); }
}

@media (max-width: 900px) {
    .tt-body { padding: 0.8rem; }
    /* Stack the two calendars top/bottom on tablet/phone. Each keeps its own horizontal scroll
       so the 720px min-width grid stays usable on a narrow viewport. */
    .tt-calendars { flex-direction: column; }
    .tt-calendar { overflow-x: auto; }
    .tt-grid { min-width: 720px; }

    /* chat collapses to a slide-in sheet toggled by the FAB */
    .tt-chat {
        position: fixed;
        inset: auto 0 0 0;
        flex-basis: auto;
        height: 72vh;
        border-radius: 16px 16px 0 0;
        transform: translateY(105%);
        transition: transform .25s ease;
        z-index: 60;
    }
    .tt-chat.is-open { transform: translateY(0); }
    .tt-chat-close { display: inline-block; }
    .tt-chat-fab { display: inline-flex; align-items: center; justify-content: center; }
    .tt-chat-fab.is-hidden { display: none; }
}

@media (max-width: 620px) {
    .tt-topbar { flex-wrap: wrap; gap: 0.6rem 1rem; padding: 0.7rem 1rem; }
    .tt-weeknav { order: 3; width: 100%; }
    .tt-weeklabel { margin-left: auto; }
    .tt-user { display: none; }
}

/* =========================================================================
   Chat dock — tabs, conflict threads, toasts
   ========================================================================= */
.tt-tabs {
    display: inline-flex;
    gap: 0.2rem;
    margin-left: 0.4rem;
}
.tt-tab {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.02em;
    color: var(--seafoam);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 0.25rem 0.55rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.tt-tab:hover { color: var(--paper); }
.tt-tab.is-active {
    color: var(--paper);
    border-color: var(--harbor-3);
    background: var(--harbor);
}
.tt-tab-badge {
    background: var(--coral);
    color: #fff;
    border-radius: 999px;
    font-size: 0.62rem;
    padding: 0 0.32rem;
    line-height: 1.5;
    font-weight: 600;
}

/* Only one panel is visible at a time; each fills the dock body. */
.tt-panel { display: none; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.tt-panel.is-active { display: flex; }

/* Hide the claw "new" button while on the conflicts tab (chat-widget.js toggles this class). */
.tt-chat.tab-conflicts .tt-chat-new { display: none; }

/* --- Conflict list --- */
.tt-conf-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    scrollbar-width: thin;
}
.tt-conf-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    width: 100%;
    text-align: left;
    background: var(--harbor);
    border: 1px solid var(--harbor-3);
    border-radius: 10px;
    padding: 0.6rem 0.7rem;
    cursor: pointer;
    color: var(--paper);
}
.tt-conf-item:hover { border-color: var(--seafoam-dim); background: var(--harbor-3); }
.tt-conf-item.has-unread { border-color: var(--coral); }
.tt-conf-dot {
    flex: 0 0 auto;
    width: 10px; height: 10px;
    border-radius: 50%;
    margin-top: 0.35rem;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.06);
}
.tt-conf-item-main { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; flex: 1 1 auto; }
.tt-conf-item-name { font-weight: 600; font-size: 0.88rem; }
.tt-conf-item-ev { font-size: 0.74rem; color: var(--seafoam); }
.tt-conf-item-preview {
    font-size: 0.78rem;
    color: var(--seafoam);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tt-conf-item.has-unread .tt-conf-item-preview { color: var(--paper); }
.tt-conf-item-badge {
    flex: 0 0 auto;
    background: var(--coral);
    color: #fff;
    border-radius: 999px;
    font-size: 0.66rem;
    padding: 0.05rem 0.4rem;
    font-weight: 600;
    align-self: center;
}

/* --- Conflict thread view --- */
.tt-conf-thread { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.tt-conf-thread-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--harbor-3);
}
.tt-conf-back, .tt-conf-resolve {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--seafoam);
    background: transparent;
    border: 1px solid var(--harbor-3);
    border-radius: 7px;
    padding: 0.25rem 0.55rem;
    cursor: pointer;
}
.tt-conf-back:hover, .tt-conf-resolve:hover { color: var(--paper); border-color: var(--seafoam-dim); }
.tt-conf-thread-title {
    flex: 1 1 auto;
    font-size: 0.86rem;
    color: var(--paper);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tt-conf-log { background: var(--harbor-2); }

/* --- Conflict reason hint (advisory, auto-generated + human-editable) --- */
.tt-conf-reason {
    flex: 0 0 auto;
    padding: 0.4rem 0.7rem;
    border-bottom: 1px solid var(--harbor-3);
    background: var(--harbor);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.tt-conf-reason-view {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}
.tt-conf-reason-text {
    flex: 1 1 auto;
    font-size: 0.74rem;
    line-height: 1.35;
    color: var(--seafoam);
    font-style: italic;
}
.tt-conf-reason-edit {
    flex: 0 0 auto;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--seafoam);
    background: transparent;
    border: 1px solid var(--harbor-3);
    border-radius: 6px;
    padding: 0.15rem 0.45rem;
    cursor: pointer;
}
.tt-conf-reason-edit:hover { color: var(--paper); border-color: var(--seafoam-dim); }
.tt-conf-reason-edit-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.tt-conf-reason-edit-row input {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.76rem;
    color: var(--paper);
    background: var(--harbor-2);
    border: 1px solid var(--harbor-3);
    border-radius: 6px;
    padding: 0.25rem 0.45rem;
}
.tt-conf-reason-edit-row input:focus { outline: none; border-color: var(--coral); }
.tt-conf-reason-edit-row button {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--paper);
    background: var(--coral);
    border: 1px solid var(--coral);
    border-radius: 6px;
    padding: 0.25rem 0.55rem;
    cursor: pointer;
}
.tt-conf-reason-edit-row button:hover { background: var(--coral-deep); border-color: var(--coral-deep); }
.tt-conf-reason-edit-row button[aria-label="Cancel edit"] {
    color: var(--seafoam);
    background: transparent;
    border-color: var(--harbor-3);
}
.tt-conf-reason-edit-row button[aria-label="Cancel edit"]:hover {
    color: var(--paper);
    border-color: var(--seafoam-dim);
}

/* --- Conflict messages --- */
.tt-cmsg {
    max-width: 85%;
    padding: 0.45rem 0.65rem;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
    position: relative;
}
.tt-cmsg-self {
    align-self: flex-end;
    background: var(--coral);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.tt-cmsg-other {
    align-self: flex-start;
    background: var(--harbor-3);
    color: var(--paper);
    border-bottom-left-radius: 4px;
}
.tt-cmsg-agent {
    align-self: flex-start;
    background: rgba(143, 184, 176, 0.16);
    border: 1px solid var(--seafoam-dim);
    color: var(--paper);
    border-bottom-left-radius: 4px;
}
.tt-cmsg-tag {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.64rem;
    letter-spacing: 0.02em;
    color: var(--seafoam);
    margin-bottom: 0.2rem;
}
.tt-cmsg-system {
    align-self: center;
    max-width: 92%;
    background: transparent;
    border: 1px dashed var(--harbor-3);
    color: var(--seafoam);
    font-size: 0.76rem;
    text-align: center;
    border-radius: 8px;
}
.tt-cmsg-time {
    display: block;
    font-size: 0.62rem;
    opacity: 0.7;
    margin-top: 0.2rem;
}
.tt-cmsg-typing { padding: 0.55rem 0.7rem; }

/* --- Toasts (conflict detection prompts) --- */
.tt-toast-host {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(360px, 90vw);
    pointer-events: none;
}
.tt-toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--harbor-2);
    border: 1px solid var(--coral);
    border-radius: 10px;
    box-shadow: var(--shadow-float);
    padding: 0.6rem 0.7rem;
    color: var(--paper);
    font-size: 0.82rem;
    animation: tt-toast-in 0.18s ease-out;
}
.tt-toast-msg { flex: 1 1 auto; }
.tt-toast-open, .tt-toast-dismiss {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    border-radius: 6px;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
}
.tt-toast-open { background: var(--coral); color: #fff; border: 1px solid var(--coral); }
.tt-toast-open:hover { background: var(--coral-deep); }
.tt-toast-dismiss { background: transparent; color: var(--seafoam); border: 1px solid var(--harbor-3); }
.tt-toast-dismiss:hover { color: var(--paper); }
@keyframes tt-toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Quick-reply choice chips (claw-choices) ---
   The claw emits a fenced ```claw-choices``` block in its reply when it wants the user to pick
   between concrete options (a slot, an event, a yes/no). The block is parsed out of the prose
   before markdown rendering (see chat-widget.js) and rendered here as a stack of tappable
   pills below the bubble. One tap sends that text as the user's next message; the user can also
   always type freely. Once consumed (tap or typed), the group fades to .is-used. The other
   participant in a conflict thread sees a static .is-readonly preview labelled "offered to …". */
.tt-choices {
    margin-top: 0.5rem;
    padding-top: 0.45rem;
    border-top: 1px solid var(--harbor-3);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    animation: tt-choices-in 0.18s ease-out;
}
.tt-choices-label {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--seafoam-dim);
}
.tt-choices-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.tt-choice {
    /* full-width stack so labels never truncate — the user must see what they're picking */
    width: 100%;
    text-align: left;
    font-family: var(--font-body);
    font-size: 0.85rem;
    line-height: 1.35;
    color: var(--paper);
    background: var(--harbor-2);
    border: 1px solid var(--harbor-3);
    border-radius: 10px;
    padding: 0.5rem 0.7rem;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease,
                transform 0.08s ease;
}
.tt-choice:hover:not(:disabled) {
    background: var(--coral-wash);
    border-color: var(--coral);
    color: var(--paper);
    transform: translateY(-1px);
}
.tt-choice:active:not(:disabled) {
    transform: translateY(0);
    border-color: var(--coral-deep);
}
.tt-choice:focus-visible {
    outline: 2px solid var(--coral);
    outline-offset: 2px;
}

/* Used: the user has tapped a chip or typed past this turn. The chips fade back, no longer
   tappable — a soft visual record of what was on the table. */
.tt-choices.is-used {
    opacity: 0.45;
    cursor: default;
    border-top-color: var(--harbor-3);
}
.tt-choices.is-used .tt-choice {
    cursor: default;
}

/* Readonly: shown to the non-addressee in a conflict thread ("the claw offered these to …").
   Distinct from .is-used — these were never interactive on this side. Italic, muted, no
   hover affordance. */
.tt-choices.is-readonly {
    border-top-style: dashed;
}
.tt-choices.is-readonly .tt-choice {
    font-style: italic;
    color: var(--seafoam);
    background: transparent;
    border-color: var(--harbor-3);
    cursor: default;
}
.tt-choices.is-readonly .tt-choice:hover {
    /* no hover affordance — make explicit that these aren't for the current viewer */
    transform: none;
    background: transparent;
    border-color: var(--harbor-3);
    color: var(--seafoam);
}

/* Inside conflict agent bubbles, the bubble already has its own padding+background, so the
   chip group's top border reads as a divider rather than a panel edge. Nudge slightly so the
   visual rhythm matches the Claw tab. */
.tt-cmsg-agent .tt-choices { margin-top: 0.6rem; }

@keyframes tt-choices-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .tt-choices { animation: none; }
}

/* =========================================================================
   /Agents — self-service enrollment page (standard nav layout, light bg).
   Reuses the harbor palette on paper surfaces; mono for every secret.
   ========================================================================= */
.tt-agents {
    max-width: 860px;
}

.tt-agents h1 {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--ink);
}

.tt-agents .tt-card {
    background: var(--paper);
    border: 1px solid var(--tideline);
    border-radius: 14px;
    box-shadow: 0 8px 24px -18px rgba(15, 46, 46, 0.45);
}

.tt-agents .tt-card .card-title {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--ink);
}

.tt-agents .tt-btn-primary {
    background: var(--coral);
    border: none;
    color: #fff;
    font-weight: 600;
    border-radius: 10px;
}

.tt-agents .tt-btn-primary:hover {
    background: var(--coral-deep);
    color: #fff;
}

.tt-agents .tt-btn-danger {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: 8px;
}

.tt-agents .tt-btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

/* One-time credentials panel — a little more presence than the plain cards. */
.tt-agents .tt-result {
    border-color: rgba(201, 154, 75, 0.55);
}

.tt-agents .tt-once-alert {
    background: var(--coral-wash);
    border: 1px solid rgba(232, 84, 47, 0.35);
    border-radius: 10px;
    color: var(--ink);
}

.tt-agents .tt-field-label {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
    margin-bottom: 0.35rem;
}

/* Secret/URL copy box: mono on paper, hairline border, copy button on the right. */
.tt-agents .tt-copybox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--paper-2);
    border: 1px solid var(--tideline);
    border-radius: 10px;
    padding: 0.55rem 0.75rem;
}

.tt-agents .tt-copybox code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--ink);
    white-space: nowrap;
    overflow-x: auto;
    flex: 1 1 auto;
    min-width: 0;
}

/* The JSON config block wraps instead of scrolling. */
.tt-agents .tt-copybox-block {
    flex-direction: column;
    align-items: stretch;
}

.tt-agents .tt-copybox-block pre {
    margin: 0;
    width: 100%;
}

.tt-agents .tt-copybox-block pre code {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--ink);
    white-space: pre-wrap;
    overflow-x: visible;
    display: block;
}

.tt-agents .tt-copybox-block .tt-copy-btn {
    align-self: flex-end;
    margin-top: 0.4rem;
}

.tt-agents .tt-copy-btn {
    flex: 0 0 auto;
    background: var(--harbor);
    color: var(--paper);
    border: none;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.3rem 0.8rem;
}

.tt-agents .tt-copy-btn:hover {
    background: var(--harbor-3);
    color: #fff;
}

.tt-agents .tt-copy-btn.is-copied { background: #2A9D8F; }
.tt-agents .tt-copy-btn.is-failed { background: var(--danger); }

.tt-agents .tt-mono {
    font-family: var(--font-mono);
    font-size: 0.88em;
}

.tt-agents .tt-badge-user {
    background: var(--harbor);
    color: var(--paper);
    font-weight: 500;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.tt-agents .tt-badge-live {
    background: rgba(42, 157, 143, 0.16);
    color: #1F7A6E;
    font-weight: 600;
}

.tt-agents .tt-badge-dead {
    background: rgba(178, 58, 46, 0.12);
    color: var(--danger);
    font-weight: 600;
}

.tt-agents .tt-steps {
    margin-bottom: 0;
    color: var(--ink);
}

.tt-agents .tt-steps code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--paper-2);
    border-radius: 4px;
    padding: 0.05rem 0.3rem;
}

/* ===================== Categories & agent autonomy ===================== */

/* Categorized events: the left border takes the category color (set inline as --tt-cat by
   calendar-week.js). Conflicts keep the dominant treatment — the dashed coral must win over any
   category color so a double-booking is never visually buried. */
.tt-event.has-category {
    border-left-color: var(--tt-cat, var(--coral));
}
.tt-event.has-category.is-conflicted,
.tt-event.has-category.is-meeting.is-conflicted {
    border-left-color: var(--coral-deep);
}
/* Small dot next to the time mirroring the border color — scannable even where lanes squeeze
   the border out of view. */
.tt-event-cat-dot {
    flex: 0 0 auto;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--tt-cat, var(--coral));
    align-self: center;
}

/* Category row inside the event details popover. */
.tt-detail-cat {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    margin-top: 0.3rem;
}
.tt-detail-cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--paper-2);
    border-radius: 999px;
    padding: 0.1rem 0.55rem 0.1rem 0.35rem;
}
.tt-detail-cat-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--tt-cat, #8E7DBE);
}
.tt-detail-cat-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink);
}
.tt-detail-cat-name.is-uncategorized {
    font-style: italic;
    font-weight: 400;
    color: var(--ink-soft);
}
.tt-detail-cat-hint {
    font-size: 0.72rem;
    color: var(--ink-soft);
}
.tt-detail-cat-edit {
    margin-left: auto;
    border: none;
    background: transparent;
    color: var(--seafoam-dim);
    font-size: 0.72rem;
    cursor: pointer;
    border-radius: 6px;
    padding: 0.15rem 0.4rem;
}
.tt-detail-cat-edit:hover { background: var(--tideline); color: var(--ink); }
.tt-detail-cat-editor {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    margin-top: 0.3rem;
}
.tt-detail-cat-select {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.8rem;
    border: 1px solid var(--tideline);
    border-radius: 7px;
    padding: 0.25rem 0.35rem;
    background: var(--paper);
    color: var(--ink);
}
.tt-detail-cat-save,
.tt-detail-cat-cancel {
    border: none;
    border-radius: 7px;
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
}
.tt-detail-cat-save { background: var(--coral); color: var(--paper); }
.tt-detail-cat-save:hover { background: var(--coral-deep); }
.tt-detail-cat-cancel { background: transparent; color: var(--ink-soft); }
.tt-detail-cat-cancel:hover { background: var(--tideline); }

/* Approval chips — [approve: …] / [decline: …] items inside a claw-choices block. Approve reads
   as a clear affirmative action (seafoam-green), decline stays deliberately quieter so the
   affirmative is the visually louder path. */
.tt-choice.is-approve {
    background: #2A9D8F;
    border-color: #1F7A6E;
    color: #fff;
    font-weight: 600;
}
.tt-choice.is-approve:hover:not(:disabled) {
    background: #21867a;
    border-color: #17625A;
    color: #fff;
}
.tt-choice.is-decline {
    background: transparent;
    color: var(--seafoam);
    font-weight: 400;
}
.tt-choice.is-decline:hover:not(:disabled) {
    color: var(--seafoam);
    border-color: var(--harbor-3);
    background: transparent;
}

/* Category rows on the /Agents editor card. */
.tt-agents .tt-cat-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--tideline);
    max-width: 640px;
}
.tt-agents .tt-cat-row:last-of-type { border-bottom: none; }
.tt-agents .tt-cat-color {
    flex: 0 0 auto;
    width: 34px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--tideline);
    border-radius: 7px;
    background: var(--paper);
    cursor: pointer;
}
.tt-agents .tt-cat-name {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 220px;
}
.tt-agents .tt-cat-row .form-check-label {
    font-size: 0.8rem;
    color: var(--ink-soft);
    white-space: nowrap;
}
