/* ============================================================
 * KOffice · 精致界面样式
 * 文字 / 表格 / 演示 / PDF 四大模块
 * ============================================================ */

/* ---------- 根布局 ---------- */
.office {
  display: flex; flex-direction: column;
  width: 100%; height: 100%;
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--fs-13);
  overflow: hidden;
}

/* ---------- 菜单栏 ---------- */
.of-menubar {
  display: flex; align-items: center; gap: var(--space-1);
  height: 32px; flex: 0 0 auto;
  padding: 0 var(--space-2);
  background: var(--surface-solid);
  border-bottom: 1px solid var(--stroke);
  position: relative;
}
.of-menu { position: relative; }
.of-menu-title {
  height: 26px; padding: 0 var(--space-3);
  border: none; background: transparent;
  color: var(--text); font-size: var(--fs-12); font-weight: 500;
  border-radius: var(--radius-xs); cursor: pointer;
  transition: background-color .14s var(--ease), color .14s;
}
.of-menu-title:hover { background: var(--stroke); }
.of-menu-drop {
  position: absolute; top: 100%; left: 0; z-index: 50;
  min-width: 200px; padding: var(--space-2);
  background: var(--surface-solid);
  border: 1px solid var(--stroke-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-panel);
  animation: ofDrop .16s var(--ease) both;
}
@keyframes ofDrop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.of-menu-item {
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-xs);
  font-size: var(--fs-13); color: var(--text); cursor: pointer;
  transition: background-color .12s, color .12s;
}
.of-menu-item:hover { background: var(--accent-soft); color: var(--accent); }
.of-menu-sep { height: 1px; background: var(--stroke); margin: var(--space-2) var(--space-2); }
.of-menubar-brand {
  margin-left: auto;
  font-size: var(--fs-12); font-weight: 600; letter-spacing: .5px;
  color: var(--accent); opacity: .75;
}

/* ---------- 功能区 ---------- */
.of-ribbon {
  display: flex; align-items: stretch; gap: var(--space-1);
  height: 96px; flex: 0 0 auto;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-solid);
  border-bottom: 1px solid var(--stroke);
  overflow-x: auto; overflow-y: hidden;
}
.of-rgroup {
  display: flex; flex-direction: column;
  padding: 0 var(--space-3); border-right: 1px solid var(--stroke);
  min-width: fit-content;
}
.of-rgroup:last-child { border-right: none; }
.of-rgroup-btns { display: flex; align-items: center; gap: var(--space-1); flex: 1; }
.of-rgroup-label {
  text-align: center; font-size: var(--fs-11); color: var(--text-dim);
  padding-top: var(--space-1); letter-spacing: .3px;
}
.of-rbtn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-1); min-width: 44px; height: 60px; padding: var(--space-1) var(--space-2);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--text);
  cursor: pointer; font-size: var(--fs-11); font-weight: 500;
  transition: background-color .14s, border-color .14s, transform .12s;
}
.of-rbtn:hover { background: var(--stroke); border-color: var(--stroke-strong); }
.of-rbtn:active { transform: scale(.95); }
.of-rbtn .ri { width: 18px; height: 18px; fill: currentColor; opacity: .8; }
.of-rbtn.bold { font-weight: 800; }
.of-rbtn.italic { font-style: italic; }
.of-rbtn.underline { text-decoration: underline; }
.of-rbtn.strike { text-decoration: line-through; }
.of-rbtn span { line-height: 1; }
.of-select {
  height: 30px; padding: 0 var(--space-2);
  border: 1px solid var(--stroke-strong); border-radius: var(--radius-xs);
  background: var(--surface-2); color: var(--text);
  font-size: var(--fs-12); cursor: pointer; outline: none;
  transition: border-color .14s;
}
.of-select:focus { border-color: var(--accent); }
.of-color {
  width: 32px; height: 30px; padding: 0;
  border: 1px solid var(--stroke-strong); border-radius: var(--radius-xs);
  background: transparent; cursor: pointer;
}
.of-rlbl { font-size: var(--fs-11); color: var(--text-dim); white-space: nowrap; }

/* ---------- 标签栏 ---------- */
.of-tabs {
  display: flex; align-items: stretch; gap: var(--space-1);
  height: 38px; flex: 0 0 auto;
  padding: 0 var(--space-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--stroke);
  overflow-x: auto; overflow-y: hidden;
}
.of-tab {
  display: flex; align-items: center; gap: var(--space-2);
  height: 34px; margin-top: var(--space-1); padding: 0 var(--space-3);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--surface-solid);
  border: 1px solid var(--stroke); border-bottom: none;
  cursor: pointer; transition: background-color .14s;
  max-width: 200px;
}
.of-tab:hover { background: var(--surface-2); }
.of-tab.active {
  background: var(--surface-solid);
  box-shadow: 0 -2px 0 var(--accent) inset;
}
.of-tab-ico { width: 14px; height: 14px; flex: 0 0 auto; color: var(--accent); }
.of-tab-ico svg { width: 14px; height: 14px; fill: currentColor; }
.of-tab-name { font-size: var(--fs-12); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.of-tab-close {
  width: 18px; height: 18px; border: none; border-radius: var(--radius-xs);
  background: transparent; color: var(--text-dim); font-size: var(--fs-11); cursor: pointer;
  display: grid; place-items: center; transition: background-color .12s, color .12s;
}
.of-tab-close:hover { background: var(--danger); color: #fff; }
.of-tab-add {
  width: 32px; height: 30px; margin-top: var(--space-2); align-self: flex-start;
  border: none; border-radius: var(--radius-sm); background: transparent;
  color: var(--text-dim); font-size: var(--fs-16); cursor: pointer;
  transition: background-color .14s, color .14s;
}
.of-tab-add:hover { background: var(--stroke); color: var(--text); }
.of-tab-empty { align-self: center; color: var(--text-dim); font-size: var(--fs-12); padding-left: var(--space-2); }

/* 新建文档弹出菜单 */
.of-newmenu {
  position: fixed; z-index: 200; min-width: 160px;
  padding: var(--space-2); background: var(--surface-solid);
  border: 1px solid var(--stroke-strong); border-radius: var(--radius-md);
  box-shadow: var(--shadow-panel);
}

/* ---------- 工作区 ---------- */
.of-workspace { flex: 1; min-height: 0; position: relative; background: var(--surface-2); }

/* ---------- 状态栏 ---------- */
.of-status {
  display: flex; align-items: center; gap: var(--space-4);
  height: 26px; flex: 0 0 auto;
  padding: 0 var(--space-4);
  background: var(--surface-solid);
  border-top: 1px solid var(--stroke);
  font-size: var(--fs-12); color: var(--text-dim);
}
.of-status-spacer { flex: 1; }

/* ============================================================
 * 主页
 * ============================================================ */
.of-home {
  height: 100%; overflow-y: auto;
  padding: var(--space-10) var(--space-12);
  background:
    radial-gradient(1200px 600px at 20% -10%, var(--accent-soft), transparent 60%),
    var(--surface-2);
}
.of-home-head { display: flex; align-items: center; gap: var(--space-5); margin-bottom: var(--space-8); }
.of-home-logo { width: 64px; height: 64px; border-radius: var(--radius-xl); box-shadow: var(--shadow-panel); }
.of-home-head h1 { font-size: var(--fs-32); font-weight: 700; margin: 0; letter-spacing: -.5px; }
.of-home-head p { margin: var(--space-1) 0 0; color: var(--text-dim); font-size: var(--fs-13); }

.of-home-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-5); margin-bottom: var(--space-8);
}
.of-home-card {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-6); border-radius: var(--radius-lg);
  background: var(--surface-solid);
  border: 1px solid var(--stroke);
  cursor: pointer;
  transition: transform .25s var(--ease-spring), box-shadow .25s, border-color .2s;
}
.of-home-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 44px -16px rgba(0,0,0,.35);
  border-color: var(--accent);
}
.of-home-ico {
  width: 52px; height: 52px; border-radius: var(--radius-md);
  display: grid; place-items: center; color: #fff; flex: 0 0 auto;
  box-shadow: 0 10px 22px -8px rgba(0,0,0,.4);
}
.of-home-ico svg { width: 28px; height: 28px; fill: currentColor; }
.of-home-name { font-size: var(--fs-16); font-weight: 600; margin-bottom: var(--space-1); }
.of-home-sub { font-size: var(--fs-12); color: var(--text-dim); }

.of-home-sec { font-size: var(--fs-13); font-weight: 600; color: var(--text-dim); margin: 0 0 var(--space-3); }
.of-home-recent { display: flex; flex-direction: column; gap: var(--space-1); }
.of-home-recitem {
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); cursor: pointer;
  font-size: var(--fs-13); transition: background-color .12s;
}
.of-home-recitem:hover { background: var(--surface-solid); }

/* ============================================================
 * 文字文档（Word）
 * ============================================================ */
.of-word {
  height: 100%; overflow: auto;
  padding: var(--space-8) 0;
  display: flex; justify-content: center;
  background:
    repeating-linear-gradient(45deg, rgba(0,0,0,.02) 0 2px, transparent 2px 12px),
    var(--surface-2);
}
.of-word-page {
  width: min(780px, 90%);
  min-height: 1000px;
  padding: 72px 80px;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: 0 2px 10px rgba(0,0,0,.08), 0 24px 60px -20px rgba(0,0,0,.35);
  border-radius: var(--radius-xs);
  line-height: 1.7; font-size: var(--fs-14);
  outline: none;
}
.of-word-page:focus { box-shadow: 0 0 0 2px var(--accent-soft), 0 24px 60px -20px rgba(0,0,0,.35); }
.of-word-page h1 { font-size: var(--fs-24); font-weight: 700; margin: 0 0 var(--space-4); }
.of-word-page h2 { font-size: var(--fs-24); font-weight: 600; margin: var(--space-5) 0 var(--space-3); }
.of-word-page h3 { font-size: var(--fs-16); font-weight: 600; margin: var(--space-4) 0 var(--space-2); }
.of-word-page p { margin: 0 0 var(--space-3); }
.of-word-page blockquote {
  margin: var(--space-3) 0; padding: var(--space-3) var(--space-5);
  border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-dim);
}
.of-word-page table { border-collapse: collapse; margin: var(--space-3) 0; }
.of-word-page td { border: 1px solid var(--stroke-strong); padding: var(--space-2) var(--space-3); }
.of-word-page img { max-width: 100%; border-radius: var(--radius-xs); }
.of-word-page hr { border: none; border-top: 1px solid var(--stroke); margin: var(--space-4) 0; }

/* ============================================================
 * 电子表格（Excel）
 * ============================================================ */
.of-sheet { display: flex; flex-direction: column; height: 100%; background: var(--surface-solid); }
.of-fbar {
  display: flex; align-items: center; gap: var(--space-3);
  height: 36px; flex: 0 0 auto;
  padding: 0 var(--space-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--stroke);
}
.of-fref {
  min-width: 56px; padding: var(--space-1) var(--space-3);
  border: 1px solid var(--stroke-strong); border-radius: var(--radius-xs);
  background: var(--surface-solid); text-align: center;
  font-family: ui-monospace, monospace; font-size: var(--fs-12); font-weight: 600;
}
.of-fx { font-style: italic; font-weight: 700; color: var(--text-dim); font-size: var(--fs-13); }
.of-finput {
  flex: 1; height: 28px; padding: 0 var(--space-3);
  border: 1px solid var(--stroke); border-radius: var(--radius-xs);
  background: var(--surface-solid); color: var(--text);
  font-family: ui-monospace, monospace; font-size: var(--fs-13); outline: none;
  transition: border-color .14s;
}
.of-finput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.of-sheet-scroll { flex: 1; overflow: auto; position: relative; }
.of-grid {
  display: grid; position: sticky; top: 0; left: 0;
  grid-template-columns: 44px repeat(12, 92px);
  background: var(--surface-solid);
  min-width: min-content;
}
.of-corner {
  position: sticky; top: 0; left: 0; z-index: 5;
  background: var(--surface-2);
  border-right: 1px solid var(--stroke); border-bottom: 1px solid var(--stroke);
}
.of-colh {
  position: sticky; top: 0; z-index: 4;
  height: 30px; display: grid; place-items: center;
  background: var(--surface-2);
  border-right: 1px solid var(--stroke); border-bottom: 1px solid var(--stroke);
  font-size: var(--fs-12); font-weight: 600; color: var(--text-dim);
}
.of-rowh {
  position: sticky; left: 0; z-index: 3;
  width: 44px; height: 26px; display: grid; place-items: center;
  background: var(--surface-2);
  border-right: 1px solid var(--stroke); border-bottom: 1px solid var(--stroke);
  font-size: var(--fs-12); font-weight: 600; color: var(--text-dim);
}
.of-cell {
  height: 26px; padding: 0 var(--space-2);
  border-right: 1px solid var(--stroke); border-bottom: 1px solid var(--stroke);
  display: flex; align-items: center;
  font-size: var(--fs-12); cursor: cell; outline: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background-color .08s;
}
.of-cell.num { justify-content: flex-end; font-family: ui-monospace, monospace; }
.of-cell:hover { background: var(--accent-soft); }
.of-cell.sel {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
  z-index: 2;
}
.of-cell[contenteditable="true"] {
  background: var(--surface-solid);
  box-shadow: inset 0 0 0 2px var(--accent);
  z-index: 10;
}

/* ============================================================
 * 演示文稿（PPT）
 * ============================================================ */
.of-ppt { display: flex; height: 100%; background: var(--surface-2); }
.of-slide-list {
  width: 180px; flex: 0 0 auto;
  overflow-y: auto; padding: var(--space-3) var(--space-2);
  background: var(--surface-solid);
  border-right: 1px solid var(--stroke);
  display: flex; flex-direction: column; gap: var(--space-2);
}
.of-slide-thumb {
  display: flex; gap: var(--space-2); padding: var(--space-2); border-radius: var(--radius-sm);
  cursor: pointer; border: 2px solid transparent;
  transition: background-color .14s, border-color .14s;
}
.of-slide-thumb:hover { background: var(--stroke); }
.of-slide-thumb.active { border-color: var(--accent); background: var(--accent-soft); }
.of-slide-num {
  width: 22px; flex: 0 0 auto; text-align: center;
  font-size: var(--fs-11); font-weight: 700; color: var(--text-dim); padding-top: var(--space-1);
}
.of-slide-mini {
  flex: 1; aspect-ratio: 16/9; border-radius: var(--radius-xs);
  display: grid; place-items: center; padding: var(--space-1);
  font-size: var(--fs-11); overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.mini-t { text-align: center; font-weight: 600; }
.of-slide-add {
  padding: var(--space-3); border: 1.5px dashed var(--stroke-strong); border-radius: var(--radius-sm);
  background: transparent; color: var(--text-dim); font-size: var(--fs-12);
  cursor: pointer; transition: border-color .14s, color .14s, background-color .14s;
}
.of-slide-add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.of-slide-stage {
  flex: 1; display: grid; place-items: center;
  padding: var(--space-6); overflow: auto;
}
.of-slide {
  width: min(100%, 860px); aspect-ratio: 16/9;
  border-radius: var(--radius-md); padding: var(--space-12) var(--space-12);
  display: flex; flex-direction: column; justify-content: center; gap: var(--space-5);
  box-shadow: 0 24px 70px -20px rgba(0,0,0,.5);
}
.of-slide-title {
  width: 100%; background: transparent; border: none; outline: none;
  font-size: var(--fs-48); font-weight: 700; color: inherit;
  resize: none; font-family: inherit;
}
.of-slide-body {
  width: 100%; background: transparent; border: none; outline: none;
  font-size: var(--fs-20); color: inherit; line-height: 1.5;
  resize: none; font-family: inherit;
}
.of-slide-empty { color: var(--text-dim); font-size: var(--fs-14); }

/* 全屏放映 */
.of-present {
  position: fixed; inset: 0; z-index: 9999;
  background: #000; display: grid; place-items: center;
  cursor: pointer;
}
.of-present-slide {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 8%; text-align: center;
}
.of-present-title { font-size: clamp(32px, 7vw, 84px); font-weight: 800; margin-bottom: var(--space-6); }
.of-present-body { font-size: clamp(var(--fs-16), 3.5vw, 42px); line-height: 1.5; max-width: 900px; }
.of-present-hint {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  font-size: var(--fs-13); color: rgba(255,255,255,.5);
}

/* ============================================================
 * PDF 阅读
 * ============================================================ */
.of-pdf { display: flex; flex-direction: column; height: 100%; background: var(--surface-2); }
.of-pdf-bar {
  display: flex; align-items: center; gap: var(--space-3);
  height: 44px; flex: 0 0 auto; padding: 0 var(--space-4);
  background: var(--surface-solid); border-bottom: 1px solid var(--stroke);
}
.of-pdf-name { font-size: var(--fs-13); font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.of-pdf-frame { flex: 1; width: 100%; border: none; background: #fff; }

.of-pdf-drop {
  flex: 1; margin: var(--space-8); border: 2.5px dashed var(--stroke-strong);
  border-radius: var(--radius-xl); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: var(--space-4);
  color: var(--text-dim); transition: border-color .2s, background-color .2s;
}
.of-pdf-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.of-pdf-ico {
  width: 72px; height: 72px; border-radius: var(--radius-xl);
  /* 用 KOffice 自己的身份色（琥珀），不再自带一套紫 */
  background: linear-gradient(145deg, #B45309, #FBBF24);
  display: grid; place-items: center; color: var(--accent-fg);
  box-shadow: 0 16px 40px -12px rgba(180, 83, 9, .5);
}
.of-pdf-ico svg { width: 36px; height: 36px; fill: currentColor; }
.of-pdf-drop h3 { margin: 0; font-size: var(--fs-20); color: var(--text); }
.of-pdf-drop p { margin: 0; font-size: var(--fs-13); max-width: 360px; text-align: center; }
