/* ==========================================================================
   Schedules — a read-only appendix to the session list
   ========================================================================== */
.schedules {
    margin: 16px 2px 2px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}
.schedules[hidden] { display: none; }
.schedules > summary {
    display: flex; align-items: center; gap: 7px;
    min-height: 32px;
    padding: 2px 10px;
    color: var(--dim);
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.06em; text-transform: uppercase;
    cursor: pointer;
    list-style: none;
}
.schedules > summary::-webkit-details-marker { display: none; }
/* The way to make one, on the same line as the count. Pushed to the end with `auto` rather than
   given a place in the flow, so the count keeps sitting against the word it counts. */
.schedules > summary .add {
    position: relative;     /* anchors the touch target below, without adding to this box */
    margin-left: auto; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    width: 22px; height: 22px;
    border: 1px solid var(--line); border-radius: 6px;
    background: var(--card); color: var(--dim);
}
.schedules > summary .add:hover { background: var(--card-hi); color: var(--ink); }
.schedules > summary .add svg { display: block; width: 11px; height: 11px; }
/* The visible button stays 22px — any taller and `summary` (`min-height: 32px`) would grow past
   it, moving the word and count it shares this one line with. A phone still needs a real target,
   so the other 22px is added as an invisible hit area instead: absolutely positioned, so it costs
   the row no layout space of its own. 44px is the same thumb's worth `.sheet .place` in
   sheets.css already gives a row. */
.schedules > summary .add::before {
    content: "";
    position: absolute;
    top: 50%; left: 50%;
    width: 44px; height: 44px;
    transform: translate(-50%, -50%);
}
.schedules > summary::before {
    content: "›";
    color: var(--faint);
    font: 16px/1 var(--ui);
    transform: rotate(90deg);
    transition: transform 160ms var(--ease);
}
.schedules:not([open]) > summary::before { transform: none; }
.schedules > summary .count {
    min-width: 18px;
    padding: 1px 5px;
    border: 1px solid var(--line); border-radius: 8px;
    color: var(--faint);
    font: 10px/1.3 var(--mono);
    text-align: center;
}
.schedule-rows { list-style: none; margin: 3px 0 0; padding: 0; }
.schedule-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 9px;
    padding: 9px 10px;
    border-radius: 8px;
}
.schedule-row + .schedule-row { border-top: 1px solid var(--line); }
.schedule-name {
    min-width: 0;
    display: flex; align-items: center; gap: 8px;
}
.enabled-dot {
    flex: 0 0 auto;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--faint);
}
.enabled-dot[data-enabled="1"] { background: var(--ok); }
.enabled-dot[data-enabled="0"] { background: var(--line); }
.enabled-dot[data-enabled="invalid"] { background: var(--bad); }
.schedule-title {
    min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--ink);
    font-size: 12.5px; font-weight: 500;
}
.schedule-meta {
    grid-column: 1;
    padding-left: 15px;
    min-width: 0;
    display: flex; align-items: baseline;
    color: var(--faint);
    font: 10.5px/1.3 var(--mono);
}
.schedule-project {
    min-width: 0;
    display: inline-flex; align-items: center; gap: 5px;
}
.schedule-project-mark {
    flex: 0 0 auto;
    display: block;
    image-rendering: pixelated;
    opacity: 0.9;
}
.schedule-project-mark.none {
    width: 18px; height: 10px;
    border-radius: 2px;
    background: #202028;
}
.schedule-project-name {
    min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--dim);
}
.schedule-meta-sep { flex: 0 0 auto; }
.schedule-next { flex: 0 0 auto; }
.schedule-result {
    align-self: center;
    padding: 2px 6px;
    border: 1px solid var(--line); border-radius: 6px;
    color: var(--faint);
    font: 9.5px/1.2 var(--mono);
    text-transform: lowercase;
}
.schedule-result[data-state="success"] { color: var(--ok); border-color: rgba(95, 158, 115, 0.32); }
.schedule-result[data-state="failure"],
.schedule-result[data-state="timeout"],
.schedule-result[data-state="cancelled"],
.schedule-result[data-state="spawn_failed"],
.schedule-result[data-state="invalid"] { color: var(--bad); border-color: rgba(163, 86, 74, 0.42); }
.schedule-result[data-state="queued"],
.schedule-result[data-state="spawning"],
.schedule-result[data-state="briefed"] { color: var(--dim); border-color: var(--line); }
.schedule-missed {
    grid-column: 1 / -1;
    padding-left: 15px;
    color: var(--warn);
    font: 10px/1.3 var(--mono);
}
.schedule-error {
    grid-column: 1 / -1;
    margin: 0; padding-left: 15px;
    color: var(--bad);
    font-size: 10.5px; line-height: 1.35;
    overflow-wrap: anywhere;
}

/* A schedule as a timeline of sessions. It is deliberately a separate sheet from the editor:
   opening history is read-only, while Edit is an explicit second press before any writable form
   appears. The run list scrolls inside the card so its Close button remains reachable on a phone. */
.schedule-history-sheet {
    width: min(500px, 100%);
    max-height: min(720px, calc(100vh - 28px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.schedule-history-head {
    display: flex; align-items: flex-start; gap: 12px;
    padding-bottom: 13px;
    border-bottom: 1px solid var(--line);
}
.schedule-history-heading { min-width: 0; flex: 1 1 auto; }
.schedule-history-heading h2 {
    margin: 0;
    color: var(--ink);
    font: 600 19px/1.2 var(--ui);
    overflow-wrap: anywhere;
}
.schedule-history-heading p {
    margin: 5px 0 0;
    color: var(--faint);
    font: 10.5px/1.35 var(--mono);
    overflow-wrap: anywhere;
}
.schedule-history-head > .chip { flex: 0 0 auto; }
.schedule-history-sheet > .said {
    min-height: 18px;
    margin: 9px 0 0;
    color: var(--bad);
    font-size: 11px;
}
.schedule-history-sheet h3 {
    margin: 8px 0 7px;
    color: var(--dim);
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.07em; text-transform: uppercase;
}
.schedule-run-rows {
    min-height: 0;
    margin: 0; padding: 0;
    overflow-y: auto;
    list-style: none;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--card);
}
.schedule-run + .schedule-run { border-top: 1px solid var(--line); }
.schedule-run-button {
    width: 100%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 4px 9px;
    padding: 11px 12px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--ink);
    text-align: left;
}
.schedule-run-button:not([disabled]):hover { background: var(--card-hi); }
.schedule-run-button[disabled] { opacity: 0.62; cursor: default; }
.schedule-run-state {
    padding: 2px 6px;
    border: 1px solid var(--line); border-radius: 6px;
    color: var(--faint);
    font: 9.5px/1.2 var(--mono);
    text-transform: lowercase;
}
.schedule-run-state[data-state="success"] { color: var(--ok); border-color: rgba(95, 158, 115, 0.32); }
.schedule-run-state[data-state="failure"],
.schedule-run-state[data-state="timeout"],
.schedule-run-state[data-state="cancelled"],
.schedule-run-state[data-state="spawn_failed"] { color: var(--bad); border-color: rgba(163, 86, 74, 0.42); }
.schedule-run-time {
    min-width: 0;
    align-self: center;
    color: var(--dim);
    font: 10.5px/1.25 var(--mono);
}
.schedule-run-summary {
    grid-column: 1 / -1;
    /* This sheet is a picker, not a place to read a report. Two lines are enough to tell one
       occurrence from another, and the rest of the summary would push the older runs off a
       phone screen; the whole text stays in the title and in the conversation the row opens. */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    color: var(--ink);
    font-size: 12px; line-height: 1.35;
    overflow-wrap: anywhere;
}
.schedule-run-meta {
    grid-column: 1 / 3;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--faint);
    font: 10px/1.25 var(--mono);
}
.schedule-run-action {
    grid-column: 3;
    grid-row: 1;
    align-self: center;
    color: var(--accent);
    font-size: 10.5px;
    white-space: nowrap;
}
.schedule-run-button[disabled] .schedule-run-action { color: var(--faint); }
.schedule-history-empty, .schedule-history-capped {
    margin: 10px 1px 0;
    color: var(--faint);
    font-size: 11px; line-height: 1.4;
}
.schedule-history-capped { color: var(--warn); }
.schedule-history-sheet > .buttons {
    flex: 0 0 auto;
    display: flex; justify-content: flex-end;
    margin-top: 14px;
}

@media (max-width: 899px) {
    .schedules { margin-top: 18px; }
    .schedules > summary { min-height: 40px; padding: 4px 12px; }
    .schedule-row { padding: 11px 12px; gap: 6px 10px; }
    .schedule-title { font-size: 13.5px; }
    .schedule-meta, .schedule-missed, .schedule-error { padding-left: 15px; font-size: 11px; }
    .schedule-history-sheet { max-height: calc(100vh - 16px); }
    .schedule-history-head { align-items: center; }
    .schedule-run-button { min-height: 64px; padding: 12px; }
}
