/* Base 10 Blocks layout and visuals */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Helvetica Neue", Arial, sans-serif;
  background: #f8fafc;
  color: #123047;
}

body {
  overscroll-behavior: none;
  touch-action: none;
}

.app-root,
#workspace {
  width: 100%;
  height: 100dvh;
  min-height: 100vh;
}

#top-header {
  display: none;
}

#app-version {
  font-size: 0.55em;
  color: #707070;
}

#workspace {
  position: relative;
  padding: 84px 104px 72px 108px;
  background: #f8fafc;
}

.workspace-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #d8e0ec;
  border-radius: 8px;
  background: #f4f6fb;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}

.workspace-header {
  position: absolute;
  top: 14px;
  left: 18px;
  z-index: 5;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

.workspace-container {
  position: absolute;
  inset: 44px 18px 18px;
  overflow: hidden;
  border: 1px solid #dce4ef;
  border-radius: 8px;
  background-color: #f4f6fb;
  background-image: radial-gradient(circle, rgba(148, 163, 184, 0.55) 1px, transparent 0);
  background-size: 32px 32px;
  touch-action: none;
}

#stage-container {
  width: 100%;
  height: 100%;
}

.readout {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 1250;
  max-width: calc(100vw - 236px);
  transform: translateX(-50%);
  padding: 8px 14px;
  border: 1px solid #d8e0ec;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  color: #334155;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.selection-menu {
  position: fixed;
  z-index: 5250;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid #d7deea;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.2);
  touch-action: manipulation;
}

.selection-menu-button {
  display: inline-flex;
  width: 40px;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 5px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #3567c8;
  cursor: pointer;
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.selection-menu-button:hover:not(:disabled),
.selection-menu-button:focus-visible {
  background: #eef3fb;
  outline: 0;
}

.selection-menu-button:focus-visible {
  box-shadow: inset 0 0 0 2px #3567c8;
}

.selection-menu-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.selection-menu-button-danger {
  color: #b91c1c;
}

body.dreyfous-annotation-active .selection-menu {
  display: none;
}

body.dreyfous-shell-enabled #workspace {
  padding: 84px 104px 72px 108px;
}

body.dreyfous-shell-enabled #toolbar {
  position: fixed;
  top: 92px;
  bottom: auto;
  left: 0;
  z-index: 1300;
  display: flex;
  width: 86px;
  max-width: none;
  max-height: calc(100dvh - 116px);
  margin: 0;
  padding: 18px 10px;
  overflow-x: hidden;
  overflow-y: auto;
  transform: none;
  border: 1px solid #e5e7eb;
  border-left: 0;
  border-radius: 0 34px 34px 0;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}

.block-palette-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.palette-item {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-width: 0;
  min-height: 74px;
  padding: 8px 6px;
  border-radius: 8px;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  transition: background 0.15s ease, transform 0.15s ease;
}

.palette-item:hover,
.palette-item:focus-visible {
  background: #f3f6fb;
  outline: 0;
}

.palette-item:active {
  cursor: grabbing;
}

.palette-item.dragging {
  opacity: 0.6;
}

.palette-divider {
  flex: 0 0 auto;
  width: 100%;
  height: 1px;
  margin: 0;
  background: rgba(15, 23, 42, 0.1);
}

.palette-label {
  color: #516579;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
}

.palette-unit-img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.palette-ten-img {
  width: 22px;
  height: 112px;
  object-fit: contain;
}

.palette-hundred-img,
.palette-thousand-img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

#action-rail {
  position: fixed;
  top: 196px;
  right: 0;
  z-index: 5200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 86px;
  padding: 18px 12px;
  border: 1px solid #e5e7eb;
  border-right: 0;
  border-radius: 34px 0 0 34px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}

body.dreyfous-annotation-active #action-rail {
  display: none;
}

.side-toolbar-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 1px solid #d7deea;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  color: #3567c8;
  cursor: pointer;
  font-size: 21px;
  touch-action: manipulation;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.side-toolbar-icon-button:hover:not(:disabled),
.side-toolbar-icon-button:focus-visible {
  background: #f3f6fb;
  outline: 0;
}

.side-toolbar-icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.side-toolbar-icon-button.split-active,
.side-toolbar-icon-button.group-active {
  border-color: #2f5ab0;
  background: #3567c8;
  color: #fff;
}

.side-toolbar-icon-button-danger {
  color: #b91c1c;
}

.palette-drag-ghost {
  position: fixed;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(15, 23, 42, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.18);
}

.palette-drag-ghost-img {
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 5400;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.8);
}

.modal-content {
  width: 80%;
  max-width: 400px;
  margin: auto;
  padding: 20px;
  border: 1px solid #888;
  border-radius: 8px;
  background-color: #fefefe;
  text-align: center;
}

.modal-content h2 {
  margin-top: 0;
}

.modal-content button {
  padding: 10px 20px;
  border: 0;
  border-radius: 4px;
  background-color: #4caf50;
  color: #fff;
  cursor: pointer;
}

.modal-content button:hover {
  background-color: #45a049;
}

.error-message {
  display: none;
  margin-bottom: 15px;
  color: red;
}

.hidden {
  display: none !important;
}

@media (hover: none) {
  .palette-item:hover,
  .side-toolbar-icon-button:hover:not(:disabled),
  .side-toolbar-icon-button-danger:hover {
    background: #fff;
  }

  .side-toolbar-icon-button.split-active:hover:not(:disabled),
  .side-toolbar-icon-button.group-active:hover:not(:disabled) {
    background: #3567c8;
  }

  .selection-menu-button:hover:not(:disabled) {
    background: transparent;
  }
}

@media (max-width: 1100px) {
  #workspace {
    padding-right: 20px;
    padding-left: 108px;
  }

  body.dreyfous-shell-enabled #workspace {
    padding-right: 20px;
    padding-left: 108px;
  }

  .readout {
    max-width: calc(100vw - 132px);
  }
}

@media (max-width: 760px) {
  #workspace {
    padding: 78px 12px 62px 84px;
  }

  body.dreyfous-shell-enabled #workspace {
    padding: 78px 12px 62px 84px;
  }

  .workspace-header {
    top: 10px;
    left: 12px;
    font-size: 12px;
  }

  .workspace-container {
    inset: 34px 10px 10px;
  }

  .readout {
    bottom: 12px;
    max-width: calc(100vw - 108px);
    padding: 7px 12px;
    font-size: 12px;
  }

  body.dreyfous-shell-enabled #toolbar {
    top: 80px;
    width: 72px;
    max-height: calc(100dvh - 96px);
    padding: 12px 8px;
    border-radius: 0 28px 28px 0;
  }

  .block-palette-inner {
    gap: 8px;
  }

  .palette-item {
    min-height: 64px;
    padding: 7px 5px;
  }

  .palette-divider {
    width: 100%;
    height: 1px;
  }

  .palette-label {
    font-size: 14px;
  }

  .palette-unit-img {
    width: 42px;
    height: 42px;
  }

  .palette-ten-img {
    width: 20px;
    height: 92px;
  }

  .palette-hundred-img,
  .palette-thousand-img {
    width: 52px;
    height: 52px;
  }

  #action-rail {
    top: auto;
    right: 12px;
    bottom: 76px;
    width: auto;
    max-width: calc(100vw - 24px);
    flex-direction: row;
    padding: 8px;
    overflow-x: auto;
    border-right: 1px solid #e5e7eb;
    border-radius: 999px;
  }

  .side-toolbar-icon-button {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    font-size: 18px;
  }
}
