:root {
  --dreyfous-blue: #1976f3;
  --dreyfous-ink: #1f2937;
  --dreyfous-muted: #667085;
  --dreyfous-border: #e5e7eb;
  --dreyfous-surface: #ffffff;
  --dreyfous-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}

.dreyfous-shell-enabled {
  background: #f8fafc;
}

.dreyfous-shell-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5200;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 68px;
  padding: 0 12px 0 22px;
  background: var(--dreyfous-surface);
  border-bottom: 1px solid var(--dreyfous-border);
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.04);
  box-sizing: border-box;
}

.dreyfous-shell-brand {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--dreyfous-blue);
  font: 500 23px/1.1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.dreyfous-shell-brand sup {
  font-size: 0.55em;
}

.dreyfous-shell-spacer {
  flex: 1;
}

.dreyfous-shell-icon,
.dreyfous-shell-back,
.dreyfous-shell-round,
.dreyfous-shell-swatch,
.dreyfous-shell-size,
.dreyfous-shell-annotation-trigger,
.dreyfous-shell-image-tool,
.dreyfous-shell-menu-item,
.dreyfous-shell-color {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.dreyfous-shell-icon,
.dreyfous-shell-back {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: transparent;
  color: var(--dreyfous-ink);
  text-decoration: none;
  font-size: 24px;
}

.dreyfous-shell-back {
  background: #eef2f7;
  color: #64748b;
}

.dreyfous-shell-mode-dock {
  position: fixed;
  top: 92px;
  right: 0;
  z-index: 5200;
  width: 86px;
  padding: 12px;
  box-sizing: border-box;
  background: var(--dreyfous-surface);
  border: 1px solid var(--dreyfous-border);
  border-right: 0;
  border-radius: 22px 0 0 22px;
  box-shadow: var(--dreyfous-shadow);
}

.dreyfous-shell-mode-dock:has(.dreyfous-shell-mode-button[hidden]) {
  display: none;
}

.dreyfous-shell-rail {
  position: fixed;
  top: 196px;
  right: 0;
  z-index: 5200;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 86px;
  padding: 18px 12px;
  box-sizing: border-box;
  background: var(--dreyfous-surface);
  border: 1px solid var(--dreyfous-border);
  border-right: 0;
  border-radius: 34px 0 0 34px;
  box-shadow: var(--dreyfous-shadow);
}

body.dreyfous-annotation-active .dreyfous-shell-rail {
  display: flex;
}

.dreyfous-shell-round,
.dreyfous-shell-swatch,
.dreyfous-shell-size {
  width: 52px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #fff;
  color: #3567c8;
  border: 1px solid #d7deea;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  font-size: 23px;
}

.dreyfous-shell-round:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.dreyfous-shell-round[data-shell-action="zoom-in"],
.dreyfous-shell-round[data-shell-action="zoom-out"],
.dreyfous-shell-round[data-shell-action="fit"] {
  display: none;
}

.dreyfous-shell-round.is-active {
  color: #fff;
  background: #3567c8;
  border-color: #2f5ab0;
}

.dreyfous-shell-tool-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dreyfous-shell-swatch {
  background: #000;
}

.dreyfous-shell-menu,
.dreyfous-shell-color-popover {
  position: fixed;
  z-index: 5300;
  display: none;
  background: #fff;
  border: 1px solid var(--dreyfous-border);
  border-radius: 12px;
  box-shadow: var(--dreyfous-shadow);
}

.dreyfous-shell-menu.is-open,
.dreyfous-shell-color-popover.is-open {
  display: block;
}

.dreyfous-shell-menu {
  top: 92px;
  right: 102px;
  min-width: 210px;
  padding: 12px 0;
}

.dreyfous-shell-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  color: #111827;
  padding: 11px 18px;
  font: 500 15px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-align: left;
}

.dreyfous-shell-menu-item:hover {
  background: #f3f6fb;
}

.dreyfous-shell-check {
  width: 16px;
  color: #225cc7;
  font-weight: 800;
}

.dreyfous-shell-color-popover {
  left: auto;
  top: auto;
  right: 96px;
  bottom: auto;
  width: 212px;
  padding: 12px;
  grid-template-columns: repeat(5, 32px);
  gap: 10px;
}

.dreyfous-shell-color-popover.is-open {
  display: grid;
}

.dreyfous-shell-color {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  outline: 0;
}

.dreyfous-shell-color.is-active {
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--dreyfous-blue);
}

.dreyfous-shell-size-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dreyfous-shell-size {
  height: 32px;
  box-shadow: none;
  border: 0;
  background: transparent;
}

.dreyfous-shell-size span {
  display: block;
  border-radius: 999px;
  background: #3567c8;
}

.dreyfous-shell-size.is-active span {
  box-shadow: 0 0 0 4px rgba(25, 118, 243, 0.2);
}

.dreyfous-shell-tool-dock {
  position: fixed;
  right: 18px;
  bottom: 0;
  z-index: 5250;
  display: flex;
  align-items: flex-end;
  gap: 14px;
  height: 133px;
  overflow: hidden;
  pointer-events: none;
}

.dreyfous-shell-annotation-trigger {
  position: fixed;
  right: 18px;
  bottom: 168px;
  z-index: 5250;
  display: none;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: #fff;
  color: #3567c8;
  border: 1px solid #d7deea;
  box-shadow: var(--dreyfous-shadow);
  font-size: 1.25em;
}

.dreyfous-shell-annotation-trigger[aria-expanded="true"] {
  color: var(--dreyfous-blue);
  box-shadow: 0 0 0 4px rgba(25, 118, 243, 0.16), var(--dreyfous-shadow);
}

.dreyfous-shell-image-tool {
  width: 44px;
  height: 133px;
  flex: 0 0 44px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: transparent;
  border-radius: 0;
  outline-offset: -8px;
  pointer-events: auto;
  transform: translateY(20%);
  transition: transform 180ms ease;
}

.dreyfous-shell-image-tool.is-active,
.dreyfous-shell-image-tool:focus-visible {
  transform: translateY(0);
}

.dreyfous-shell-image-tool img {
  display: block;
  width: 44px;
  max-height: 133px;
  object-fit: contain;
  object-position: bottom center;
  user-select: none;
  -webkit-user-drag: none;
}

.dreyfous-annotation-layer {
  position: fixed;
  inset: 0;
  z-index: 5000;
  pointer-events: none;
  touch-action: none;
}

.dreyfous-annotation-layer.is-active {
  pointer-events: auto;
  cursor: crosshair;
}

body.dreyfous-shell-enabled #top-header {
  display: none;
}

body.dreyfous-shell-enabled #workspace {
  padding-top: 68px;
  padding-bottom: 224px;
  box-sizing: border-box;
}

body.dreyfous-shell-enabled #controls {
  display: none !important;
  position: absolute;
  right: 104px;
  top: 88px;
  z-index: 1200;
  margin: 0;
  border: 1px solid var(--dreyfous-border);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

body.dreyfous-shell-enabled #practice-mode-selector,
body.dreyfous-shell-enabled #practice-mode-selector-label {
  display: none !important;
}

body.dreyfous-shell-enabled #toolbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 1300;
  transform: translateX(-50%);
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: calc(100vw - 260px);
  width: fit-content;
  max-height: 156px;
  margin: 0;
  padding: 14px 22px 12px;
  border-radius: 12px 12px 0 0;
  background: #fff;
  box-shadow: 0 10px 32px rgba(15, 23, 42, 0.12);
  border: 1px solid var(--dreyfous-border);
  border-bottom: 0;
}

body.dreyfous-shell-enabled #toolbar .toolbar-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  align-self: center;
  gap: 0;
  padding: 0;
  margin-right: 0;
}

body.dreyfous-shell-enabled #toolbar .toolbar-actions .icon-btn {
  width: 44px;
  height: 44px;
  margin: 0;
  flex: 0 0 44px;
  background: #fff;
  color: var(--dreyfous-blue);
  border: 0;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.1);
  font-size: 1.15em;
}

body.dreyfous-shell-enabled #toolbar .toolbar-actions .icon-btn.workspace-actions-trigger {
  gap: 8px;
  width: auto;
  min-width: 124px;
  height: 44px;
  flex: 0 0 auto;
  padding: 0 14px;
  border: 1px solid rgba(0, 123, 255, 0.25);
  border-radius: 10px;
  color: var(--dreyfous-blue);
  font: 700 14px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.dreyfous-shell-enabled #toolbar .toolbar-actions .icon-btn.workspace-actions-trigger:hover,
body.dreyfous-shell-enabled #toolbar .toolbar-actions .icon-btn.workspace-actions-trigger:focus-visible {
  border-color: rgba(0, 123, 255, 0.5);
  background: #eef6ff;
  color: var(--dreyfous-blue);
  outline: 3px solid rgba(0, 123, 255, 0.18);
  outline-offset: 2px;
}

body.dreyfous-shell-enabled #toolbar .toolbar-actions .icon-btn.workspace-actions-trigger[aria-expanded="true"] {
  border-color: var(--dreyfous-blue);
  background: var(--dreyfous-blue);
  color: #ffffff;
  outline: none;
}

body.dreyfous-shell-enabled #canvas-tile-summary {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 168px;
  z-index: 1250;
  margin: 0;
  transform: translateX(-50%);
  box-sizing: border-box;
}

body.dreyfous-shell-enabled #toolbar .tile-toggle {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
}

body.dreyfous-shell-enabled #toolbar .tile-toggle div:not(.controls-overlay) {
  color: #516579 !important;
  margin-top: 7px;
  font: 700 15px/1.1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.dreyfous-shell-enabled #toolbar .tile-img[data-type="unit"] {
  width: 48px !important;
  height: 48px !important;
  max-width: 48px !important;
  max-height: 48px !important;
}

body.dreyfous-shell-enabled #toolbar .tile-img[data-type="x"] {
  width: 88px !important;
  height: 48px !important;
  max-width: 88px !important;
  max-height: 48px !important;
}

body.dreyfous-shell-enabled #toolbar .tile-img[data-type="x2"] {
  width: 88px !important;
  height: 88px !important;
  max-width: 88px !important;
  max-height: 88px !important;
}

body.dreyfous-shell-enabled #toolbar .tile-img[data-type="y"] {
  width: 113px !important;
  height: 48px !important;
  max-width: 113px !important;
  max-height: 48px !important;
}

body.dreyfous-shell-enabled #toolbar .tile-img[data-type="z"] {
  width: 130px !important;
  height: 48px !important;
  max-width: 130px !important;
  max-height: 48px !important;
}

body.dreyfous-shell-enabled #toolbar .tile-img[data-type="y2"] {
  width: 113px !important;
  height: 113px !important;
  max-width: 113px !important;
  max-height: 113px !important;
}

body.dreyfous-shell-enabled #toolbar .tile-img[data-type="xy"] {
  width: 113px !important;
  height: 88px !important;
  max-width: 113px !important;
  max-height: 88px !important;
}

body.dreyfous-shell-enabled #canvas-container {
  margin-right: 104px;
}

body.dreyfous-shell-enabled #feedback-modal,
body.dreyfous-shell-enabled #problem-list-sidebar {
  z-index: 5400;
}

body.dreyfous-shell-enabled #dev-panel,
body.dreyfous-shell-enabled #dev-indicator {
  display: none !important;
}

@media (min-width: 761px) and (max-width: 1100px) {
  .dreyfous-shell-annotation-trigger {
    display: inline-flex;
  }

  body.dreyfous-annotation-active .dreyfous-shell-annotation-trigger {
    display: none;
  }

  .dreyfous-shell-tool-dock {
    display: none;
  }

  body.dreyfous-annotation-active .dreyfous-shell-tool-dock {
    display: flex;
  }

  body.dreyfous-annotation-active .dreyfous-shell-rail {
    display: flex;
  }

  body.dreyfous-shell-enabled #toolbar {
    max-width: calc(100vw - 24px);
  }
}

@media (max-width: 760px) {
  .dreyfous-shell-mode-dock {
    top: auto;
    right: 12px;
    bottom: 78px;
    width: auto;
    padding: 8px;
    border-radius: 999px;
    border-right: 1px solid var(--dreyfous-border);
  }

  .dreyfous-shell-rail {
    top: auto;
    right: 12px;
    bottom: 16px;
    width: auto;
    max-width: calc(100vw - 24px);
    flex-direction: row;
    border-radius: 999px;
    border-right: 1px solid var(--dreyfous-border);
    overflow-x: auto;
  }

  body.dreyfous-annotation-active .dreyfous-shell-rail {
    display: flex;
  }

  .dreyfous-shell-tool-group,
  .dreyfous-shell-size-list {
    flex-direction: row;
  }

  .dreyfous-shell-round,
  .dreyfous-shell-swatch {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
  }

  .dreyfous-shell-menu {
    top: auto;
    right: 12px;
    bottom: 138px;
  }

  body.dreyfous-shell-enabled #workspace {
    padding-bottom: 220px;
  }

  .dreyfous-shell-tool-dock {
    right: 10px;
    height: 109px;
    gap: 8px;
  }

  .dreyfous-shell-image-tool {
    width: 36px;
    height: 109px;
    flex-basis: 36px;
  }

  .dreyfous-shell-image-tool img {
    width: 36px;
    max-height: 109px;
  }

  body.dreyfous-shell-enabled #canvas-container {
    margin-right: 20px;
  }

  body.dreyfous-shell-enabled #toolbar {
    bottom: 0;
    width: fit-content;
    max-width: calc(100vw - 24px);
  }

  body.dreyfous-shell-enabled #toolbar.has-workspace-actions {
    justify-content: flex-start;
  }

  body.dreyfous-shell-enabled #toolbar .toolbar-actions {
    gap: 0;
    padding: 0;
  }

  body.dreyfous-shell-enabled #toolbar .toolbar-actions .icon-btn {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
    font-size: 1.15em;
  }

  body.dreyfous-shell-enabled #toolbar .toolbar-actions .icon-btn.workspace-actions-trigger {
    width: auto;
    min-width: 124px;
    flex-basis: auto;
    padding: 0 14px;
    font-size: 14px;
  }

  body.dreyfous-shell-enabled #canvas-tile-summary {
    right: auto;
    bottom: 166px;
  }
}
