.office-app {
  --office-accent: #217346;
  --office-ink: #242424;
  --office-border: #d7d7d7;
  display: flex;
  width: min(100%, 1200px);
  min-height: 550px;
  max-height: calc(100vh - 205px);
  flex-direction: column;
  margin-inline: auto;
  overflow: hidden;
  border: 1px solid #b9bdc3;
  border-radius: 7px;
  background: #f3f3f3;
  box-shadow: 0 8px 26px rgb(0 0 0 / 14%);
  color: var(--office-ink);
  font: 13px/1.35 "Segoe UI", Arial, sans-serif;
}

.word-simulator { --office-accent: #185abd; }
.excel-app { --office-accent: #217346; }
.powerpoint-app { --office-accent: #c43e1c; }

.office-titlebar {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 12px;
  background: var(--office-accent);
  color: white;
}

.office-titlebar__left,
.office-titlebar__right,
.office-search {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.office-app-icon {
  display: grid;
  width: 25px;
  height: 28px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 72%);
  border-radius: 3px;
  font-size: 17px;
  font-weight: 700;
}

.office-titlebar__button,
.office-account {
  min-height: 30px;
  padding: 4px 9px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.office-titlebar__button:hover { background: rgb(255 255 255 / 17%); }
.office-account { width: 30px; min-width: 30px; border-radius: 50%; background: #fff; color: #3c4651; font-weight: 700; }
.office-document-name { overflow: hidden; max-width: 190px; text-overflow: ellipsis; white-space: nowrap; }
.office-save-state { color: rgb(255 255 255 / 78%); font-size: 11px; }

.office-search {
  width: min(320px, 34vw);
  min-height: 30px;
  padding-inline: 9px;
  border: 1px solid rgb(255 255 255 / 42%);
  border-radius: 4px;
  background: rgb(255 255 255 / 94%);
  color: #626262;
}

.office-search input { width: 100%; border: 0; outline: 0; background: transparent; font: inherit; }

.office-tabs {
  display: flex;
  min-height: 36px;
  align-items: stretch;
  gap: 2px;
  overflow-x: auto;
  padding-inline: 10px;
  border-bottom: 1px solid var(--office-border);
  background: #fff;
  scrollbar-width: thin;
}

.office-tab {
  position: relative;
  flex: 0 0 auto;
  min-width: 43px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: #333;
  font: inherit;
  cursor: pointer;
}

.office-tab:hover { background: #f2f2f2; }
.office-tab.is-active::after { position: absolute; right: 9px; bottom: 0; left: 9px; height: 2px; background: var(--office-accent); content: ""; }

.office-ribbon {
  display: flex;
  min-height: 94px;
  align-items: stretch;
  gap: 3px;
  overflow-x: auto;
  padding: 7px 8px 4px;
  border-bottom: 1px solid var(--office-border);
  background: #fff;
  scrollbar-width: thin;
}

.office-ribbon-group {
  position: relative;
  display: flex;
  min-width: 58px;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 7px 18px;
  border-right: 1px solid #e6e6e6;
}

.office-ribbon-group__label { position: absolute; right: 3px; bottom: 1px; left: 3px; color: #6a6a6a; font-size: 10px; text-align: center; white-space: nowrap; }
.office-ribbon-command { display: flex; min-width: 46px; min-height: 54px; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 4px; border: 1px solid transparent; border-radius: 3px; background: transparent; color: #303030; font: inherit; cursor: pointer; }
.office-ribbon-command:hover,.office-mini-tools button:hover { border-color: #c8d7e8; background: #edf4fb; }
.office-ribbon-command > span { max-width: 72px; font-size: 10px; text-align: center; }
.office-ribbon-command:not(:has(> span)) { color: var(--office-accent); font-size: 23px; }
.office-ribbon-group--font { min-width: 210px; flex-wrap: wrap; align-content: center; justify-content: flex-start; }
.office-ribbon-group--font label,.office-theme-tools label { display: flex; align-items: center; gap: 4px; font-size: 10px; }
.office-ribbon-group--font select,.office-theme-tools select { max-width: 90px; min-height: 26px; border: 1px solid #c8c8c8; background: #fff; color: #222; font: inherit; }
.office-mini-tools { display: flex; gap: 1px; }
.office-mini-tools button { min-width: 29px; min-height: 29px; border: 1px solid transparent; border-radius: 3px; background: #fff; color: #262626; font: inherit; cursor: pointer; }
.office-ribbon--excel,.office-ribbon--powerpoint { min-height: 104px; }
.office-ribbon--word { min-height: 88px; padding: 0; }
.office-ribbon--word .office-ribbon__toolbar { display: flex; width: 100%; min-height: 86px; align-items: stretch; gap: 3px; padding: 6px 8px 3px; }
.office-ribbon__group { position: relative; display: flex; min-width: 60px; align-items: center; justify-content: center; gap: 3px; padding: 4px 7px; border-right: 1px solid #e6e6e6; }
.office-ribbon__font-size { display: flex; align-items: center; gap: 5px; padding: 4px; font-size: 10px; }
.office-ribbon__font-size select { min-height: 28px; border: 1px solid #c8c8c8; border-radius: 2px; background: #fff; color: #222; font: inherit; }
.office-ribbon__group:last-child { justify-content: flex-start; }
.office-ribbon__group:has([data-action]) { min-width: max-content; }
.office-ribbon__group .office-tool { min-height: 43px; border-radius: 3px; }
.office-ribbon__group .office-tool:hover { border-color: #c6d6e8; background: #edf4fb; }
.office-ribbon__group .office-tool--wide { min-width: 105px; font-size: 10px; }
.word-simulator .office-doc-page { flex: 1; }
.office-ribbon--excel .office-ribbon-group--sort { min-width: 132px; }
.office-ribbon--excel .office-ribbon-group--sort .office-ribbon-command { min-width: 56px; }
.office-theme-tools { min-width: 132px; flex-direction: column; }

.office-doc-page {
  position: relative;
  width: min(816px, calc(100% - 40px));
  min-height: 460px;
  margin: 22px auto;
  padding: 68px 74px;
  overflow: auto;
  background: #fff;
  box-shadow: 0 1px 5px rgb(0 0 0 / 20%);
  color: #202020;
  font: 16px/1.5 Calibri, "Segoe UI", sans-serif;
}

.office-doc-page:focus { outline: 1px solid #9bbde0; }
.office-doc-page table { width: 100%; border-collapse: collapse; }
.office-doc-page td,.office-doc-page th { min-width: 60px; padding: 5px; border: 1px solid #777; }
.office-statusbar { display: flex; min-height: 26px; align-items: center; gap: 18px; margin-top: auto; padding: 3px 12px; background: var(--office-accent); color: #fff; font-size: 11px; }
.office-statusbar__spacer { flex: 1; }

.excel-formula-bar { display: flex; min-height: 32px; align-items: center; gap: 8px; padding: 3px 8px; border-bottom: 1px solid #c9c9c9; background: #fff; }
.excel-name-box { width: 76px; }
.excel-name-box input,.excel-formula-input { width: 100%; height: 25px; padding: 2px 6px; border: 1px solid #c6c6c6; border-radius: 2px; font: inherit; }
.excel-fx { font-family: Georgia,serif; font-style: italic; }
.excel-formula-input { flex: 1; }
.excel-grid-scroll { min-height: 250px; flex: 1; overflow: auto; background: #fff; }
.excel-grid { min-width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; font: 12px Calibri,"Segoe UI",sans-serif; }
.excel-grid th { position: sticky; z-index: 1; min-width: 86px; height: 22px; border-right: 1px solid #d4d4d4; border-bottom: 1px solid #d4d4d4; background: #f3f3f3; color: #444; font-weight: 400; text-align: center; }
.excel-grid thead th { top: 0; }
.excel-grid tbody th { left: 0; min-width: 38px; }
.excel-grid .excel-corner { left: 0; z-index: 2; min-width: 38px; }
.excel-grid td { min-width: 86px; height: 23px; padding: 2px 4px; border-right: 1px solid #e4e4e4; border-bottom: 1px solid #e4e4e4; background: #fff; outline: 0; white-space: nowrap; }
.excel-grid td:focus,.excel-grid td.is-selected { position: relative; outline: 2px solid #217346; outline-offset: -2px; }
.excel-grid.is-formatted-table tbody tr:nth-child(even) td { background: #e2f0d9; }
.excel-grid.is-formatted-table tbody tr:first-child td { background: #217346; color: #fff; }
.excel-chart-area { display: flex; max-height: 110px; justify-content: center; background: #fff; }
.excel-column-chart { display: flex; width: 210px; height: 92px; align-items: end; justify-content: space-around; gap: 8px; padding: 4px 14px; border-left: 1px solid #777; border-bottom: 1px solid #777; background: repeating-linear-gradient(to bottom,#fff 0,#fff 22px,#e8e8e8 23px); }
.excel-chart-bar { width: 22px; min-height: 6px; background: #4472c4; }

.powerpoint-workspace { display: grid; min-height: 0; flex: 1; grid-template-columns: 144px minmax(250px,1fr) 178px; background: #e8e8e8; }
.powerpoint-thumbnails { overflow: auto; padding: 10px 7px; background: #f6f6f6; }
.powerpoint-thumbnails ol { display: grid; gap: 9px; margin: 10px 0 0; padding: 0; list-style: none; }
.powerpoint-add-slide { width: 100%; min-height: 29px; border: 1px solid #bbb; border-radius: 3px; background: #fff; color: #333; font: inherit; cursor: pointer; }
.powerpoint-thumbnail { display: flex; width: 100%; align-items: center; gap: 7px; padding: 3px; border: 1px solid transparent; background: transparent; color: #333; text-align: left; cursor: pointer; }
.powerpoint-thumbnail.is-active { border-color: #c43e1c; background: #fff; }
.powerpoint-thumbnail__number { width: 16px; font-size: 11px; text-align: right; }
.powerpoint-thumbnail__preview { display: grid; width: 96px; aspect-ratio: 16/9; overflow: hidden; place-items: center; padding: 5px; background: white; box-shadow: 0 1px 2px #aaa; color: #4a4a4a; font-size: 8px; text-align: center; }
.powerpoint-canvas-wrap { display: grid; overflow: auto; place-items: center; padding: 18px; }
.powerpoint-slide { display: flex; width: min(100%, 700px); aspect-ratio: 16/9; flex-direction: column; justify-content: center; gap: 22px; padding: 7%; background: white; box-shadow: 0 2px 9px rgb(0 0 0 / 20%); color: #333; }
.powerpoint-slide[data-theme="Facet"] { border-top: 10px solid #00a6a6; }
.powerpoint-slide[data-theme="Integral"] { border-left: 12px solid #7030a0; }
.powerpoint-slide[data-theme="Ion"] { background: linear-gradient(135deg,#fff 0 82%,#e8edf6 82%); }
.powerpoint-slide[data-theme="Retrospect"] { border-bottom: 12px solid #e97824; }
.powerpoint-slide h1 { min-height: 1.3em; margin: 0; color: #365f91; font-size: clamp(20px,3vw,34px); }
.powerpoint-slide__body { min-height: 1.5em; margin: 0; color: #555; font-size: clamp(14px,2vw,20px); }
.powerpoint-slide ul { padding-left: 1.4em; }
.powerpoint-sidepane { padding: 14px 12px; border-left: 1px solid #d2d2d2; background: #f7f7f7; color: #484848; font-size: 12px; }
.powerpoint-sidepane h2 { margin: 0 0 18px; font-size: 14px; font-weight: 500; }
.powerpoint-app.is-presenting .office-titlebar,.powerpoint-app.is-presenting .office-tabs,.powerpoint-app.is-presenting .office-ribbon,.powerpoint-app.is-presenting .powerpoint-thumbnails,.powerpoint-app.is-presenting .powerpoint-sidepane,.powerpoint-app.is-presenting .office-statusbar { display: none; }
.powerpoint-app.is-presenting { position: fixed; z-index: 1000; inset: 0; width: 100vw; height: 100vh; max-height: none; border: 0; border-radius: 0; }
.powerpoint-app.is-presenting .powerpoint-workspace { display: block; background: #000; }
.powerpoint-app.is-presenting .powerpoint-canvas-wrap { height: 100%; padding: 0; }
.powerpoint-app.is-presenting .powerpoint-slide { width: min(100vw, 177.78vh); height: min(100vh, 56.25vw); max-width: none; aspect-ratio: 16/9; }

@media(max-width:850px) {
  .office-app { max-height: calc(100vh - 170px); }
  .office-save-state,.office-titlebar__right .office-titlebar__button,.powerpoint-sidepane { display: none; }
  .powerpoint-workspace { grid-template-columns: 108px minmax(220px,1fr); }
  .powerpoint-thumbnail__preview { width: 70px; }
}

@media(max-width:600px) {
  .office-app { width: 100%; min-height: 480px; max-height: calc(100vh - 176px); border-radius: 0; }
  .office-titlebar { gap: 6px; padding-inline: 7px; }
  .office-document-name { max-width: 90px; font-size: 11px; }
  .office-search { width: 95px; }
  .office-titlebar__left,.office-titlebar__right { gap: 4px; }
  .office-ribbon { min-height: 83px; }
  .office-doc-page { width: calc(100% - 20px); min-height: 390px; margin: 10px auto; padding: 30px 24px; }
  .powerpoint-workspace { grid-template-columns: 78px minmax(180px,1fr); }
  .powerpoint-thumbnail__preview { width: 54px; font-size: 6px; }
  .powerpoint-thumbnails { padding-inline: 3px; }
  .powerpoint-canvas-wrap { padding: 8px; }
  .office-statusbar { gap: 8px; }
}
