#editorShell[data-active-tab="tab-draw"] {
  grid-template-columns: minmax(0, 1fr);
}

#ribbon-draw {
  --draw-surface: #f6f7fa;
  --draw-ink: #253345;
  --draw-muted: #4d5969;
  --draw-divider: #d7dee7;
  --draw-icon: #445871;
  --draw-accent: #245fb9;
  --draw-hover: #e7eef9;
  --draw-selected: #dfebfd;
  --draw-selected-line: #84a8e3;
  align-items: stretch;
  gap: 0;
  min-height: 106px;
  padding: 5px 8px 4px;
  overflow: auto hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--draw-divider) transparent;
  background: var(--draw-surface);
  color: var(--draw-ink);
}

:root[data-office-theme="dark"] #ribbon-draw {
  --draw-surface: #282e38;
  --draw-ink: #f1f3f8;
  --draw-muted: #c5cbd6;
  --draw-divider: #48515f;
  --draw-icon: #d5dce8;
  --draw-accent: #80acf8;
  --draw-hover: #394659;
  --draw-selected: #354d75;
  --draw-selected-line: #719bea;
}

.ribbon-tabs #tab-draw[aria-selected="true"] {
  border-radius: 4px 4px 0 0;
  box-shadow: inset 0 -2px #5689e5;
}

.draw-group {
  display: grid;
  grid-template-rows: 72px 18px;
  flex: 0 0 auto;
  align-content: end;
  padding: 0 6px;
  border-inline-end: 1px solid var(--draw-divider);
}
.draw-group:first-child { padding-inline-start: 0; }
.draw-group:last-child { border-inline-end: 0; }
.draw-group-body { display: flex; align-items: start; justify-content: center; gap: 2px; }
.draw-caption {
  align-self: end;
  color: var(--draw-muted);
  font-size: .6875rem;
  line-height: 15px;
  text-align: center;
  white-space: nowrap;
}

.draw-ribbon button {
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0;
}
.draw-ribbon button:not(:disabled):is(:hover,:focus-visible) {
  background: var(--draw-hover);
  border-color: var(--draw-divider);
}
.draw-ribbon button[aria-pressed="true"] {
  background: var(--draw-selected);
  border-color: var(--draw-selected-line);
}
.draw-ribbon button:focus-visible { outline: 2px solid var(--draw-accent); outline-offset: -2px; }
.draw-ribbon button:disabled { opacity: .38; cursor: default; }

.draw-ribbon .draw-command {
  display: grid;
  grid-template-rows: 34px auto;
  justify-items: center;
  align-items: center;
  align-content: start;
  min-width: 49px;
  min-height: 64px;
  max-width: 108px;
  padding: 3px 5px 2px;
  font-size: .75rem;
  line-height: 1.05;
  text-align: center;
}
.draw-command span { align-self: start; white-space: nowrap; }
.draw-icon {
  display: block;
  width: 28px;
  height: 28px;
  fill: none;
  stroke: var(--draw-icon);
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.draw-icon .draw-icon-accent { stroke: var(--draw-accent); }
.draw-split { display: grid; grid-template-rows: 56px 13px; justify-items: stretch; }
.draw-split .draw-command { min-height: 56px; }
.draw-split .draw-command:is([data-draw-action="shape"], [data-draw-action="canvas"]) {
  grid-template-rows: 29px auto;
  padding-block-start: 1px;
}
.draw-subcommand::before {
  content: "";
  display: block;
  width: 5px;
  height: 5px;
  border-inline-end: 1px solid currentColor;
  border-block-end: 1px solid currentColor;
  margin: 0 auto 2px;
  rotate: 45deg;
}
.draw-ribbon .draw-math-command { min-width: 110px; max-width: none; }
.draw-ribbon .draw-add-command { margin-inline-start: 2px; }

.draw-history {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: stretch;
  align-content: start;
  gap: 3px;
  padding-top: 4px;
}
.draw-ribbon .draw-history-command {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 26px;
  padding: 2px 5px;
  font-size: .75rem;
  text-align: start;
}
.draw-history-command svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--draw-icon);
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.draw-tools { gap: 2px; }
.draw-profile-gallery {
  display: flex;
  align-items: start;
  gap: 1px;
  padding: 0 3px;
}
.draw-profile {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 56px 13px;
  flex: none;
  width: 34px;
}
.draw-ribbon .draw-profile-button {
  display: grid;
  place-items: center;
  height: 56px;
}
.draw-profile svg { display: block; width: 23px; height: 53px; overflow: visible; }
.draw-profile-gear { font-size: .625rem; line-height: 9px; }
.draw-profile-gear::before { width: 4px; height: 4px; margin-block-end: 3px; }

.draw-preferences {
  width: min(492px, calc(100% - 30px));
  max-height: calc(100dvh - 30px);
  overflow: auto;
}
.draw-preferences form { margin: 0; }
.draw-preferences .draw-profile-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px 12px;
}
.draw-profile-fields label { margin-top: 0; }
.draw-profile-fields :is(select, input) { width: 100%; }
.draw-profile-fields input[type="color"] { min-height: 32px; padding: 4px; }
.draw-profile-fields input[type="checkbox"],
.draw-preferences .draw-touch-check input { width: auto; }
.draw-profile-fields .draw-check-field { grid-column: 1 / -1; }
.draw-profile-preview {
  display: grid;
  gap: 3px;
  margin: 12px 0 5px;
  color: var(--muted);
  font-size: .8125rem;
}
.draw-profile-preview svg {
  display: block;
  width: 100%;
  height: 68px;
  border: 1px solid #d2d8e3;
  border-radius: 5px;
  background: #fff;
}
.draw-profile-manager {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-block: 11px;
}
.draw-profile-manager button:disabled { opacity: .5; cursor: default; }
.draw-preferences .draw-pref-status { margin: 8px 0 0; font-size: .8125rem; }
.draw-preferences .draw-touch-check { display: flex; align-items: center; gap: 7px; margin-block: 10px; }
.draw-ink-help { width: min(620px, calc(100% - 30px)); }
.draw-ink-help ul { display: grid; gap: 6px; padding-inline-start: 22px; }
.draw-ink-help p:last-child { margin-bottom: 0; }

@media (max-width: 630px) {
  #ribbon-draw { padding-inline: 5px; }
  .draw-group { padding-inline: 4px; }
  .draw-profile { width: 31px; }
}
@media (max-width: 380px) {
  .draw-preferences .draw-profile-fields { grid-template-columns: 1fr; }
}
@media print {
  #ribbon-draw, .draw-preferences { display: none !important; }
}
