/* Excel ribbon geometry with the active GistHub theme palette. */
.neo-main > .excel-topbar,
.neo-main > .workspace-ribbon {
  color: hsl(var(--foreground)) !important;
  background: hsl(var(--background)) !important;
  font-family: var(--font-ui) !important;
  font-size: 14px;
  letter-spacing: normal !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}
.neo-main > .excel-topbar {
  position: relative;
  flex-shrink: 0;
  min-height: 44px;
  height: 44px;
  padding: 0 20px !important;
  border: 0 !important;
  border-bottom: 1px solid hsl(var(--border)) !important;
}
.excel-topbar .neo-topbar-brand { gap: 8px !important; flex: 0 1 auto; }
.excel-topbar .neo-topbar-brand .neo-brand-mark { display: block !important; width: 24px !important; height: 24px !important; border: 0 !important; border-radius: 4px !important; box-shadow: none !important; }
.excel-topbar .neo-kicker { display: none !important; }
.excel-topbar .neo-topbar-brand h1 { font: 400 15px var(--font-ui) !important; border: 0 !important; outline: none !important; background: none !important; color: hsl(var(--foreground)) !important; }
.excel-topbar .neo-topbar-brand h1 a { border: 0 !important; color: inherit !important; box-shadow: none !important; background: transparent !important; text-decoration: none !important; }
.excel-workspace-title { font-weight: 600; }
.excel-workspace > .excel-topbar .excel-workspace-title {
  flex: 1; min-width: 0; margin-inline: 12px; overflow: hidden;
  text-align: center; text-overflow: ellipsis; white-space: nowrap;
}
.excel-topbar .neo-topbar-actions { gap: 8px !important; flex: 0 1 auto; }
.neo-main > .excel-topbar .neo-topbar-actions :is(.neo-icon-button, .neo-new-snippet) {
  min-width: 32px !important;
  width: 32px !important;
  height: 32px !important;
  min-height: 32px !important;
  padding: 5px !important;
  border: 0 !important;
  border-radius: 4px !important;
  background: transparent !important;
  color: hsl(var(--muted-foreground)) !important;
  box-shadow: none !important;
  transform: none !important;
}
.excel-topbar .neo-new-snippet__label { display: none !important; }
.workspace-layout-toggle {
  display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; flex: none;
  gap: 2px; padding-block: 2px; padding-inline: 2px;
  border: 1px solid hsl(var(--border)); border-radius: 8px;
  background: hsl(var(--muted)); white-space: nowrap;
}
:root[data-interface-style] .neo-topbar .workspace-layout-toggle button {
  min-height: 28px; padding-block: 3px !important; padding-inline: 8px !important;
  border: 1px solid transparent !important; border-radius: 5px !important;
  background: transparent !important; color: hsl(var(--muted-foreground)) !important;
  font: 500 12px/18px var(--font-ui) !important;
  box-shadow: none !important; transform: none !important;
}
:root[data-interface-style] .neo-topbar .workspace-layout-toggle button:hover {
  color: hsl(var(--foreground)) !important;
}
:root[data-interface-style] .neo-topbar .workspace-layout-toggle button[aria-pressed="true"] {
  background: hsl(var(--primary)) !important;
  color: hsl(var(--primary-foreground)) !important;
  font-weight: 600 !important;
}
.workspace-layout-toggle button:focus-visible {
  outline: 2px solid hsl(var(--ring)) !important; outline-offset: 2px;
}
@media (pointer: coarse) {
  .workspace-layout-toggle button { min-height: 44px !important; }
}

.excel-topbar .workspace-more-trigger { display: none; }
:root:not([data-pwa-install-available]) .workspace-install-action { display: none !important; }
@media (min-width: 768px) {
  .excel-topbar .workspace-more-panel { display: contents; }
}
/* Compact command strip: categories scroll independently of the fixed collapse control. */
.neo-main > .workspace-ribbon { position: relative; z-index: 20; padding: 0; border: 0 !important; border-bottom: 1px solid hsl(var(--border)) !important; }
.workspace-tab-row { display: flex; align-items: center; padding: 0 12px; gap: 8px; }
.workspace-ribbon .workspace-tabs { flex: 1; min-width: 0; gap: 2px; height: 44px; min-height: 44px; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; padding: 0; border: 0; align-items: stretch; scrollbar-width: thin; }
.neo-main .workspace-ribbon .workspace-tabs > button {
  position: relative; flex: 0 0 auto; min-height: 40px; padding: 8px 10px;
  border: 0 !important; border-radius: 0 !important; background: transparent !important;
  color: hsl(var(--muted-foreground)) !important; font: 400 13px/20px var(--font-ui) !important;
  box-shadow: none !important; transform: none !important; text-transform: none !important; white-space: nowrap;
}
.neo-main .workspace-ribbon .workspace-tabs > button:hover { color: hsl(var(--foreground)) !important; }
.neo-main .workspace-ribbon .workspace-tabs > button[aria-selected="true"] { color: hsl(var(--foreground)) !important; font-weight: 600 !important; }
.workspace-tabs > button[aria-selected="true"]::after { content: ""; position: absolute; height: 1px; background: hsl(var(--primary)); bottom: 0; left: 10px; right: 10px; }
.workspace-ribbon .ribbon-toggle { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 36px; height: 36px; padding: 0; border: 1px solid hsl(var(--border)); border-radius: 6px; background: transparent; color: hsl(var(--muted-foreground)); }
.workspace-ribbon .ribbon-toggle:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.ribbon-toggle[aria-expanded="false"] svg { transform: rotate(180deg); }
.neo-main .workspace-ribbon .workspace-commands[hidden] { display: none !important; }
.neo-main .workspace-ribbon .workspace-commands {
  display: flex; flex-direction: column; align-items: stretch; margin: 0; padding: 8px 12px;
  min-height: 0; gap: 6px; border: 0 !important; border-top: 1px solid hsl(var(--border)) !important;
  border-radius: 0 !important; background: hsl(var(--background)) !important; box-shadow: none !important;
}
.workspace-ribbon .workspace-command-area { display: block; width: 100%; min-width: 0; }
.workspace-ribbon .workspace-command-area > .workspace-command-group { display: flex; flex-wrap: wrap; align-items: stretch; gap: 4px; }
.workspace-ribbon .ribbon-command { display: flex; flex-direction: row; align-items: center; gap: 2px; padding: 2px; max-width: 100%; min-width: 0; border: 1px solid hsl(var(--border)); border-radius: 6px; background: hsl(var(--card)); }
.workspace-ribbon .ribbon-command > .tool-list-entry { display: flex; flex-wrap: nowrap; flex: 1; gap: 0; min-width: 0; }
.neo-main .workspace-ribbon .tool-list-entry > :is(a, button:not(.tool-help-button)) {
  display: inline-flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px;
  width: auto; max-width: 230px; height: auto; min-height: 36px; padding: 6px 8px !important;
  border: 0 !important; border-radius: 4px !important; background: transparent !important;
  color: hsl(var(--foreground)) !important; box-shadow: none !important; transform: none !important;
  font: 400 13px/18px var(--font-ui) !important; text-transform: none !important; text-align: left; white-space: normal;
}
.workspace-ribbon .tool-list-entry > :is(a, button:not(.tool-help-button)) > span { min-height: 0; }
.workspace-ribbon :is(.ribbon-command-icon, .ribbon-tool-icon) { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 18px; width: 18px; height: 18px; min-height: 0; color: hsl(var(--muted-foreground)); font-size: 13px; }
.workspace-ribbon .ribbon-tool-icon svg { width: 18px; height: 18px; }
.workspace-ribbon .tool-list-entry > .tool-help-button { flex: 0 0 28px; width: 28px; height: 32px; min-height: 32px; padding: 4px; border: 0; background: transparent; color: hsl(var(--muted-foreground)); }
.workspace-ribbon .quick-access-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 0; }
.workspace-ribbon .quick-access-actions button { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; width: 28px; height: 32px; min-height: 32px; padding: 4px; border: 0; border-radius: 4px; background: transparent; color: hsl(var(--muted-foreground)); font-size: 14px; }
.workspace-ribbon .quick-access-actions button[aria-pressed="true"] { color: hsl(var(--foreground)); }
@media (hover: hover) and (pointer: fine) and (not (any-pointer: coarse)) {
  .excel-workspace .workspace-ribbon:not(.is-quick-access) .ribbon-command:not(:hover):not(:focus-within) [data-quick-access-toggle] {
    opacity: 0; pointer-events: none;
  }
}
.workspace-ribbon :is(.quick-access-actions button, .tool-help-button):hover,
.neo-main .workspace-ribbon .tool-list-entry > :is(a, button):hover { background: hsl(var(--accent)) !important; }
.neo-main .workspace-ribbon .tool-list-entry > a.active { background: hsl(var(--accent)) !important; }
.neo-main .workspace-ribbon :is(button, a):focus-visible { outline: 2px solid hsl(var(--primary)) !important; outline-offset: -2px; }
.workspace-ribbon .ribbon-command.is-drop-target { border-left: 3px solid hsl(var(--primary)); background: hsl(var(--accent)); }
.workspace-ribbon.is-quick-access .ribbon-command { flex-direction: column; align-items: stretch; }
.workspace-ribbon.is-quick-access .quick-access-actions { justify-content: flex-end; border-top: 1px solid hsl(var(--border)); }
.workspace-ribbon .quick-access-drag { min-width: 28px; height: 32px; color: hsl(var(--muted-foreground)); }
.workspace-ribbon .quick-access-status { margin: 0; font: 400 12px/18px var(--font-ui); color: hsl(var(--muted-foreground)); }
.workspace-ribbon .ribbon-setting { display: flex; flex-direction: row; align-items: center; gap: 6px; width: auto; min-height: 36px; padding: 0 8px; font-size: 13px; }
.workspace-ribbon .ribbon-setting .neo-theme-trigger { min-height: 32px; padding: 4px; }
.workspace-ribbon .ribbon-setting .neo-theme-trigger__name { display: none; }
.workspace-ribbon .ribbon-setting .neo-sound-toggle { width: 32px; height: 32px; min-height: 32px; padding: 5px !important; border: 0 !important; background: transparent !important; box-shadow: none !important; color: hsl(var(--muted-foreground)); }
@media (max-width: 767px) {
  .neo-main > .excel-topbar { min-height: 44px; height: auto; padding: 4px 12px !important; flex-wrap: nowrap; gap: 8px; }
  .excel-workspace-title { display: none; }
  .excel-topbar .neo-topbar-brand { flex: 0 0 auto !important; }
  .excel-topbar .neo-topbar-brand h1 { display: none; }
  .excel-topbar .neo-topbar-actions {
    flex: 0 1 auto !important; flex-wrap: nowrap; gap: 4px !important;
    min-width: 0; margin-inline-start: auto;
  }
  .neo-main > .excel-topbar .neo-topbar-actions .workspace-more-trigger {
    display: inline-flex; justify-content: center; align-items: center;
    min-width: 52px !important; min-height: 44px !important;
  }
  .excel-topbar .workspace-more-panel:popover-open {
    display: grid; gap: 4px; position: fixed; inset: 64px 12px auto auto;
    margin: 0; width: min(300px, calc(100% - 24px)); max-height: calc(100dvh - 76px);
    overflow-y: auto; padding: 10px; border: 1px solid hsl(var(--border));
    border-radius: 12px; background: hsl(var(--card)); color: hsl(var(--foreground));
    box-shadow: 0 6px 28px hsl(var(--foreground) / .12);
  }
  .neo-main > .excel-topbar .workspace-more-panel :is(.neo-icon-button, .neo-new-snippet) {
    display: flex; align-items: center; justify-content: flex-start; gap: 10px;
    width: 100% !important; height: auto !important; min-height: 44px !important;
    padding: 8px !important; text-align: start; color: hsl(var(--foreground)) !important;
  }
  .workspace-more-panel :is(.neo-icon-button, .neo-new-snippet)::after { content: attr(aria-label) / ""; }
  .workspace-more-panel [data-testid="blur-files-trigger"]::after { content: attr(title) / ""; }
  .workspace-more-panel .workspace-layout-toggle { width: 100%; }
  .workspace-more-panel .workspace-layout-toggle button { min-height: 44px !important; }
  .workspace-more-panel .workspace-install-action { min-height: 44px; justify-content: flex-start; }
  .workspace-tab-row { padding-inline: 8px; gap: 4px; }
  .neo-main .workspace-ribbon .workspace-commands { padding: 6px 8px; }
  .neo-main .workspace-ribbon .tool-list-entry > :is(a, button:not(.tool-help-button)) { max-width: 190px; }
}
@media (pointer: coarse) {
  .workspace-ribbon .ribbon-toggle { flex-basis: 44px; height: 44px; }
  .workspace-ribbon .quick-access-actions button,
  .workspace-ribbon .tool-list-entry > .tool-help-button { min-width: 44px; width: 44px; min-height: 44px; height: 44px; }
  .neo-main .workspace-ribbon .tool-list-entry > :is(a, button:not(.tool-help-button)) { min-height: 44px; }
}

.excel-topbar .profile-avatar { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; gap: 8px; min-width: 32px; height: 32px; padding: 0 !important; border: 0 !important; background: transparent !important; color: hsl(var(--foreground)) !important; box-shadow: none !important; }
.profile-avatar img { width: 32px; height: 32px; object-fit: cover; border: 2px solid hsl(var(--card)); border-radius: 50%; outline: 1px solid hsl(var(--foreground)); outline-offset: 1px; }
.profile-chevron { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 9px; background: hsl(var(--secondary)); }
.profile-dropdown { position: fixed; inset: 52px 12px auto auto; margin: 0; width: min(320px, calc(100vw - 24px)); padding: 20px; border: 1px solid hsl(var(--border) / .4); border-radius: 18px; background: hsl(var(--card)); color: hsl(var(--foreground)); box-shadow: 0 6px 28px hsl(var(--foreground) / .12); font-family: var(--font-ui); }
.profile-dropdown::backdrop { background: transparent; }
.profile-section-label { display: block; margin: 0 0 16px; font-size: 12px; line-height: 18px; font-weight: 500; color: hsl(var(--muted-foreground)); }
.profile-current-account { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.profile-current-account > img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.profile-dropdown-identity { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.profile-dropdown-identity strong { font-size: 14px; line-height: 20px; font-weight: 600; }
.profile-dropdown-identity p { margin: 0; font-size: 12px; line-height: 18px; color: hsl(var(--muted-foreground)); }
.profile-dropdown-identity span { font-size: 12px; line-height: 18px; color: hsl(var(--muted-foreground)); }
.profile-accounts { margin-bottom: 8px; text-decoration: none; }
.profile-accounts:hover { color: hsl(var(--foreground)); }
.profile-signout { display: block; width: 100%; padding: 8px 0; border: 0; background: transparent; text-align: left; font-size: 14px; line-height: 20px; color: hsl(var(--foreground)); }
.profile-signout:hover { color: hsl(var(--primary)); }
.excel-topbar .profile-avatar:focus-visible, .profile-dropdown :is(a, button):focus-visible { outline: 2px solid hsl(var(--primary)); outline-offset: 3px; }

.neo-main .neo-canvas.neo-canvas--tool { display: flex; flex-direction: column; padding: 0 !important; overflow: hidden !important; }
.neo-content[hidden], .tool-workspace-session[hidden] { display: none !important; }
.tool-workspace-session { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; position: relative; z-index: 1; }
.tool-workspace { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; background: hsl(var(--background)); color: hsl(var(--foreground)); overflow: hidden; }
.tool-page-header { display: flex; align-items: center; flex: 0 0 auto; gap: 12px; min-height: 48px; padding: 8px 16px; border-bottom: 1px solid hsl(var(--border)); background: hsl(var(--card)); }
.tool-page-header > h2 { margin: 0 !important; font-size: 18px !important; line-height: 24px !important; font-weight: 600 !important; letter-spacing: normal !important; }
.tool-page-header > button { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 32px; height: 32px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: inherit; }
.tool-page-header > button:hover { background: hsl(var(--accent)); }
.tool-workspace :is(button, a, input, select, textarea):focus-visible { outline: 2px solid hsl(var(--primary)); outline-offset: 2px; }
.tool-page-content { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 16px; }
.tool-page-content > .compact-tool-page { max-width: none; margin: 0; }
.compact-tool-page > :is(div, header):first-child { gap: 8px; margin-bottom: 12px; padding-bottom: 12px !important; }
.compact-tool-page > :is(div, header):first-child h2 { font-size: 18px !important; line-height: 24px !important; font-weight: 600 !important; letter-spacing: normal !important; margin: 0 !important; }
.compact-tool-page > :is(div, header):first-child p { margin-top: 4px !important; font-size: 13px !important; line-height: 20px !important; }
.compact-tool-page > :is(div, header):first-child .neo-kicker { display: none; }
.tool-page-content .compact-tool-page > :is(div, header):first-child h2 { display: none; }
.tool-page-content .compact-tool-page > :is(div, header):first-child { margin-bottom: 0; padding-bottom: 0 !important; }
.tool-page-content .compact-tool-page > div:first-child:not(:has(p, button, a, input, select, textarea, details)) { display: none; }
.tool-page-content .compact-tool-page:not(.skills-page) > * + * { margin-top: 12px; }
.tool-page-content .skills-page { gap: 12px; }
.compact-tool-page .skills-filters { padding: 12px; gap: 12px; }
.compact-tool-page .skills-filters label { font-size: 12px !important; }
.compact-tool-page .skills-filters :is(input, select, button) { min-height: 36px; padding: 6px 10px; font-size: 13px !important; }
@media (max-width: 767px) {
  .tool-page-header { padding-inline: 12px; }
  .tool-page-header > h2 { font-size: 16px !important; }
  .tool-page-content { padding: 12px; }
}
@media print {
  body.printing-markdown .tool-page-header { display: none !important; }
  body.printing-markdown .neo-content[hidden] { display: none !important; }
  body.printing-markdown .neo-main .neo-canvas.neo-canvas--tool { display: block !important; overflow: visible !important; }
  body.printing-markdown .tool-workspace-session:not([hidden]) { position: static; display: block; }
  body.printing-markdown .tool-workspace { height: auto; overflow: visible; }
  body.printing-markdown .tool-page-content { overflow: visible; padding: 0; }
}

.tool-list-entry { display: flex; align-items: center; gap: 2px; }
.tool-help-button { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: hsl(var(--foreground)); font-size: 20px; cursor: pointer; }
.tool-help-button:hover { background: hsl(var(--accent)); }
.tool-help-button:focus-visible { outline: 2px solid hsl(var(--primary)); outline-offset: 2px; }
.tool-help-dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 24px; overflow: auto; border: 1px solid hsl(var(--border)); border-radius: 12px; background: hsl(var(--card)); color: hsl(var(--foreground)); box-shadow: 0 16px 48px #0004; }
.tool-help-dialog::backdrop { background: #0008; }
.tool-help-dialog h2 { font-size: 20px; font-weight: 700; }
.tool-help-dialog h3 { font-weight: 700; margin-bottom: 8px; }
.tool-help-dialog section { margin: 20px 0; }
.tool-help-dialog p { margin: 8px 0; line-height: 1.8; }
.tool-help-dialog [lang="my"] { line-height: 1.9; }

.tool-heading-inline { display: flex; align-items: center; gap: 8px; }
.tool-heading-inline > :is(h1, h2) { min-width: 0; }

/* Reference grouping has no effect on the alternate sidebar or older appearances. */
.ribbon-group,.ribbon-group-items { display:contents; }
.ribbon-group-label { display:none; }

/* Favorite commands use a badge; Quick Access keeps its reorder controls. */
.excel-workspace .workspace-ribbon:not(.is-quick-access) .ribbon-command { position: relative; }
.excel-workspace .workspace-ribbon:not(.is-quick-access) .quick-access-actions {
  position: absolute; top: 2px; right: 2px; z-index: 1;
}
.excel-workspace .workspace-ribbon:not(.is-quick-access) .quick-access-actions [data-quick-access-toggle] {
  width: 24px; min-width: 24px; height: 24px; min-height: 24px;
  padding-block: 0; padding-inline: 0;
  border: 1px solid hsl(var(--border)); border-radius: 50%; background: hsl(var(--card));
}
.excel-workspace .workspace-ribbon:not(.is-quick-access) .tool-list-entry { padding-right: 0; }
/* Help is a sibling control, so anchor the badge before it rather than outside the tile. */
.excel-workspace .workspace-ribbon:not(.is-quick-access) .ribbon-command:has(.tool-help-button) .quick-access-actions { right:30px; }

@media (max-width:767px), (pointer:coarse) {
  .excel-workspace .workspace-ribbon:not(.is-quick-access) .quick-access-actions { position: static; }
  .excel-workspace .workspace-ribbon:not(.is-quick-access) .quick-access-actions [data-quick-access-toggle] {
    width:44px; min-width:44px; height:44px; min-height:44px;
    border:0; background:radial-gradient(circle, hsl(var(--secondary)) 12px, transparent 13px);
  }
}
