/* Modified 2026-11-04: Fit the schedule workspace to the existing tournament Settings shell. */
body.test-shell:has(#schedule-planner) { width: 100%; }
/* Modified 2026-11-04: Reserve enough document space below the schedule for the fixed composer. */
#schedule-planner { padding-bottom: calc(var(--sp-composer-height, 100px) + 24px); box-sizing: border-box; margin: 16px; color: var(--shell-dialog-text, #e4eaf1); font: 13px/1.5 Arial, sans-serif; }
#schedule-planner *, #schedule-planner *::before, #schedule-planner *::after { box-sizing: border-box; }
#schedule-planner h1 { margin: 0; font-size: 22px; }
#schedule-planner h2 { font-size: 17px; }
#schedule-planner h3 { margin: 0 0 10px; font-size: 14px; }
#schedule-planner p { white-space: normal; }
#schedule-planner label { display: flex; flex-direction: column; gap: 5px; white-space: normal; }
#schedule-planner input, #schedule-planner select, #schedule-planner textarea {
    width: 100%; min-width: 0; padding: 7px 9px; border-radius: 5px;
    border: 1px solid var(--shell-dialog-border, #39475a);
    background: var(--shell-dialog-field-background, #141b24); color: inherit; font: inherit;
}
#schedule-planner button {
    width: auto; margin: 0; padding: 7px 11px; border-radius: 5px; white-space: normal;
    border: 1px solid var(--shell-dialog-border, #39475a);
    background: var(--shell-accent-surface, #24374c); color: inherit; cursor: pointer;
}
#schedule-planner button:disabled { opacity: .45; cursor: default; }
#schedule-planner button:focus-visible, #schedule-planner input:focus-visible,
#schedule-planner select:focus-visible, #schedule-planner textarea:focus-visible {
    outline: 2px solid var(--shell-accent, #4f9cfa); outline-offset: 2px;
}
#schedule-planner .sp-heading, #schedule-planner .sp-actions, #schedule-planner .sp-options {
    display: flex; flex-wrap: wrap; align-items: end; gap: 10px;
}
#schedule-planner .sp-heading { align-items: center; justify-content: space-between; }
#sp-provider { padding: 5px 10px; border-radius: 20px; background: #233a32; color: #b8e9ca; }
/* Modified 2026-11-04: Anchor the growing command composer to the viewport and keep its actions compact. */
#schedule-planner .sp-composer {
    position: fixed; z-index: 80; left: 50%; bottom: max(16px, env(safe-area-inset-bottom));
    transform: translateX(-50%); width: min(920px, calc(100% - 32px));
    border-radius: 24px; background: #202731; box-shadow: 0 10px 36px #0006;
}
#schedule-planner .sp-composer-feedback { padding: 0 16px; }
#schedule-planner .sp-composer-feedback p { margin: 0; }
#schedule-planner .sp-composer-feedback p:not(:empty) { padding: 8px 0 0; }
#schedule-planner #sp-answer { max-height: 96px; overflow-y: auto; color: #c6d1df; }
#schedule-planner #sp-status { min-height: 0; color: #9cabbc; font-size: 12px; }
#schedule-planner .sp-composer-field {
    display: flex; align-items: flex-end; gap: 8px; padding: 12px;
    border: 1px solid #48515f; border-radius: 24px; background: #252d38;
}
#schedule-planner .sp-composer-field:focus-within { border-color: #8291a5; }
#schedule-planner #sp-command-text {
    flex: 1 1 auto; min-width: 0; min-height: 36px; max-height: min(220px, 35vh);
    height: 36px; margin: 0; padding: 6px 2px; resize: none; overflow-y: auto;
    border: 0; border-radius: 0; background: transparent; box-shadow: none;
    color: #e8edf5; font: 14px/24px Arial, sans-serif;
}
#schedule-planner #sp-command-text::placeholder { color: #9ba8b9; }
#schedule-planner #sp-command-text:focus-visible { outline: none; }
#schedule-planner .sp-icon-button {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 36px;
    width: 36px; height: 36px; padding: 7px; border: 0; border-radius: 50%;
}
#schedule-planner .sp-icon-button svg { width: 22px; height: 22px; pointer-events: none; }
#schedule-planner .sp-record-button { background: transparent; color: #e3eaf3; }
#schedule-planner .sp-record-button:hover { background: #ffffff12; }
#schedule-planner .sp-record-button .sp-stop-icon { display: none; }
#schedule-planner .sp-record-button[aria-pressed="true"] { background: #b6424226; color: #ffadad; }
#schedule-planner .sp-record-button[aria-pressed="true"] .sp-mic-icon { display: none; }
#schedule-planner .sp-record-button[aria-pressed="true"] .sp-stop-icon { display: block; }
#schedule-planner .sp-send-button { background: #e8edf5; color: #202731; }
#schedule-planner .sp-send-button:hover { background: #fff; }
#schedule-planner .sp-visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
#schedule-planner .sp-options { margin: 10px 0; }
#schedule-planner .sp-options label { flex: 0 1 190px; }
#schedule-planner .sp-day { margin: 20px 0; }
#schedule-planner .sp-lanes { display: grid; grid-auto-columns: minmax(240px, 300px); grid-auto-flow: column; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: stretch; }
#schedule-planner .sp-lane { min-height: 180px; padding: 12px; border: 1px solid var(--shell-dialog-border, #39475a); border-radius: 8px; background: #171e28; }
#schedule-planner .sp-block { padding: 12px; margin-bottom: 10px; border: 1px solid #405a76; border-left: 3px solid var(--shell-accent, #4f9cfa); border-radius: 6px; background: #233044; cursor: grab; }
/* Modified 2026-11-05: Keep discipline headings readable over dark rule cards. */
#schedule-planner .sp-block strong { color: #f2f6fc; }
#schedule-planner .sp-block p { margin: 6px 0; color: #b8c5d6; }
#schedule-planner .sp-block button { padding: 4px 7px; font-size: 11px; }
#sp-result { overflow-x: auto; margin-top: 20px; }
#sp-result table { width: 100%; border-collapse: collapse; background: #171e28; }
#sp-result th, #sp-result td { padding: 8px; border: 1px solid #39475a; text-align: left; white-space: normal; }
#schedule-planner .sp-warning { padding: 12px; border: 1px solid #ad8342; border-radius: 6px; background: #3c3020; color: #ffda9e; }
#sp-editor { width: min(760px, calc(100vw - 32px)); max-height: 85vh; overflow: auto; padding: 20px; border: 1px solid #4e6179; border-radius: 8px; background: #1b222c; color: #e4eaf1; }
#sp-editor::backdrop { background: #0009; }
#sp-editor-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
#sp-editor select[multiple] { min-height: 120px; }
@media (max-width: 600px) {
    #schedule-planner { margin: 10px; }
    #sp-editor-fields { grid-template-columns: 1fr; }
}
/* Modified 2026-11-05: Keep the schedule matrix and consolidated instruction side by side. */
#schedule-planner .sp-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 380px); gap: 20px; align-items: start; margin-top: 16px; }
#schedule-planner .sp-schedule { min-width: 0; }
#schedule-planner .sp-instructions { min-width: 0; padding: 18px; border: 1px solid #405068; border-radius: 12px; background: #202b3a; }
#schedule-planner .sp-instructions h2 { margin-top: 0; }
#schedule-planner #sp-instruction { color: #e8edf5; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
#schedule-planner .sp-instructions .sp-actions { margin: 18px 0; }
#schedule-planner #sp-board { overflow: auto; border: 1px solid #39475a; border-radius: 10px; }
#schedule-planner #sp-board table { width: 100%; border-collapse: separate; border-spacing: 0; background: #171e28; color: #e8edf5; }
#schedule-planner #sp-board th, #schedule-planner #sp-board td { min-width: 190px; padding: 12px; text-align: left; vertical-align: top; border-right: 1px solid #39475a; border-bottom: 1px solid #39475a; white-space: normal; }
#schedule-planner #sp-board th { background: #202b3a; color: #f2f6fc; }
#schedule-planner #sp-board tbody th { min-width: 125px; position: sticky; left: 0; z-index: 1; }
#schedule-planner #sp-board th small { display: block; font-weight: normal; color: #bac7d8; margin-top: 6px; }
#schedule-planner .sp-category { padding: 10px; margin-bottom: 10px; border-left: 3px solid #58c9ef; border-radius: 5px; background: #25364c; }
#schedule-planner .sp-category:last-child { margin-bottom: 0; }
#schedule-planner .sp-category strong, #schedule-planner .sp-remaining strong { color: #f2f6fc; }
#schedule-planner .sp-category p { color: #c3d0e1; margin: 6px 0 0; font-size: 12px; }
#schedule-planner .sp-empty { color: #a8b8ca; }
#schedule-planner #sp-unassigned { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
#schedule-planner .sp-remaining { padding: 12px; border: 1px solid #80643e; border-radius: 8px; background: #342c22; }
#schedule-planner .sp-remaining p { margin: 5px 0; color: #ffdfb0; }
#schedule-planner .sp-remaining small { color: #d5c9b9; }
#schedule-planner #sp-chat { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
#schedule-planner #sp-chat p { margin: 0; padding: 10px; border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; color: #e8edf5; }
#schedule-planner .sp-chat-user { margin-left: 24px !important; background: #304461; }
#schedule-planner .sp-chat-reply { margin-right: 24px !important; background: #17212e; }
@media (max-width: 1000px) {
    /* Modified 2026-11-05: Stack the instruction and matrix on smaller screens. */
    #schedule-planner .sp-workspace { grid-template-columns: minmax(0, 1fr); }
}
@media print {
    /* Modified 2026-11-05: Print the matrix and coverage summary without command controls. */
    #schedule-planner { padding-bottom: 0; }
    #schedule-planner .sp-composer, #schedule-planner .sp-instructions, #sp-provider { display: none; }
    #schedule-planner .sp-workspace { display: block; }
    #schedule-planner #sp-board { overflow: visible; }
    #schedule-planner #sp-board table, #schedule-planner #sp-board th, #schedule-planner #sp-board td { background: #fff; color: #000; }
    #schedule-planner .sp-category { background: #fff; border: 1px solid #888; }
    #schedule-planner .sp-category strong, #schedule-planner .sp-category p { color: #000; }
}

/* Modified 2026-11-05: Separate estimated ring finishes from the activity descriptions. */
#schedule-planner #sp-board td { position: relative; padding-bottom: 82px; }
#schedule-planner .sp-ring-finish { position: absolute; left: 12px; right: 12px; bottom: 12px; margin: 0; padding-top: 10px; border-top: 1px solid #52647b; color: #c3d0e1; }
#schedule-planner .sp-ring-finish strong { color: #f2f6fc; white-space: nowrap; }

/* Modified 2026-11-05: Keep actual match and performance counts clear in cards and ring totals. */
#schedule-planner .sp-count { display: block; margin-top: 6px; color: #f2f6fc; font-weight: bold; }
/* Modified 2026-11-05: Float the integrated chat above instructions with compact circular controls. */
#schedule-planner { padding-bottom: 24px; }
#schedule-planner .sp-workspace { align-items: stretch; }
#schedule-planner .sp-sidebar { min-width: 0; }
#schedule-planner .sp-chat-panel { position: sticky; top: 12px; z-index: 5; padding: 12px; margin-bottom: 16px; background: #202b3a; border: 1px solid #405068; border-radius: 16px; box-shadow: 0 8px 24px #0005; }
#schedule-planner #sp-chat { max-height: min(32vh, 300px); overflow-y: auto; }
#schedule-planner .sp-composer { position: static; width: 100%; transform: none; margin-top: 10px; box-shadow: none; background: transparent; }
#schedule-planner .sp-composer-feedback { padding: 0 2px 8px; }
#schedule-planner .sp-composer-field { padding: 7px; gap: 5px; border-radius: 22px; }
#schedule-planner .sp-icon-button { flex: 0 0 30px; width: 30px; height: 30px; padding: 6px; border-radius: 50%; }
#schedule-planner .sp-icon-button svg { width: 18px; height: 18px; }
#schedule-planner .sp-instructions .sp-actions { margin: 0 0 16px; }
@media print { #schedule-planner .sp-sidebar { display: none; } }
/* Modified 2026-11-05: Override shared jQuery UI button dimensions only inside the floating chat. */
#schedule-planner .sp-icon-button { min-width: 30px; max-width: 30px; min-height: 30px; margin: 0; line-height: 1; border-radius: 50% !important; }
#schedule-planner .sp-icon-button .ui-button-text { display: flex; align-items: center; justify-content: center; padding: 0; line-height: 1; }
#schedule-planner #sp-command-text { flex: 1 1 0; width: 0; min-width: 0; }
/* Modified 2026-11-05: Keep instructions at the top and open chat as an overlay from a compact launcher. */
#schedule-planner .sp-chat-panel { position: fixed; top: auto; bottom: 70px; right: 18px; width: min(380px, calc(100vw - 36px)); max-height: calc(100dvh - 100px); margin: 0; overflow-y: auto; z-index: 90; }
#schedule-planner .sp-chat-panel[hidden] { display: none; }
#schedule-planner .sp-chat-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
#schedule-planner .sp-chat-heading h3 { margin: 0; }
#schedule-planner #sp-chat-toggle { position: fixed; right: 18px; bottom: 18px; z-index: 91; width: 42px; min-width: 42px; max-width: 42px; height: 42px; padding: 10px; background: #e8edf5; color: #202731; box-shadow: 0 4px 18px #0006; }
#schedule-planner #sp-chat-toggle svg { width: 22px; height: 22px; }
@media print { #schedule-planner #sp-chat-toggle, #schedule-planner .sp-chat-panel { display: none; } }
/* Modified 2026-11-05: Respect launcher visibility even after shared button styling is applied. */
#schedule-planner #sp-chat-toggle[hidden] { display: none; }
/* Modified 2026-11-05: Scroll the schedule and instructions independently on the two-column desktop layout. */
@media screen and (min-width: 1001px) {
    #schedule-planner { padding-bottom: 0; }
    #schedule-planner .sp-workspace { height: var(--sp-workspace-height, calc(100dvh - 240px)); min-height: 0; }
    #schedule-planner .sp-schedule { min-height: 0; overflow: auto; overscroll-behavior: contain; }
    #schedule-planner .sp-sidebar { min-height: 0; }
    #schedule-planner .sp-instructions { height: 100%; overflow: auto; overscroll-behavior: contain; }
}
/* Modified 2026-11-05: Make request progress and retryable errors visible next to the chat input. */
#schedule-planner .sp-chat-state:empty { display: none; }
#schedule-planner .sp-chat-state.is-working { display: flex; align-items: center; gap: 8px; color: #dce9fa; }
#schedule-planner .sp-chat-state.is-working::before { content: ''; flex: 0 0 14px; width: 14px; height: 14px; border: 2px solid #60728b; border-top-color: #78d4ff; border-radius: 50%; animation: sp-chat-spin .8s linear infinite; }
#schedule-planner .sp-chat-state.is-error { margin: 0; padding: 10px !important; border: 1px solid #a96969; border-radius: 8px; background: #422d32; color: #ffe0e0; }
@keyframes sp-chat-spin { to { transform: rotate(360deg); } }
/* Modified 2026-11-05: Reclaim the removed title space and separate the lower chat overlay from instructions. */
#schedule-planner .sp-workspace { margin-top: 0; }
#schedule-planner .sp-chat-panel { bottom: 18px; max-height: calc(100dvh - 36px); border-color: #71839c; box-shadow: 0 20px 70px 20px #000b, 0 4px 18px #0009; }
/* Modified 2026-11-05: Explain estimates, selected priorities and idle intervals without detailed match lists. */
#schedule-planner .sp-estimate-note { margin: 0 0 12px; color: #c3d0e1; }
#schedule-planner .sp-priority-label { margin: 12px 0 6px; }
#schedule-planner #sp-priority { width: 100%; min-width: 0; height: auto; margin-bottom: 16px; }
#schedule-planner .sp-pause { padding: 8px; border-left: 3px solid #e1b66b; border-radius: 5px; background: #342e25; color: #ffdfad; font-size: 12px; }
#schedule-planner .sp-pause strong { color: #ffe9c6; }
#schedule-planner .sp-pauses { margin: 10px 0; color: #e1cba7; }
#schedule-planner .sp-pauses summary { cursor: pointer; }
#schedule-planner #sp-board td { padding-bottom: 104px; }
/* Modified 2026-11-06: Reserve a compact timing footer for command-controlled break text. */
#schedule-planner #sp-board td { padding-bottom: 124px; }
/* Modified 2026-11-06: Keep action labels centered before and during generation, including jQuery UI wrappers. */
#schedule-planner .sp-actions button { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; line-height: 1.2; }
#schedule-planner .sp-actions button .ui-button-text { display: block; padding: 0; line-height: inherit; }
/* Modified 2026-11-06: Show pending generation independently of transient progress and autosave messages. */
#schedule-planner #sp-rebuild-status { padding: 10px; border: 1px solid #98783e; border-radius: 6px; color: #ffe1a3; background: #342e25; }
#schedule-planner #sp-rebuild-status[hidden] { display: none; }
#schedule-planner .sp-exit-dialog { max-width: 520px; padding: 22px; border: 1px solid #71839c; border-radius: 10px; background: #202c3b; color: #edf4ff; }
#schedule-planner .sp-exit-dialog::backdrop { background: #09101bb3; }
#schedule-planner .sp-exit-dialog button { margin: 8px 8px 0 0; }
/* Modified 2026-11-06: Keep the reusable instruction readable as an editor, with compact copy/apply actions. */
#schedule-planner textarea#sp-instruction { min-height: 320px; resize: vertical; color: #e8edf5; font: inherit; line-height: 1.7; }
#schedule-planner .sp-instruction-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
#schedule-planner .sp-instruction-actions button .ui-button-text { padding: 0; }

/* Modified 2026-11-10: Show five readable starting-plan cards before the workspace is used or after clearing it. */
#schedule-planner #sp-presets[hidden] { display: none; }
#schedule-planner.sp-choosing-preset .sp-workspace,
#schedule-planner.sp-choosing-preset #sp-chat-toggle { display: none; }
#sp-preset-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 16px; }
#schedule-planner .sp-preset-card { display: flex; flex-direction: column; padding: 20px; border: 1px solid var(--shell-dialog-border, #39475a); border-radius: 12px; background: var(--shell-dialog-field-background, #141b24); }
#schedule-planner .sp-preset-card h3 { font-size: 17px; }
#schedule-planner .sp-preset-card p { flex: 1; margin: 0 0 20px; color: inherit; }
#schedule-planner .sp-preset-card button { align-self: flex-start; }

/* Modified 2026-11-11: Keep the four setup steps readable on desktop and narrow screens. */
/* Modified 2026-11-12: Override the global black bold text for workload totals and per-day wizard headings. */
#schedule-planner #sp-wizard-workload strong,
#schedule-planner #sp-wizard-form strong { color: #f2f6fc; }
/* Modified 2026-11-12: Keep date headings, labels and native date/time field text light on the dark screen. */
@media screen {
    #schedule-planner #sp-wizard-form label,
    #schedule-planner #sp-wizard-day-times strong,
    #schedule-planner #sp-board th[scope="row"] { color: #f2f6fc; }
    #schedule-planner #sp-wizard-form input[type="date"],
    #schedule-planner #sp-wizard-form input[type="time"] {
        color: #f2f6fc;
        -webkit-text-fill-color: #f2f6fc;
        color-scheme: dark;
    }
    #schedule-planner #sp-wizard-form input::-webkit-datetime-edit { color: #f2f6fc; }
}
#schedule-planner [data-sp-step][hidden], #schedule-planner #sp-wizard-back[hidden],
#schedule-planner #sp-wizard-next[hidden], #schedule-planner #sp-wizard-break-options[hidden] { display: none; }
#sp-wizard-steps { padding: 16px 0; line-height: 2; }
#sp-wizard-form { max-width: 1200px; }
#sp-wizard-form > section { padding: 20px; border: 1px solid var(--shell-dialog-border, #39475a); border-radius: 12px; }
#sp-wizard-form input, #sp-wizard-form select { min-height: 38px; max-width: 100%; color: inherit; color-scheme: dark; }
#sp-wizard-form input[type=number] { width: 140px; }
#schedule-planner .sp-wizard-fields { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; margin: 12px 0; }
#sp-wizard-breaks { margin-top: 16px; }
#sp-break-preview { overflow-wrap: anywhere; }
#schedule-planner .sp-wizard-actions { display: flex; gap: 12px; padding: 20px 0; }

/* Modified 2026-11-12: Keep daily work and percentage summaries readable beside the time fields. */
#schedule-planner .sp-wizard-day-capacity { flex: 1 1 360px; color: #e4eaf1; }
#schedule-planner .sp-wizard-day-capacity p { margin: 4px 0; }
#schedule-planner #sp-wizard-capacity-total { margin-top: 16px; color: #e4eaf1; }

/* Modified 2026-11-11: Align the applied-preset selector with the instruction fields. */
#schedule-planner #sp-applied-preset { width: 100%; min-width: 0; height: auto; margin: 12px 0; }
