:root {
  --line: #cfd8e3;
  --ink: #0f172a;
  --muted: #5b6472;
  --paper: #ffffff;
  --wash: #eef4fb;
  --board: #214e88;
  --desk: #f8fbff;
  --desk-line: #90a4c2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #edf3fa, #f7fafc);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

.floorplan-page {
  width: min(1200px, calc(100% - 24px));
  margin: 18px auto 28px;
  display: grid;
  gap: 18px;
}

.floorplan-shell {
  display: block;
}

.floorplan-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.floorplan-kicker,
.print-kicker {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #466893;
}

.floorplan-card h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.floorplan-copy {
  margin: 10px 0 0;
  max-width: 760px;
  color: var(--muted);
  line-height: 1.5;
}

.floorplan-controls {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 14px;
  margin-top: 18px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-weight: 700;
  color: #24476e;
}

.field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 16px;
  background: #fff;
}

.field-wide {
  min-width: 0;
}

.floorplan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.floorplan-actions button {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  background: #1d4ed8;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.floorplan-actions button.secondary {
  background: #dbe7f7;
  color: #163862;
}

.floorplan-hint {
  margin: 14px 0 0;
  color: var(--muted);
}

.print-sheet {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  background: var(--paper);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  padding: 14mm 12mm 12mm;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8mm;
}

.print-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  border-bottom: 2px solid #d9e3f0;
  padding-bottom: 5mm;
}

.print-header h2 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.2;
}

.print-meta {
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.classroom {
  position: relative;
  min-height: 220mm;
  border: 3px solid #8597ae;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(224, 236, 248, 0.85), rgba(248, 251, 255, 0.95)),
    repeating-linear-gradient(
      to right,
      rgba(148, 163, 184, 0.08) 0,
      rgba(148, 163, 184, 0.08) 1px,
      transparent 1px,
      transparent 42px
    ),
    repeating-linear-gradient(
      to bottom,
      rgba(148, 163, 184, 0.08) 0,
      rgba(148, 163, 184, 0.08) 1px,
      transparent 1px,
      transparent 42px
    );
  overflow: hidden;
}

.board-label {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 180px;
  text-align: center;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--board);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.desk-layer {
  position: absolute;
  inset: 58px 14px 14px;
}

.desk {
  position: absolute;
  width: 124px;
  min-height: 78px;
  padding: 20px 10px 8px;
  border: 2px solid var(--desk-line);
  border-radius: 7px;
  background: linear-gradient(180deg, var(--desk), #eef5ff);
  box-shadow: 0 8px 18px rgba(55, 91, 141, 0.14);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.desk.is-dragging {
  cursor: grabbing;
  box-shadow: 0 14px 26px rgba(29, 78, 216, 0.18);
}

.desk-rotate {
  position: absolute;
  left: 50%;
  top: -16px;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  border: 2px solid #7691b8;
  border-radius: 999px;
  background: #f8fbff;
  box-shadow: 0 2px 6px rgba(55, 91, 141, 0.18);
  cursor: pointer;
}

.desk-rotate::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 2px;
  height: 14px;
  background: #9bb0ce;
  transform: translateX(-50%);
}

.desk-name-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.desk-name {
  width: 100%;
  border: 1px dashed #b4c5da;
  border-radius: 5px;
  padding: 8px 9px;
  background: rgba(255, 255, 255, 0.86);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
}

.page-links {
  display: flex;
  justify-content: center;
}

.page-links a {
  color: #1d4ed8;
  font-weight: 700;
  text-decoration: none;
}

@media (max-width: 1000px) {
  .floorplan-page {
    width: min(100%, calc(100% - 16px));
    margin: 12px auto 20px;
  }

  .floorplan-controls {
    grid-template-columns: 1fr;
  }

  .print-sheet {
    width: 100%;
    min-height: auto;
    padding: 18px;
  }

  .classroom {
    min-height: 70vh;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  body {
    background: #fff;
  }

  .no-print,
  .page-links,
  .dm-topbar,
  .dm-watermark {
    display: none !important;
  }

  .floorplan-page {
    width: auto;
    margin: 0;
    gap: 0;
  }

  .print-sheet {
    width: 210mm;
    min-height: 297mm;
    box-shadow: none;
    margin: 0;
  }

  .desk-rotate {
    display: none !important;
  }
}
