:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #d1d5db;
  --primary: #2563eb;
  --danger: #dc2626;
  --overlay: rgba(15, 23, 42, 0.55);
  --radius: 12px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app-header {
  padding: 24px 20px 12px;
}

.header-top-row {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.app-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.language-switcher {
  min-width: 160px;
  text-align: left;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 20px 28px;
}

.view {
  display: block;
}

.hidden {
  display: none;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  background: #eef2ff;
  color: #1e3a8a;
}

button:hover {
  filter: brightness(0.97);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-danger {
  background: #fee2e2;
  color: #991b1b;
}

.btn-ghost {
  background: #f8fafc;
  color: #1e293b;
  border-color: var(--line);
}

.home-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.classroom-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.classroom-item {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.classroom-item h3 {
  margin: 0;
  font-size: 1.05rem;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.editor-top {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
}

.editor-top-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
  color: var(--muted);
}

input[type="text"],
input[type="number"],
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.desk-grid-wrapper {
  overflow-x: auto;
}

.desk-grid {
  display: grid;
  gap: 12px;
  align-items: stretch;
}

.desk-card {
  border-radius: 12px;
  border: 1px solid #94a3b8;
  overflow: hidden;
  position: relative;
  background: #cbd5e1;
}

.seat-slot {
  min-height: 148px;
  background: #cbd5e1;
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.desk-double-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.desk-double-card .seat-slot:first-child {
  border-right: 1px solid rgba(148, 163, 184, 0.8);
}

.desk-card.dragging {
  opacity: 0.45;
}

.seat-slot.dragging {
  opacity: 0.45;
}

.desk-overlay {
  padding: 10px;
  background: var(--overlay);
  color: #fff;
  display: grid;
  gap: 8px;
}

.desk-student-name {
  margin: 0;
  font-weight: 600;
}

.desk-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.desk-actions button {
  padding: 6px 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
}

.desk-placeholder {
  opacity: 0.45;
}

.seat-slot-empty {
  background: #e2e8f0;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.empty-state {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.start-test-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  box-shadow: var(--shadow);
}

.test-pools {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.test-stats-panel {
  margin-bottom: 10px;
  padding: 10px 12px;
}

.test-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.test-badge {
  border-radius: 999px;
  font-size: 0.8rem;
  padding: 4px 9px;
  border: 1px solid transparent;
}

.badge-correct {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.badge-partial {
  background: #ffedd5;
  border-color: #fdba74;
  color: #9a3412;
}

.badge-incorrect {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.badge-neutral {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: #334155;
}

.test-pool {
  padding: 12px;
}

.test-pool-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.test-pool-head h3 {
  margin: 0;
  font-size: 1rem;
}

.pool-list {
  min-height: 72px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
  transition: background-color 120ms ease;
}

.pool-item {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #1e293b;
  border-radius: 8px;
  padding: 7px 10px;
  cursor: grab;
}

.pool-photo-item {
  width: 72px;
  height: 72px;
  padding: 0;
  overflow: hidden;
}

.pool-photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dragging {
  opacity: 0.45;
}

.slot-active {
  background: #eff6ff;
}

.test-seat-slot {
  min-height: 148px;
  display: grid;
  grid-template-rows: auto 1fr;
  transition: background-color 220ms ease, border-color 220ms ease;
  border: 1px solid transparent;
}

.test-seat-header {
  padding: 8px 10px;
  font-size: 0.8rem;
  color: #334155;
  border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.5);
}

.test-seat-droparea {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 8px;
}

.test-drop-slot {
  min-height: 48px;
  border: 1px dashed rgba(148, 163, 184, 0.9);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #334155;
  font-size: 0.84rem;
  text-align: center;
  padding: 6px;
}

.test-drop-slot .pool-item {
  width: 100%;
}

.test-drop-slot.slot-photo .pool-item {
  width: 72px;
}

.test-neutral {
  background: #f8fafc;
}

.test-correct {
  background: #dcfce7;
  border-color: #4ade80;
}

.test-partial {
  background: #ffedd5;
  border-color: #fb923c;
}

.test-incorrect {
  background: #fee2e2;
  border-color: #ef4444;
}

@media (min-width: 900px) {
  .app-shell {
    padding-left: 28px;
    padding-right: 28px;
  }

  .test-pools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
