:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #1d2129;
  --muted: #6b7785;
  --line: #e5e6eb;
  --line-strong: #c9cdd4;
  --primary: #5f9f86;
  --primary-hover: #4d876f;
  --primary-soft: #eef8f4;
  --queued: #f2f3f5;
  --queued-text: #86909c;
  --danger: #f53f3f;
  --danger-soft: #ffece8;
  --shadow: 0 8px 24px rgba(29, 33, 41, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid transparent;
  border-radius: 6px;
  color: #fff;
  background: var(--primary);
  padding: 0.68rem 0.95rem;
  cursor: pointer;
  font-weight: 700;
}

button:hover:not(:disabled) {
  background: var(--primary-hover);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

input {
  width: 100%;
  min-width: 0;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 0.8rem;
  color: var(--ink);
  background: #fff;
}

input:focus,
.event-title.editing {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(95, 159, 134, 0.16);
  outline: none;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 44px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.app-name,
.label {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.03;
}

h2 {
  font-size: 1.08rem;
}

.title-editor {
  display: grid;
  gap: 8px;
}

.event-title {
  width: fit-content;
  max-width: min(720px, 100%);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 2px 4px;
  cursor: text;
}

.event-title.placeholder {
  color: #86909c;
  font-style: italic;
  font-weight: 700;
}

.event-title.editing {
  background: #fff;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 12px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(440px, 1.45fr) minmax(280px, 0.55fr);
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.now-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}

.now-panel.active {
  border-color: #a7d8c4;
  background: #f6fbf8;
  box-shadow: inset 3px 0 0 var(--primary), var(--shadow);
}

.now-name {
  min-height: 1.1em;
  font-size: clamp(1.9rem, 4.8vw, 4.3rem);
  font-weight: 900;
  line-height: 1;
  overflow-wrap: anywhere;
}

.queue-panel {
  min-height: 500px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.queue-panel.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(95, 159, 134, 0.16), var(--shadow);
}

.students-panel {
  align-self: start;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  border-radius: 999px;
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 900;
}

.muted {
  color: var(--muted);
}

.compact {
  margin: 8px 0 16px;
  font-size: 0.93rem;
}

.student-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  margin-bottom: 10px;
}

.student-form button {
  width: 42px;
  height: 40px;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
}

.student-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 2px;
}

.student-card {
  display: grid;
  gap: 5px;
  min-height: 96px;
  padding: 12px;
  text-align: left;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.student-card.queued {
  color: var(--queued-text);
  border-color: var(--line);
  background: var(--queued);
}

.student-card.current {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
}

.student-card[draggable="true"] {
  cursor: grab;
}

.student-card.dragging,
.queue-list li.dragging {
  opacity: 0.55;
}

.student-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: center;
  gap: 8px;
}

.student-name {
  font-size: 1rem;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.student-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: #000;
  background: transparent;
  border-color: transparent;
  font-size: 1.35rem;
  line-height: 1;
}

.student-delete-btn:hover {
  color: #fff;
  background: var(--danger);
  border-color: transparent;
}

.student-meta,
.student-state {
  font-size: 0.84rem;
}

.student-state {
  color: var(--muted);
  font-weight: 800;
}

.student-card.queued .student-state,
.student-card.queued .student-meta {
  color: var(--queued-text);
}

.student-card.current .student-state {
  color: rgba(255, 255, 255, 0.82);
}

.student-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: end;
  margin-top: 2px;
  justify-content: space-between;
}

.student-action-btn,
.queue-action-btn {
  min-height: 36px;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  font-size: 0.84rem;
  font-weight: 900;
  white-space: nowrap;
}

.student-action-btn.primary,
.queue-action-btn.primary {
  color: #fff;
  background: var(--primary);
}

.student-action-btn.primary:hover,
.queue-action-btn.primary:hover {
  background: var(--primary-hover);
}

.queue-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.queue-current-block,
.queue-list li {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.queue-current-block {
  margin-bottom: 10px;
  border-color: #a7d8c4;
  background: #f6fbf8;
  box-shadow: inset 3px 0 0 var(--primary);
}

.queue-current-block[hidden] {
  display: none;
}

.queue-list li[draggable="true"] {
  cursor: grab;
}

.queue-list li.row-drag-over {
  border-color: var(--primary);
  background: #f6fbf8;
}

.queue-list li.empty {
  display: block;
  min-height: 0;
  white-space: nowrap;
}

.queue-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  color: #4e5969;
  background: #f2f3f5;
  font-weight: 900;
}

.queue-rank.active {
  width: 42px;
  color: #fff;
  background: var(--primary);
  font-size: 0.72rem;
}

.queue-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.queue-name {
  font-weight: 900;
  overflow-wrap: anywhere;
}

.queue-count {
  color: var(--muted);
  font-size: 0.85rem;
}

.queue-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.queue-action-btn.secondary,
.secondary,
.ghost {
  color: #4e5969;
  background: #fff;
  border-color: var(--line-strong);
}

.queue-action-btn.secondary:hover {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #ffb4a8;
}

.secondary:hover:not(:disabled),
.ghost:hover:not(:disabled) {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: #a7d8c4;
}

.danger {
  background: var(--danger);
}

.danger.subtle {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #ffb4a8;
}

.danger.subtle:hover:not(:disabled) {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.empty {
  color: var(--muted);
  margin: 0;
}

.status {
  min-height: 1.5rem;
  color: var(--primary);
  font-weight: 800;
}

.status.error {
  color: var(--danger);
}

@media (max-width: 820px) {
  .topbar,
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .top-actions {
    justify-content: flex-start;
    padding-top: 0;
  }

  .queue-panel {
    min-height: 320px;
  }

  .queue-current-block,
  .queue-list li {
    grid-template-columns: 1fr;
  }

  .queue-actions {
    justify-content: flex-start;
  }
}
