:root {
  --ink: #1f2933;
  --muted: #68717d;
  --line: #d7d9dd;
  --panel: #fbfbfa;
  --surface: #f3f4f2;
  --surface-strong: #e8ebe8;
  --accent: #2f3a45;
  --accent-hover: #1f2933;
  --accent-soft: #edf0ee;
  --danger: #b4232a;
  --floor: #ead8b9;
  --desk: #c99252;
  --desk-edge: #8b6238;
  --chair: #35424d;
  --shadow: 0 14px 36px rgba(31, 41, 51, 0.09);
  --shadow-soft: 0 6px 18px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1080px;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: var(--surface);
}

button,
input,
textarea {
  font: inherit;
}

button,
.file-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfbfa;
  padding: 0 16px;
  cursor: pointer;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    color 140ms ease;
}

button:hover,
.file-button:hover {
  border-color: #aeb4ba;
  background: #f4f5f3;
  box-shadow: var(--shadow-soft);
}

.primary-btn {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.primary-btn:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 24px;
  background: rgba(251, 251, 250, 0.96);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.15;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.file-button {
  display: inline-grid;
  place-items: center;
}

.file-button input {
  display: none;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 310px minmax(700px, 1fr) auto;
  gap: 16px;
  padding: 16px;
}

.panel,
.room-section {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  border-radius: 10px;
  padding: 18px;
  overflow: visible;
}

.student-panel,
.tools-panel {
  width: 310px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  transition:
    width 180ms ease,
    padding 180ms ease;
}

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

.panel-heading h2 {
  font-size: 18px;
}

.count-pill {
  min-width: 30px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 9px;
  text-align: center;
  font-weight: 700;
}

.collapse-btn {
  width: 34px;
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.tools-content {
  display: block;
}

.tools-panel.collapsed {
  width: 64px;
  padding: 14px;
  overflow: hidden;
}

.tools-panel.collapsed .panel-heading {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin-bottom: 0;
}

.tools-panel.collapsed h2,
.tools-panel.collapsed .tools-content {
  display: none;
}

.tools-panel.collapsed .collapse-btn {
  transform: rotate(180deg);
}

.add-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  padding: 10px 12px;
}

input:focus,
textarea:focus {
  border-color: #9ca3aa;
  outline: 3px solid rgba(47, 58, 69, 0.12);
}

textarea {
  resize: vertical;
}

.bulk-input {
  margin-top: 10px;
}

.wide-btn {
  width: 100%;
  margin-top: 10px;
}

.student-list {
  list-style: none;
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
}

.student-item {
  min-height: 42px;
  display: grid;
  grid-template-columns: 22px 1fr 34px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 6px 0 10px;
}

.student-item.assigned {
  color: #6b7280;
  background: #f3f4f2;
}

.student-item button {
  min-height: 30px;
  padding: 0;
  color: var(--danger);
}

.drag-handle {
  color: #9aa4b2;
  cursor: grab;
}

.room-section {
  min-height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  overflow: hidden;
  min-width: 0;
}

.room-toolbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
}

.room-toolbar label {
  color: var(--muted);
  font-size: 13px;
}

.room-toolbar input {
  width: 320px;
  border: 0;
  padding: 4px 0;
  font-weight: 700;
}

.zoom-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.zoom-tools button {
  width: 38px;
  min-height: 34px;
  padding: 0;
}

.room-scroll {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6px 10px 10px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.42) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.42) 1px, transparent 1px), var(--surface-strong);
  background-size: 32px 32px;
}

.room-frame {
  position: relative;
  flex: 0 0 auto;
}

.room {
  position: relative;
  width: 1500px;
  height: 1000px;
  overflow: hidden;
  border: 8px solid #cfc4b2;
  border-radius: 10px;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(135, 91, 41, 0.1) 0,
      rgba(135, 91, 41, 0.1) 1px,
      transparent 1px,
      transparent 72px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(135, 91, 41, 0.08) 0,
      rgba(135, 91, 41, 0.08) 1px,
      transparent 1px,
      transparent 170px
    ),
    var(--floor);
  box-shadow:
    inset 0 0 38px rgba(109, 76, 37, 0.12),
    0 12px 30px rgba(31, 41, 51, 0.08);
  transform-origin: top left;
}

.whiteboard {
  position: absolute;
  top: 14px;
  left: 475px;
  width: 550px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 4px solid #8d969c;
  border-radius: 4px;
  color: #59626b;
  background: #f8f8f6;
  font-size: 12px;
  font-weight: 700;
}

.teacher-desk {
  position: absolute;
  top: 770px;
  left: 1334px;
  width: 76px;
  height: 150px;
  display: grid;
  place-items: center;
  border: 2px solid var(--desk-edge);
  border-radius: 8px;
  color: #3f2c1e;
  background: linear-gradient(#dfb678, var(--desk));
  box-shadow: 0 8px 16px rgba(69, 41, 18, 0.16);
  cursor: grab;
  font-weight: 800;
  text-align: center;
  touch-action: none;
  user-select: none;
  z-index: 4;
}

.teacher-desk:active {
  cursor: grabbing;
}

.plant {
  position: absolute;
  top: 28px;
  width: 62px;
  height: 84px;
  pointer-events: none;
}

.plant-left {
  left: 48px;
}

.plant::before {
  content: "";
  position: absolute;
  left: 16px;
  bottom: 0;
  width: 30px;
  height: 34px;
  border: 2px solid #9a6238;
  border-radius: 6px 6px 12px 12px;
  background: linear-gradient(#c78650, #9d5d35);
}

.plant::after,
.plant span::before,
.plant span::after {
  content: "";
  position: absolute;
  border-radius: 999px 999px 999px 0;
  background: #4f9b45;
  box-shadow:
    10px -8px 0 #3e8739,
    -10px -6px 0 #63ad55,
    3px -20px 0 #5faa4d;
}

.plant::after {
  left: 20px;
  top: 18px;
  width: 22px;
  height: 34px;
  transform: rotate(25deg);
}

.plant span::before {
  left: 13px;
  top: 24px;
  width: 20px;
  height: 32px;
  transform: rotate(-48deg);
}

.plant span::after {
  left: 29px;
  top: 20px;
  width: 18px;
  height: 30px;
  transform: rotate(78deg);
}

.desk-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.element-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.room-element {
  position: absolute;
  border: 1px solid rgba(31, 41, 51, 0.2);
  border-radius: 999px;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  box-shadow: 0 8px 18px rgba(31, 41, 51, 0.12);
}

.room-element:active {
  cursor: grabbing;
}

.nile-river {
  display: grid;
  place-items: center;
  overflow: visible;
  border: 0;
  color: #134253;
  background:
    radial-gradient(ellipse at 18% 20%, rgba(255, 255, 255, 0.42) 0 4%, transparent 5%),
    radial-gradient(ellipse at 70% 38%, rgba(255, 255, 255, 0.35) 0 5%, transparent 6%),
    radial-gradient(ellipse at 28% 64%, rgba(255, 255, 255, 0.36) 0 4%, transparent 5%),
    linear-gradient(90deg, #5fd4df 0 13%, #2db9cf 14% 25%, #129ab4 42%, #0c8fac 58%, #28bad0 78%, #70dce4 100%);
  box-shadow:
    inset 12px 0 0 rgba(255, 239, 181, 0.82),
    inset -12px 0 0 rgba(255, 239, 181, 0.82),
    inset 24px 0 0 rgba(255, 248, 212, 0.58),
    inset -24px 0 0 rgba(255, 248, 212, 0.58),
    0 8px 18px rgba(31, 41, 51, 0.12);
}

.nile-river::before,
.nile-river::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-repeat: repeat-y;
  pointer-events: none;
}

.nile-river::before {
  opacity: 0.72;
  background-image: url("data:image/svg+xml,%3Csvg width='150' height='260' viewBox='0 0 150 260' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M48 0 C78 28 24 54 54 84 C86 116 33 139 58 168 C90 205 31 224 62 260' fill='none' stroke='%236fdde6' stroke-width='30' stroke-linecap='round' opacity='.58'/%3E%3Cpath d='M107 0 C79 32 128 58 101 88 C73 122 125 148 94 184 C65 218 119 232 88 260' fill='none' stroke='%2389e7ee' stroke-width='22' stroke-linecap='round' opacity='.42'/%3E%3C/svg%3E");
  background-size: 100% 260px;
}

.nile-river::after {
  opacity: 0.9;
  background-image: url("data:image/svg+xml,%3Csvg width='150' height='220' viewBox='0 0 150 220' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M38 28 C54 17 70 18 84 28' fill='none' stroke='white' stroke-width='7' stroke-linecap='round' opacity='.56'/%3E%3Cpath d='M62 74 C76 64 94 64 108 74' fill='none' stroke='white' stroke-width='6' stroke-linecap='round' opacity='.42'/%3E%3Cpath d='M28 126 C45 116 66 117 82 127' fill='none' stroke='white' stroke-width='7' stroke-linecap='round' opacity='.5'/%3E%3Cpath d='M72 176 C88 166 108 166 124 176' fill='none' stroke='white' stroke-width='6' stroke-linecap='round' opacity='.44'/%3E%3C/svg%3E");
  background-size: 100% 220px;
}

.dig-sight {
  display: grid;
  place-items: center;
  overflow: visible;
  border-radius: 8px;
  color: #4a3624;
  background:
    radial-gradient(circle at 22% 28%, rgba(122, 88, 52, 0.28) 0 3px, transparent 4px),
    radial-gradient(circle at 72% 42%, rgba(122, 88, 52, 0.22) 0 4px, transparent 5px),
    radial-gradient(circle at 44% 72%, rgba(255, 255, 255, 0.22) 0 5px, transparent 6px),
    linear-gradient(135deg, #dfc48c, #cda86d 52%, #b88c55);
}

.dig-sight::before {
  content: "";
  position: absolute;
  inset: 12%;
  border: 2px dashed rgba(78, 55, 34, 0.36);
  border-radius: 6px;
  pointer-events: none;
}

.element-label {
  position: relative;
  z-index: 1;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  padding: 5px 12px;
  color: #17324c;
  font-size: 14px;
  font-weight: 800;
}

.element-label-input {
  width: min(78%, 120px);
  min-height: 38px;
  border: 1px solid rgba(78, 55, 34, 0.24);
  border-radius: 8px;
  color: #4a3624;
  background: rgba(255, 255, 255, 0.78);
  padding: 6px 10px;
  text-align: center;
}

.element-label-input:focus {
  border-color: rgba(78, 55, 34, 0.46);
  outline: 3px solid rgba(78, 55, 34, 0.14);
}

.element-remove {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 30px;
  min-height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  color: var(--danger);
  background: #fff;
  z-index: 2;
}

.element-resize {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 20px;
  height: 20px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 3px 8px rgba(31, 41, 51, 0.18);
  cursor: nwse-resize;
  z-index: 2;
}

.desk {
  position: absolute;
  width: 122px;
  height: 77px;
  padding: 0;
  border: 2px solid var(--desk-edge);
  border-radius: 8px;
  background: linear-gradient(#dfb678, var(--desk));
  box-shadow: 0 8px 14px rgba(69, 41, 18, 0.16);
  cursor: grab;
  pointer-events: auto;
  user-select: none;
  touch-action: none;
}

.rotate-desk-btn {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 34px;
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border-color: #c8ccd1;
  border-radius: 999px;
  color: var(--accent);
  background: #fff;
  box-shadow: 0 4px 10px rgba(31, 41, 51, 0.14);
  font-size: 17px;
  font-weight: 800;
  z-index: 5;
}

.desk:active {
  cursor: grabbing;
}

.desk::before,
.desk::after {
  content: "";
  position: absolute;
  bottom: -22px;
  width: 50px;
  height: 22px;
  border-radius: 0 0 12px 12px;
  background: var(--chair);
}

.desk::before {
  left: 22px;
}

.desk::after {
  right: 22px;
}

.desk.rotated::before,
.desk.rotated::after {
  right: -22px;
  bottom: auto;
  width: 22px;
  height: 50px;
  border-radius: 0 12px 12px 0;
}

.desk.rotated::before {
  left: auto;
  top: 22px;
}

.desk.rotated::after {
  top: auto;
  bottom: 22px;
}

.desk.rotated-left::before,
.desk.rotated-left::after {
  left: -22px;
  right: auto;
  border-radius: 12px 0 0 12px;
}

.desk.rotated-left::before {
  top: 22px;
}

.desk.rotated-left::after {
  top: auto;
  bottom: 22px;
}

.desk-name {
  position: absolute;
  top: 17px;
  left: 12px;
  width: calc(100% - 24px);
  min-height: 36px;
  border: 0;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  padding: 4px 8px;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 2px 7px rgba(31, 41, 51, 0.12);
}

.desk.rotated .desk-name {
  top: 50px;
}

.desk-name:focus {
  outline: 2px solid var(--accent);
}

.desk.empty .desk-name {
  color: #7c8798;
  font-weight: 600;
}

.desk.drop-ready {
  outline: 4px solid rgba(47, 58, 69, 0.22);
}

.hint {
  margin: 0;
  padding: 12px 18px;
  color: #4d5660;
  border-top: 1px solid var(--line);
  background: #f7f7f5;
  text-align: center;
}

.tool-group {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 18px;
}

.tool-group:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.tool-group h3 {
  margin-bottom: 12px;
  font-size: 14px;
}

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

.layout-option {
  min-height: 78px;
  height: auto;
  padding: 12px 10px;
}

.layout-option.active {
  border-color: #9ca3aa;
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 800;
}

.setting-row output {
  color: var(--accent);
  font-weight: 800;
}

.setting-row {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.setting-row input {
  color: var(--ink);
}

.checkbox-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.tool-toggle {
  min-height: 44px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-weight: 700;
}

.tool-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

@media print {
  body {
    min-width: 0;
    background: #fff;
  }

  .topbar,
  .student-panel,
  .tools-panel,
  .room-toolbar,
  .hint {
    display: none;
  }

  .workspace {
    display: block;
    padding: 0;
  }

  .room-section {
    border: 0;
    box-shadow: none;
  }

  .room-scroll {
    padding: 0;
    overflow: visible;
    background: #fff;
  }

  .room {
    transform: scale(0.72);
    transform-origin: top left;
  }
}
