:root {
  color-scheme: light;
  --bg: #e7ecee;
  --ink: #1e252b;
  --muted: #66707a;
  --line: #c8d1d6;
  --shadow: 0 18px 42px rgba(31, 39, 45, 0.16);
  --focus: #1d6552;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101418;
  --ink: #e7edf2;
  --muted: #9ba8b2;
  --line: #34404a;
  --shadow: 0 22px 52px rgba(0, 0, 0, 0.48);
  --focus: #74baa5;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.file-button {
  min-height: 30px;
  border: 1px solid #27313a;
  border-radius: 7px;
  background: #26323a;
  color: #ffffff;
  padding: 5px 9px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.file-button:hover {
  background: #12191f;
}

button.quiet {
  border-color: #a8b1b8;
  background: #ffffff;
  color: #27313a;
}

button.quiet:hover {
  background: #f1f4f5;
}

.app-shell {
  height: 100vh;
}

.board-frame {
  height: 100vh;
  padding: 10px;
}

.wall-panel {
  position: relative;
  height: 100%;
  overflow: hidden;
  border: 1px solid #9fabb2;
  background: #f8f7f1;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}

.board-header {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 30;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  pointer-events: none;
}

.board-title,
.unit-buttons,
.board-actions {
  pointer-events: auto;
}

.board-title {
  display: flex;
  align-items: center;
  padding: 0;
}

.board-actions p {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.25;
}

.unit-buttons,
.board-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.unit-buttons {
  justify-content: flex-start;
}

.board-actions {
  justify-content: flex-end;
}

.unit-add-button {
  border-color: var(--course-color);
  background: var(--course-color);
  color: #ffffff;
  min-width: 118px;
}

.unit-add-button:hover {
  filter: brightness(0.88);
}

.lesson-add-button {
  border-color: #9b6d16;
  background: #b88724;
  color: #ffffff;
  min-width: 128px;
}

.lesson-add-button:hover {
  background: #8e6417;
}

.badge-library-button {
  min-height: 32px;
  border-color: #b74b43;
  background: #b74b43;
  color: #ffffff;
  box-shadow: 0 7px 18px rgba(142, 47, 42, 0.18);
  font-size: 0.82rem;
  font-weight: 700;
}

.badge-library-button:hover,
.badge-library-button.is-open {
  background: #8e2f2a;
}

.file-button {
  display: inline-flex;
  align-items: center;
}

.file-button input {
  display: none;
}

.zoom-control {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 8px;
  min-height: 30px;
  font-size: 0.78rem;
}

.zoom-control input {
  width: 94px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  border-color: rgba(39, 49, 58, 0.22);
  background: rgba(255, 255, 255, 0.9);
  color: #4f5961;
  padding: 4px 8px;
  font-size: 0.78rem;
  font-weight: 700;
}

.theme-toggle:hover {
  background: #ffffff;
}

.theme-toggle-icon {
  position: relative;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #d7a72f;
  box-shadow: 0 0 0 3px rgba(215, 167, 47, 0.16);
}

.theme-toggle-text {
  min-width: 30px;
  text-align: left;
}

.wall-scroll {
  height: 100%;
  overflow: auto;
  cursor: grab;
  background:
    linear-gradient(90deg, rgba(39, 49, 58, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(39, 49, 58, 0.08) 1px, transparent 1px),
    #f8f7f1;
  background-size: 28px 28px;
}

.wall-scroll.panning {
  cursor: grabbing;
}

.wall-viewport {
  position: relative;
  width: 4440px;
  height: 2800px;
}

.wall-space {
  position: absolute;
  top: 0;
  left: 0;
  width: 4440px;
  height: 2800px;
  transform-origin: top left;
}

.lane-layer,
.cards-layer,
#sketchCanvas {
  position: absolute;
  inset: 0;
}

.lane-layer {
  z-index: 1;
}

#sketchCanvas {
  z-index: 5;
  pointer-events: none;
}

.cards-layer {
  z-index: 10;
}

.quarter-lane {
  position: absolute;
  top: 82px;
  bottom: 60px;
  border-left: 2px solid rgba(30, 37, 43, 0.18);
  border-right: 1px solid rgba(30, 37, 43, 0.1);
  background: rgba(255, 255, 255, 0.28);
}

.quarter-lane header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  min-height: 68px;
  padding: 14px 16px;
  background: rgba(255, 253, 248, 0.92);
  border-bottom: 1px solid rgba(30, 37, 43, 0.14);
}

.quarter-lane strong {
  display: block;
  font-size: 1.12rem;
}

.quarter-lane span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.3;
  margin-top: 4px;
}

.quarter-lane .months {
  color: #27313a;
  font-weight: 700;
  text-align: right;
  min-width: 72px;
}

.planning-card {
  position: absolute;
  width: 720px;
  height: 420px;
  border: 1px solid rgba(30, 37, 43, 0.2);
  border-top: 7px solid var(--course-color);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 26px rgba(31, 39, 45, 0.16);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: text;
}

.planning-card.minimized {
  height: 82px;
  overflow: visible;
}

.planning-card.selected {
  outline: 3px solid rgba(29, 101, 82, 0.44);
  box-shadow: var(--shadow);
}

.unit-card-handle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 12px;
  border-bottom: 1px solid #d9e0e3;
  background: #f8faf9;
  cursor: grab;
}

.unit-card-handle:active {
  cursor: grabbing;
}

.handle-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.compact-handle {
  min-height: 100%;
  border-bottom: 0;
}

.planning-card.minimized .compact-handle {
  height: 82px;
  border-radius: 0 0 8px 8px;
  border-bottom: 1px solid #d9e0e3;
}

.compact-summary {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: center;
}

.compact-summary strong {
  min-width: 0;
  line-height: 1.2;
  overflow-wrap: anywhere;
  white-space: normal;
}

.minimize-unit,
.delete-unit {
  min-height: 30px;
  background: #ffffff;
  padding: 5px 9px;
  font-weight: 700;
}

.minimize-unit {
  border-color: #9fabaf;
  color: #26323a;
}

.delete-unit {
  min-height: 36px;
  border-color: #b74b43;
  color: #8e2f2a;
}

.minimize-unit:hover {
  background: #eef2f3;
}

.delete-unit:hover {
  background: #f9ecea;
}

.unit-card-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.unit-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.unit-title-field {
  grid-column: 1 / -1;
}

.unit-field,
.unit-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #4b555f;
  font-size: 0.9rem;
  font-weight: 700;
}

.unit-box {
  border: 1px solid #d7dde0;
  border-radius: 7px;
  background: #fbfcfc;
  padding: 10px;
  margin-bottom: 9px;
}

.unit-field input,
.unit-field select,
.unit-box textarea {
  width: 100%;
  border: 1px solid #a8b1b8;
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 8px 9px;
  font-size: 0.95rem;
}

.unit-field input {
  font-size: 1.08rem;
  font-weight: 700;
}

.unit-box textarea {
  resize: none;
  overflow: hidden;
  min-height: 72px;
  line-height: 1.35;
}

.detected-links {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding-top: 2px;
  font-size: 0.82rem;
  line-height: 1.25;
}

.detected-links[hidden] {
  display: none;
}

.detected-links > span {
  flex: 0 0 auto;
  color: #64717a;
  font-weight: 800;
}

.detected-link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.detected-link-list a {
  max-width: 100%;
  overflow-wrap: anywhere;
  border: 1px solid rgba(39, 83, 103, 0.24);
  border-radius: 999px;
  background: rgba(245, 250, 251, 0.88);
  color: #24566e;
  padding: 3px 8px;
  font-weight: 800;
  text-decoration: none;
}

.detected-link-list a:hover {
  border-color: rgba(39, 83, 103, 0.44);
  background: #ffffff;
  text-decoration: underline;
}

.course-pill,
.type-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #ffffff;
  background: var(--course-color);
}

.type-pill {
  color: #27313a;
  background: #e7ecef;
}

.badge-zone-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-bottom: 2px;
}

.badge-zone {
  min-height: 92px;
  border: 1px solid #cdd6da;
  border-radius: 7px;
  background: #ffffff;
  padding: 8px;
}

.badge-zone.needs-badge {
  border-color: #c76760;
  background: #fff1ef;
}

.badge-zone-heading {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.badge-zone-heading h4 {
  margin: 0;
  font-size: 0.84rem;
}

.badge-zone-heading span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-zone-body {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.empty-badge-slot {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  border: 1px dashed #b74b43;
  border-radius: 999px;
  color: #8e2f2a;
  background: #ffffff;
  padding: 4px 8px;
  font-size: 0.78rem;
  font-weight: 700;
}

.applied-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid color-mix(in srgb, var(--badge-color) 55%, #ffffff);
  border-left: 5px solid var(--badge-color);
  border-radius: 999px;
  background: #ffffff;
  color: #39454e;
  padding: 4px 7px 4px 6px;
  font-size: 0.78rem;
  line-height: 1.15;
  cursor: help;
}

.applied-badge button {
  display: inline-grid;
  place-items: center;
  min-height: 18px;
  width: 18px;
  border: 0;
  border-radius: 999px;
  background: #e7ecef;
  color: #39454e;
  padding: 0;
  font-size: 0.72rem;
}

.unit-card-footer {
  display: flex;
  justify-content: flex-end;
  padding: 12px 0 2px;
  margin-top: 10px;
  border-top: 1px solid #dce2e5;
}

.attached-lesson-dock {
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-top: 1px solid #d9d0ad;
  background: #fffaf0;
}

.attached-lesson-dock.dock-preview-target {
  background: #fff3cf;
  box-shadow: inset 0 0 0 2px rgba(184, 135, 36, 0.28);
}

.planning-card.minimized .attached-lesson-dock {
  position: absolute;
  left: 12px;
  right: 12px;
  top: calc(100% - 7px);
  min-height: 52px;
  align-items: flex-start;
  padding: 0;
  border-top: 0;
  background: transparent;
}

.lesson-dock-label {
  flex: 0 0 auto;
  color: #6f5519;
  font-size: 0.76rem;
  font-weight: 700;
}

.planning-card.minimized .lesson-dock-label {
  display: none;
}

.attached-lesson-row {
  min-width: 0;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 2px 4px;
}

.planning-card.minimized .attached-lesson-row {
  width: 100%;
  overflow: visible;
  padding: 0;
}

.lesson-sticky {
  width: 48px;
  height: 48px;
  min-height: 48px;
  flex: 0 0 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid #b9922f;
  border-radius: 4px;
  background: #f1ca61;
  color: #2d2718;
  box-shadow: 0 5px 10px rgba(99, 75, 19, 0.18);
  padding: 4px;
  white-space: normal;
  touch-action: none;
}

.lesson-sticky span {
  max-height: 30px;
  overflow: hidden;
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1.05;
  text-align: center;
}

.lesson-sticky small {
  color: #5f4917;
  font-size: 0.52rem;
  font-weight: 800;
  line-height: 1;
}

.lesson-sticky:hover {
  background: #e6ba47;
}

.lesson-sticky.dragging {
  opacity: 0.82;
  transform: translateY(-3px) scale(1.04);
  cursor: grabbing;
}

.lesson-dock-preview {
  opacity: 0.9;
  pointer-events: none;
}

.lesson-card {
  position: absolute;
  width: 360px;
  height: 300px;
  border: 1px solid #b6902d;
  border-radius: 7px;
  background: #f4cf68;
  box-shadow: 0 13px 28px rgba(74, 61, 31, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: text;
}

.lesson-card.selected {
  outline: 3px solid rgba(148, 104, 19, 0.45);
  box-shadow: 0 18px 36px rgba(74, 61, 31, 0.28);
}

.lesson-card.attached-editor {
  border-color: #8d6a18;
  box-shadow: 0 15px 32px rgba(74, 61, 31, 0.24), 0 0 0 4px rgba(255, 246, 211, 0.86);
}

.lesson-card.collapsed {
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.lesson-card.collapsed::before {
  content: attr(data-short-title);
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #b9922f;
  border-radius: 4px;
  background: #f1ca61;
  color: #2d2718;
  box-shadow: 0 5px 10px rgba(99, 75, 19, 0.18);
  padding: 4px;
  text-align: center;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.05;
  white-space: normal;
}

.lesson-card.collapsed::after {
  content: attr(data-date-label);
  position: absolute;
  left: 5px;
  top: 42px;
  min-width: 44px;
  min-height: 14px;
  display: grid;
  place-items: center;
  border: 1px solid #b9922f;
  border-radius: 999px;
  background: #fff6d3;
  color: #5f4917;
  font-size: 0.5rem;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

.lesson-card.collapsed[data-date-label=""]::after {
  display: none;
}

.lesson-card.collapsed.selected {
  outline: 0;
  box-shadow: none;
}

.lesson-card.collapsed.selected::before {
  outline: 3px solid rgba(148, 104, 19, 0.45);
}

.lesson-card.dock-previewing {
  opacity: 0;
}

.lesson-card.collapsed .lesson-card-handle,
.lesson-card.collapsed .lesson-card-body,
.lesson-card.collapsed .lesson-card-footer {
  display: none;
}

.lesson-card-handle {
  flex: 0 0 auto;
  min-height: 44px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(126, 95, 24, 0.32);
  background: rgba(255, 239, 177, 0.76);
  cursor: grab;
}

.lesson-card-handle:active {
  cursor: grabbing;
}

.lesson-type-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  color: #2d2718;
  background: #fff6d3;
  border: 1px solid rgba(124, 93, 23, 0.26);
  font-size: 0.82rem;
  font-weight: 700;
}

.lesson-window-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.collapse-lesson,
.delete-lesson {
  min-height: 30px;
  border-color: #8b6216;
  background: #fff8dd;
  color: #604512;
  padding: 5px 9px;
  font-weight: 700;
}

.collapse-lesson:hover,
.delete-lesson:hover {
  background: #f9e7a9;
}

.lesson-card-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

.lesson-card-footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  padding: 9px 12px 10px;
  border-top: 1px solid rgba(126, 95, 24, 0.32);
  background: rgba(255, 239, 177, 0.5);
}

.lesson-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #604512;
  font-size: 0.86rem;
  font-weight: 700;
}

.lesson-notes-field {
  flex: 1;
}

.lesson-field input,
.lesson-field textarea,
.lesson-date-button {
  width: 100%;
  border: 1px solid #a88125;
  border-radius: 6px;
  background: #fffdf3;
  color: #2d2718;
  padding: 8px 9px;
  font-size: 0.95rem;
}

.lesson-field input {
  font-size: 1.04rem;
  font-weight: 700;
}

.lesson-date-button {
  min-height: 38px;
  text-align: left;
  font-weight: 700;
}

.lesson-date-button:hover {
  background: #fff6d3;
}

.lesson-field textarea {
  flex: 1;
  min-height: 142px;
  resize: none;
  line-height: 1.35;
}

.badge-window {
  position: absolute;
  z-index: 45;
  width: min(340px, calc(100vw - 32px));
  max-height: min(66vh, 680px);
  overflow: hidden;
  border: 1px solid #aeb8bf;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 34px rgba(31, 39, 45, 0.22);
}

.badge-window-header {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid #dce2e5;
  background: #f8faf9;
  cursor: default;
}

.badge-window h2 {
  margin: 0;
  font-size: 0.98rem;
}

.badge-window.collapsed {
  display: none;
}

.badge-window.collapsed .badge-library {
  display: none;
}

.badge-window.collapsed .badge-window-header {
  border-bottom: 0;
}

.badge-library {
  max-height: calc(min(66vh, 680px) - 42px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
}

.badge-group {
  border-top: 1px solid #dce2e5;
  padding-top: 10px;
}

.badge-group:first-child {
  border-top: 0;
  padding-top: 0;
}

.badge-group h3 {
  margin: 0;
  font-size: 0.92rem;
}

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.badge-token {
  min-height: 32px;
  border: 1px solid color-mix(in srgb, var(--badge-color) 58%, #ffffff);
  border-left: 5px solid var(--badge-color);
  border-radius: 999px;
  background: #ffffff;
  color: #27313a;
  padding: 5px 9px 5px 8px;
  font-size: 0.82rem;
  cursor: grab;
  text-align: left;
  white-space: normal;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge-token[data-badge-detail] {
  cursor: grab;
}

.badge-token:hover {
  background: color-mix(in srgb, var(--badge-color) 10%, #ffffff);
}

.badge-token.is-used {
  background: color-mix(in srgb, var(--badge-color) 7%, #ffffff);
}

.badge-token-label {
  min-width: 0;
}

.badge-used-mark {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  border-radius: 999px;
  background: var(--badge-color);
  box-shadow: 0 0 0 2px #ffffff;
}

.badge-used-mark::after {
  content: "";
  width: 5px;
  height: 8px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg);
}

.badge-token:active {
  cursor: grabbing;
}

.badge-detail-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: min(430px, calc(100vw - 24px));
  max-height: min(44vh, 360px);
  overflow: auto;
  border: 1px solid #24313a;
  border-radius: 8px;
  background: rgba(24, 31, 37, 0.97);
  color: #ffffff;
  box-shadow: 0 16px 42px rgba(18, 24, 28, 0.3);
  padding: 11px 12px;
  font-size: 0.84rem;
  line-height: 1.42;
  pointer-events: none;
}

.badge-detail-tooltip[hidden] {
  display: none;
}

.calendar-button {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 60;
  min-height: 34px;
  border-color: #315f47;
  background: #315f47;
  color: #ffffff;
  box-shadow: 0 9px 24px rgba(31, 39, 45, 0.22);
  font-size: 0.84rem;
  font-weight: 700;
}

.calendar-button:hover,
.calendar-button.is-open {
  background: #244a36;
}

.calendar-panel,
.calendar-day-window,
.lesson-date-picker {
  position: absolute;
  z-index: 58;
  border: 1px solid rgba(53, 73, 64, 0.52);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(31, 39, 45, 0.24);
  backdrop-filter: blur(7px);
}

.calendar-panel[hidden],
.calendar-day-window[hidden],
.lesson-date-picker[hidden] {
  display: none;
}

.calendar-panel {
  right: 14px;
  bottom: 58px;
  width: clamp(460px, 25vw, 620px);
  height: clamp(375px, 37.5vh, 540px);
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px;
  background: rgba(247, 250, 247, 0.84);
  color: #26323a;
}

.lesson-date-picker {
  z-index: 72;
  width: clamp(230px, 12.5vw, 310px);
  height: clamp(250px, 25vh, 360px);
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px;
  background: rgba(247, 250, 247, 0.92);
  color: #26323a;
}

.calendar-panel-header {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 30px;
  gap: 6px;
  align-items: center;
}

.calendar-nav-button {
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  border-color: #9fabaf;
  background: rgba(255, 255, 255, 0.78);
  color: #27313a;
  font-weight: 800;
}

.calendar-nav-button:hover {
  background: #ffffff;
}

.calendar-selectors {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(62px, 0.65fr);
  gap: 5px;
}

.calendar-selectors select {
  min-width: 0;
  width: 100%;
  border: 1px solid #a8b1b8;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.88);
  color: #27313a;
  padding: 5px 6px;
  font-size: 0.78rem;
  font-weight: 700;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.calendar-weekdays span {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.calendar-panel .calendar-weekdays span {
  font-size: 0.68rem;
}

.calendar-grid {
  flex: 1;
  align-content: start;
  overflow: auto;
}

.calendar-panel .calendar-grid {
  grid-auto-rows: minmax(44px, 1fr);
  align-content: stretch;
  gap: 7px;
}

.calendar-day,
.calendar-day-spacer {
  min-width: 0;
  min-height: 28px;
}

.calendar-panel .calendar-day,
.calendar-panel .calendar-day-spacer {
  min-height: 44px;
}

.calendar-day {
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid rgba(159, 171, 178, 0.72);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
  color: #27313a;
  padding: 2px;
  font-size: 0.76rem;
  font-weight: 800;
}

.calendar-panel .calendar-day {
  font-size: 1rem;
}

.calendar-day:hover {
  background: #ffffff;
}

.calendar-day.has-lessons {
  border-color: #2d7f54;
  background: rgba(45, 127, 84, 0.9);
  color: #ffffff;
}

.calendar-day.selected {
  outline: 3px solid rgba(45, 127, 84, 0.28);
}

.calendar-day-window {
  right: calc(24px + clamp(460px, 25vw, 620px));
  bottom: 58px;
  width: clamp(310px, 22vw, 430px);
  height: clamp(190px, 24vh, 310px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    rgba(24, 42, 32, 0.94);
  background-size: 18px 18px;
  color: #f1f6ee;
}

.calendar-day-header {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(226, 237, 226, 0.2);
}

.calendar-day-header strong {
  font-size: 0.92rem;
}

.calendar-day-board {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 9px;
  padding: 10px;
}

.calendar-empty-day {
  margin: 8px 0;
  color: rgba(241, 246, 238, 0.74);
  font-size: 0.86rem;
  font-weight: 700;
}

.calendar-lesson-icon {
  width: 76px;
  min-height: 74px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  border: 1px solid #b9922f;
  border-left: 6px solid var(--course-color);
  border-radius: 5px;
  background: #f1ca61;
  color: #2d2718;
  box-shadow: 0 7px 16px rgba(9, 18, 12, 0.25);
  padding: 7px 6px;
  text-align: left;
  white-space: normal;
}

.calendar-lesson-icon:hover {
  background: #e6ba47;
}

.calendar-lesson-icon span {
  max-height: 34px;
  overflow: hidden;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.08;
}

.calendar-lesson-icon small {
  max-height: 24px;
  overflow: hidden;
  color: #5f4917;
  font-size: 0.54rem;
  font-weight: 800;
  line-height: 1.1;
}

.lesson-date-picker-footer {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding-top: 2px;
}

.lesson-date-picker-footer button {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 0.76rem;
}

html[data-theme="dark"] button,
html[data-theme="dark"] .file-button {
  border-color: #48545e;
  background: #252d35;
  color: #eef4f8;
}

html[data-theme="dark"] button:hover,
html[data-theme="dark"] .file-button:hover {
  background: #313b44;
}

html[data-theme="dark"] button.quiet {
  border-color: #46525d;
  background: #171d23;
  color: #dbe4ea;
}

html[data-theme="dark"] button.quiet:hover {
  background: #222a31;
}

html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .zoom-control {
  border-color: rgba(178, 190, 200, 0.18);
  background: rgba(19, 24, 29, 0.84);
  color: #b7c2cb;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

html[data-theme="dark"] .theme-toggle:hover {
  background: rgba(28, 35, 42, 0.95);
}

html[data-theme="dark"] .theme-toggle-icon {
  background: #d8e1ec;
  box-shadow: inset -5px -3px 0 #171d23, 0 0 0 3px rgba(120, 151, 176, 0.16);
}

html[data-theme="dark"] .badge-library-button {
  border-color: #b86159;
  background: #9d514b;
  color: #fff8f7;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .badge-library-button:hover,
html[data-theme="dark"] .badge-library-button.is-open {
  background: #8f413c;
}

html[data-theme="dark"] .calendar-button {
  border-color: #4a8162;
  background: #315f47;
  color: #f1f6ee;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
}

html[data-theme="dark"] .calendar-button:hover,
html[data-theme="dark"] .calendar-button.is-open {
  background: #244a36;
}

html[data-theme="dark"] .calendar-panel,
html[data-theme="dark"] .lesson-date-picker {
  border-color: rgba(168, 184, 176, 0.26);
  background: rgba(19, 25, 29, 0.82);
  color: #e7edf2;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.46);
}

html[data-theme="dark"] .calendar-nav-button,
html[data-theme="dark"] .calendar-selectors select {
  border-color: #46525d;
  background: rgba(24, 31, 37, 0.9);
  color: #dbe4ea;
}

html[data-theme="dark"] .calendar-nav-button:hover {
  background: #222a31;
}

html[data-theme="dark"] .calendar-day {
  border-color: rgba(157, 171, 182, 0.28);
  background: rgba(31, 38, 45, 0.78);
  color: #dbe4ea;
}

html[data-theme="dark"] .calendar-day:hover {
  background: rgba(45, 55, 64, 0.94);
}

html[data-theme="dark"] .calendar-day.has-lessons {
  border-color: #4a9b6a;
  background: rgba(45, 127, 84, 0.86);
  color: #ffffff;
}

html[data-theme="dark"] .calendar-day-window {
  border-color: rgba(195, 214, 198, 0.26);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .lesson-date-button {
  border-color: #7a6324;
  background: #2a2413;
  color: #f6e7ad;
}

html[data-theme="dark"] .lesson-date-button:hover {
  background: #352d18;
}

html[data-theme="dark"] .wall-panel {
  border-color: #2b353e;
  background: #151a20;
  box-shadow: inset 0 0 0 1px rgba(221, 230, 237, 0.04);
}

html[data-theme="dark"] .board-title {
  color: #eef4f8;
}

html[data-theme="dark"] .wall-scroll {
  background:
    linear-gradient(90deg, rgba(199, 211, 220, 0.07) 1px, transparent 1px),
    linear-gradient(0deg, rgba(199, 211, 220, 0.07) 1px, transparent 1px),
    #151a20;
}

html[data-theme="dark"] .quarter-lane {
  border-left-color: rgba(219, 229, 237, 0.18);
  border-right-color: rgba(219, 229, 237, 0.08);
  background: rgba(255, 255, 255, 0.035);
}

html[data-theme="dark"] .quarter-lane header {
  background: rgba(20, 26, 31, 0.94);
  border-bottom-color: rgba(219, 229, 237, 0.12);
}

html[data-theme="dark"] .quarter-lane .months {
  color: #dbe4ea;
}

html[data-theme="dark"] .planning-card {
  border-color: rgba(219, 229, 237, 0.18);
  background: rgba(27, 33, 39, 0.985);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.38);
}

html[data-theme="dark"] .planning-card.selected {
  outline-color: rgba(116, 186, 165, 0.42);
  box-shadow: var(--shadow);
}

html[data-theme="dark"] .unit-card-handle {
  border-bottom-color: #34404a;
  background: #222a31;
}

html[data-theme="dark"] .planning-card.minimized .compact-handle {
  border-bottom-color: #34404a;
}

html[data-theme="dark"] .unit-field,
html[data-theme="dark"] .unit-box {
  color: #b7c2cb;
}

html[data-theme="dark"] .minimize-unit {
  border-color: #52606a;
  background: #171d23;
  color: #dbe4ea;
}

html[data-theme="dark"] .minimize-unit:hover {
  background: #222a31;
}

html[data-theme="dark"] .delete-unit,
html[data-theme="dark"] .delete-lesson {
  border-color: #9d514b;
  background: #241719;
  color: #f0b6b1;
}

html[data-theme="dark"] .delete-unit:hover,
html[data-theme="dark"] .delete-lesson:hover {
  background: #321d20;
}

html[data-theme="dark"] .unit-box {
  border-color: #34404a;
  background: #1f262d;
}

html[data-theme="dark"] .unit-field input,
html[data-theme="dark"] .unit-field select,
html[data-theme="dark"] .unit-box textarea {
  border-color: #4b5964;
  background: #12171c;
  color: #eef4f8;
}

html[data-theme="dark"] .detected-links > span {
  color: #9facb6;
}

html[data-theme="dark"] .detected-link-list a {
  border-color: rgba(126, 163, 184, 0.26);
  background: rgba(24, 32, 39, 0.94);
  color: #b7d9e9;
}

html[data-theme="dark"] .detected-link-list a:hover {
  border-color: rgba(126, 163, 184, 0.48);
  background: #10161b;
}

html[data-theme="dark"] .type-pill {
  color: #dbe4ea;
  background: #303a43;
}

html[data-theme="dark"] .badge-zone {
  border-color: #34404a;
  background: #171d23;
}

html[data-theme="dark"] .badge-zone.needs-badge {
  border-color: #9d514b;
  background: #2a1718;
}

html[data-theme="dark"] .empty-badge-slot {
  border-color: #b86159;
  color: #f0b6b1;
  background: #1c2228;
}

html[data-theme="dark"] .applied-badge {
  border-color: color-mix(in srgb, var(--badge-color) 62%, #1b2228);
  background: #1b2228;
  color: #dbe4ea;
}

html[data-theme="dark"] .applied-badge button {
  background: #303a43;
  color: #dbe4ea;
}

html[data-theme="dark"] .unit-card-footer {
  border-top-color: #34404a;
}

html[data-theme="dark"] .attached-lesson-dock {
  border-top-color: #5b4a24;
  background: #262111;
}

html[data-theme="dark"] .attached-lesson-dock.dock-preview-target {
  background: #342b12;
  box-shadow: inset 0 0 0 2px rgba(241, 202, 97, 0.24);
}

html[data-theme="dark"] .lesson-dock-label {
  color: #dcbf72;
}

html[data-theme="dark"] .lesson-card.attached-editor {
  box-shadow: 0 15px 32px rgba(0, 0, 0, 0.36), 0 0 0 4px rgba(88, 70, 22, 0.52);
}

html[data-theme="dark"] .badge-window {
  border-color: #3a4650;
  background: rgba(22, 27, 33, 0.95);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.48);
}

html[data-theme="dark"] .badge-window-header {
  border-bottom-color: #34404a;
  background: rgba(31, 38, 45, 0.96);
}

html[data-theme="dark"] .badge-group {
  border-top-color: #34404a;
}

html[data-theme="dark"] .badge-token {
  border-color: color-mix(in srgb, var(--badge-color) 62%, #1b2228);
  background: #1b2228;
  color: #e7edf2;
}

html[data-theme="dark"] .badge-token:hover,
html[data-theme="dark"] .badge-token.is-used {
  background: color-mix(in srgb, var(--badge-color) 17%, #1b2228);
}

html[data-theme="dark"] .badge-used-mark {
  box-shadow: 0 0 0 2px #1b2228;
}

html[data-theme="dark"] .badge-detail-tooltip {
  border-color: #5d6b76;
  background: rgba(12, 16, 20, 0.98);
  color: #eef4f8;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.55);
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .board-frame {
    min-height: 100vh;
  }

  .board-header {
    grid-template-columns: 1fr;
  }

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

  .calendar-panel {
    width: min(620px, calc(100vw - 28px));
    height: min(540px, 54vh);
  }

  .lesson-date-picker {
    width: min(310px, calc(100vw - 28px));
    height: min(340px, 42vh);
  }

  .calendar-day-window {
    right: 14px;
    bottom: min(610px, 58vh);
    width: min(430px, calc(100vw - 28px));
  }
}

.workspace-dialog {
  position: absolute;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(31, 39, 45, 0.22);
  backdrop-filter: blur(3px);
}

.workspace-dialog[hidden] {
  display: none;
}

.dialog-card {
  width: min(620px, calc(100vw - 32px));
  max-height: min(76vh, 720px);
  overflow: hidden;
  border: 1px solid #a8b1b8;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 24px 70px rgba(31, 39, 45, 0.28);
  display: flex;
  flex-direction: column;
}

.dialog-header {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid #dce2e5;
  background: #f8faf9;
}

.dialog-header h2,
.dialog-section h3 {
  margin: 0;
}

.dialog-header h2 {
  font-size: 1.05rem;
}

.dialog-body {
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.dialog-section + .dialog-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #dce2e5;
}

.dialog-section h3 {
  font-size: 0.92rem;
}

.dialog-muted {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.workspace-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.workspace-list-item {
  width: 100%;
  min-height: 54px;
  justify-content: flex-start;
  border-color: #c8d1d6;
  border-left: 6px solid #315f47;
  background: #ffffff;
  color: #26323a;
  padding: 9px 11px;
  text-align: left;
  white-space: normal;
  display: grid;
  gap: 3px;
}

.workspace-list-item:hover {
  background: #eef5f1;
}

.workspace-list-item span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(39, 49, 58, 0.09) 1px, transparent 1px),
    linear-gradient(0deg, rgba(39, 49, 58, 0.09) 1px, transparent 1px),
    #e7ecee;
  background-size: 28px 28px;
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  width: min(360px, calc(100vw - 32px));
  border: 1px solid #9fabb2;
  border-top: 7px solid #8e2f2a;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
  padding: 20px;
  display: grid;
  gap: 14px;
}

.auth-card h1 {
  margin: 0;
  font-size: 1.35rem;
}

.auth-card label {
  display: grid;
  gap: 6px;
  color: #4b555f;
  font-size: 0.9rem;
  font-weight: 700;
}

.auth-card input {
  width: 100%;
  border: 1px solid #a8b1b8;
  border-radius: 6px;
  padding: 10px;
  background: #ffffff;
  color: var(--ink);
}

.auth-card p {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

html[data-theme="dark"] .workspace-dialog {
  background: rgba(0, 0, 0, 0.32);
}

html[data-theme="dark"] .dialog-card,
html[data-theme="dark"] .auth-card {
  border-color: #3a4650;
  background: rgba(22, 27, 33, 0.97);
}

html[data-theme="dark"] .dialog-header {
  border-bottom-color: #34404a;
  background: #222a31;
}

html[data-theme="dark"] .dialog-section + .dialog-section {
  border-top-color: #34404a;
}

html[data-theme="dark"] .workspace-list-item {
  border-color: #34404a;
  background: #171d23;
  color: #e7edf2;
}

html[data-theme="dark"] .workspace-list-item:hover {
  background: #222a31;
}

html[data-theme="dark"] .auth-gate {
  background:
    linear-gradient(90deg, rgba(199, 211, 220, 0.07) 1px, transparent 1px),
    linear-gradient(0deg, rgba(199, 211, 220, 0.07) 1px, transparent 1px),
    #101418;
}

html[data-theme="dark"] .auth-card input {
  border-color: #4b5964;
  background: #12171c;
  color: #eef4f8;
}

@media (max-width: 760px) {
  html,
  body,
  .app-shell {
    height: auto;
    min-height: 100%;
  }

  body {
    overflow: auto;
  }

  .board-frame {
    height: auto;
    min-height: 100vh;
    padding: 0;
  }

  .wall-panel {
    min-height: 100vh;
    height: auto;
    overflow: visible;
    border: 0;
  }

  .board-header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 82;
    grid-template-columns: 1fr;
    gap: 7px;
    padding: 8px;
    background: rgba(248, 247, 241, 0.96);
    border-bottom: 1px solid rgba(30, 37, 43, 0.14);
    pointer-events: auto;
  }

  .board-title,
  .unit-buttons,
  .board-actions {
    min-width: 0;
  }

  .unit-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .unit-add-button,
  .lesson-add-button {
    min-width: 0;
    width: 100%;
  }

  .board-actions {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .board-actions p {
    flex: 1 0 170px;
  }

  .zoom-control {
    display: none;
  }

  .wall-scroll {
    height: auto;
    min-height: calc(100vh - 138px);
    overflow: visible;
    cursor: auto;
  }

  .wall-scroll.panning {
    cursor: auto;
  }

  .wall-viewport,
  .wall-space {
    position: static;
    width: auto !important;
    height: auto !important;
    transform: none !important;
  }

  .lane-layer,
  #sketchCanvas {
    display: none;
  }

  .cards-layer {
    position: relative;
    inset: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 14px 10px 190px;
  }

  .planning-card,
  .lesson-card {
    position: relative;
    left: auto !important;
    top: auto !important;
    width: 100%;
    max-width: none;
    height: auto;
    min-height: 0;
    order: var(--mobile-order);
  }

  .planning-card {
    overflow: visible;
  }

  .planning-card.minimized {
    height: auto;
    min-height: 82px;
  }

  .unit-card-scroll,
  .lesson-card-body {
    max-height: none;
    overflow: visible;
  }

  .unit-card-grid,
  .badge-zone-grid {
    grid-template-columns: 1fr;
  }

  .unit-card-handle,
  .lesson-card-handle {
    cursor: default;
  }

  .planning-card.minimized .attached-lesson-dock {
    position: static;
    margin: 0 10px 9px;
  }

  .attached-lesson-dock {
    align-items: flex-start;
  }

  .attached-lesson-row {
    flex-wrap: wrap;
    overflow: visible;
  }

  .lesson-card {
    min-height: 300px;
  }

  .lesson-card.collapsed {
    width: 100%;
    height: 64px;
    min-height: 64px;
    cursor: pointer;
  }

  .lesson-card.collapsed::before {
    width: 100%;
    height: 64px;
    justify-items: start;
    padding: 10px 14px;
    text-align: left;
    font-size: 0.9rem;
  }

  .lesson-card.collapsed::after {
    left: auto;
    right: 10px;
    top: 38px;
  }

  .badge-window {
    position: fixed;
    left: 8px !important;
    top: 126px !important;
    width: calc(100vw - 16px);
    max-height: 56vh;
  }

  .calendar-button {
    position: fixed;
    right: 10px;
    bottom: 10px;
  }

  .calendar-panel {
    position: fixed;
    right: 8px;
    bottom: 54px;
    width: calc(100vw - 16px);
    height: min(440px, 60vh);
  }

  .calendar-day-window {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: min(506px, calc(60vh + 66px));
    width: auto;
    height: min(220px, 28vh);
  }

  .lesson-date-picker {
    position: fixed;
    left: 8px !important;
    right: 8px;
    top: 112px !important;
    width: auto;
    height: min(340px, 48vh);
  }

  .workspace-dialog {
    position: fixed;
    padding: 10px;
  }

  .dialog-card {
    width: 100%;
    max-height: calc(100vh - 20px);
  }

  html[data-theme="dark"] .board-header {
    background: rgba(20, 26, 31, 0.96);
    border-bottom-color: rgba(219, 229, 237, 0.12);
  }
}
