/* ============================================
   Bedömningsmatriser v2 — Feature-specific styles
   Custom matrix component with mobile-card view
   ============================================ */

/* ---- Page header ---- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header__title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--gray-darker, #333);
}

.page-header__subtitle {
    margin: 4px 0 0;
    font-size: 0.875rem;
    color: var(--gray-dark, #666);
}

.page-header__actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ---- Buttons ---- */
.btn-primary,
.btn-outlined,
.btn-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    font-family: inherit;
}

.btn-primary {
    padding: 8px 20px;
    border: none;
    background: var(--cl-hard, #26418f);
    color: #fff;
    font-size: 0.875rem;
}

.btn-primary:hover { background: #1a3070; }
.btn-primary .material-icons { font-size: 18px; }

.btn-outlined {
    padding: 7px 16px;
    border: 1px solid var(--cl-hard, #26418f);
    background: var(--white, #fff);
    color: var(--cl-hard, #26418f);
    font-size: 0.8125rem;
}

.btn-outlined:hover { background: var(--cl-super-soft, #e8eaf6); }
.btn-outlined .material-icons { font-size: 16px; }

.btn-text {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--cl-hard, #26418f);
    font-size: 0.8125rem;
}

.btn-text:hover { background: var(--cl-super-soft, #e8eaf6); }
.btn-text .material-icons { font-size: 16px; }

.btn-danger { border-color: #d32f2f; color: #d32f2f; }
.btn-danger:hover { background: #ffebee; }

/* ---- Info banner ---- */
.info-banner {
    background: var(--cl-super-soft, #e8eaf6);
    border-left: 4px solid var(--cl-hard, #26418f);
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 0 4px 4px 0;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 0.875rem;
    color: var(--gray-darker, #333);
}

.info-banner .material-icons {
    font-size: 20px;
    color: var(--cl-hard, #26418f);
    flex-shrink: 0;
    margin-top: 1px;
}

.warning-banner {
    background: #fff8e1;
    border-left: 4px solid #ffc107;
    color: #5d4037;
}
.warning-banner .material-icons { color: #f57f17; }

/* ---- Tabs ---- */
.tab-bar {
    display: flex;
    border-bottom: 2px solid var(--gray-lighter, #e0e0e0);
    margin-bottom: 16px;
    overflow-x: auto;
}

.tab-item {
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-dark, #666);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: all 0.15s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

.tab-item:hover { color: var(--cl-hard, #26418f); }

.tab-item--active {
    color: var(--cl-hard, #26418f);
    border-bottom-color: var(--cl-hard, #26418f);
}

.tab-content { display: none; }
.tab-content.is-active { display: block; }
.sub-tab-content { display: none; }
.sub-tab-content.is-active { display: block; }

.sub-tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.sub-tab-item {
    padding: 6px 16px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-dark, #666);
    background: var(--gray-lightest, #f5f5f5);
    border: 1px solid var(--gray-lighter, #e0e0e0);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.sub-tab-item:hover { background: var(--gray-lighter, #e0e0e0); }

.sub-tab-item--active {
    background: var(--cl-super-soft, #e8eaf6);
    border-color: var(--cl-soft, #7986cb);
    color: var(--cl-hard, #26418f);
}

/* ---- Filter bar ---- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    padding: 10px 16px;
    background: var(--white, #fff);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--gray-lighter, #e0e0e0);
}

.filter-bar__label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-dark, #666);
    margin-right: 4px;
}

.filter-select {
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid var(--gray-light, #ccc);
    font-size: 0.8125rem;
    color: var(--gray-darker, #333);
    background: var(--white, #fff);
    cursor: pointer;
    font-family: inherit;
}

.filter-bar__spacer { flex: 1; }

.view-toggle {
    display: flex;
    border: 1px solid var(--gray-lighter, #e0e0e0);
    border-radius: 4px;
    overflow: hidden;
}

.view-toggle__btn {
    padding: 5px 10px;
    background: var(--white, #fff);
    border: none;
    cursor: pointer;
    color: var(--gray-dark, #666);
    transition: all 0.15s;
    display: flex;
    align-items: center;
    font-family: inherit;
}

.view-toggle__btn:not(:last-child) {
    border-right: 1px solid var(--gray-lighter, #e0e0e0);
}

.view-toggle__btn--active {
    background: var(--cl-super-soft, #e8eaf6);
    color: var(--cl-hard, #26418f);
}

.view-toggle__btn .material-icons { font-size: 18px; }

/* ---- Matrix list table (overview list) ---- */
.matrix-table-wrapper {
    background: var(--white, #fff);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--gray-lighter, #e0e0e0);
    overflow-x: auto;
}

.matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.matrix-table thead {
    background: var(--gray-lightest, #f5f5f5);
    border-bottom: 2px solid var(--gray-lighter, #e0e0e0);
}

.matrix-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 500;
    color: var(--gray-dark, #666);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.matrix-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-lighter, #e0e0e0);
    vertical-align: middle;
}

.matrix-table tr:last-child td { border-bottom: none; }
.matrix-table tbody tr:hover { background: var(--gray-lightest, #fafafa); }

/* Stars and chips */
.star-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: var(--gray-light, #ccc);
    transition: color 0.15s;
}

.star-btn:hover { color: #FFC107; }
.star-btn--active { color: #FFC107; }
.star-btn .material-icons { font-size: 20px; }

.connection-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.connection-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.6875rem;
    font-weight: 500;
    background: var(--cl-super-soft, #e8eaf6);
    color: var(--cl-hard, #26418f);
}

.connection-chip--planning { background: #e8f5e9; color: #2e7d32; }
.connection-chip--exam { background: #fff3e0; color: #e65100; }
.connection-chip .material-icons { font-size: 12px; }

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.6875rem;
    font-weight: 600;
}

.status-badge--active { background: #e8f5e9; color: #2e7d32; }
.status-badge--archived { background: var(--gray-lightest, #f5f5f5); color: var(--gray, #999); }
.status-badge--draft { background: #fff3e0; color: #e65100; }
.status-badge--published { background: #e8f5e9; color: #2e7d32; }
.status-badge--max { background: #fff8e1; color: #f57f17; }

.size-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--gray-lightest, #f5f5f5);
    color: var(--gray-dark, #666);
    font-size: 0.6875rem;
    font-weight: 500;
}

.shared-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.75rem;
    color: var(--cl-hard, #26418f);
}

.shared-badge .material-icons { font-size: 14px; }

.matrix-title-link {
    font-weight: 500;
    color: var(--cl-hard, #26418f);
    cursor: pointer;
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    text-align: left;
    font-family: inherit;
    font-size: inherit;
}

.matrix-title-link:hover { text-decoration: underline; }

.matrix-description {
    font-size: 0.75rem;
    color: var(--gray-dark, #666);
    margin-top: 2px;
    max-width: 380px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.matrix-meta-info { font-size: 0.75rem; color: var(--gray, #999); }

.table-actions { display: flex; gap: 4px; }

.table-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    color: var(--gray-dark, #666);
    transition: all 0.15s;
}

.table-action-btn:hover {
    background: var(--gray-lightest, #f5f5f5);
    color: var(--cl-hard, #26418f);
}

.table-action-btn .material-icons { font-size: 20px; }

/* ---- Matrix cards ---- */
.matrix-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.matrix-card {
    background: var(--white, #fff);
    border: 1px solid var(--gray-lighter, #e0e0e0);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    text-align: left;
    font-family: inherit;
}

.matrix-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.matrix-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 8px;
}

.matrix-card__title {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--gray-darker, #333);
    margin: 0;
}

.matrix-card__description {
    font-size: 0.8125rem;
    color: var(--gray-dark, #666);
    margin-bottom: 12px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.matrix-card__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--gray, #999);
    gap: 8px;
    flex-wrap: wrap;
}

.matrix-card__connections {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

/* ============================================
   CUSTOM MATRIX COMPONENT
   This is the desktop grid + mobile card view.
   No existing V2 component covers this need.
   ============================================ */

/* Assessment context bar */
.assessment-context {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--white, #fff);
    border: 1px solid var(--gray-lighter, #e0e0e0);
    border-radius: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.assessment-context__group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.assessment-context__label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-dark, #666);
}

.assessment-context select {
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid var(--gray-light, #ccc);
    font-size: 0.875rem;
    color: var(--gray-darker, #333);
    background: var(--white, #fff);
    cursor: pointer;
    min-width: 180px;
    font-family: inherit;
}

/* Assessment mode switcher */
.assessment-mode-switch {
    display: inline-flex;
    border: 1px solid var(--gray-lighter, #e0e0e0);
    border-radius: 4px;
    overflow: hidden;
    background: var(--white, #fff);
}

.assessment-mode-switch__btn {
    padding: 6px 12px;
    border: none;
    background: var(--white, #fff);
    color: var(--gray-dark, #666);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: inherit;
}

.assessment-mode-switch__btn:not(:last-child) {
    border-right: 1px solid var(--gray-lighter, #e0e0e0);
}

.assessment-mode-switch__btn--active {
    background: var(--cl-super-soft, #e8eaf6);
    color: var(--cl-hard, #26418f);
}

.assessment-mode-switch__btn .material-icons { font-size: 16px; }

/* ---- Legend (with icons, not only color) ---- */
.legend {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 0.8125rem;
    color: var(--gray-dark, #666);
    flex-wrap: wrap;
    padding: 8px 12px;
    background: var(--gray-lightest, #fafafa);
    border-radius: 6px;
}

.legend__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend__chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.legend__chip--teacher {
    background: #4CAF50;
    color: #fff;
}

.legend__chip--student {
    background: #2196F3;
    color: #fff;
}

.legend__chip--none {
    background: var(--white, #fff);
    border: 1px dashed var(--gray-light, #ccc);
    color: var(--gray, #999);
}

/* ============================================
   ASSESSMENT MATRIX — DESKTOP (table view)
   ============================================ */

.assess-matrix {
    /* default desktop layout: classic grid */
    background: var(--white, #fff);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--gray-lighter, #e0e0e0);
    margin-bottom: 16px;
    overflow: hidden;
}

/* Desktop table — wide screens only */
.assess-matrix__table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.assess-matrix__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    table-layout: fixed;
}

.assess-matrix__table thead th {
    padding: 10px 8px;
    text-align: center;
    font-weight: 600;
    color: var(--gray-darker, #333);
    background: var(--gray-lightest, #f5f5f5);
    border-bottom: 2px solid var(--gray-lighter, #e0e0e0);
    font-size: 0.75rem;
    line-height: 1.3;
    word-wrap: break-word;
}

.assess-matrix__table thead th:first-child {
    text-align: left;
    width: 30%;
    min-width: 220px;
    background: var(--gray-lightest, #f5f5f5);
    position: sticky;
    left: 0;
    z-index: 1;
}

.assess-matrix__col-abbr {
    display: block;
    font-size: 0.6875rem;
    color: var(--gray, #999);
    font-weight: 400;
    margin-top: 2px;
}

.assess-matrix__table tbody td {
    padding: 6px 4px;
    border-bottom: 1px solid var(--gray-lighter, #e0e0e0);
    text-align: center;
    vertical-align: middle;
    position: relative;
}

.assess-matrix__table tbody td:first-child {
    text-align: left;
    padding: 8px 12px;
    background: var(--white, #fff);
    position: sticky;
    left: 0;
    z-index: 1;
    border-right: 1px solid var(--gray-lighter, #e0e0e0);
    font-size: 0.8125rem;
    color: var(--gray-darker, #333);
    line-height: 1.4;
}

.assess-matrix__section-row td {
    background: var(--cl-super-soft, #e8eaf6) !important;
    font-weight: 600;
    color: var(--cl-hard, #26418f);
    font-size: 0.8125rem;
    text-align: left !important;
    padding: 6px 12px !important;
    position: static !important;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* Assessment cell */
.am-cell {
    width: 100%;
    height: 100%;
    min-height: 36px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    border: 1px solid transparent;
    background: var(--white, #fff);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray, #999);
    gap: 2px;
    padding: 4px;
}

.am-cell:hover {
    background: var(--gray-lightest, #f5f5f5);
    border-color: var(--gray-lighter, #e0e0e0);
}

.am-cell--readonly { cursor: default; }
.am-cell--readonly:hover { background: var(--white, #fff); border-color: transparent; }

.am-cell__marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
}

.am-cell__marker--teacher { background: #4CAF50; }
.am-cell__marker--student { background: #2196F3; }

.am-cell--teacher { background: #E8F5E9; border-color: #A5D6A7; }
.am-cell--student { background: #E3F2FD; border-color: #90CAF9; }
.am-cell--both {
    background: linear-gradient(135deg, #E8F5E9 50%, #E3F2FD 50%);
    border-color: var(--cl-soft, #7986cb);
}

/* ============================================
   ASSESSMENT MATRIX — MOBILE ACCORDION (v3)
   Vertical dragspels-/accordion-list. One card per criterion.
   Inside each card: segmented level chooser + level description
   + assessment action area. No horizontal scroll on iPhone.
   ============================================ */

.assess-matrix__mobile {
    display: none;
}

.am-accordion-helper {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 4px 12px;
    font-size: 0.75rem;
    color: var(--gray-dark, #666);
}

.am-accordion-helper__hint { line-height: 1.3; }

.am-accordion-helper__btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--cl-soft, #7986cb);
    background: var(--white, #fff);
    color: var(--cl-hard, #26418f);
    border-radius: 16px;
    padding: 4px 10px 4px 8px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}
.am-accordion-helper__btn .material-icons { font-size: 16px; }

.am-accordion {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.am-accordion__section-header {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    padding: 6px 4px;
    color: var(--cl-hard, #26418f);
    font-weight: 600;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.am-accordion__section-header .material-icons {
    font-size: 16px;
    color: var(--cl-medium, #5c6bc0);
}

.am-card {
    background: var(--white, #fff);
    border: 1px solid var(--gray-lighter, #e0e0e0);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.15s ease;
}

.am-card--open {
    border-color: var(--cl-soft, #7986cb);
    box-shadow: 0 2px 8px rgba(38, 65, 143, 0.10);
}

.am-card__header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 14px;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    color: var(--gray-darker, #333);
    min-height: 56px;
}
.am-card__header:focus-visible {
    outline: 2px solid var(--cl-medium, #5c6bc0);
    outline-offset: -2px;
}

.am-card__index {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--cl-super-soft, #e8eaf6);
    color: var(--cl-hard, #26418f);
    font-weight: 700;
    font-size: 0.8125rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.am-card--open .am-card__index {
    background: var(--cl-hard, #26418f);
    color: #fff;
}

.am-card__title-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.am-card__title {
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.35;
    color: var(--gray-darker, #333);
}

.am-card__status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.am-card__chevron {
    flex-shrink: 0;
    font-size: 24px !important;
    color: var(--gray-dark, #666);
    transition: transform 0.2s ease;
    margin-top: 2px;
}

.am-card--open .am-card__chevron {
    transform: rotate(180deg);
}

.am-card__body {
    padding: 0 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    border-top: 1px dashed var(--gray-lighter, #e0e0e0);
}

.am-card__body[hidden] {
    display: none;
}

/* --- Status pills shown in the closed card header --- */
.am-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.am-status__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.am-status--teacher {
    background: #E8F5E9;
    color: #2e7d32;
}
.am-status--student {
    background: #E3F2FD;
    color: #1565c0;
}
.am-status--none {
    background: var(--gray-lightest, #f5f5f5);
    color: var(--gray-dark, #666);
}

/* --- Segmented level chooser --- */
.am-segmented {
    display: flex;
    gap: 6px;
    padding-top: 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scroll-snap-type: x mandatory;
    margin: 0 -2px;
    padding-left: 2px;
    padding-right: 2px;
}
.am-segmented::-webkit-scrollbar { height: 4px; }
.am-segmented::-webkit-scrollbar-thumb {
    background: var(--gray-lighter, #e0e0e0);
    border-radius: 2px;
}

.am-segmented__item {
    flex: 0 0 auto;
    min-width: 56px;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1.5px solid var(--gray-lighter, #e0e0e0);
    background: var(--white, #fff);
    color: var(--gray-darker, #333);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
    position: relative;
    min-height: 52px;
}

.am-segmented__item:hover {
    border-color: var(--cl-soft, #7986cb);
}

.am-segmented__item--active {
    border-color: var(--cl-hard, #26418f);
    background: var(--cl-super-soft, #e8eaf6);
    color: var(--cl-hard, #26418f);
    box-shadow: 0 0 0 3px rgba(38, 65, 143, 0.10);
}

.am-segmented__abbr {
    font-size: 0.9375rem;
    font-weight: 700;
    line-height: 1;
}

.am-segmented__header {
    font-size: 0.625rem;
    color: var(--gray-dark, #666);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.am-segmented__item--active .am-segmented__header {
    color: var(--cl-hard, #26418f);
}

/* Teacher / student marker dots on the segmented buttons */
.am-segmented__markers {
    position: absolute;
    top: -6px;
    right: -6px;
    display: inline-flex;
    gap: 2px;
}

.am-segmented__marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 0.625rem;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 0 0 2px var(--white, #fff);
}
.am-segmented__marker--teacher { background: #2e7d32; }
.am-segmented__marker--student { background: #1565c0; }

.am-segmented__item--teacher { border-color: #66BB6A; }
.am-segmented__item--student { border-color: #42A5F5; }
.am-segmented__item--both {
    background: linear-gradient(135deg, #E8F5E9 50%, #E3F2FD 50%);
    border-color: var(--cl-medium, #5c6bc0);
}

/* --- Level description block --- */
.am-level-detail {
    background: var(--gray-lightest, #fafafa);
    border-radius: 8px;
    padding: 12px 14px;
}
.am-level-detail__label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-dark, #666);
    margin-bottom: 4px;
}
.am-level-detail__label strong {
    color: var(--cl-hard, #26418f);
}
.am-level-detail__text {
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--gray-darker, #333);
    margin: 0;
}

/* --- Action area --- */
.am-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.am-action {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1.5px solid var(--gray-lighter, #e0e0e0);
    background: var(--white, #fff);
    color: var(--gray-darker, #333);
    font-family: inherit;
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
}

.am-action--readonly {
    cursor: default;
}

.am-action__check { display: inline-flex; flex-shrink: 0; }
.am-action__check .material-icons { font-size: 22px; }

.am-action__label { flex: 1; line-height: 1.35; }

.am-action--muted { background: var(--gray-lightest, #fafafa); }

.am-action--teacher { border-color: #A5D6A7; }
.am-action--teacher .am-action__check .material-icons { color: #2e7d32; }
.am-action--teacher.am-action--checked {
    background: #E8F5E9;
    border-color: #2e7d32;
    color: #1b5e20;
}

.am-action--student { border-color: #90CAF9; }
.am-action--student .am-action__check .material-icons { color: #1565c0; }
.am-action--student.am-action--checked {
    background: #E3F2FD;
    border-color: #1565c0;
    color: #0d47a1;
}

/* --- Per-row comment field --- */
.am-comment {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.am-comment__label {
    font-size: 0.75rem;
    color: var(--gray-dark, #666);
    font-weight: 500;
}
.am-comment__input {
    border: 1px solid var(--gray-lighter, #e0e0e0);
    border-radius: 8px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--gray-darker, #333);
    background: var(--white, #fff);
    min-height: 60px;
    resize: vertical;
}
.am-comment__input:focus {
    outline: 2px solid var(--cl-medium, #5c6bc0);
    outline-offset: -1px;
}
.am-comment__input[readonly] {
    background: var(--gray-lightest, #fafafa);
    color: var(--gray-dark, #666);
    cursor: default;
}

/* ============================================
   GROUP ASSESSMENT VIEW
   Sticky student column + level chips per student
   ============================================ */
.group-table-wrap {
    background: var(--white, #fff);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--gray-lighter, #e0e0e0);
    overflow: hidden;
}

.group-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.group-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.group-table thead th {
    padding: 8px 6px;
    text-align: center;
    font-weight: 600;
    color: var(--gray-darker, #333);
    background: var(--gray-lightest, #f5f5f5);
    border-bottom: 2px solid var(--gray-lighter, #e0e0e0);
    font-size: 0.6875rem;
    line-height: 1.3;
    min-width: 60px;
}

.group-table thead th:first-child {
    text-align: left;
    width: 230px;
    min-width: 200px;
    background: var(--gray-lightest, #f5f5f5);
    position: sticky;
    left: 0;
    z-index: 2;
    font-size: 0.75rem;
}

.group-table tbody td {
    padding: 4px 4px;
    border-bottom: 1px solid var(--gray-lighter, #e0e0e0);
    text-align: center;
    vertical-align: middle;
}

.group-table tbody td:first-child {
    text-align: left;
    padding: 8px 12px;
    background: var(--white, #fff);
    position: sticky;
    left: 0;
    z-index: 1;
    border-right: 1px solid var(--gray-lighter, #e0e0e0);
}

.group-student-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.group-student-cell__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--cl-super-soft, #e8eaf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--cl-hard, #26418f);
    font-size: 0.75rem;
    flex-shrink: 0;
    overflow: hidden;
}

.group-student-cell__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.group-student-cell__info { line-height: 1.2; }

.group-student-cell__name {
    font-weight: 500;
    color: var(--gray-darker, #333);
    font-size: 0.8125rem;
}

.group-student-cell__status {
    font-size: 0.6875rem;
    color: var(--gray-dark, #666);
}

.group-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.625rem;
    font-weight: 600;
    margin-top: 2px;
}

.group-status-pill--published { background: #e8f5e9; color: #2e7d32; }
.group-status-pill--draft { background: #fff3e0; color: #e65100; }
.group-status-pill--none { background: var(--gray-lightest, #f5f5f5); color: var(--gray, #999); }

.group-row-header {
    padding: 8px 12px !important;
    background: var(--cl-super-soft, #e8eaf6) !important;
    color: var(--cl-hard, #26418f);
    font-weight: 600;
    font-size: 0.75rem;
    text-align: left !important;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    position: static !important;
}

.group-row-header__title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.group-cell-select {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 28px;
    border-radius: 4px;
    background: var(--white, #fff);
    border: 1px solid var(--gray-lighter, #e0e0e0);
    color: var(--gray-dark, #666);
    font-size: 0.6875rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.group-cell-select:hover {
    border-color: var(--cl-soft, #7986cb);
    background: var(--gray-lightest, #f5f5f5);
}

.group-cell-select--marked {
    background: #4CAF50;
    color: #fff;
    border-color: #2e7d32;
}

.group-cell-select--marked-draft {
    background: #fff3e0;
    color: #e65100;
    border-color: #ffb74d;
}

/* Group view row toggling (when there are too many rows) */
.group-row-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--gray-lightest, #fafafa);
    font-size: 0.8125rem;
    color: var(--gray-dark, #666);
    border-bottom: 1px solid var(--gray-lighter, #e0e0e0);
    gap: 12px;
    flex-wrap: wrap;
}

.group-row-toggle__filter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ============================================
   STUDENT SELECTOR  (individual mode)
   ============================================ */
.student-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding: 12px 16px;
    background: var(--white, #fff);
    border-radius: 8px;
    border: 1px solid var(--gray-lighter, #e0e0e0);
    flex-wrap: wrap;
}

.student-selector__label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-dark, #666);
}

.student-selector select {
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid var(--gray-light, #ccc);
    font-size: 0.875rem;
    color: var(--gray-darker, #333);
    background: var(--white, #fff);
    cursor: pointer;
    min-width: 200px;
    font-family: inherit;
}

.student-selector__pager {
    display: inline-flex;
    gap: 4px;
    margin-left: auto;
}

.student-selector__pager button {
    width: 32px;
    height: 32px;
    border: 1px solid var(--gray-lighter, #e0e0e0);
    background: var(--white, #fff);
    border-radius: 4px;
    cursor: pointer;
    color: var(--gray-dark, #666);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.student-selector__pager button:hover { background: var(--gray-lightest, #fafafa); }

/* Comment area */
.comment-area { margin-bottom: 16px; }

.comment-area__label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-dark, #666);
    margin-bottom: 6px;
}

.comment-area textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px 12px;
    border: 1px solid var(--gray-light, #ccc);
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: 'Roboto', sans-serif;
    resize: vertical;
    color: var(--gray-darker, #333);
    box-sizing: border-box;
}

.comment-area textarea:focus { outline: none; border-color: var(--cl-hard, #26418f); }

.comment-area__text {
    padding: 10px 12px;
    background: var(--gray-lightest, #f5f5f5);
    border-radius: 4px;
    font-size: 0.875rem;
    color: var(--gray-darker, #333);
    line-height: 1.5;
    white-space: pre-wrap;
}

/* Sticky footer actions (per safe-area guidance) */
.sticky-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--gray-lighter, #e0e0e0);
    background: var(--white, #fff);
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
    flex-wrap: wrap;
}

.sticky-actions__status {
    margin-right: auto;
    font-size: 0.8125rem;
    color: var(--gray-dark, #666);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.sticky-actions__status .material-icons { font-size: 16px; }

/* Detail panel container */
.detail-panel {
    background: var(--white, #fff);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--gray-lighter, #e0e0e0);
    padding: 0;
    margin-bottom: 16px;
    overflow: hidden;
}

.detail-panel__inner { padding: 20px; }

.detail-panel__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 12px;
}

.detail-panel__title {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--gray-darker, #333);
    margin: 0;
}

.detail-panel__description {
    font-size: 0.875rem;
    color: var(--gray-dark, #666);
    margin-bottom: 12px;
}

.detail-panel__meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

/* Create form */
.create-form-section {
    margin-bottom: 20px;
}

.create-form-section__label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--gray-dark, #666);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.create-form-section__label__count {
    font-weight: 600;
    color: var(--gray, #999);
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.75rem;
}

.create-form-section__label__count--max {
    color: #f57f17;
}

.create-form-section__hint {
    font-size: 0.75rem;
    color: var(--gray, #999);
    margin-top: 4px;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-light, #ccc);
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: 'Roboto', sans-serif;
    color: var(--gray-darker, #333);
    box-sizing: border-box;
}

.form-textarea {
    min-height: 60px;
    resize: vertical;
}

.form-input:focus,
.form-textarea:focus { outline: none; border-color: var(--cl-hard, #26418f); }

.editor-list { list-style: none; padding: 0; margin: 0; }

.editor-list__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--gray-lighter, #eee);
}

.editor-list__item:last-child { border-bottom: none; }

.editor-list__handle {
    color: var(--gray-light, #ccc);
    font-size: 18px;
    cursor: grab;
}

.editor-list__input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--gray-light, #ccc);
    border-radius: 4px;
    font-size: 0.8125rem;
    font-family: inherit;
}

.editor-list__input--short { max-width: 80px; }

.editor-list__remove {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--gray, #999);
    border-radius: 50%;
}

.editor-list__remove:hover { color: #d32f2f; background: #ffebee; }
.editor-list__remove .material-icons { font-size: 18px; }

.add-item-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px dashed var(--gray-light, #ccc);
    border-radius: 4px;
    background: transparent;
    color: var(--cl-hard, #26418f);
    font-size: 0.8125rem;
    cursor: pointer;
    margin-top: 8px;
    font-family: inherit;
}

.add-item-btn:hover {
    background: var(--cl-super-soft, #e8eaf6);
    border-color: var(--cl-soft, #7986cb);
}

.add-item-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: transparent;
}

.add-item-btn .material-icons { font-size: 16px; }

/* Back button */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--cl-hard, #26418f);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    margin-bottom: 12px;
    font-family: inherit;
}

.back-btn:hover { background: var(--cl-super-soft, #e8eaf6); }
.back-btn .material-icons { font-size: 18px; }

.is-hidden { display: none !important; }

/* Child header card (custodian) */
.child-header-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--white, #fff);
    border: 1px solid var(--gray-lighter, #e0e0e0);
    border-radius: 8px;
    margin-bottom: 16px;
}

.child-header-card__avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--cl-super-soft, #e8eaf6);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.child-header-card__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.child-header-card__name {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--gray-darker, #333);
    margin: 0 0 4px;
}

.child-header-card__details {
    font-size: 0.8125rem;
    color: var(--gray-dark, #666);
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8125rem;
    color: var(--gray-dark, #666);
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.breadcrumb a { color: var(--cl-hard, #26418f); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb__separator { color: var(--gray-light, #ccc); }

/* Assessment status indicator */
.assessment-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
}

.assessment-status .material-icons { font-size: 12px; }
.assessment-status--has-assessment { background: #e8f5e9; color: #2e7d32; }
.assessment-status--has-self { background: #e3f2fd; color: #1565c0; }
.assessment-status--none { background: var(--gray-lightest, #f5f5f5); color: var(--gray, #999); }

/* ============================================
   RESPONSIVE — Switch to mobile matrix view
   ============================================ */
@media (max-width: 767px) {
    /* Hide the desktop matrix table */
    .assess-matrix__table-wrap { display: none; }
    /* Show mobile-friendly accordion view */
    .assess-matrix__mobile { display: block; }
    .am-accordion-helper { display: flex; }

    .page-header { flex-direction: column; align-items: stretch; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .matrix-card-grid { grid-template-columns: 1fr; }
    .detail-panel__inner { padding: 14px; }
    .student-selector { flex-direction: column; align-items: stretch; }
    .student-selector__pager { margin-left: 0; }

    /* Matrix list table -> stack cards on mobile */
    .matrix-table thead { display: none; }
    .matrix-table,
    .matrix-table tbody,
    .matrix-table tr,
    .matrix-table td { display: block; }
    .matrix-table tr {
        margin-bottom: 12px;
        background: var(--white, #fff);
        border: 1px solid var(--gray-lighter, #e0e0e0);
        border-radius: 8px;
        padding: 12px;
    }
    .matrix-table td {
        padding: 4px 0;
        border-bottom: none;
        text-align: left !important;
    }
    .matrix-table td:before {
        content: attr(data-label);
        font-size: 0.6875rem;
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--gray-dark, #666);
        display: block;
        margin-bottom: 2px;
    }
    .matrix-table td[data-label=""]:before { content: ""; margin: 0; }

    .sticky-actions { padding: 10px 12px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
    .sticky-actions .btn-primary,
    .sticky-actions .btn-outlined { flex: 1; justify-content: center; }
}

/* Scroll container for assessment view bottom reachability */
.assess-scroll-region {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    scroll-padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

/* Print */
@media print {
    .vk-layout__toolbar,
    .vk-layout__main-menu,
    .menu-overlay,
    .sticky-actions,
    .back-btn,
    .assessment-mode-switch,
    .tab-bar,
    .sub-tab-bar,
    .page-header__actions { display: none !important; }
    .assess-matrix__table-wrap { display: block !important; overflow: visible !important; }
    .assess-matrix__mobile { display: none !important; }
    .am-cell { background: var(--white) !important; border: 1px solid #999 !important; }
}

/* ============================================================
   v4 ADDITIONS — Per-cell text, dual L/E indicators in cells,
   group view with student names, cell-grid editor.
   These rules WIN over older rules above (CSS source-order).
   ============================================================ */

/* ---- Desktop assessment matrix (v4) ---- */
.assess-matrix__table.assess-matrix__table--v4 {
    width: 100%;
    border-collapse: separate;
    border-spacing: 4px;
    table-layout: fixed;
    margin: 8px 0 16px;
}

.assess-matrix__table--v4 .assess-matrix__row-header-col {
    width: 240px;
    min-width: 200px;
    background: var(--gray-bg, #f5f5f5);
    color: var(--gray-darker, #333);
    text-align: left;
    padding: 8px 12px;
    font-weight: 500;
    font-size: 0.8125rem;
    border-radius: 6px;
}

.assess-matrix__table--v4 .assess-matrix__col-head {
    background: var(--cl-super-soft, #e8eaf6);
    color: var(--cl-hard, #26418f);
    text-align: center;
    padding: 8px 6px;
    font-weight: 500;
    font-size: 0.8125rem;
    border-radius: 6px;
    line-height: 1.2;
    vertical-align: middle;
}

.assess-matrix__col-head__short {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.1;
}

.assess-matrix__col-head__long {
    display: block;
    font-size: 0.6875rem;
    font-weight: 400;
    color: var(--gray-darker, #444);
    margin-top: 2px;
    text-transform: none;
}

.assess-matrix__table--v4 .assess-matrix__row-header {
    background: var(--white, #fff);
    border: 1px solid var(--gray-light, #e0e0e0);
    border-radius: 6px;
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--gray-darker, #333);
    font-weight: 500;
    display: flex;
    gap: 8px;
}

.assess-matrix__row-index {
    flex: 0 0 auto;
    background: var(--cl-super-soft, #e8eaf6);
    color: var(--cl-hard, #26418f);
    width: 22px; height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.assess-matrix__row-text {
    flex: 1 1 auto;
    word-break: break-word;
}

.assess-matrix__table--v4 .assess-matrix__section-row td {
    background: var(--cl-hard, #26418f);
    color: #fff;
    padding: 6px 12px;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.assess-matrix__table--v4 .am-cell-wrap {
    padding: 0;
}

/* ---- Cell (v4): box with header + criterion text ---- */
.am-cell-wrap > .am-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 86px;
    padding: 8px 10px;
    background: var(--white, #fff);
    border: 1.5px solid var(--gray-light, #d8d8d8);
    border-radius: 6px;
    text-align: left;
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--gray-darker, #333);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    width: 100%;
}

.am-cell-wrap > .am-cell:hover {
    border-color: var(--cl-hard, #26418f);
    box-shadow: 0 0 0 1px var(--cl-hard, #26418f) inset;
    background: var(--cl-super-soft, #f3f5fb);
}

.am-cell-wrap > .am-cell--readonly {
    cursor: default;
}

.am-cell-wrap > .am-cell--readonly:hover {
    border-color: var(--gray-light, #d8d8d8);
    box-shadow: none;
    background: var(--white, #fff);
}

.am-cell-wrap > .am-cell:focus-visible {
    outline: 3px solid var(--cl-hard, #26418f);
    outline-offset: 2px;
}

/*
 * Empty assessment cell (no criterion text saved yet).
 *
 * v5 fix (pin 12, Andreas 2026-05-22): the previous variant relied
 * on the cell inheriting `.am-cell` styling and only differed via a
 * faint diagonal pattern. In dark mode that meant the cell ended up
 * solid #2a2a2a — i.e. a black box — which is not in line with the
 * Vklass design system (which never uses pure dark fills for
 * content surfaces in either theme).
 *
 * Carried over verbatim into v6 (which is v5 + a11y hardening).
 */
.am-cell-wrap > .am-cell--empty {
    background: var(--gray-lightest, #fafafa);
    border-style: dashed;
    border-color: var(--gray-light, #d8d8d8);
}

.am-cell-wrap > .am-cell--empty:hover {
    background: var(--cl-super-soft, #e8eaf6);
    border-style: dashed;
    border-color: var(--cl-soft, #7986cb);
    box-shadow: none;
}

.am-cell-wrap > .am-cell--empty .am-cell__short {
    background: var(--white, #fff);
    color: var(--gray-dark, #666);
    border: 1px solid var(--gray-light, #d8d8d8);
}

.am-cell__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 22px;
}

.am-cell__short {
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--gray-dark, #666);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--gray-bg, #f0f0f0);
    padding: 2px 6px;
    border-radius: 999px;
    line-height: 1.4;
}

.am-cell__markers {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 18px;
}

.am-cell__markers--placeholder {
    display: none;
}

.am-cell__marker {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 1px 6px;
    border-radius: 999px;
    line-height: 1.4;
}

.am-cell__marker-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.am-cell__marker--teacher {
    background: #2e7d32;
    color: #fff;
}

.am-cell__marker--student {
    background: #1565c0;
    color: #fff;
}

.am-cell__text {
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--gray-darker, #2a2a2a);
    word-break: break-word;
    hyphens: auto;
}

.am-cell__empty-hint {
    color: var(--gray-dark, #999);
    font-style: italic;
    font-size: 0.7rem;
}

/* Teacher selection */
.am-cell-wrap > .am-cell--teacher {
    border-color: #2e7d32;
    background: rgba(46, 125, 50, 0.08);
    box-shadow: 0 0 0 1px #2e7d32 inset;
}

.am-cell-wrap > .am-cell--teacher .am-cell__short {
    background: rgba(46, 125, 50, 0.18);
    color: #1b5e20;
}

/* Student-only selection */
.am-cell-wrap > .am-cell--student {
    border-color: #1565c0;
    background: rgba(21, 101, 192, 0.08);
    box-shadow: 0 0 0 1px #1565c0 inset;
}

.am-cell-wrap > .am-cell--student .am-cell__short {
    background: rgba(21, 101, 192, 0.18);
    color: #0d47a1;
}

/* Both teacher AND student picked the same cell */
.am-cell-wrap > .am-cell--both {
    border-color: #4e0094;
    background: linear-gradient(135deg,
        rgba(46, 125, 50, 0.16) 0%,
        rgba(46, 125, 50, 0.10) 48%,
        rgba(21, 101, 192, 0.10) 52%,
        rgba(21, 101, 192, 0.16) 100%);
    box-shadow: 0 0 0 2px #4e0094 inset;
}

/* ---- Group view (v4) — students on rows, criterion columns ---- */
.group-table.group-table--v4 {
    border-collapse: separate;
    border-spacing: 4px;
    width: max-content;
    min-width: 100%;
    table-layout: fixed;
}

.group-table--v4 thead th {
    background: var(--cl-super-soft, #e8eaf6);
    color: var(--cl-hard, #26418f);
    font-weight: 500;
    font-size: 0.75rem;
    padding: 8px 6px;
    border-radius: 6px;
    text-align: left;
    vertical-align: top;
}

.group-table--v4 .group-table__student-col {
    position: sticky;
    left: 0;
    z-index: 4;
    min-width: 200px;
    width: 200px;
    background: var(--cl-hard, #26418f);
    color: #fff;
}

.group-table--v4 .group-table__criterion-col {
    min-width: 140px;
    width: 150px;
    line-height: 1.25;
}

.group-table--v4 .group-table__criterion-no {
    display: inline-block;
    background: var(--cl-hard, #26418f);
    color: #fff;
    width: 22px; height: 22px;
    border-radius: 50%;
    text-align: center;
    font-weight: 700;
    font-size: 0.6875rem;
    line-height: 22px;
    margin-bottom: 4px;
}

.group-table--v4 .group-table__criterion-section {
    display: block;
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--gray-dark, #555);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.group-table--v4 .group-table__criterion-text {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--cl-hard, #26418f);
    white-space: normal;
    word-break: break-word;
}

.group-table--v4 .group-table__status-col {
    min-width: 130px;
    width: 130px;
    text-align: center;
}

.group-table--v4 tbody td {
    background: var(--white, #fff);
    border: 1px solid var(--gray-light, #e0e0e0);
    border-radius: 6px;
    padding: 6px;
    vertical-align: middle;
}

.group-table--v4 .group-table__student-cell {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--white, #fff);
    box-shadow: 2px 0 6px rgba(0,0,0,0.05);
}

.group-table--v4 .group-cell-select {
    width: 100%;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    padding: 4px;
    background: var(--gray-bg, #f8f8f8);
    border: 1.5px dashed var(--gray-light, #d0d0d0);
    border-radius: 6px;
    color: var(--gray-darker, #333);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.group-table--v4 .group-cell-select:hover {
    border-color: var(--cl-hard, #26418f);
    background: var(--cl-super-soft, #f0f4ff);
}

.group-table--v4 .group-cell-select--marked {
    border-style: solid;
    border-color: #2e7d32;
    background: rgba(46, 125, 50, 0.10);
}

.group-table--v4 .group-cell-select--marked-draft {
    border-style: solid;
    border-color: #2e7d32;
    background: repeating-linear-gradient(45deg, rgba(46, 125, 50, 0.10), rgba(46, 125, 50, 0.10) 6px, rgba(46, 125, 50, 0.04) 6px, rgba(46, 125, 50, 0.04) 12px);
}

.group-cell-select__main {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
}

.group-cell-select__main--empty {
    color: var(--gray-dark, #999);
    font-weight: 400;
}

.group-cell-select__markers {
    display: inline-flex;
    gap: 3px;
    flex-wrap: wrap;
    justify-content: center;
}

.group-cell-select__marker {
    font-size: 0.625rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 999px;
    line-height: 1.4;
    letter-spacing: 0.04em;
}

.group-cell-select__marker--teacher {
    background: #2e7d32;
    color: #fff;
}

.group-cell-select__marker--student {
    background: #1565c0;
    color: #fff;
}

.group-table--v4 .group-cell-select--has-self {
    box-shadow: 0 0 0 1px rgba(21, 101, 192, 0.4);
}

/* ---- Create form: per-cell criterion-text grid ---- */
.cell-grid__intro {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: var(--cl-super-soft, #f3f5fb);
    color: var(--cl-hard, #26418f);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.8125rem;
    line-height: 1.4;
    margin-bottom: 12px;
    border-left: 3px solid var(--cl-hard, #26418f);
}

.cell-grid__intro .material-icons { font-size: 18px; margin-top: 1px; }

.cell-grid__empty {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--gray-bg, #f8f8f8);
    color: var(--gray-dark, #555);
    padding: 18px;
    border-radius: 6px;
    font-size: 0.875rem;
    text-align: left;
    line-height: 1.5;
}

.cell-grid__empty .material-icons {
    color: var(--cl-hard, #26418f);
    font-size: 22px;
}

.cell-grid__wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--gray-light, #e0e0e0);
    border-radius: 6px;
}

.cell-grid {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    width: 100%;
    min-width: 700px;
}

.cell-grid thead th {
    background: var(--cl-super-soft, #e8eaf6);
    color: var(--cl-hard, #26418f);
    font-weight: 500;
    padding: 8px;
    text-align: center;
    border-bottom: 1px solid var(--gray-light, #e0e0e0);
}

.cell-grid__row-head-col {
    width: 200px;
    min-width: 160px;
    text-align: left !important;
}

.cell-grid__col-head {
    width: 200px;
    min-width: 160px;
}

.cell-grid__col-short {
    display: block;
    font-size: 1rem;
    font-weight: 700;
}

.cell-grid__col-long {
    display: block;
    font-size: 0.6875rem;
    font-weight: 400;
    color: var(--gray-dark, #555);
    margin-top: 2px;
}

.cell-grid tbody th.cell-grid__row-head {
    background: var(--gray-bg, #f5f5f5);
    text-align: left;
    padding: 8px;
    border-bottom: 1px solid var(--gray-light, #e0e0e0);
    border-right: 1px solid var(--gray-light, #e0e0e0);
    vertical-align: top;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-darker, #333);
}

.cell-grid__row-index {
    background: var(--cl-hard, #26418f);
    color: #fff;
    width: 20px; height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    margin-right: 6px;
    vertical-align: middle;
}

.cell-grid__row-text {
    display: inline;
    word-break: break-word;
}

.cell-grid__cell {
    padding: 4px;
    border-bottom: 1px solid var(--gray-light, #e0e0e0);
    border-right: 1px solid var(--gray-light, #e0e0e0);
    vertical-align: top;
    background: var(--white, #fff);
}

.cell-grid__textarea {
    width: 100%;
    min-height: 64px;
    border: 1px solid var(--gray-light, #d0d0d0);
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 0.8125rem;
    line-height: 1.4;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
}

.cell-grid__textarea:focus {
    outline: 2px solid var(--cl-hard, #26418f);
    outline-offset: -1px;
    border-color: var(--cl-hard, #26418f);
}

.cell-grid__char-count {
    text-align: right;
    font-size: 0.625rem;
    color: var(--gray-dark, #888);
    margin-top: 2px;
}

/* Editor-list tweaks for paired column inputs */
.editor-list__pair {
    display: flex;
    gap: 8px;
    flex: 1;
}

.editor-list__pair .editor-list__input {
    flex: 1 1 auto;
}

.editor-list__pair .editor-list__input--short {
    flex: 0 0 100px;
    max-width: 100px;
}

.editor-list__index {
    background: var(--cl-super-soft, #e8eaf6);
    color: var(--cl-hard, #26418f);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 600;
    flex: 0 0 auto;
    margin-right: 4px;
}

/* ---- Mobile (accordion v4 — level detail with chip) ---- */
.am-level-detail__chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--cl-hard, #26418f);
    color: #fff;
    font-weight: 700;
    font-size: 0.75rem;
    min-width: 28px;
    height: 24px;
    padding: 0 6px;
    border-radius: 999px;
    margin-right: 8px;
}

.am-level-detail__label {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 0.8125rem;
    color: var(--gray-darker, #333);
    margin-bottom: 6px;
}

/* ---- Responsive: mobile-first matrix table view ---- */
@media (max-width: 767px) {
    .assess-matrix__table--v4 {
        display: none;
    }
}

@media (min-width: 768px) {
    .assess-matrix__mobile {
        display: none;
    }
}

/* ---- High-contrast / dark-mode polish ---- */
@media (prefers-color-scheme: dark) {
    .am-cell-wrap > .am-cell { background: #2a2a2a; color: #f0f0f0; border-color: #444; }
    .am-cell__text { color: #f0f0f0; }
    .am-cell__short { background: #3a3a3a; color: #ccc; }
    .am-cell-wrap > .am-cell--teacher { background: rgba(76, 175, 80, 0.18); }
    .am-cell-wrap > .am-cell--student { background: rgba(33, 150, 243, 0.18); }
    .assess-matrix__table--v4 .assess-matrix__row-header { background: #2a2a2a; color: #f0f0f0; border-color: #444; }
    .cell-grid__textarea { background: #2a2a2a; color: #f0f0f0; border-color: #444; }

    /*
     * Empty-cell dark-mode override (v5, pin 12) — kept verbatim in v6.
     * Previously the empty cell rendered as a flat #2a2a2a — black —
     * because the light-mode striped fill did not survive the cascade.
     * Now the empty cell uses a lighter charcoal with a dashed border so
     * it is clearly distinct from filled cells and matches Vklass
     * dark-mode tonality.
     */
    .am-cell-wrap > .am-cell--empty {
        background: #383838;
        border-color: #5a5a5a;
        border-style: dashed;
    }
    .am-cell-wrap > .am-cell--empty .am-cell__short {
        background: #2a2a2a;
        color: #d0d0d0;
        border-color: #5a5a5a;
    }
    .am-cell-wrap > .am-cell--empty .am-cell__empty-hint {
        color: #b0b0b0;
    }
}

/* ---- Safe-area / sticky reachability ---- */
.sticky-actions {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

.assess-scroll-region {
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    scroll-padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

/* ---- Info banner: v4 callout ---- */
.info-banner--v4 {
    background: linear-gradient(135deg, #e8f5e9 0%, #e3f2fd 100%);
    border-left-color: #4e0094;
}

/* ---- Accessibility: focus visibility on dual-marker cells ---- */
.am-cell:focus-visible,
.group-cell-select:focus-visible,
.am-segmented__item:focus-visible {
    outline: 3px solid #4e0094;
    outline-offset: 2px;
}

/* ---- v6: Arkivera-bekräftelsedialogens danger-primärknapp ---- */
.btn-primary--danger {
    background: var(--cl-red, #c62828) !important;
}
.btn-primary--danger:hover {
    background: #a51b1b !important;
}

/* v6: Dialog-titelraden får en vänsterjusterad rubrik och X-knapp till höger */
.mdc-dialog__title .mdc-button {
    background: transparent;
    border: none;
    color: var(--gray-darker, #3e3e3e);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.mdc-dialog__title .mdc-button:hover { background: var(--gray-lightest, #f5f5f5); }
.mdc-dialog__title .mdc-button:focus-visible {
    outline: 2px solid var(--cl-hard, #26418f);
    outline-offset: 2px;
}
