:root {
  --sidebar-width: 280px;
  --document-width: 100%;
  --document-padding: 24px;
  --document-top: 24px;
  --title-size: 28px;
  --search-width: 100%;
  --calendar-day-height: 36px;
}

#sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 24;
  width: var(--sidebar-width);
  max-width: 100%;
  transform: translateX(0);
}

#app.collapsed #sidebar {
  width: var(--sidebar-width);
  transform: translateX(-100%);
}

#app:not(.collapsed) #overlay {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#sidebar-open {
  width: 32px;
  opacity: 1;
  pointer-events: auto;
}

#app:not(.collapsed) main {
  pointer-events: none;
}

.tree-actions {
  opacity: 1;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  grid-area: 1 / 1;
  flex-wrap: wrap;
  gap: 4px 8px;
  min-width: 0;
  padding: 8px 12px;
}

.workspace {
  grid-area: 3 / 1;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

#document-metadata {
  flex-basis: 100%;
  flex-wrap: wrap;
  gap: 4px 12px;
  min-width: 0;
  font-size: 10px;
}

.metadata-item {
  gap: 4px;
}

.metadata-item svg {
  width: 12px;
  height: 12px;
}

.document-header {
  padding-top: 12px;
  padding-bottom: 16px;
  margin-bottom: 16px;
}

#title {
  min-height: 40px;
}

#editor {
  font-size: 14px;
  line-height: 180%;
}

.block-controls {
  display: none !important;
}

.editor-block {
  min-height: 32px;
  padding: 4px 0;
  margin: 0;
}

.block-content {
  min-height: 24px;
}

.editor-block[data-type="heading1"] {
  margin-top: 20px;
}

.editor-block[data-type="heading2"] {
  margin-top: 16px;
}

.editor-block[data-type="heading3"] {
  margin-top: 12px;
}

.editor-block[data-type="heading1"] .block-content {
  font-size: 24px;
}

.editor-block[data-type="heading2"] .block-content {
  font-size: 20px;
}

.editor-block[data-type="heading3"] .block-content {
  font-size: 18px;
}

.editor-block[data-type="quote"] .block-content {
  padding: 4px 12px;
  font-size: 14px;
}

.editor-block[data-type="quote"] .block-content.is-empty::before {
  left: 12px;
}

.editor-block[data-type="code"] .block-content {
  padding: 12px;
  font-size: 12px;
}

.editor-block[data-type="code"] .block-content.is-empty::before {
  top: 12px;
  left: 12px;
}

.block-content code {
  padding: 2px 4px;
  font-size: 88%;
}

.block-marker {
  width: 24px;
  min-height: 24px;
}

.block-checkbox {
  width: 14px;
  height: 14px;
  margin-top: 6px;
}

.block-checkbox:checked::after {
  font-size: 10px;
  line-height: 10px;
}

.block-hidden-summary {
  min-height: 28px;
  font-size: 12px;
}

.add-block {
  min-height: 36px;
  margin-top: 8px;
  font-size: 12px;
}

.latex-block-preview-content {
  font-size: 12px;
}

.modal-overlay {
  padding: 24px 16px;
}

.search-window {
  max-height: calc(100dvh - 48px);
}

.search-header {
  gap: 8px;
  padding: 12px 16px;
}

.search-footer {
  gap: 12px;
  padding: 12px;
}

.dialog-window {
  padding: 20px;
}

.popup-menu {
  width: 224px;
}

#calendar-overlay {
  padding: 16px;
}

.calendar-window {
  width: 100%;
  max-height: calc(100dvh - 32px);
}

.calendar-header {
  gap: 8px;
  min-height: 56px;
  padding: 12px 16px;
}

.calendar-header h2 {
  font-size: 18px;
}

.calendar-body {
  gap: 16px;
  padding: 16px;
}

.calendar-navigation {
  flex-wrap: wrap;
  gap: 4px;
}

.calendar-selectors {
  gap: 4px;
}

.calendar-selectors select {
  padding: 6px 8px;
}

.calendar-today {
  padding: 6px 8px;
}

#calendar-months {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.calendar-month-panel:nth-child(2) {
  display: none;
}

.calendar-day,
.calendar-blank {
  height: 36px;
}

.calendar-month-title {
  font-size: 14px;
}

.schedule-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.schedule-field:last-child {
  grid-column: 1 / -1;
}

.schedule-field input,
#schedule-name {
  padding: 8px;
  font-size: 12px;
}

.schedule-submit-row {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

#schedule-name {
  flex: none;
}

.schedule-submit {
  width: 100%;
}

.schedule-item {
  gap: 8px;
  padding: 8px;
}

.schedule-item-icon {
  width: 32px;
  height: 32px;
}

.schedule-item-description {
  font-size: 10px;
}

#toast-layer {
  position: relative;
  grid-area: 2 / 1;
  align-self: start;
  justify-self: stretch;
  inset: auto;
  width: auto;
  min-width: 0;
  max-width: 100%;
  max-height: 40dvh;
  margin: 0;
  padding: 8px 8px 12px;
  gap: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  pointer-events: none;
}

#toast-layer:empty {
  display: none;
}

#toast-layer::-webkit-scrollbar {
  display: none;
}

#toast-layer .toast {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  gap: 8px;
  min-height: 44px;
  padding: 6px 8px;
  border-radius: 8px;
  box-shadow: 0 4px 12px var(--shadow);
  pointer-events: auto;
}

#app:not(.collapsed) #toast-layer .toast {
  pointer-events: none;
}

#toast-layer .toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

#toast-layer .toast-icon svg {
  width: 18px;
  height: 18px;
}

#toast-layer .toast-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

#toast-layer .toast-marquee {
  min-width: 0;
  overflow: hidden;
}

#toast-layer .toast-title {
  font-size: 12px;
}

#toast-layer .toast-date {
  display: block;
  flex-shrink: 0;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 10px;
}

#toast-layer .toast-close {
  width: 28px;
  height: 28px;
  padding: 4px;
  flex-shrink: 0;
}

#toast-layer .toast-close svg {
  width: 16px;
  height: 16px;
}

#schedule-list .schedule-item {
  gap: 8px;
  min-height: 44px;
  padding: 6px 8px;
  border-radius: 8px;
}

#schedule-list .schedule-item-icon {
  width: 20px;
  height: 20px;
}

#schedule-list .schedule-item-icon svg {
  width: 18px;
  height: 18px;
}

.schedule-marquee,
.toast-marquee {
  font-size: 12px;
}

.schedule-item-date {
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 10px;
}

#schedule-list .schedule-remove {
  width: 28px;
  height: 28px;
  padding: 4px;
}

#schedule-list .schedule-remove svg {
  width: 16px;
  height: 16px;
}

.alignment-panel {
  gap: 0;
  padding: 0;
}

.alignment-header {
  display: none;
}

.alignment-track {
  gap: 8px;
  padding: 4px 0;
}

.alignment-track > .editor-block {
  width: 200px;
  min-width: 200px;
  min-height: 88px;
  padding: 12px;
}

.alignment-track > .editor-block[data-type="code"],
.alignment-track > .editor-block[data-type="latex"] {
  width: 260px;
  min-width: 260px;
}

.alignment-track > .editor-block[data-type="divider"] {
  width: 120px;
  min-width: 120px;
}

.alignment-track > .editor-block.block-hidden {
  width: 160px;
  min-width: 160px;
}

.alignment-track .alignment-child-controls {
  display: none !important;
}

.alignment-add {
  flex-basis: 36px;
  width: 36px;
  min-width: 36px;
  min-height: 88px;
}

.alignment-add svg {
  width: 16px;
  height: 16px;
}

.ratio-track {
  --ratio-min-width: 240px;
  --ratio-double-width: 480px;
  --ratio-block-height: 88px;

  gap: 8px;
}

.alignment-track.ratio-track > .editor-block,
.alignment-track.ratio-track > .editor-block[data-type],
.alignment-track.ratio-track > .editor-block.block-hidden {
  padding: 12px;
}

.alignment-track.ratio-track > .ratio-empty-slot {
  padding: 8px;
  gap: 6px;
}

.ratio-empty-slot svg {
  width: 18px;
  height: 18px;
}

.ratio-empty-label {
  font-size: 12px;
}

.media-overlay {
  padding: 12px;
}

.media-window {
  max-height: calc(100dvh - 24px);
}

.media-window-header {
  gap: 8px;
  min-height: 52px;
  padding: 8px 12px;
}

.media-window-header h2 {
  font-size: 16px;
}

.media-calendar-window {
  width: 100%;
  height: min(800px, calc(100dvh - 24px));
}

.media-calendar-body {
  gap: 12px;
  padding: 12px;
}

.media-calendar-grid {
  grid-template-rows: 24px repeat(6, 36px);
}

.media-calendar-day,
.media-calendar-blank {
  height: 36px;
}

.media-calendar-mini-grid .media-calendar-day,
.media-calendar-mini-grid .media-calendar-blank {
  height: 24px;
}

.media-calendar-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.media-calendar-fields > :last-child {
  grid-column: 1 / -1;
}

.media-calendar-submit-row {
  flex-direction: column;
  align-items: stretch;
}

.media-schedule-item {
  gap: 8px;
  min-height: 44px;
  padding: 6px 8px;
}

.media-schedule-item .marquee {
  font-size: 12px;
}

.media-schedule-date {
  font-size: 10px;
  max-width: 40%;
}

.media-calendar-preview {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 8px;
  gap: 8px;
}

.sketch-overlay {
  padding: 8px;
}

.sketch-window {
  width: 100%;
  height: calc(100dvh - 16px);
  max-height: calc(100dvh - 16px);
  border: 2px solid var(--border);
  border-radius: 8px;
}

.sketch-layout {
  position: relative;
}

.sketch-inspector {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 16;
  width: 240px;
  max-width: 88%;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 240ms var(--transition-ease), visibility 240ms ease;
  box-shadow: -8px 0 24px var(--shadow);
}

.sketch-layout.inspector-open .sketch-inspector {
  transform: translateX(0);
  visibility: visible;
}

.sketch-inspector-toggle {
  display: inline-flex;
}

.sketch-toolbar {
  bottom: 12px;
  gap: 2px;
  max-width: calc(100% - 16px);
  padding: 4px;
  border-radius: 10px;
}

.sketch-tool-button {
  width: 34px;
  height: 36px;
  padding: 6px;
}

.sketch-tool-button svg {
  width: 18px;
  height: 18px;
}

.sketch-dimension-status {
  font-size: 10px;
}

.sketch-zoom-label {
  top: 8px;
  left: 8px;
  font-size: 10px;
}

.sketch-color-square {
  height: 112px;
}

.sketch-preview {
  min-height: 120px;
}

.sketch-preview-placeholder {
  min-height: 120px;
  font-size: 12px;
}

.sketch-toolbar-dock {
  bottom: 12px;
  gap: 6px;
  max-width: calc(100% - 16px);
}

.sketch-toolbar-dock .sketch-toolbar,
.sketch-history-toolbar {
  gap: 2px;
  padding: 4px;
  border-radius: 10px;
}

.sketch-toolbar-dock .sketch-toolbar {
  min-width: 0;
  overflow-x: auto;
}

.sketch-toolbar-dock .sketch-tool-button {
  width: 32px;
  height: 36px;
  padding: 6px;
}

.sketch-toolbar-dock .sketch-tool-button svg {
  width: 18px;
  height: 18px;
}

.sketch-range-control {
  height: 36px;
  border-radius: 6px;
}

.sketch-range-output {
  font-size: 12px;
}

.sketch-range-fill {
  border-radius: 4px;
}

.latex-window {
  width: 100%;
  height: min(640px, calc(100dvh - 24px));
  max-height: calc(100dvh - 24px);
}

.latex-window-content {
  gap: 16px;
  padding: 12px;
}

.latex-window-section {
  gap: 8px;
}

.latex-window-input {
  min-height: 100px;
  padding: 12px;
  font-size: 12px;
}

.latex-window-preview {
  min-height: 100px;
  padding: 12px;
}

.latex-window-status {
  gap: 6px;
  font-size: 10px;
}

.latex-block-preview {
  min-height: 56px;
  padding: 12px;
}

.latex-block-placeholder {
  gap: 6px;
  font-size: 12px;
}

.latex-block-placeholder svg {
  width: 16px;
  height: 16px;
}

.tree-drag-handle {
  display: none;
}

.vector-window {
  width: 100%;
  height: calc(100dvh - 16px);
  max-height: calc(100dvh - 16px);
  border-radius: 8px;
}

.vector-toolbar-dock {
  bottom: 12px;
  gap: 6px;
  max-width: calc(100% - 16px);
}

.vector-toolbar,
.vector-history-toolbar {
  gap: 2px;
  padding: 4px;
  border-radius: 10px;
}

.vector-toolbar .sketch-tool-button,
.vector-history-toolbar .sketch-tool-button {
  width: 32px;
  height: 36px;
  padding: 6px;
}

.vector-toolbar .sketch-tool-button svg,
.vector-history-toolbar .sketch-tool-button svg {
  width: 18px;
  height: 18px;
}

.vector-inspector {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 16;
  width: 240px;
  max-width: 88%;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 240ms var(--transition-ease), visibility 240ms ease;
  box-shadow: -8px 0 24px var(--shadow);
}

.vector-layout.inspector-open .vector-inspector {
  transform: translateX(0);
  visibility: visible;
}

.vector-inspector-toggle {
  display: inline-flex;
}

.vector-preview,
.vector-preview-placeholder {
  min-height: 120px;
}

.vector-preview-placeholder {
  font-size: 12px;
}

.vector-zoom-label {
  top: 8px;
  left: 8px;
  font-size: 10px;
}

.diagram-connector-options {
  bottom: 68px;
  gap: 2px;
  padding: 4px;
  border-radius: 8px;
}

.diagram-connector-options .sketch-tool-button {
  width: 32px;
  height: 36px;
  padding: 6px;
}

.diagram-connector-options svg {
  width: 20px;
  height: 20px;
}

.diagram-option {
  min-height: 28px;
  padding: 2px;
}

.diagram-option svg {
  height: 20px;
}

.diagram-property-input {
  min-height: 32px;
  font-size: 12px;
}

.diagram-quick-create {
  width: 280px;
  max-width: calc(100% - 16px);
  gap: 6px;
  padding: 6px;
  border-radius: 8px;
}

.diagram-quick-grid {
  gap: 2px;
}

.diagram-quick-shape {
  gap: 4px;
  min-height: 60px;
  padding: 6px 4px;
}

.diagram-quick-shape svg {
  width: 26px;
  height: 26px;
}

.diagram-quick-label {
  font-size: 10px;
}

.diagram-toolbar-shapes {
  bottom: 68px;
}

.diagram-advanced-properties {
  gap: 8px;
  padding-top: 8px;
}

.diagram-coordinate-grid {
  gap: 4px;
}

.diagram-waypoint-item {
  padding: 6px;
}

.diagram-waypoint-list {
  max-height: 240px;
}

.color-picker {
  width: 248px;
  max-width: calc(100dvw - 16px);
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
}

.color-picker-square {
  height: 144px;
}

.color-picker-hue {
  height: 20px;
  border-radius: 10px;
}

.color-picker-hue-cursor {
  width: 20px;
  height: 20px;
  border-radius: 10px;
}

.color-picker-square-cursor {
  width: 16px;
  height: 16px;
  border-radius: 8px;
}

.color-picker-hex-input {
  height: 36px;
}

.color-picker-rgb-row {
  gap: 6px;
}

.color-picker-rgb-field {
  height: 36px;
  padding: 6px;
}

.color-picker-icon-button {
  width: 36px;
  height: 36px;
}

.color-picker.color-picker-inline {
  width: 100%;
  max-width: none;
  padding: 0;
}

#calendar-months .birthday-day::before {
  top: -4px;
  font-size: 16px;
  transform: translateX(4px) rotate(16deg);
}

.youtube-overlay,
.code-language-overlay {
  padding: 12px;
}

.youtube-window,
.code-language-window {
  max-height: calc(100dvh - 24px);
  border-radius: 10px;
}

.youtube-header,
.youtube-footer {
  padding: 12px;
}

.youtube-header-title {
  font-size: 16px;
}

.youtube-body {
  gap: 8px;
  padding: 12px;
}

.youtube-block-description {
  font-size: 12px;
}

.youtube-url-input,
.youtube-description-input {
  padding: 8px;
  font-size: 14px;
}

.youtube-block-empty {
  min-height: 120px;
  font-size: 12px;
}

.source-code-panel {
  max-height: 400px;
}

.source-code-surface {
  --code-font-size: 12px;
  --code-line-height: 20px;
  --code-padding-top: 8px;
  --code-padding-bottom: 12px;
  --code-padding-horizontal: 12px;
  --code-max-height: 352px;
}

.source-code-toolbar {
  min-height: 36px;
  padding: 4px 6px;
}

.source-code-button {
  width: 28px;
  height: 28px;
  padding: 6px;
}

.source-code-button svg {
  width: 16px;
  height: 16px;
}

.source-output-text {
  font-size: 12px;
}

.code-language-window {
  width: 320px;
  gap: 8px;
  padding: 10px;
}

.code-language-search {
  min-height: 36px;
  padding: 6px 8px;
}