/* One opaque, one-pixel grid for SCH interface tables. Mathematical tables
   are deliberately outside this class list. Each shared edge has one owner;
   separate borders also keep sticky and cloned headers fully visible. */
@media screen {
    body.has-app-shell { --sch-table-line: var(--line); }

    :root body.has-app-shell table:is(.data-table, .timetable-grid, .dictation-table, .student-results-roster-table, .student-results-history-table, .main-lzk-grid, .learning-analysis-table, .kor-operator-subtasks-table, .kor-demand-table) {
        border-collapse: separate;
        border-spacing: 0;
        border: 0;
        border-left: 1px solid var(--sch-table-line);
    }

    :root body.has-app-shell table:is(.data-table, .timetable-grid, .dictation-table, .student-results-roster-table, .student-results-history-table, .main-lzk-grid, .learning-analysis-table, .kor-operator-subtasks-table, .kor-demand-table) > :is(thead, tbody, tfoot),
    :root body.has-app-shell table:is(.data-table, .timetable-grid, .dictation-table, .student-results-roster-table, .student-results-history-table, .main-lzk-grid, .learning-analysis-table, .kor-operator-subtasks-table, .kor-demand-table) > :is(thead, tbody, tfoot) > tr {
        border: 0;
    }

    :root body.has-app-shell table:is(.data-table, .timetable-grid, .dictation-table, .student-results-roster-table, .student-results-history-table, .main-lzk-grid, .learning-analysis-table, .kor-operator-subtasks-table, .kor-demand-table) > :is(thead, tbody, tfoot) > tr > :is(th, td) {
        border: 0;
        border-right: 1px solid var(--sch-table-line);
        border-bottom: 1px solid var(--sch-table-line);
    }

    :root body.has-app-shell table:is(.data-table, .timetable-grid, .dictation-table, .student-results-roster-table, .student-results-history-table, .main-lzk-grid, .learning-analysis-table, .kor-operator-subtasks-table, .kor-demand-table) > thead > tr:first-child > :is(th, td),
    :root body.has-app-shell table:is(.curriculum-general-table, .kor-demand-table) > tbody:first-of-type > tr:first-child > :is(th, td) {
        border-top: 1px solid var(--sch-table-line);
    }

    /* A shadow below an already bordered header would add a second line. */
    :root body.has-app-shell table:is(.data-table, .timetable-grid, .dictation-table, .student-results-roster-table, .student-results-history-table, .main-lzk-grid, .learning-analysis-table, .kor-operator-subtasks-table, .kor-demand-table) > thead,
    :root body.has-app-shell table:is(.data-table, .timetable-grid, .dictation-table, .student-results-roster-table, .student-results-history-table, .main-lzk-grid, .learning-analysis-table, .kor-operator-subtasks-table, .kor-demand-table) > thead > tr > :is(th, td) {
        box-shadow: none;
    }

    /* Grouped general information remains one group, including its spanning
       label. The final row and the spanning label own the bottom edge. */
    :root body.has-app-shell .curriculum-model-general-table > tbody > .curriculum-general-classification-internal-row > :is(th, td):not([rowspan]) {
        border-bottom: 0;
    }

    /* These scrolling regions already own the outside frame. Do not draw
       that frame again on their direct table or its outside cells. */
    :root body.has-app-shell :is(.week-planning-table-scroll, .timetable-scroll, .dictation-scroll) {
        border: 1px solid var(--sch-table-line);
    }
    :root body.has-app-shell :is(.week-planning-table-scroll, .timetable-scroll, .dictation-scroll) > table {
        border: 0;
    }
    :root body.has-app-shell :is(.week-planning-table-scroll, .timetable-scroll, .dictation-scroll) > table > thead > tr:first-child > :is(th, td) {
        border-top: 0;
    }
    :root body.has-app-shell :is(.week-planning-table-scroll, .timetable-scroll, .dictation-scroll) > table > :is(thead, tbody, tfoot) > tr > :is(th, td):last-child {
        border-right: 0;
    }
    :root body.has-app-shell :is(.week-planning-table-scroll, .timetable-scroll, .dictation-scroll) > table > tbody:last-child > tr:last-child > :is(th, td) {
        border-bottom: 0;
    }
    :root body.has-app-shell .lzk-results .table-scroll { border: 0; }

    /* The KOR task card owns the outside border and the line above its
       subtask header. Nested demand tables keep their own complete frame. */
    :root body.has-app-shell .kor-operator-task { border-color: var(--sch-table-line); }
    :root body.has-app-shell .kor-operator-task > header { border-bottom: 1px solid var(--sch-table-line); }
    :root body.has-app-shell .kor-operator-task > .kor-operator-subtasks-table { border: 0; }
    :root body.has-app-shell .kor-operator-task > .kor-operator-subtasks-table > thead > tr:first-child > th { border-top: 0; }
    :root body.has-app-shell .kor-operator-task > .kor-operator-subtasks-table > :is(thead, tbody) > tr > :is(th, td):last-child { border-right: 0; }
    :root body.has-app-shell .kor-operator-task > .kor-operator-subtasks-table > tbody > tr:last-child > :is(th, td) { border-bottom: 0; }

    /* Subcolumns inside a spanning cell share the same opaque grid color.
       The enclosing cell owns the final edge. */
    :root body.has-app-shell .curriculum-classification-data .curriculum-condition-track > span + span {
        border-left: 1px solid var(--sch-table-line);
    }
    :root body.has-app-shell .curriculum-classification-data .classification-condition,
    :root body.has-app-shell .student-results-units > span {
        border-right: 1px solid var(--sch-table-line);
    }
    :root body.has-app-shell .curriculum-classification-data .classification-condition:last-child,
    :root body.has-app-shell .student-results-units > span:last-child { border-right: 0; }

    /* Keep the frame joined to UNT's adjacent toolbar/status strip. */
    :root body.has-app-shell .dictation-analysis-toolbar + .dictation-scroll { border-top: 0; }
}

/* UNT changes its input tables into cards at this breakpoint. Each card
   still has just one separator; its stacked cells must not create a grid. */
@media screen and (max-width: 620px) {
    /* Any selected weekday becomes the last visible column on a phone. */
    :root body.has-app-shell .timetable-scroll > table.timetable-grid > :is(thead, tbody) > tr > [data-day-column]:not(.is-other-day) { border-right: 0; }
    :root body.has-app-shell table.dictation-table > tbody > tr { border-bottom: 1px solid var(--sch-table-line); }
    :root body.has-app-shell table.dictation-table > tbody > tr > :is(th, td):first-child,
    :root body.has-app-shell table.dictation-table > tbody > tr > :is(th, td):not(:first-child) { border: 0; }
    :root body.has-app-shell .dictation-scroll > table.dictation-table > tbody > tr:last-child { border-bottom: 0; }
    :root body.has-app-shell table.kor-demand-table > tbody:first-of-type > tr:first-child > td { border-top: 0; }
}
@container kor-raster (max-width: 30rem) {
    @media screen {
        :root body.has-app-shell table.kor-demand-table > tbody:first-of-type > tr:first-child > td { border-top: 0; }
    }
}
