/* SMAS Student Web - Phase 1 foundation styles. Isolated from the legacy
   admin/portal templates; nothing here is shared with or loaded by them. */

:root {
  --sw-primary: #2f6fed;
  --sw-primary-dark: #1e4fc4;
  --sw-bg: #f4f6fb;
  --sw-surface: #ffffff;
  --sw-text: #1b1f27;
  --sw-muted: #667085;
  --sw-border: #e3e7ef;
  --sw-danger: #d92d20;
  --sw-danger-bg: #fef3f2;
  --sw-success: #067647;
  --sw-success-bg: #ecfdf3;
  --sw-warn: #f79009;
  --sw-radius: 14px;
  --sw-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.08);
  --sw-shadow-hover: 0 4px 8px rgba(16, 24, 40, 0.06), 0 12px 32px rgba(16, 24, 40, 0.12);
  --sw-max-width: 1080px;
}

* { box-sizing: border-box; }

/* Any element toggled via the `hidden` attribute must actually hide, even
   when a class on it also sets `display` (author styles otherwise win over
   the UA stylesheet's [hidden] rule). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
}

.sw-body {
  min-height: 100vh;
  background: linear-gradient(180deg, #eef3ff 0%, var(--sw-bg) 280px);
  color: var(--sw-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input {
  font-family: inherit;
}

/* ---------- Buttons ---------- */

.sw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.sw-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.sw-btn-primary {
  background: var(--sw-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(47, 111, 237, 0.3);
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.sw-btn-primary:hover:not(:disabled) {
  background: var(--sw-primary-dark);
  box-shadow: 0 4px 12px rgba(47, 111, 237, 0.4);
  transform: translateY(-1px);
}

.sw-btn-ghost {
  background: transparent;
  color: var(--sw-muted);
  border: 1px solid var(--sw-border);
  padding: 8px 16px;
}

.sw-btn-ghost:hover:not(:disabled) {
  background: var(--sw-bg);
  color: var(--sw-text);
}

.sw-btn-block {
  width: 100%;
}

/* ---------- Auth shell (login) ---------- */

.sw-auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(180deg, #eef3ff 0%, var(--sw-bg) 55%);
}

.sw-auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--sw-surface);
  border-radius: var(--sw-radius);
  box-shadow: var(--sw-shadow);
  padding: 32px 28px;
  text-align: center;
}

.sw-logo {
  display: block;
  margin: 0 auto 16px;
  height: 56px;
  width: auto;
  object-fit: contain;
}

.sw-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
}

.sw-subtitle {
  margin: 0 0 24px;
  color: var(--sw-muted);
  font-size: 14px;
}

.sw-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.sw-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sw-field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--sw-muted);
}

.sw-field input {
  border: 1px solid var(--sw-border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  color: var(--sw-text);
  background: var(--sw-surface);
}

.sw-field input:focus {
  outline: none;
  border-color: var(--sw-primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.15);
}

.sw-alert {
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  text-align: left;
  margin-bottom: 16px;
}

.sw-alert-error {
  background: var(--sw-danger-bg);
  color: var(--sw-danger);
}

.sw-alert-info {
  background: rgba(47, 111, 237, 0.1);
  color: var(--sw-primary-dark);
}

.sw-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px;
  color: var(--sw-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sw-divider::before,
.sw-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--sw-border);
}

.sw-google-btn {
  display: flex;
  justify-content: center;
}

/* ---------- App shell (dashboard) ---------- */

.sw-shell {
  max-width: var(--sw-max-width);
  margin: 0 auto;
  padding-bottom: 32px;
}

.sw-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--sw-surface);
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

.sw-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sw-brand-logo {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.sw-brand-name {
  font-weight: 800;
  font-size: 16.5px;
  letter-spacing: -0.01em;
}

.sw-tabbar {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  overflow-x: auto;
  background: var(--sw-surface);
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.06);
}

.sw-tab {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--sw-muted);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}

.sw-tab:hover:not(.sw-tab-disabled) {
  background: var(--sw-bg);
  color: var(--sw-text);
}

.sw-tab-active,
.sw-tab-active:hover {
  background: var(--sw-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(47, 111, 237, 0.35);
}

.sw-tab-disabled {
  opacity: 0.5;
  cursor: default;
}

.sw-main {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sw-card {
  background: var(--sw-surface);
  border-radius: var(--sw-radius);
  box-shadow: var(--sw-shadow);
  padding: 20px;
}

.sw-card-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
}

.sw-muted {
  color: var(--sw-muted);
  font-size: 14px;
  margin: 0;
}

.sw-profile-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, rgba(47, 111, 237, 0.07), var(--sw-surface) 60%);
}

.sw-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  background: var(--sw-bg);
  border: 3px solid var(--sw-surface);
  box-shadow: 0 0 0 1px var(--sw-border);
}

.sw-profile-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.sw-profile-greeting {
  color: var(--sw-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sw-profile-name {
  font-weight: 700;
  font-size: 16px;
}

.sw-profile-course {
  color: var(--sw-muted);
  font-size: 13.5px;
}

.sw-skeleton-line {
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--sw-border) 25%, #eef1f6 37%, var(--sw-border) 63%);
  background-size: 400% 100%;
  animation: sw-shimmer 1.4s ease infinite;
  margin: 6px 0;
}

.sw-skeleton-wide {
  width: 60%;
}

@keyframes sw-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.sw-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  background: var(--sw-primary);
}

.sw-profile-meta {
  color: var(--sw-muted);
  font-size: 12.5px;
}

/* ---------- Card header row ---------- */

.sw-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.sw-card-head .sw-card-title {
  margin: 0;
}

.sw-link-disabled {
  font-size: 13px;
  font-weight: 600;
  color: var(--sw-muted);
  opacity: 0.55;
  white-space: nowrap;
  cursor: default;
}

.sw-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--sw-primary);
  text-decoration: none;
  white-space: nowrap;
}

.sw-link:hover {
  text-decoration: underline;
}

button.sw-link {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
}

button.sw-link:disabled {
  opacity: 0.6;
  cursor: default;
}

.sw-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--sw-muted);
  text-decoration: none;
}

.sw-back-link:hover {
  color: var(--sw-text);
}

/* ---------- Stats row ---------- */

.sw-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.sw-stat {
  position: relative;
  background: var(--sw-surface);
  border-radius: var(--sw-radius);
  box-shadow: var(--sw-shadow);
  padding: 17px 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-align: center;
  overflow: hidden;
}

.sw-stat::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--sw-primary);
}

.sw-stats-row .sw-stat:nth-child(2)::before {
  background: var(--sw-warn);
}

.sw-stats-row .sw-stat:nth-child(3)::before {
  background: var(--sw-danger);
}

.sw-stat-value {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.sw-stat-label {
  font-size: 11.5px;
  color: var(--sw-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* ---------- Live class banner ---------- */

.sw-live-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #ecfdf3;
  box-shadow: none;
  border: 1px solid #abefc6;
}

.sw-live-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #12b76a;
  box-shadow: 0 0 0 4px rgba(18, 183, 106, 0.18);
}

.sw-live-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sw-live-title {
  font-weight: 700;
  font-size: 14.5px;
  color: #05603a;
}

.sw-live-sub {
  font-size: 13px;
  color: #12734d;
}

/* ---------- List rows (classes / to do / activity / notifications) ---------- */

.sw-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sw-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--sw-border);
  text-decoration: none;
  color: inherit;
}

.sw-row:first-child {
  border-top: none;
  padding-top: 0;
}

a.sw-row:hover {
  background: var(--sw-bg);
}

.sw-row-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--sw-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--sw-primary);
  overflow: hidden;
}

.sw-row-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sw-row-body {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sw-row-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--sw-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sw-row-sub {
  font-size: 12.5px;
  color: var(--sw-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sw-row-text {
  font-size: 13.5px;
  color: var(--sw-text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.sw-row-meta {
  font-size: 12px;
  color: var(--sw-muted);
}

.sw-row-status {
  flex: 0 0 auto;
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  align-self: center;
}

.sw-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sw-muted);
}

.sw-status-dot.sw-status-danger { background: var(--sw-danger); }
.sw-status-dot.sw-status-warn { background: #f79009; }
.sw-status-dot.sw-status-ok { background: #12b76a; }
.sw-status-dot.sw-status-primary { background: var(--sw-primary); }

.sw-row-status.sw-status-danger-text { color: var(--sw-danger); }
.sw-row-status.sw-status-warn-text { color: #b54708; }

.sw-row-unread .sw-row-title {
  font-weight: 700;
}

.sw-row-unread::before {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sw-primary);
  margin-top: 6px;
}

/* ---------- Empty / error states within cards ---------- */

.sw-empty {
  color: var(--sw-muted);
  font-size: 13.5px;
  padding: 8px 0;
  margin: 0;
}

.sw-inline-error {
  color: var(--sw-danger);
  font-size: 13.5px;
  margin: 0;
}

/* ---------- Attendance summary ---------- */

.sw-attendance-rate {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 4px;
}

.sw-attendance-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.sw-attendance-cell {
  text-align: center;
  padding: 8px 4px;
  border-radius: 10px;
  background: var(--sw-bg);
}

.sw-attendance-cell-value {
  display: block;
  font-size: 16px;
  font-weight: 700;
}

.sw-attendance-cell-label {
  display: block;
  font-size: 10.5px;
  color: var(--sw-muted);
  font-weight: 600;
  margin-top: 2px;
}

/* ---------- Classes list page ---------- */

.sw-classes-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.sw-class-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--sw-surface);
  border: 1px solid var(--sw-border);
  border-radius: var(--sw-radius);
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.sw-class-card:hover {
  box-shadow: var(--sw-shadow-hover);
  border-color: var(--sw-primary);
  transform: translateY(-1px);
}

.sw-class-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sw-class-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--sw-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sw-class-sub {
  font-size: 13px;
  color: var(--sw-muted);
  font-weight: 600;
}

.sw-class-meta {
  font-size: 12.5px;
  color: var(--sw-muted);
}

/* ---------- Class detail header ---------- */

.sw-class-detail-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sw-class-detail-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.sw-class-detail-title {
  font-size: 18px;
  font-weight: 700;
}

.sw-class-detail-sub {
  font-size: 13.5px;
  color: var(--sw-muted);
  font-weight: 600;
}

.sw-class-detail-meta {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--sw-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sw-class-detail-meta-row {
  font-size: 13px;
  color: var(--sw-muted);
}

.sw-class-detail-meta-row strong {
  color: var(--sw-text);
  font-weight: 600;
}

/* ---------- Class detail navigation tiles ---------- */

.sw-class-nav {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.sw-class-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--sw-surface);
  border: 1px solid var(--sw-border);
  border-radius: var(--sw-radius);
  padding: 18px 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--sw-muted);
  opacity: 0.6;
  cursor: default;
  text-decoration: none;
}

.sw-class-tile-active {
  opacity: 1;
  color: var(--sw-text);
  cursor: pointer;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.sw-class-tile-active:hover {
  box-shadow: var(--sw-shadow-hover);
  border-color: var(--sw-primary);
  color: var(--sw-primary);
  transform: translateY(-1px);
}

/* ---------- Posts feed ---------- */

.sw-posts-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 12px;
}

.sw-posts-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sw-post {
  background: var(--sw-surface);
  border-radius: var(--sw-radius);
  box-shadow: var(--sw-shadow);
  padding: 16px;
}

.sw-post-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.sw-post-text {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--sw-text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sw-post-media {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin-top: 10px;
  border-radius: 10px;
  overflow: hidden;
}

.sw-post-media-count-2,
.sw-post-media-count-3,
.sw-post-media-count-4 {
  grid-template-columns: 1fr 1fr;
}

.sw-post-media-item {
  position: relative;
  width: 100%;
  border: none;
  padding: 0;
  margin: 0;
  background: var(--sw-bg);
  overflow: hidden;
  display: block;
  cursor: pointer;
}

.sw-post-media-item.sw-media-broken {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}

.sw-media-broken-text {
  font-size: 12.5px;
  color: var(--sw-muted);
}

.sw-post-media-img,
.sw-post-media-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sw-post-actions {
  display: flex;
  gap: 4px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--sw-border);
}

.sw-post-action-btn {
  flex: 1 1 0;
  background: none;
  border: none;
  border-radius: 8px;
  padding: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--sw-muted);
  cursor: pointer;
  text-align: center;
}

.sw-post-action-btn:hover:not(:disabled) {
  background: var(--sw-bg);
  color: var(--sw-text);
}

.sw-post-action-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.sw-like-btn-active {
  color: var(--sw-primary);
}

/* ---------- Comments ---------- */

.sw-post-comments {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--sw-border);
}

.sw-comments-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.sw-comment-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.sw-comment-avatar {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.sw-comment-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  background: var(--sw-bg);
  border-radius: 12px;
  padding: 6px 10px;
}

.sw-comment-author {
  font-size: 12.5px;
  font-weight: 700;
}

.sw-comment-text {
  font-size: 13px;
  color: var(--sw-text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sw-comment-meta {
  font-size: 11px;
  color: var(--sw-muted);
  margin-top: 2px;
}

.sw-comment-form {
  display: flex;
  gap: 8px;
}

.sw-comment-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--sw-border);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13.5px;
  color: var(--sw-text);
  background: var(--sw-surface);
}

.sw-comment-input:focus {
  outline: none;
  border-color: var(--sw-primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.15);
}

.sw-comment-submit {
  flex: 0 0 auto;
  padding: 9px 16px;
  font-size: 13px;
}

/* ---------- Lightbox ---------- */

.sw-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.sw-lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.sw-lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.sw-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* ---------- Assessments list ---------- */

.sw-assessments-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sw-assessment-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--sw-surface);
  border: 1px solid var(--sw-border);
  border-radius: var(--sw-radius);
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.sw-assessment-card:hover {
  box-shadow: var(--sw-shadow);
  border-color: var(--sw-primary);
}

.sw-assessment-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sw-assessment-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--sw-text);
}

.sw-assessment-status {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.sw-assessment-status.sw-status-ok-text { color: #12734d; }
.sw-assessment-status.sw-status-warn-text { color: #b54708; }
.sw-assessment-status.sw-status-primary-text { color: var(--sw-primary); }
.sw-assessment-status.sw-status-danger-text { color: var(--sw-danger); }

.sw-assessment-meta {
  font-size: 12.5px;
  color: var(--sw-muted);
}

.sw-assessment-score {
  font-size: 13px;
  font-weight: 600;
  color: var(--sw-text);
  margin-top: 2px;
}

.sw-quiz-action-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

/* ---------- Quiz: timer + progress ---------- */

.sw-quiz-timer {
  font-size: 14px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--sw-bg);
  color: var(--sw-text);
}

.sw-quiz-timer-warn {
  background: #fff4e5;
  color: #b54708;
}

.sw-quiz-timer-danger {
  background: var(--sw-danger-bg);
  color: var(--sw-danger);
}

.sw-quiz-progress-track {
  height: 6px;
  background: var(--sw-border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}

.sw-quiz-progress-fill {
  height: 100%;
  background: var(--sw-primary);
  transition: width 0.2s ease;
}

.sw-quiz-progress-text {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--sw-muted);
  margin-bottom: 12px;
}

.sw-quiz-qnav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
}

.sw-quiz-qnav-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--sw-border);
  background: var(--sw-surface);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--sw-muted);
  cursor: pointer;
}

.sw-quiz-qnav-btn:hover {
  border-color: var(--sw-primary);
}

.sw-quiz-qnav-current {
  border-color: var(--sw-primary);
  color: var(--sw-primary);
}

.sw-quiz-qnav-answered {
  background: rgba(47, 111, 237, 0.12);
  color: var(--sw-primary);
  border-color: transparent;
}

/* ---------- Quiz: question card ---------- */

.sw-quiz-question-card {
  padding: 20px;
}

.sw-quiz-question-text {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sw-quiz-question-points {
  font-size: 12px;
  color: var(--sw-muted);
  font-weight: 600;
  margin-bottom: 14px;
}

.sw-quiz-question-image {
  display: block;
  max-width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: 10px;
  margin-bottom: 14px;
  background: var(--sw-bg);
}

.sw-quiz-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid var(--sw-border);
  border-radius: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  font-size: 14.5px;
  color: var(--sw-text);
}

.sw-quiz-option:hover {
  border-color: var(--sw-primary);
}

.sw-quiz-option:focus-visible {
  outline: none;
  border-color: var(--sw-primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.15);
}

.sw-quiz-option-selected {
  border-color: var(--sw-primary);
  background: rgba(47, 111, 237, 0.08);
}

.sw-quiz-option-marker {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--sw-border);
}

.sw-quiz-option-marker-square {
  border-radius: 6px;
}

.sw-quiz-option-selected .sw-quiz-option-marker {
  border-color: var(--sw-primary);
  background: var(--sw-primary);
}

.sw-quiz-option-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.sw-quiz-option-image {
  max-width: 100%;
  max-height: 140px;
  object-fit: contain;
  border-radius: 8px;
}

.sw-quiz-text-input,
.sw-quiz-select {
  width: 100%;
  border: 1px solid var(--sw-border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14.5px;
  color: var(--sw-text);
  background: var(--sw-surface);
  margin-bottom: 10px;
}

.sw-quiz-text-input:focus,
.sw-quiz-select:focus {
  outline: none;
  border-color: var(--sw-primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.15);
}

.sw-quiz-item-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--sw-muted);
  margin-bottom: 4px;
}

.sw-quiz-match-row,
.sw-quiz-rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.sw-quiz-match-left {
  flex: 1 1 45%;
  font-size: 14px;
  font-weight: 600;
}

.sw-quiz-match-row .sw-quiz-select {
  flex: 1 1 55%;
  margin-bottom: 0;
}

.sw-quiz-rank-select {
  flex: 0 0 auto;
  width: 76px;
  margin-bottom: 0;
}

.sw-quiz-rank-text {
  flex: 1 1 auto;
  font-size: 14px;
}

/* ---------- Quiz: sticky controls ---------- */

.sw-quiz-controls {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: var(--sw-surface);
  border-top: 1px solid var(--sw-border);
  max-width: var(--sw-max-width);
  margin: 0 auto;
  z-index: 20;
}

.sw-quiz-controls .sw-btn {
  flex: 1 1 0;
}

/* ---------- Confirmation overlay ---------- */

.sw-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.sw-confirm-card {
  background: var(--sw-surface);
  border-radius: var(--sw-radius);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: var(--sw-shadow);
}

.sw-confirm-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 8px;
}

.sw-confirm-text {
  font-size: 13.5px;
  color: var(--sw-muted);
  margin: 0 0 20px;
}

.sw-confirm-actions {
  display: flex;
  gap: 10px;
}

.sw-confirm-actions .sw-btn {
  flex: 1 1 0;
}

/* ---------- Quiz review list (pre-submit) ---------- */

.sw-review-row-answered .sw-row-status {
  color: #12734d;
}

.sw-review-row-unanswered .sw-row-status {
  color: var(--sw-danger);
}

/* ---------- Result view ---------- */

.sw-result-card {
  background: var(--sw-surface);
  border-radius: var(--sw-radius);
  box-shadow: var(--sw-shadow);
  padding: 24px;
  text-align: center;
  margin-bottom: 16px;
}

.sw-result-score {
  font-size: 36px;
  font-weight: 800;
}

.sw-result-percentage {
  font-size: 15px;
  color: var(--sw-muted);
  font-weight: 600;
  margin-top: 2px;
}

.sw-result-meta {
  font-size: 13px;
  color: var(--sw-muted);
  margin-top: 10px;
}

.sw-result-notice {
  font-size: 13px;
  color: var(--sw-muted);
  background: var(--sw-bg);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.sw-result-review-item {
  padding: 14px;
  border-radius: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--sw-border);
}

.sw-result-correct {
  border-color: #abefc6;
  background: #f6fef9;
}

.sw-result-incorrect {
  border-color: #fda29b;
  background: #fffbfa;
}

.sw-result-review-q {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.sw-result-review-answer {
  font-size: 13px;
  color: var(--sw-text);
  margin-bottom: 2px;
}

.sw-result-review-points {
  font-size: 12px;
  color: var(--sw-muted);
  margin-top: 4px;
}

/* ---------- Task detail ---------- */

.sw-task-meta-row {
  font-size: 13px;
  color: var(--sw-muted);
  margin-bottom: 4px;
}

.sw-task-meta-row strong {
  color: var(--sw-text);
  font-weight: 600;
}

.sw-task-instructions {
  font-size: 14px;
  line-height: 1.5;
  color: var(--sw-text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 12px 0;
}

.sw-task-section-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--sw-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 16px 0 8px;
}

.sw-task-section-label:first-child {
  margin-top: 0;
}

.sw-task-attachments {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sw-task-attachment-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--sw-border);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
}

.sw-task-attachment-row:hover {
  border-color: var(--sw-primary);
}

.sw-task-attachment-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--sw-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--sw-primary);
  overflow: hidden;
}

.sw-task-attachment-thumb {
  object-fit: cover;
}

.sw-task-attachment-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.sw-task-attachment-name {
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sw-task-attachment-meta {
  font-size: 11.5px;
  color: var(--sw-muted);
}

.sw-task-attachment-broken {
  font-size: 12.5px;
  color: var(--sw-muted);
  padding: 10px 12px;
}

.sw-task-score-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.sw-task-score-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--sw-text);
}

.sw-task-score-max {
  font-size: 14px;
  color: var(--sw-muted);
  font-weight: 600;
}

.sw-task-feedback {
  font-size: 13.5px;
  color: var(--sw-text);
  background: var(--sw-bg);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sw-textarea {
  width: 100%;
  border: 1px solid var(--sw-border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--sw-text);
  background: var(--sw-surface);
  resize: vertical;
  min-height: 100px;
  margin-bottom: 10px;
}

.sw-textarea:focus {
  outline: none;
  border-color: var(--sw-primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.15);
}

.sw-task-file-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* Deliberately NOT display:none - some mobile browsers/WebViews never
   open the native file picker for a label-for click (or a programmatic
   .click()) targeting a display:none input. This keeps the element in
   the layout (so it stays clickable/focusable everywhere) while making
   it visually invisible and take up no visible space. */
.sw-task-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sw-task-file-upload-status {
  font-size: 12.5px;
  color: var(--sw-muted);
  margin-top: 8px;
}

.sw-task-gate-notice {
  font-size: 13px;
  color: var(--sw-muted);
  background: var(--sw-bg);
  border-radius: 10px;
  padding: 12px 14px;
}

/* ---------- Materials list ---------- */

.sw-materials-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sw-material-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--sw-surface);
  border: 1px solid var(--sw-border);
  border-radius: var(--sw-radius);
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

a.sw-material-card:hover {
  box-shadow: var(--sw-shadow);
  border-color: var(--sw-primary);
}

.sw-material-icon {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--sw-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--sw-primary);
  overflow: hidden;
}

.sw-material-thumb {
  object-fit: cover;
}

.sw-material-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.sw-material-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--sw-text);
}

.sw-material-description {
  font-size: 13px;
  color: var(--sw-text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.sw-material-meta {
  font-size: 12px;
  color: var(--sw-muted);
}

.sw-material-extra-link {
  font-size: 12px;
  color: var(--sw-muted);
}

.sw-material-extra-link a {
  color: var(--sw-primary);
  text-decoration: none;
}

.sw-material-extra-link a:hover {
  text-decoration: underline;
}

/* ---------- Classmates ---------- */

.sw-instructor-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--sw-muted);
  margin-bottom: 10px;
}

.sw-instructor-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

a.sw-instructor-row-link {
  text-decoration: none;
  color: inherit;
  border-radius: var(--sw-radius);
  padding: 4px;
  margin: -4px;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

a.sw-instructor-row-link:hover {
  box-shadow: var(--sw-shadow-hover);
  transform: translateY(-1px);
}

.sw-classmates-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sw-classmate-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--sw-surface);
  border: 1px solid var(--sw-border);
  border-radius: var(--sw-radius);
  padding: 12px 16px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

a.sw-classmate-card:hover {
  box-shadow: var(--sw-shadow-hover);
  border-color: var(--sw-primary);
  transform: translateY(-1px);
}

.sw-classmate-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.sw-classmate-name {
  font-size: 14.5px;
  font-weight: 700;
}

.sw-classmate-meta {
  font-size: 12.5px;
  color: var(--sw-muted);
}

.sw-classmate-message-hint {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--sw-primary);
}

/* ---------- Messages: conversation list ---------- */

.sw-conversations-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ---------- Messages: conversation thread ---------- */

.sw-chat-main {
  display: flex;
  flex-direction: column;
}

.sw-chat-participant {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.sw-chat-participant-name {
  font-size: 16px;
  font-weight: 700;
}

.sw-chat-header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 15px;
}

.sw-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 8px;
  min-height: 120px;
}

.sw-chat-bubble-row {
  display: flex;
}

.sw-chat-own {
  justify-content: flex-end;
}

.sw-chat-other {
  justify-content: flex-start;
}

.sw-chat-bubble-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 78%;
}

.sw-chat-own .sw-chat-bubble-wrap {
  align-items: flex-end;
}

.sw-chat-other .sw-chat-bubble-wrap {
  align-items: flex-start;
}

.sw-chat-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sw-chat-own .sw-chat-bubble {
  background: var(--sw-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 6px rgba(47, 111, 237, 0.25);
}

.sw-chat-other .sw-chat-bubble {
  background: var(--sw-surface);
  color: var(--sw-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

.sw-chat-meta {
  font-size: 11px;
  color: var(--sw-muted);
  padding: 0 4px;
}

.sw-chat-attachment-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  text-decoration: none;
  padding: 2px;
}

.sw-chat-own .sw-chat-attachment-link {
  color: #fff;
  text-decoration: underline;
}

.sw-chat-other .sw-chat-attachment-link {
  color: var(--sw-primary);
}

.sw-chat-attachment-image {
  max-width: 220px;
  max-height: 220px;
  border-radius: 12px;
  display: block;
  object-fit: cover;
}

/* ---------- Messages: composer ---------- */

.sw-chat-composer {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--sw-surface);
  box-shadow: 0 -1px 0 rgba(16, 24, 40, 0.06), 0 -8px 24px rgba(16, 24, 40, 0.04);
  max-width: var(--sw-max-width);
  margin: 0 auto;
  z-index: 20;
}

.sw-chat-attach-label {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sw-chat-text-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--sw-border);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14.5px;
  color: var(--sw-text);
  background: var(--sw-surface);
}

.sw-chat-text-input:focus {
  outline: none;
  border-color: var(--sw-primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.15);
}

.sw-chat-file-status {
  font-size: 12px;
  color: var(--sw-muted);
  text-align: center;
  max-width: var(--sw-max-width);
  margin: 0 auto;
  padding: 4px 16px 8px;
}

/* ---------- PWA: connectivity banner ---------- */

.sw-connectivity-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 300;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  color: #fff;
}

.sw-connectivity-offline {
  background: var(--sw-danger);
}

.sw-connectivity-online {
  background: #12b76a;
}

/* ---------- PWA: install hint ---------- */

.sw-install-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(47, 111, 237, 0.08);
  border: 1px solid rgba(47, 111, 237, 0.25);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--sw-primary-dark);
}

.sw-install-hint .sw-btn {
  flex: 0 0 auto;
  padding: 6px 14px;
  font-size: 13px;
}

/* ---------- Responsive: tablet and up ---------- */

@media (min-width: 640px) {
  .sw-auth-card {
    padding: 40px 36px;
  }

  .sw-main {
    padding: 24px;
  }

  .sw-classes-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .sw-class-nav {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- Responsive: desktop ---------- */

@media (min-width: 1024px) {
  .sw-topbar,
  .sw-tabbar {
    padding-left: 24px;
    padding-right: 24px;
  }

  .sw-main {
    padding: 32px 24px;
  }

  .sw-stats-row {
    grid-template-columns: repeat(3, 180px);
  }

  .sw-classes-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .sw-class-nav {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ---------- Settings ---------- */

.sw-alert-success {
  background: var(--sw-success-bg);
  color: var(--sw-success);
}

.sw-settings-form .sw-card {
  margin-bottom: 14px;
}

.sw-settings-form .sw-field {
  margin-bottom: 14px;
}

.sw-settings-form .sw-field:last-child {
  margin-bottom: 0;
}

.sw-settings-avatar-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.sw-avatar-lg {
  width: 64px;
  height: 64px;
  font-size: 20px;
}

.sw-settings-avatar-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sw-settings-readonly-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--sw-muted);
}

.sw-settings-avatar-hint {
  font-size: 12.5px;
}

.sw-settings-avatar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 4px;
}

.sw-settings-avatar-btn {
  padding: 6px 14px;
  font-size: 13px;
}

.sw-settings-readonly-value {
  font-size: 15px;
  color: var(--sw-text);
  padding: 12px 14px;
  border: 1px solid var(--sw-border);
  border-radius: 10px;
  background: var(--sw-bg);
}

.sw-settings-term-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.sw-settings-term-hint {
  font-size: 12.5px;
  margin-top: 8px;
}

/* ---------- Register ---------- */

.sw-auth-switch {
  text-align: center;
  font-size: 13.5px;
  color: var(--sw-muted);
  margin: 20px 0 0;
}

.sw-checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--sw-muted);
  margin: 4px 0 16px;
  cursor: pointer;
}

.sw-checkbox-field input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: var(--sw-primary);
}
