/* Final responsive visual system for the existing teacher workspace. */
:root {
  --primary: #3B82F6;
  --orange: #F97316;
  --green: #22C55E;
  --purple: #8B5CF6;
  --pink: #EC4899;
  --yellow: #F59E0B;
  --red: #EF4444;
  --cyan: #14B8A6;
  --page-bg: #F6F8FC;
  --card-bg: #FFFFFF;
  --border: #E5EAF2;
  --text-main: #1E293B;
  --text-muted: #64748B;
  --shadow-soft: 0 16px 42px rgba(30, 41, 59, 0.08);
  --shadow-card: 0 10px 28px rgba(30, 41, 59, 0.07);
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

html {
  background: var(--page-bg);
  overflow-x: hidden;
}

body:not(.display-body) {
  color: var(--text-main);
  background:
    radial-gradient(circle at 8% 0%, rgba(59, 130, 246, 0.14), transparent 26rem),
    radial-gradient(circle at 94% 6%, rgba(20, 184, 166, 0.12), transparent 24rem),
    linear-gradient(180deg, #fbfdff 0%, var(--page-bg) 38%, #eef4ff 100%);
}

body,
button,
select,
input,
textarea {
  letter-spacing: 0;
}

.app-shell {
  width: min(1680px, 100%);
  padding-inline: clamp(18px, 2.2vw, 34px);
}

.topbar,
.main-tabs,
.wall-panel,
.workspace-panel,
#scoreAnalysisView,
.notice-editor-panel,
.teacher-access-card,
.modal {
  border-color: rgba(226, 232, 240, 0.92);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-soft);
}

.topbar {
  border-radius: 28px;
}

.brand-mark,
.teacher-access-mark {
  background: linear-gradient(135deg, var(--primary), var(--cyan));
}

.main-tabs {
  position: sticky;
  z-index: 20;
  top: 10px;
  backdrop-filter: blur(14px);
}

.main-tab {
  border-radius: 14px;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.main-tab:hover {
  color: var(--primary);
  background: #eff6ff;
}

.main-tab.active {
  background: linear-gradient(135deg, #2563eb, #14b8a6);
}

.button,
.class-tab,
.display-close,
.stat-card,
.student-card,
.pending-summary-card,
.exam-followup-card,
.workspace-empty,
.empty-state,
.list-empty,
.recent-evaluation,
.profile-contact-grid article,
.profile-focus-card,
.profile-controls,
.profile-preview-wrap,
.notice-canvas-toolbar label,
.ticker-style-controls label {
  border-radius: var(--radius-md);
}

.button {
  min-height: 48px;
  border-radius: var(--radius-sm);
}

.button-primary {
  background: linear-gradient(135deg, var(--primary), #2563eb);
}

.button-display {
  background: linear-gradient(135deg, #1f2937, #475569);
}

.button-praise,
.stat-praise .stat-icon {
  color: #1d4ed8;
  background: #dbeafe;
}

.button-improve,
.stat-pending .stat-icon {
  color: #c2410c;
  background: #ffedd5;
}

.button-success,
.stat-completed .stat-icon {
  color: #15803d;
  background: #dcfce7;
}

.button-exam,
.stat-exam .stat-icon {
  color: #fff;
  background: linear-gradient(135deg, var(--purple), #2563eb);
}

.button:hover,
.class-tab:hover,
.stat-card:hover,
.student-card:hover,
.pending-summary-card:hover,
.exam-followup-card:hover {
  transform: translateY(-2px);
}

.stat-card {
  min-height: 118px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.98), rgba(248,250,252,0.92)),
    var(--card-bg);
  box-shadow: var(--shadow-card);
}

.stat-praise {
  border-top: 4px solid var(--primary);
}

.stat-pending {
  border-top: 4px solid var(--orange);
}

.stat-completed {
  border-top: 4px solid var(--green);
}

.stat-exam {
  border-top: 4px solid var(--purple);
}

.wall-panel {
  border-radius: 30px;
}

.student-grid {
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 14px;
}

.roster-student-card {
  min-height: 134px;
  background: linear-gradient(180deg, #ffffff, #f8fbff) !important;
  box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.82) !important;
}

.roster-student-card.has-pending,
.student-card.has-pending {
  background: linear-gradient(180deg, #fff7ed, #ffffff) !important;
}

.student-card.has-overdue,
.student-card.has-weekly-repeat,
.student-card.has-commitment-repeat,
.student-card.is-alert {
  background: linear-gradient(180deg, #fff1f2, #ffffff) !important;
}

.mini-badge,
.score-status-pill,
.badge,
.status-pill,
.date-status,
.exam-selected-students span {
  border-radius: 999px;
}

.empty-state,
.workspace-empty,
.list-empty,
.exam-empty,
.recent-evaluation-empty {
  position: relative;
  border: 1px dashed rgba(148, 163, 184, 0.55);
  background: linear-gradient(135deg, #ffffff, #f8fbff);
  color: var(--text-muted);
}

.empty-state::before,
.workspace-empty::before,
.list-empty::before,
.exam-empty::before,
.recent-evaluation-empty::before {
  display: grid;
  width: 42px;
  height: 42px;
  margin: 0 auto 10px;
  place-items: center;
  border-radius: 14px;
  color: var(--primary);
  background: #dbeafe;
  content: "i";
  font-weight: 900;
}

.modal-backdrop {
  animation: responsiveFadeIn 160ms ease;
}

.modal {
  animation: responsivePanelIn 180ms ease;
}

@keyframes responsiveFadeIn {
  from { opacity: 0; }
}

@keyframes responsivePanelIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (min-width: 768px) and (max-width: 1199px) {
  .app-shell {
    padding: 12px 18px 34px;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 14px;
  }

  .brand-block {
    justify-content: center;
    text-align: center;
  }

  .class-picker,
  .header-actions {
    justify-content: center;
    flex-wrap: wrap;
  }

  .main-tabs {
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
  }

  .main-tab {
    min-width: 132px;
    min-height: 50px;
    padding-inline: 20px;
    font-size: 16px;
    flex: 0 0 auto;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .student-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
  }

  .roster-student-card {
    min-height: 156px;
    padding: 16px;
  }

  .roster-student-card .student-avatar {
    width: 66px;
    height: 66px;
  }

  .roster-student-card .student-name {
    font-size: 16px;
    white-space: normal;
  }

  .pending-student-grid,
  .exam-followup-board,
  .profile-layout,
  .notice-editor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .exam-followup-board {
    overflow-x: visible;
  }

  .exam-status-list {
    max-height: none;
  }

  .profile-preview-wrap {
    max-height: none;
  }

  .notice-editor-heading,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .notice-canvas-toolbar,
  .ticker-editor-controls {
    align-items: stretch;
  }

  .notice-canvas-toolbar .button,
  .ticker-editor-controls .button {
    min-height: 48px;
  }

  .modal {
    width: min(92vw, 980px);
    max-height: min(86vh, 920px);
  }
}

@media (max-width: 767px) {
  :root {
    --shadow-soft: 0 8px 22px rgba(30, 41, 59, 0.08);
    --shadow-card: 0 4px 14px rgba(30, 41, 59, 0.06);
  }

  body {
    font-size: 15px;
  }

  body.mobile-nav-ready {
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
  }

  .app-shell {
    padding: 10px 12px calc(92px + env(safe-area-inset-bottom));
  }

  .topbar {
    order: 1;
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 8px;
    padding: 14px;
    border-radius: 22px;
  }

  .brand-block {
    align-items: flex-start;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
  }

  .brand-block h1 {
    font-size: 21px;
  }

  .brand-block p {
    font-size: 13px;
    line-height: 1.45;
  }

  .class-picker {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
  }

  .class-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
  }

  .class-tab {
    min-width: 0;
    min-height: 44px;
    padding: 0 10px;
    font-size: 15px;
  }

  .header-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .header-actions .button {
    min-width: 0;
    width: 100%;
    min-height: 46px;
    padding: 0 10px;
    white-space: normal;
  }

  .header-actions .cloud-button {
    grid-column: 1 / -1;
  }

  .main-tabs {
    display: none;
  }

  #recordsView,
  .workspace-page,
  .notice-editor-page {
    order: 2;
    margin-top: 12px;
  }

  .stats-grid {
    display: flex;
    gap: 12px;
    margin: 14px -12px 14px;
    padding: 2px 12px 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
  }

  .stat-card {
    grid-template-columns: auto 1fr;
    min-width: 72vw;
    min-height: 106px;
    padding: 16px;
    scroll-snap-align: start;
  }

  .stat-arrow {
    grid-column: 1 / -1;
    font-size: 13px;
  }

  .wall-panel,
  .workspace-panel,
  #scoreAnalysisView,
  .notice-editor-panel {
    padding: 14px;
    border-radius: 22px;
  }

  .section-heading,
  .workspace-heading,
  .notice-editor-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .section-heading .class-wall-title,
  .workspace-heading h2,
  .notice-editor-heading h2 {
    font-size: 22px;
  }

  .wall-tools,
  .workspace-actions,
  .score-toolbar,
  .notice-canvas-toolbar,
  .ticker-style-controls,
  .ticker-editor-controls,
  .batch-toolbar,
  .exam-followup-toolbar,
  .exam-followup-toolbar .exam-followup-toolbar-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .wall-hint {
    display: none;
  }

  .button,
  .button-small,
  .large-action,
  .exam-card-actions button,
  .notice-canvas-toolbar label,
  .ticker-style-controls label {
    min-height: 44px;
    width: 100%;
    justify-content: center;
    font-size: 15px;
  }

  .student-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .roster-student-card {
    display: grid;
    grid-template-columns: 58px 1fr auto;
    min-height: 94px;
    align-items: center;
    justify-items: start;
    padding: 14px 16px;
    text-align: left;
  }

  .roster-student-card .student-avatar {
    grid-row: 1 / span 2;
    width: 54px;
    height: 54px;
    font-size: 20px;
  }

  .roster-student-card .student-name {
    width: auto;
    margin: 0;
    padding-left: 12px;
    font-size: 18px;
    text-align: left;
    white-space: normal;
  }

  .roster-student-card .student-badges {
    position: static;
    grid-column: 2;
    grid-row: 2;
    align-items: flex-start;
    margin-left: 12px;
  }

  .roster-student-card::after {
    grid-column: 3;
    grid-row: 1 / span 2;
    padding: 8px 10px;
    border-radius: 999px;
    color: #1d4ed8;
    background: #dbeafe;
    content: "查看/操作";
    font-size: 13px;
    font-weight: 900;
    white-space: nowrap;
  }

  .student-card:hover,
  .student-card:focus-visible {
    transform: translateY(-1px);
  }

  .pending-student-grid,
  .exam-followup-board,
  .exam-status-summary,
  .exam-form-grid,
  .profile-layout,
  .profile-contact-grid,
  .profile-summary,
  .notice-option-row {
    grid-template-columns: 1fr;
  }

  .pending-summary-card {
    min-height: 132px;
  }

  .pending-student-identity {
    justify-content: flex-start;
    padding-right: 0;
  }

  .student-pending-reasons span {
    white-space: normal;
  }

  .exam-followup-board {
    overflow: visible;
  }

  .exam-status-column {
    display: none;
  }

  .exam-status-column.mobile-tab-active {
    display: block;
  }

  .mobile-section-tabs {
    display: flex;
    gap: 8px;
    margin: 0 0 12px;
    padding: 6px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
  }

  .mobile-section-tabs button {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: 12px;
    color: var(--text-muted);
    background: transparent;
    font-weight: 900;
  }

  .mobile-section-tabs button.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--purple));
  }

  .exam-status-list {
    max-height: none;
  }

  .exam-card-details > summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .exam-card-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .profile-controls,
  .profile-preview-wrap {
    max-height: none;
    padding: 14px;
  }

  .profile-preview-body,
  .profile-preview-header {
    padding: 16px;
  }

  .profile-score-list span,
  .profile-record-list article {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .profile-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .score-module-frame {
    min-height: calc(100vh - 188px);
    border-radius: 16px;
  }

  .ticker-editor {
    padding: 14px;
  }

  .ticker-editor-copy {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .ticker-editor-controls .text-input,
  .text-input,
  .text-area,
  select,
  input {
    width: 100%;
    min-height: 44px;
  }

  .notice-canvas-wrap {
    padding: 8px;
    overflow-x: hidden;
  }

  .notice-canvas {
    min-height: 190px;
  }

  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-width: none;
    max-height: min(88vh, 760px);
    border-radius: 24px 24px 0 0;
    animation: responsiveBottomSheetIn 180ms ease;
  }

  .modal-header {
    position: sticky;
    z-index: 2;
    top: 0;
    padding: 16px;
    border-radius: 24px 24px 0 0;
    background: rgba(255, 255, 255, 0.98);
  }

  .modal-body {
    max-height: calc(88vh - 82px);
    overflow-y: auto;
    padding: 0 16px 18px;
  }

  .modal-actions,
  .large-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .mobile-bottom-nav {
    position: fixed;
    z-index: 9990;
    right: 10px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    left: 10px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 8px;
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 14px 38px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(16px);
  }

  .mobile-bottom-nav button {
    display: flex;
    min-width: 0;
    min-height: 52px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 3px;
    border: 0;
    border-radius: 16px;
    color: #64748b;
    background: transparent;
    font-size: 11px;
    font-weight: 900;
  }

  .mobile-bottom-nav .nav-icon {
    font-size: 18px;
    line-height: 1;
  }

  .mobile-bottom-nav button.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--cyan));
    box-shadow: 0 8px 18px rgba(59, 130, 246, 0.24);
  }

  .mobile-more-backdrop {
    position: fixed;
    z-index: 9991;
    inset: 0;
    display: none;
    align-items: end;
    background: rgba(15, 23, 42, 0.38);
  }

  .mobile-more-backdrop.open {
    display: flex;
  }

  .mobile-more-sheet {
    width: 100%;
    padding: 16px 16px calc(18px + env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0;
    background: #fff;
    box-shadow: 0 -16px 44px rgba(15, 23, 42, 0.18);
  }

  .mobile-more-sheet header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
  }

  .mobile-more-sheet h3 {
    margin: 0;
    font-size: 18px;
  }

  .mobile-more-sheet .close-more {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: #f1f5f9;
    font-size: 20px;
  }

  .mobile-more-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .mobile-more-grid button,
  .mobile-more-grid a {
    display: flex;
    min-height: 58px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 16px;
    color: var(--text-main);
    background: linear-gradient(180deg, #fff, #f8fafc);
    font-weight: 900;
    text-decoration: none;
  }
}

@keyframes responsiveBottomSheetIn {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
}

@media (max-width: 767px) and (orientation: landscape) {
  .topbar {
    grid-template-columns: 1fr 1fr;
  }

  .brand-block,
  .class-picker,
  .header-actions {
    grid-column: auto;
  }

  .stats-grid {
    margin-top: 10px;
  }

  .stat-card {
    min-width: 42vw;
  }

  .student-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
