/* ============================================================
   Ribbon geometry — a strict grid (unchanged invariants):
   row 22px | row-gap 1px | 2-row stack 45px | big control 66px
   gallery 62px | caption strip 15px | icon slots: 34px large / 16px small
   Chrome — quiet Office neutrals measured from PowerPoint 2019:
   body #F3F3F3 flat, text #444242, separators #DCDCDC, 1px hairlines.
   ============================================================ */
.ribbon-host { flex: none; background: var(--ppt-accent); position: relative; z-index: 40; }
.ribbon-tabs {
  display: flex; align-items: flex-end; height: 27px; padding-left: 2px; gap: 1px;
  color: #FDF2EE; font-size: 12px;
}
.tab {
  padding: 4px 12px 3px; color: inherit; position: relative;
  border-radius: 3px 3px 0 0;
  border: 1px solid transparent; border-bottom: none;
  line-height: 1;
}
.tab:hover { background: rgba(255,255,255,.16); color: #fff; }
.tab.active { background: var(--ribbon-bg); color: var(--text-dark); border-color: transparent; }
.tab.file-tab { color: #fff; font-weight: 600; margin-right: 6px; }
.tab.file-tab.active { background: var(--ribbon-bg); }
.ribbon-host.collapsed .ribbon-body-outer { display: none; }
.ribbon-body-outer { background: var(--ribbon-bg); }
.ribbon-body {
  height: 96px; padding: 0 4px;
  background: var(--ribbon-bg);
  overflow: hidden; position: relative;
}
.ribbon-tab-page { display: none; align-items: stretch; height: 100%; }
.ribbon-tab-page.active { display: flex; }

/* ---- groups: uniform padding, inset separators, bottom caption strip ---- */
.rg {
  display: flex; flex-direction: row; align-items: center; column-gap: 5px;
  padding: 4px 7px 15px; position: relative; flex: none;
  height: 100%; min-width: 0;
}
.rg + .rg::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 17px;
  width: 1px; background: var(--ribbon-sep);
}
.rg-name {
  position: absolute; left: 2px; right: 2px; bottom: 1px; height: 13px;
  line-height: 13px; text-align: center;
  font-size: 9.5px; color: #434242; pointer-events: none;
  white-space: nowrap; overflow: hidden;
}
.rg.disabled { opacity: .38; pointer-events: none; }

/* ---- two-row stacks and rows (the Office line model) ---- */
.rg-col { display: flex; flex-direction: column; justify-content: center; gap: 1px; flex: none; }
.rg-rows { display: flex; flex-direction: column; justify-content: center; gap: 1px; flex: none; }
.rg-row { display: flex; align-items: center; gap: 1px; height: 22px; flex: none; }

/* compact color buttons (Font Color / Shape Fill) */
.rb.color-btn { flex-direction: column; gap: 0; padding: 1px 0 0; }
.rb.color-btn .cb-glyph { display: flex; align-items: flex-start; height: 15px; }
.rb.color-btn .cb-bar { display: block; width: 15px; height: 3px; margin-top: 1px; border: 1px solid #949799; }

/* ---- generic button chrome: exact-bounds hover, one radius ---- */
.rb {
  display: flex; align-items: center; justify-content: center;
  border-radius: 2px; position: relative; color: var(--text-dark);
  border: 1px solid transparent; flex: none;
}
.rb:hover { background: #E2E0DF; border-color: #D4D2D1; }
.rb:active, .rb.active { background: #D8D6D5; border-color: #C9C7C6; }
.rb.toggled { background: #DCDAD9; border-color: #C9C7C6; }
.rb.disabled { opacity: .35; pointer-events: none; }

/* small (row) buttons — 23x22, 16px icons */
.rb.small { width: 23px; height: 22px; }
/* small button with text label beside the 16px icon */
.rb.small-wide { height: 22px; padding: 0 6px; gap: 4px; font-size: 11px; white-space: nowrap; }
.rb.tiny { width: 17px; height: 17px; font-size: 11px; }

/* ---- large controls: fixed icon slot on top, fixed label slot at bottom ---- */
.rb.medium, .rb.big {
  flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 0; padding: 4px 3px 3px; height: 66px;
}
.rb.medium { min-width: 66px; }
.rb.big { width: 58px; }
.rb.medium .rb-icon, .rb.big .rb-icon {
  height: 34px; display: flex; align-items: flex-start; justify-content: center;
}
.rb.medium .rb-label, .rb.big .rb-label { word-break: normal;
  height: 25px; padding-top: 1px; display: flex; align-items: flex-start; justify-content: center;
  font-size: 11px; line-height: 1.15; text-align: center; color: #444242;
  overflow: hidden; padding-left: 2px; padding-right: 2px;
}

/* split buttons: 66px tall, main area + 10px chevron strip */
.rb-split { display: flex; flex-direction: column; align-items: stretch; width: 58px; height: 66px; flex: none; }
.rb-split .rb-split-main {
  flex: 1 1 auto; min-height: 0; width: 100%; border-radius: 2px 2px 0 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 0; padding: 4px 3px 3px; border: 1px solid transparent;
}
.rb-split .rb-split-main:hover { background: #E2E0DF; border-color: #D4D2D1; border-bottom: none; }
.rb-split .rb-split-main .rb-icon { height: 34px; display: flex; align-items: flex-start; justify-content: center; }
.rb-split .rb-split-main .rb-label {
  height: 25px; padding-top: 1px; display: flex; align-items: flex-start; justify-content: center;
  font-size: 11px; line-height: 1.15; text-align: center; overflow: hidden; padding-left: 2px; padding-right: 2px;
  color: #444242;
}
.rb-split .rb-split-menu {
  width: 100%; height: 10px; display: flex; align-items: center; justify-content: center;
  border-radius: 0 0 2px 2px; border: 1px solid transparent; border-top: 1px solid #DCDCDC; margin-top: 0;
  color: #5B5B5B;
}
.rb-split .rb-split-menu:hover { background: #E2E0DF; border-color: #D4D2D1; }

.rb-letter { font-size: 15px; font-weight: 600; line-height: 1; padding-top: 0; color: #444242; }
.rb-letter.serif { font-family: Georgia, "Times New Roman", serif; }

/* combo rows (font / size) */
.rb-combo-row { display: flex; gap: 1px; align-items: center; height: 22px; flex: none; }
.rb-select {
  height: 22px; min-width: 0; border: 1px solid #C8C8C8; background: #fff; border-radius: 2px;
  font-size: 11.5px; padding: 0 3px; color: #444242;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23717171' stroke-width='1.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 5px center; padding-right: 16px;
}
.rb-select:hover { border-color: #A6A6A6; }
.rb-select:disabled { background: #F3F3F3; color: #A6A6A6; }
.rb-num {
  height: 22px; width: 42px; border: 1px solid #C8C8C8; border-radius: 2px; text-align: left;
  padding: 0 5px; font-size: 11.5px; color: #444242;
}
.rb-num:disabled { background: #F3F3F3; color: #A6A6A6; }
.rb-num:focus { outline: 1px solid #2A73B7; }

/* in-ribbon gallery strips */
.rb-gallery {
  display: flex; align-items: center; height: 62px;
  border: 1px solid transparent; border-radius: 2px; overflow: hidden; flex: none;
}
.rb-gallery:hover { border-color: #DCDCDC; }
.rb-gallery .gal-frame { width: 74px; height: 60px; display: flex; align-items: stretch; padding: 3px; }
.rb-gallery .gal-frame .gal-inner { display: flex; gap: 2px; overflow: hidden; flex: 1; align-items: center; }
.rb-gallery .gal-more {
  width: 14px; align-self: stretch; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-left: 1px solid #E3E3E3;
}
.rb-gallery .gal-more:hover { background: #E2E0DF; }
.rb-gallery .gal-more .gm-bar { width: 7px; height: 1.5px; background: #717171; margin: 1.5px 0; }
.rb-gallery.disabled { opacity: .35; pointer-events: none; }

/* dropdown lists */
.rb-drop {
  position: absolute; z-index: 600; background: #fff; border: 1px solid #D4D4D4; border-radius: 2px;
  box-shadow: 0 2px 6px rgba(0,0,0,.14); padding: 3px; font-size: 12px; min-width: 150px;
  color: #444242;
}
.rb-drop-item {
  display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 10px; white-space: nowrap;
  color: #444242; border-radius: 2px;
}
.rb-drop-item:hover { background: #ECECEC; }
.rb-drop-item.disabled { color: #B3B0AD; pointer-events: none; }
.rb-drop-item .key { margin-left: auto; color: #8C8C8C; padding-left: 24px; font-size: 11px; }
.rb-drop-sep { height: 1px; background: #E5E5E5; margin: 3px 6px; }
.rb-drop-title { padding: 5px 10px 3px; font-size: 11px; color: #5B5B5B; }

/* gallery panels */
.gal-panel {
  position: absolute; z-index: 610; background: #F7F7F7; border: 1px solid #D4D4D4; border-radius: 2px;
  box-shadow: 0 3px 9px rgba(0,0,0,.15); padding: 8px; width: 428px;
}
.gal-panel.shapes { width: auto; }
.gal-panel .gal-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-height: 330px; overflow-y: auto; }
.gal-panel.shapes .gal-grid { grid-template-columns: repeat(10, 34px); gap: 3px; max-height: 240px; }
.gal-item { background: #fff; border: 1px solid #DEDEDE; border-radius: 2px; cursor: pointer; position: relative; padding: 0; display: block; }
.gal-item:hover { border-color: #7FB2E0; background: #F3F9FF; }
.gal-item.selected { border-color: var(--ppt-accent); box-shadow: 0 0 0 1px var(--ppt-accent); }
.gal-item .gi-label {
  font-size: 10px; color: #444242; text-align: center; padding: 3px 2px 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gal-item .gi-preview { height: 84px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.gal-item.shapes { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; }
.gal-panel .gal-footer { display: flex; justify-content: flex-end; border-top: 1px solid #E5E5E5; margin-top: 8px; padding-top: 6px; gap: 6px; }
.gal-panel .gal-footer button { padding: 3px 10px; border: 1px solid #C8C8C8; background: #fff; border-radius: 2px; }
.gal-panel .gal-footer button:hover { background: #ECECEC; }
.shape-icon svg { width: 22px; height: 22px; }

/* color picker panels */
.color-panel { width: 236px; }
.color-panel .cp-title { font-size: 11px; color: #5B5B5B; padding: 4px 4px 3px; }
.color-grid { display: grid; grid-template-columns: repeat(10, 17px); gap: 2px; padding: 2px; }
.color-cell { width: 17px; height: 17px; border: 1px solid rgba(0,0,0,.15); border-radius: 1px; cursor: pointer; }
.color-cell:hover { outline: 2px solid #2A73B7; }
.color-cell.nores { background: #fff; position: relative; }
.color-cell.nores::after { content: ""; position: absolute; inset: 2px; background: linear-gradient(45deg, transparent 45%, #C42B1C 45%, #C42B1C 55%, transparent 55%); }
.color-panel .cp-actions { border-top: 1px solid #E5E5E5; margin-top: 6px; padding-top: 5px; }
.color-panel .cp-actions .rb-drop-item { gap: 10px; }

/* font gallery */
.fg-item { font-size: 12.5px; padding: 4px 10px; display: flex; justify-content: space-between; gap: 18px; }
.fg-item:hover { background: #ECECEC; }

/* checkboxes / sliders inside the ribbon */
.rb-check { display: flex; align-items: center; gap: 5px; font-size: 11px; white-space: nowrap; height: 22px; }
.rb-check input { accent-color: var(--ppt-accent); margin: 0; }

/* shape icon svg sizing */
.shape-icon svg { width: 22px; height: 22px; }
