:root {
  --primary: #f5f5f5;
  --secondary: #388e3c;
  --accent: #ff6f00;
  --ink: #263238;
  --ink-soft: #5b6b72;
  --line: #c9d6d9;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--primary);
  color: var(--ink);
  font-family: "Comic Sans MS", "Segoe Print", "Chalkboard SE", "Comic Neue", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

.whiteboard {
  position: relative;
  min-height: 100vh;
  background: linear-gradient(135deg, #ffffff 0%, #f2f2f2 55%, #eaeaea 100%);
  overflow-x: hidden;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

.smudge {
  position: fixed;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(120,120,120,0.10) 0%, rgba(255,255,255,0) 70%);
  filter: blur(2px);
  pointer-events: none;
  z-index: 0;
}
.smudge-1 { width: 320px; height: 220px; top: 8%; left: -60px; }
.smudge-2 { width: 280px; height: 200px; top: 45%; right: -70px; }
.smudge-3 { width: 260px; height: 180px; bottom: 10%; left: -40px; }
.smudge-4 { width: 200px; height: 150px; top: 70%; left: 35%; }

.app-header {
  position: relative;
  z-index: 1;
  padding: calc(20px + env(safe-area-inset-top)) 20px 12px;
  text-align: center;
}
.app-title { display: flex; align-items: center; justify-content: center; gap: 10px; }
.app-logo {
  width: 34px; height: 40px;
  background: #fff;
  border: 2px solid var(--secondary);
  border-radius: 4px;
  position: relative;
  display: inline-block;
  box-shadow: 0 2px 4px rgba(0,0,0,0.12);
}
.app-logo::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 12px; height: 12px;
  background: var(--secondary);
  border-bottom-left-radius: 4px;
}
.app-logo::after {
  content: "";
  position: absolute;
  left: 50%; top: 55%;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
}
.app-title h1 {
  font-size: 1.7rem;
  letter-spacing: 1px;
  color: var(--ink);
  font-weight: 800;
}
.app-subtitle {
  color: var(--ink-soft);
  font-size: 0.85rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-top: 2px;
}

.content {
  position: relative;
  z-index: 1;
  padding: 8px 16px 20px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadein 0.2s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Eraser counters */
.eraser-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin: 14px 0 6px;
}
.eraser {
  flex: 1;
  max-width: 150px;
  text-align: center;
}
.eraser-felt {
  position: relative;
  display: block;
  aspect-ratio: 1 / 0.72;
  background: #9e8d6b;
  background: linear-gradient(180deg, #a99a7c 0%, #8d7d5d 100%);
  border-radius: 10px;
  box-shadow: inset 0 4px 0 rgba(255,255,255,0.22), inset 0 -6px 8px rgba(0,0,0,0.28), 0 6px 12px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}
.eraser-felt::after {
  content: "";
  position: absolute;
  top: 4px; left: 8px; right: 8px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(255,255,255,0.35), rgba(255,255,255,0.05));
}
.chalk-num {
  font-size: 3.2rem;
  color: #fafafa;
  font-weight: 700;
  text-shadow: 1px 2px 3px rgba(0,0,0,0.35);
  transform: rotate(-3deg);
  font-family: "Comic Sans MS", "Chalkboard SE", sans-serif;
}
.marker-label {
  display: block;
  margin-top: 8px;
  font-weight: 800;
  color: #222;
  letter-spacing: 0.5px;
}

/* Rotate button */
.rotate-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  width: 100%;
  margin: 18px 0 4px;
  padding: 14px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #43a047, var(--secondary));
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(56,142,60,0.35);
}
.rotate-btn:active { transform: translateY(1px); }
.rotate-icon { font-size: 1.2rem; }

/* Lane block / upcoming */
.lane-block { margin-top: 18px; }
.marker-heading {
  font-size: 1.1rem;
  color: #222;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.upcoming {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.empty-hint {
  color: var(--ink-soft);
  font-size: 0.9rem;
  text-align: center;
  padding: 12px;
}
.upcoming .mini-note { flex: 1 1 45%; }

/* Sticky notes */
.note {
  position: relative;
  background: #ffd54f;
  padding: 12px 14px 16px;
  border-radius: 3px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.18);
  color: #333;
  line-height: 1.3;
}
.note::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  border-style: solid;
  border-width: 0 16px 16px 0;
  border-color: transparent rgba(0,0,0,0.16) transparent transparent;
  border-radius: 0 3px 0 0;
}
.note.active-job::after {
  content: "\1F9F2";
  position: absolute;
  top: 6px; right: 6px;
  font-size: 13px;
  line-height: 1;
}
.note.inactive-job::after {
  content: "\1F4CC";
  position: absolute;
  top: 6px; right: 6px;
  font-size: 12px;
  line-height: 1;
}
.note.job-title {
  font-weight: 800;
  font-size: 1rem;
  padding-right: 18px;
  word-break: break-word;
}
.note.job-student {
  font-size: 0.82rem;
  color: rgba(0,0,0,0.6);
  margin-top: 6px;
  font-weight: 600;
}
.note.job-week {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(0,0,0,0.5);
  margin-top: 6px;
}
.mini-note { font-size: 0.78rem; }
.mini-note .job-student { margin-top: 3px; font-size: 0.72rem; }

/* Job list */
.searchbar {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 6px 0 10px;
  background: linear-gradient(180deg, #f5f5f5 60%, rgba(245,245,245,0));
}
.searchbar input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 1rem;
  outline: none;
}
.searchbar input:focus { border-color: var(--secondary); }

.job-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.job-list .note { cursor: pointer; }

/* FAB */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  width: 58px; height: 58px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(180deg, #ff8f00, var(--accent));
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  box-shadow: 0 5px 14px rgba(255,111,0,0.4);
  z-index: 5;
}
.fab:active { transform: scale(0.95); }

/* Schedule lanes */
.schedule-lanes {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  -webkit-overflow-scrolling: touch;
}
.lane {
  flex: 0 0 78%;
  max-width: 300px;
  background: #fdfcf8;
  border: 1px solid #e8e2d0;
  border-radius: 6px;
  padding: 12px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6), 0 4px 8px rgba(0,0,0,0.08);
  min-height: 240px;
}
.lane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px dashed #d9d2bd;
  padding-bottom: 8px;
  margin-bottom: 10px;
}
.lane-head h2 { font-size: 1rem; color: #333; letter-spacing: 0.5px; }
.magnet-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ff5252, #c62828);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.thumbtack { font-size: 0.9rem; }
.lane-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 140px;
}
.lane .note { cursor: pointer; }
.lane-empty { color: var(--ink-soft); font-size: 0.82rem; text-align: center; padding: 12px 0; }

/* Students */
.student-list { display: flex; flex-direction: column; gap: 10px; }
.student-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.student-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.15);
  flex: 0 0 auto;
}
.student-info { flex: 1; min-width: 0; }
.student-name { font-weight: 800; }
.student-job { font-size: 0.8rem; color: var(--ink-soft); }
.student-chev { color: var(--ink-soft); }

.student-detail { margin-top: 12px; }
.student-detail h3 { margin-bottom: 10px; font-size: 1.05rem; }
.detail-back {
  background: none;
  border: none;
  color: var(--secondary);
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 8px;
}
.detail-list { display: flex; flex-direction: column; gap: 10px; }

/* Bottom nav */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  background: linear-gradient(180deg, #f5f5f5 0%, #ececec 100%);
  border-top: 1px solid #ddd;
  padding: 8px calc(10px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
}
.magnet-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: none;
  background: #d7d7d7;
  color: #5b5b5b;
  width: 62px;
  height: 66px;
  border-radius: 50%;
  padding-top: 9px;
  box-shadow: 0 2px 3px rgba(0,0,0,0.18);
  transition: transform 0.15s ease;
}
.tab-emoji { font-size: 1.5rem; line-height: 1; }
.tab-label { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.3px; }
.magnet-tab.active {
  background: linear-gradient(180deg, #ffffff, #e8e8e8);
  color: var(--ink);
  transform: translateY(-3px);
  box-shadow: 0 4px 10px rgba(56,142,60,0.35);
}
.magnet-tab.active .tab-label { color: var(--secondary); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-card {
  width: 100%;
  max-width: 420px;
  background: #fffdf6;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.3);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-card h2 { margin-bottom: 16px; color: var(--ink); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span, .field legend {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-soft);
}
.field em { color: var(--accent); font-style: normal; }
.field input[type="text"], .field select {
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 1rem;
}
.field input:focus, .field select:focus { border-color: var(--secondary); outline: none; }
.color-field { border: none; padding: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.swatch {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid transparent;
}
.swatch.selected { border-color: var(--ink); transform: scale(1.1); }
.field input[type="color"] {
  width: 44px; height: 34px;
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 2px;
  background: #fff;
}
.form-error {
  color: #c62828;
  font-weight: 700;
  margin-bottom: 10px;
}
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.btn {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  border: none;
  font-weight: 800;
  font-size: 1rem;
}
.btn-ghost { background: #eee; color: var(--ink); }
.btn-primary { background: linear-gradient(180deg, #43a047, var(--secondary)); color: #fff; }

/* Sheet */
.sheet {
  width: 100%;
  max-width: 420px;
  background: #fffdf6;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  position: fixed;
  left: 0; right: 0; bottom: 0;
  margin: 0 auto;
  box-shadow: 0 -6px 24px rgba(0,0,0,0.25);
  z-index: 21;
}
.sheet .sheet-grab {
  width: 40px; height: 4px;
  background: #ccc;
  border-radius: 2px;
  margin: 0 auto 12px;
}
.sheet .note { margin-bottom: 12px; }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; }
.sheet .btn { flex: none; }

@media (min-width: 600px) {
  .content { max-width: 620px; margin: 0 auto; }
  .modal-card { max-width: 440px; }
}