/* Office (workspace/office) */
.office-wrap {
    position: relative;
    display: block;
    min-height: 0;
    height: -webkit-fill-available;
}

.office-main {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-radius: 20px;
    padding: 10px 6px 6px;
    min-height: 0;
    height: -webkit-fill-available;
    overflow: auto;
}

.office-toolbar {
    display: grid;
    grid-template-columns: .8fr auto 1fr; /* Right | middle | left */
    grid-template-areas:
        "left middle right";
    padding: 5px;
    border: var(--line);
    border-radius: var(--radius);
    background: var(--bg);
    isolation: isolate;
    position: sticky;
    top: 0;
    z-index: 3;
    align-items: center;
}

.office-toolbar .right {grid-area: right;justify-self: start;display: flex;gap: var(--space-3);align-items: center;justify-self: end;}
.office-toolbar .middle{ grid-area: middle; justify-self: center; display: flex; align-items: center; justify-content: center; }
.office-toolbar .left  {grid-area: left;justify-self: end;display: flex;align-items: center;gap: 5px;justify-self: auto;}

.tabs {
    display: flex;
    gap: var(--space-2);
    background: var(--muted);
    border-radius: 999px;
}

.tab {
    border: none;
    background: transparent;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
}

.tab.active {
    background: var(--pans) var(--primary-faded);
}

.actions .split {
    display: flex;
    gap: 4px;
}

.title-input {
    font: 600 16px/1.2 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    padding: 3px 12px;
    border-radius: 999px;
    background: var(--surface);
    text-align: center;
    min-width: 300px;
}

.ribbon {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 4px;
    border: var(--line);
    border-radius: 8px;
}

.ribbon .sep {
    width: 1px;
    height: 20px;
    background: color-mix(in oklab, var(--text) 20%, transparent);
    margin: 0 4px;
}

.ribbon button {
    border: var(--line);
    background: var(--muted);
    padding: 5px 7px;
    border-radius: 10px;
    cursor: pointer;
}

.ribbon button:hover {
    outline: var(--ring);
}

.paper {
    color: var(--text);
    flex: 1;
    min-height: 0;
    overflow: auto;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    scroll-behavior: smooth;
}

.doc-editor {
    width: 21.6cm;
    background: var(--bg);
    box-shadow: 0 0 20px var(--dots);
    outline: none;
    padding: 2.54cm; /* default */
    position: relative;
    box-sizing: border-box;
}

.office-issue {
    text-decoration: underline wavy var(--danger);
    text-decoration-skip-ink: none;
}

.doc-editor :where(h1,h2,h3) {
    margin: 0 0 12px;
}

.doc-editor p {
    margin: 0 0 10px;
}

.sheet-toolbar {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    padding-left: 5px;
}

.sheet-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
    border-radius: 15px 15px 0 0;
    background: var(--side) var(--bg);
    background-blend-mode: var(--blend);
}

.sheet-grid {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    min-width: 720px;
}

.sheet-grid th {
    position: sticky;
    top: 0;
    background: var(--muted);
    text-align: center;
    border-bottom: var(--line);
    z-index: 1;
    padding: 6px;
    font-weight: 600;
}

.sheet-grid th:first-child {
    z-index: 2;
}

.sheet-grid td, .sheet-grid th {
    border-right: var(--line);
    border-bottom: var(--line);
    padding: 4px 6px;
}

.sheet-grid td.selected {
    background: var(--primary-faded);
}

.sheet-grid tr th:first-child {
    position: sticky;
    left: 0;
    background: var(--muted);
    text-align: right;
    width: 30px;
    padding-left: 0;
}

.office-files[hidden] {
    display: none;
}

.office-files {
    position: absolute;
    width: min(300px, 30vw);
    top: 10px;
    left: 10px;
    height: -webkit-fill-available;
    background: var(--bg);
    isolation: isolate;
    border: var(--line);
    border-radius: 15px;
    z-index: 5;
    display: flex;
    flex-direction: column;
}

.files-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 12px;
    border-bottom: var(--line);
}

.files-scroll {
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.files-group h4 {
    margin: 8px 6px;
    color: var(--text-muted);
    font-weight: 600;
}

.file-block {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border: var(--line);
    border-radius: 8px;
    background: var(--muted);
    margin-top: 10px;
    cursor: pointer;
    justify-content: center;
}

.file-block .thumb {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 6px;
}

.file-block .meta {
    flex: 1;
    min-width: 0;
}

.file-block .name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-block .sub {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-block .icon-btn {border: none; background: transparent; font-size: 18px; line-height: 1;}
.file-block:hover { outline: var(--ring);}
/* --- Accessibility Tool Pill --- */
.has-pill #docView .ribbon,
.has-pill #sheetView .sheet-toolbar {display: none;}
.office-view {position: relative;min-height: 0;display: flex;flex-direction: column;overflow: hidden;border-radius: 15px;} /* anchor for pill absolute positioning */

.doc-ruler-corner { position: absolute; top: 0; left: 0; width: 25px; height: 25px; background: var(--muted); border-right: var(--line); border-bottom: var(--line); z-index: 4; }
.doc-ruler-top {
  position: absolute; top: 0; left: 25px; right: 0; height: 25px; background: var(--muted); border-bottom: var(--line); z-index: 3;
  display: flex; align-items: flex-end; font-size: 10px; overflow: hidden;
}
.doc-ruler-top span {min-width: 1cm;border-left: 1px solid var(--text-muted);padding-left: 2px;height: 11px;flex-shrink: 0;}

.doc-ruler-left {
  position: absolute; top: 25px; left: 0; bottom: 0; width: 25px; background: var(--muted); border-right: var(--line); z-index: 3;
  display: flex; flex-direction: column; align-items: flex-end; font-size: 10px; overflow: hidden;
}
.doc-ruler-left span { min-height: 1cm; border-top: 1px solid var(--text-muted); width: 10px; padding-top: 2px; flex-shrink: 0; }

#docPaper {margin-top: 25px;margin-left: 25px;width: calc(100% - 25px);height: calc(100% - 25px);}

.office-pill{
  position: absolute;
  top: 80px;
  left: 16px;
  background: var(--pans);
  border: var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  user-select: none;
  min-width: 260px;
  z-index: 2;
  max-width: 640px;
  -webkit-backdrop-filter: var(--backdrop);
  backdrop-filter: var(--backdrop-2);
  isolation: isolate;
}
.office-pill .pill-bar {display: flex; align-items: center; gap: 8px;padding: 6px 8px;}
.office-pill .pill-drag {border: var(--line);background: var(--muted);border-radius: 8px;padding: 2px 6px; cursor: grab;}
.office-pill .pill-core {display: flex; align-items: center; gap: 10px; flex: 1;}
.office-pill .pill-core .pill-zoom { display: inline-flex; align-items: center; gap: 6px; font-size: 12px;}
.office-pill .pill-core input[type="range"] { width: 120px; }
.office-pill .pill-stat {font-size: 12px; padding: 2px 6px; border: var(--line); border-radius: 999px; background: var(--muted);}
.office-pill .pill-toggle {border: var(--line); background: var(--muted); border-radius: 8px; padding: 4px 8px; cursor: pointer;}
.office-pill .pill-panel {display: grid; gap: 8px; padding: 12px; border-top: var(--line); background: color-mix(in oklab, var(--surface) 92%, transparent); max-height: 400px; overflow-y: auto;}
.office-pill .grp-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-top: 4px; border-bottom: 1px solid color-mix(in oklab, var(--text) 10%, transparent); padding-bottom: 2px; }
.office-pill.collapsed .pill-panel { display: none; }
.office-pill .grp {display: flex; flex-wrap: wrap; gap: 6px; align-items: center;}
.office-pill .grp .sep { width:1px; height:18px; background: color-mix(in oklab, var(--text) 20%, transparent); margin: 0 4px; }
.office-pill .grp button {border: var(--line);background: var(--muted);padding: 4px 6px;border-radius: 8px;cursor: pointer;}
.office-pill .grp button:hover { outline: var(--ring); }

/* Keep zoom smooth */
#docPaper, #sheetGridWrap { will-change: transform; transition: transform 120ms ease; }

/* Headers as handles */
.sheet-grid th.col-hdr, .sheet-grid th.row-hdr { cursor: grab; position: relative; }

.hdr-inner { padding: 4px; pointer-events: none; }

.resizer-x {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 3;
}
.resizer-x:hover { background: var(--primary-faded); }

.resizer-y {
  position: absolute; bottom: 0; left: 0; right: 0; height: 6px; cursor: row-resize; z-index: 2;
}
.resizer-y:hover { background: var(--primary-faded); }

.sheet-tabs-bar {
  display: flex;
  gap: 8px;
  padding: 4px 36px 2px;
  background: var(--muted);
  border-radius: 0 0 15px 15px;
  flex-shrink: 0;
  margin-top: -4px;
}
.sheet-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.sheet-tabs::-webkit-scrollbar { display: none; }
.sheet-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--muted);
  border-radius: 0 0 8px 8px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
}
.sheet-tab.active {background: var(--bg);font-weight: 600;color: var(--primary);}
.sheet-tab .close { border: none; background: transparent; padding: 0; font-size: 16px; opacity: 0.5; }
.sheet-tab .close:hover { opacity: 1; color: var(--danger); }
#addTab{height: 20px;width: 30px;align-self: center;padding: 0;font-size: 12px;}