.toolbar {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  background-color: rgba(255, 255, 255, 0.85);
  border-radius: 28px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  backdrop-filter: blur(10px);
  z-index: 100;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

.toolbar-left {
  left: 85px;
}

.toolbar-right {
  right: 85px;
}

.tablet-mode .toolbar-left {
  left: 40px;
}

.tablet-mode  .toolbar-right {
  right: 40px;
}

.toolbar-bottom {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translate(-50%, calc(100% + 40px));
  height: 56px;
  background-color: rgba(255, 255, 255, 0.85);
  border-radius: 28px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 0 16px;
  backdrop-filter: blur(10px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: transform 0.35s ease, opacity 0.35s ease, visibility 0.35s ease;
}

.toolbar-button {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0;
  cursor: pointer;
  color: #5f6368;
  transition: all 0.2s ease;
  position: relative;
}

.toolbar-button:hover {
  background-color: #f1f3f4;
  color: #1a73e8;
}

.toolbar-button.tool-button--selected {
  background: #1f6feb;
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(31, 111, 235, 0.35);
}

.toolbar-button.tool-button--selected img {
  filter: brightness(0) invert(1);
}

.manual-hint-toast {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9999;
  max-width: min(320px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.92);
  color: #ffffff;
  font-size: 14px;
  line-height: 1.35;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: translateX(-8px);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.manual-hint-toast.is-visible {
  opacity: 1;
  transform: translateX(0);
}

.tablet-usage-toast {
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 9999;
  transform: translate(-50%, -8px);
  max-width: min(420px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.92);
  color: #ffffff;
  font-size: 14px;
  line-height: 1.35;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.tablet-usage-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toolbar-button.is-active {
  background-color: #e8f0fe;
  color: #1a73e8;
  box-shadow: 0 0 0 1px rgba(26, 115, 232, 0.2);
}

.toolbar-button img {
  width: 20px;
  height: 20px;
}

.toolbar-button[data-tooltip]::after,
.toolbar-button[data-tooltip]::before {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toolbar-button[data-tooltip]::after {
  content: attr(data-tooltip);
  top: 50%;
  transform: translateY(-50%) translateX(0);
  background: rgba(26, 32, 44, 0.9);
  color: #fff;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
  z-index: 9999;
}

#tabletToolbarTooltipOverlay {
  position: fixed;
  z-index: 9999;
  max-width: min(280px, calc(100vw - 24px));
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(26, 32, 44, 0.92);
  color: #ffffff;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translate(0, -50%);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#tabletToolbarTooltipOverlay.is-visible {
  opacity: 1;
}

#tabletToolbarTooltipOverlay.placement-left {
  transform: translate(-100%, -50%);
}

#tabletToolbarTooltipOverlay.placement-right {
  transform: translate(0, -50%);
}

#tabletToolbarTooltipOverlay.placement-top {
  transform: translate(-50%, -100%);
}

.toolbar-left .toolbar-button[data-tooltip]::after {
  left: calc(100% + 14px);
}

.toolbar-right .toolbar-button[data-tooltip]::after {
  right: calc(100% + 14px);
}

.toolbar-bottom .toolbar-button[data-tooltip]::after {
  top: auto;
  bottom: calc(100% + 10px);
  left: 50%;
  right: auto;
  transform: translate(-50%, 0);
}

.toolbar-button[data-tooltip]:hover::after,
.toolbar-button[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.toolbar-bottom .toolbar-button[data-tooltip]:hover::after,
.toolbar-bottom .toolbar-button[data-tooltip]:focus-visible::after {
  transform: translate(-50%, 0);
}

body.tablet-mode .toolbar-button[data-tooltip]:hover::after,
body.tablet-mode .toolbar-button[data-tooltip]:focus::after,
body.tablet-mode .toolbar-button[data-tooltip]:focus-visible::after {
  opacity: 0;
}

body.tablet-mode .toolbar-button.tablet-tooltip-visible::after,
body.tablet-mode .toolbar-button.tablet-tooltip-visible:hover::after,
body.tablet-mode .toolbar-button.tablet-tooltip-visible:focus::after,
body.tablet-mode .toolbar-button.tablet-tooltip-visible:focus-visible::after {
  opacity: 1;
}

body.simple-mode-active .toolbar-left {
  transform: translate(-180%, -50%);
  opacity: 0;
  pointer-events: none;
}

body.simple-mode-active .toolbar-right {
  transform: translate(180%, -50%);
  opacity: 0;
  pointer-events: none;
}

body.simple-mode-active .toolbar-bottom {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
  visibility: visible;
}

.tablet-eraser-button {
  display: none;
}

.tablet-eraser-button.is-visible {
  display: inline-flex;
}

.tablet-eraser-button.is-active {
  background: #1f6feb;
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(31, 111, 235, 0.35);
}

.tablet-undo-redo {
  gap: 8px;
}

body.simple-mode-active .tablet-undo-redo {
  opacity: 0;
  transform: translate(-50%, calc(100% + 40px));
  pointer-events: none;
  visibility: hidden;
}

.tablet-undo-redo.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
  visibility: visible;
}

.tablet-undo-redo .toolbar-button.is-active {
  background: #1f6feb;
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(31, 111, 235, 0.35);
}

.tablet-undo-redo .toolbar-button.is-active img {
  filter: brightness(0) invert(1);
}

.tool-popouts {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 35;
}

.tool-popout {
  position: absolute;
  display: none;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
  pointer-events: auto;
}

.tool-popout.no-display {
  display: none !important;
}

.tool-popout.is-visible {
  display: flex;
}

.tool-popout .popout-button {
  margin: 0;
}

.tool-popout .toolbar-button.is-active {
  background: #1f6feb;
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(31, 111, 235, 0.35);
}

.tool-popout .toolbar-button.is-active img {
  filter: brightness(0) invert(1);
}

@media (min-width: 768px) and (max-width: 1199px) {
  body.tablet-mode .toolbar {
    width: 64px;
    padding: 20px 0;
    border-radius: 30px;
  }

  body.tablet-mode .toolbar-left {
    left: 32px;
  }

  body.tablet-mode .toolbar-right {
    right: 32px;
  }

  body.tablet-mode .toolbar-button {
    width: 44px;
    height: 44px;
    margin: 6px 0;
  }

  body.tablet-mode #simpleToolbar {
    display: none;
  }

  body.tablet-mode .tablet-undo-redo {
    bottom: 72px;
  }
}

@media (min-width: 1024px) and (max-width: 1366px) {
  body.tablet-mode .toolbar-left {
    left: 40px;
  }

  body.tablet-mode .toolbar-right {
    right: 40px;
  }

  body.tablet-mode .toolbar-bottom.tablet-undo-redo .toolbar-button {
    margin: 0 6px;
  }
}
