:root {
  --accent: #1a73e8;
  --green: #188038;
  --line: #e2e3e3;
  --head-bg: #f8f9fa;
  --head-hl: #d3e3fd;
  --text: #1f1f1f;
  --muted: #5f6368;
  --row-h: 24px;
  --col-w: 104px;
  --rowhead-w: 46px;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Segoe UI", sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: #fff; font-size: 14px; }
[hidden] { display: none !important; }

button {
  font: inherit; font-size: 13px;
  border: 1px solid #dadce0; background: #fff; color: var(--text);
  border-radius: 6px; padding: 5px 12px; cursor: pointer;
}
button:hover { background: #f1f3f4; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #1765cc; }
input { font: inherit; }

/* ---------- 上部バー ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 14px; border-bottom: 1px solid var(--line); background: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; color: var(--text); text-decoration: none; }
.logo {
  width: 26px; height: 26px; border-radius: 5px; background: var(--green); display: inline-block;
  background-image: linear-gradient(#fff, #fff), linear-gradient(#fff, #fff), linear-gradient(#fff, #fff), linear-gradient(#fff, #fff);
  background-size: 16px 1.5px, 16px 1.5px, 16px 1.5px, 1.5px 16px;
  background-position: 5px 8px, 5px 12px, 5px 16px, 10px 5px;
  background-repeat: no-repeat;
}
.spacer { flex: 1; }
.title {
  font-size: 17px; border: 1px solid transparent; border-radius: 4px; padding: 3px 6px;
  min-width: 120px; max-width: 420px; width: 32ch;
}
.title:hover { border-color: #dadce0; }
.title:focus { outline: none; border-color: var(--accent); }
.sync { font-size: 12px; color: var(--muted); white-space: nowrap; }
.sync.error { color: #c5221f; }
.users { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.chip, .me {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px; padding: 2px 10px 2px 4px; font-size: 12px; background: #f1f3f4; border: none;
  white-space: nowrap;
}
.chip i, .me i {
  width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center;
  color: #fff; font-style: normal; font-size: 11px; font-weight: 600;
}
.me { cursor: pointer; }
.me:hover { background: #e8eaed; }

/* ---------- 一覧 ---------- */
.home-main { max-width: 760px; margin: 0 auto; padding: 28px 20px 60px; }
.create { display: flex; gap: 8px; }
.create input { flex: 1; padding: 8px 10px; border: 1px solid #dadce0; border-radius: 6px; }
.create input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.create button { padding: 8px 16px; }
.home-main h2 { font-size: 15px; margin: 28px 0 8px; color: var(--muted); font-weight: 600; }
.sheet-list { list-style: none; padding: 0; margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.sheet-list li + li { border-top: 1px solid var(--line); }
.sheet-list a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: inherit; text-decoration: none; }
.sheet-list a:hover { background: #f8f9fa; }
.sheet-list .name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-list .meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.sheet-list .empty { padding: 20px; color: var(--muted); text-align: center; }
.note { font-size: 12px; color: var(--muted); margin-top: 20px; }

/* ---------- シート画面 ---------- */
.sheet { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.sheet > .topbar { height: 46px; }
.fxbar { display: flex; align-items: center; height: 32px; border-bottom: 1px solid var(--line); background: #fff; }
.namebox {
  width: 90px; height: 100%; display: grid; place-items: center; font-size: 13px;
  border-right: 1px solid var(--line); font-variant-numeric: tabular-nums; overflow: hidden; white-space: nowrap;
}
.fx-label { color: var(--muted); font-style: italic; padding: 0 10px; border-right: 1px solid var(--line); }
.fx { flex: 1; height: 100%; border: none; padding: 0 10px; font-size: 13px; }
.fx:focus { outline: none; box-shadow: inset 0 -2px 0 var(--accent); }

.wrap { flex: 1; overflow: auto; position: relative; background: #fff; }
.grid {
  border-collapse: separate; border-spacing: 0; table-layout: fixed;
  font-size: 10pt; user-select: none; -webkit-user-select: none; cursor: cell;
}
.grid th, .grid td {
  height: var(--row-h); padding: 0 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.grid td { vertical-align: bottom; }
.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid td.bool { text-align: center; }
.grid td.err { color: #c5221f; text-align: center; }
.grid td.match { background: #fce8b2; }
.wrap.painting .grid { cursor: copy; }
.grid th {
  background: var(--head-bg); color: var(--muted); font-weight: 400; font-size: 12px;
  text-align: center; position: sticky; cursor: default; border-color: #c4c7c5;
}
.grid thead th { top: 0; z-index: 5; }
.grid tbody th { left: 0; z-index: 4; width: var(--rowhead-w); min-width: var(--rowhead-w); }
.grid th.corner { left: 0; z-index: 7; width: var(--rowhead-w); min-width: var(--rowhead-w); }
.grid th.hl { background: var(--head-hl); color: #0b57d0; font-weight: 600; }

.overlay { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; z-index: 3; }
.overlay > div, #presence > div, #refLayer > div, #filterLayer > * { position: absolute; }
.sel-range { background: rgba(26, 115, 232, 0.1); border: 1px solid var(--accent); }
.sel-active { border: 2px solid var(--accent); }
.presence { border: 2px solid; }
.presence .tag {
  position: absolute; right: -2px; bottom: 100%; color: #fff; font-size: 11px; line-height: 16px;
  padding: 0 5px; border-radius: 3px 3px 0 0; white-space: nowrap;
}
.presence.top .tag { bottom: auto; top: 100%; border-radius: 0 0 3px 3px; }
.presence.quiet .tag { opacity: 0; transition: opacity .4s; }

.editor {
  position: absolute; z-index: 3; margin: 0; padding: 0 4px;
  border: none; font-size: 10pt; background: #fff;
  opacity: 0; pointer-events: none; caret-color: transparent;
}
.editor.editing {
  opacity: 1; pointer-events: auto; caret-color: auto;
  outline: 2px solid var(--accent); box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}
.more { padding: 10px 0 40px 56px; }

.statusbar {
  display: flex; justify-content: space-between; gap: 12px; height: 28px; align-items: center;
  padding: 0 12px; border-top: 1px solid var(--line); background: var(--head-bg); font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden;
}

/* ---------- モーダル・通知 ---------- */
.modal { position: fixed; inset: 0; background: rgba(32, 33, 36, .45); display: grid; place-items: center; z-index: 50; }
.modal-box { background: #fff; border-radius: 12px; padding: 22px 24px; width: min(380px, 92vw); box-shadow: 0 8px 30px rgba(0, 0, 0, .25); }
.modal-box h2 { margin: 0 0 6px; font-size: 18px; }
.modal-box p { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.modal-box input { width: 100%; padding: 9px 10px; border: 1px solid #dadce0; border-radius: 6px; font-size: 15px; }
.modal-box input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast {
  position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%); z-index: 60;
  background: #323232; color: #fff; padding: 8px 16px; border-radius: 6px; font-size: 13px;
}

/* ---------- ツールバー ---------- */
.toolbar {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  margin: 6px 10px; padding: 3px 8px; background: #f0f4f9; border-radius: 22px; min-height: 38px;
}
.toolbar button {
  min-width: 30px; height: 30px; padding: 0 6px; border: none; background: transparent; border-radius: 4px;
  display: inline-grid; place-items: center; font-size: 14px; color: #444746;
}
.toolbar button:hover { background: #e1e5ea; }
.toolbar button:disabled { opacity: .35; background: transparent; cursor: default; }
.toolbar button.on { background: #d3e3fd; color: #0b57d0; }
.toolbar button.small { font-size: 12px; }
.toolbar button.dec { font-size: 12px; font-weight: 600; letter-spacing: -.5px; display: inline-flex; align-items: baseline; }
.toolbar button.dec small { font-size: 10px; font-weight: 400; }
.toolbar svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.toolbar .serif { font-family: Georgia, "Times New Roman", serif; font-weight: 600; }
.toolbar select {
  height: 30px; border: none; background: transparent; border-radius: 4px; padding: 0 4px;
  font: inherit; font-size: 13px; color: #444746; cursor: pointer;
}
.toolbar select:hover { background: #e1e5ea; }
#font { width: 110px; }
.toolbar .sep { width: 1px; height: 20px; background: #c4c7c5; margin: 0 6px; }
.font-size {
  width: 36px; height: 26px; text-align: center; border: 1px solid #747775; border-radius: 4px;
  font-size: 13px; background: transparent;
}
.font-size:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.color-btn { display: inline-flex !important; flex-direction: column; justify-content: center; gap: 1px; }
.color-btn span:first-child { font-weight: 600; line-height: 1; }
.color-btn .bar { width: 18px; height: 4px; background: #000; border-radius: 1px; }
.dd { position: relative; }
.menu {
  position: absolute; top: 34px; left: 0; z-index: 30; background: #fff; border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .2); padding: 6px 0; min-width: 210px;
}
.menu > button {
  width: 100%; height: 32px; display: flex !important; justify-content: space-between; border-radius: 0 !important;
  padding: 0 16px !important; font-size: 13px !important;
}
.menu > button span { color: var(--muted); }
.menu > button.on { background: #e8f0fe; }
.palette { display: grid; grid-template-columns: repeat(10, 20px); gap: 4px; padding: 10px; min-width: 0; left: auto; right: 0; }
.palette button { min-width: 0 !important; width: 20px; height: 20px !important; border-radius: 50% !important; border: 1px solid rgba(0,0,0,.12) !important; padding: 0 !important; }
.palette button.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.palette .reset.on { outline: none; }
.palette .reset { grid-column: 1 / -1; width: auto; border-radius: 4px !important; border: none !important; height: 26px !important; font-size: 12px !important; }

/* ---------- 検索 ---------- */
.findbar {
  position: fixed; right: 24px; top: 140px; z-index: 20; display: flex; align-items: center; gap: 4px;
  background: #fff; padding: 6px 8px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
}
.findbar input { width: 200px; border: 1px solid #dadce0; border-radius: 4px; padding: 5px 8px; font-size: 13px; }
.findbar input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.findbar button { border: none; padding: 4px 8px; }
.find-count { font-size: 12px; color: var(--muted); min-width: 48px; text-align: center; }

/* ---------- 印刷 ---------- */
.print-area { display: none; }
@media print {
  html, body { height: auto !important; }
  body > *:not(#printArea) { display: none !important; }
  .print-area { display: block; }
  .print-area .pp-page { break-after: page; box-shadow: none !important; margin: 0 !important; }
  .print-area .pp-page:last-child { break-after: auto; }
}

/* ---------- 右クリックメニュー ---------- */
.ctx-menu {
  position: fixed; z-index: 40; background: #fff; border-radius: 8px; padding: 6px 0; min-width: 260px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .15), 0 8px 24px rgba(0, 0, 0, .12); font-size: 14px; user-select: none;
}
.ctx-item { position: relative; display: flex; align-items: center; gap: 12px; height: 32px; padding: 0 16px 0 14px; cursor: default; }
.ctx-item:hover { background: #f1f3f4; }
.ctx-icon { width: 18px; height: 18px; flex: none; display: grid; place-items: center; color: #444746; }
.ctx-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ctx-label { flex: 1; white-space: nowrap; }
.ctx-key { color: #80868b; font-size: 12px; white-space: nowrap; }
.ctx-sep { height: 1px; background: #e0e0e0; margin: 6px 0; }
.ctx-sub { display: none; position: absolute; top: -6px; left: 100%; min-width: 220px; }
.ctx-item.has-sub:hover > .ctx-sub { display: block; }
.ctx-menu.sub-left .ctx-sub { left: auto; right: 100%; }

/* ---------- 関数のアシスト ---------- */
.ref-box { border: 2px solid; pointer-events: none; }
.fn-assist {
  position: fixed; z-index: 45; background: #fff; border-radius: 8px; padding: 6px 0;
  min-width: 300px; max-width: 440px; font-size: 13px; line-height: 1.5; color: var(--text);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .15), 0 8px 24px rgba(0, 0, 0, .12);
}
.fa-item { display: flex; gap: 6px; align-items: baseline; padding: 4px 14px; cursor: pointer; white-space: nowrap; overflow: hidden; }
.fa-item.sel { background: #e8f0fe; }
.fa-name { font-weight: 400; }
.fa-name b { font-weight: 700; }
.fa-syn { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.fa-foot { border-top: 1px solid #eee; margin-top: 4px; padding: 8px 14px 2px; color: #3c4043; }
.fa-hint { padding: 2px 14px 2px; color: #80868b; font-size: 11px; }
.fa-sig { padding: 4px 14px 8px; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; border-bottom: 1px solid #eee; }
.fa-sig .cur { font-weight: 700; background: #fef7e0; border-radius: 3px; padding: 0 2px; }
.fa-sec { padding: 6px 14px 2px; }
.fa-label { color: var(--muted); font-size: 11px; }
.fa-warn { color: #c5221f; }

/* ---------- セルの書式（追加分） ---------- */
.grid td.has-comment { position: relative; }
.grid td.has-comment::after {
  content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 7px 7px 0;
  border-color: transparent #f9ab00 transparent transparent;
}
.grid td.spilling { overflow: visible; position: relative; z-index: 1; }
.grid td .spill { display: inline-block; overflow: hidden; white-space: nowrap; vertical-align: bottom; }
.cell-link { color: #1155cc; text-decoration: underline; }
.rot-tiltup, .rot-tiltdown { display: inline-block; }
.rot-tiltup { transform: rotate(-45deg); }
.rot-tiltdown { transform: rotate(45deg); }
.rot-vertical { display: inline-block; writing-mode: vertical-rl; text-orientation: upright; white-space: nowrap; }
.rot-up { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.rot-down { display: inline-block; writing-mode: vertical-rl; white-space: nowrap; }

/* ---------- ツールバー（追加分） ---------- */
.toolbar button.with-arrow { display: inline-flex !important; gap: 1px; align-items: center; }
.toolbar button.with-arrow small { font-size: 9px; color: #5f6368; }
.toolbar button.sigma { font-size: 17px; font-weight: 500; }
.dd.split { display: inline-flex; }
.dd.split .arrow { min-width: 16px; padding: 0 2px; font-size: 10px; }
.color-btn .bar.fill { background: transparent; box-shadow: inset 0 0 0 1px #c4c7c5; }
.menu.right { left: auto; right: 0; }
.icon-menu > button { justify-content: flex-start !important; gap: 10px; }
.icon-menu svg { flex: none; }
.fn-menu { max-height: 360px; overflow: auto; min-width: 180px; }
.fn-menu .sep-line { height: 1px; background: #e0e0e0; margin: 6px 0; }
.border-menu { padding: 10px; min-width: 0; display: grid; grid-template-columns: repeat(5, 32px); gap: 4px; }
.border-menu > button { width: 32px !important; height: 32px !important; padding: 0 !important; justify-content: center !important; border-radius: 4px !important; }
.border-menu .bm-row { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 6px; }
.border-menu .bm-row select { height: 26px; font-size: 12px; background: #fff; border: 1px solid #dadce0; }
.border-menu .bm-colors { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(10, 16px); gap: 3px; }
.border-menu .bm-colors button { width: 16px !important; height: 16px !important; min-width: 0 !important; padding: 0 !important; border-radius: 50% !important; border: 1px solid rgba(0,0,0,.15) !important; }
.border-menu .bm-colors button.on { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- フィルタ ---------- */
.filter-frame { border: 2px solid #188038; pointer-events: none; }
.filter-frame.personal { border-color: #3c4043; border-style: dashed; }
.filter-btn {
  pointer-events: auto; border: none !important; padding: 0 !important; border-radius: 3px !important; z-index: 2;
  background: #fff !important; color: #188038; display: grid; place-items: center; cursor: pointer; min-width: 0 !important;
}
.filter-btn:hover { background: #e6f4ea !important; }
.filter-btn.on { background: #188038 !important; color: #fff; }
.filter-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.filter-menu { min-width: 250px; padding-bottom: 10px; }
.fm-head { font-size: 12px; color: var(--muted); padding: 6px 14px 4px; }
.fm-tools { display: flex; gap: 12px; padding: 0 14px 6px; }
.link-btn { border: none; background: none; color: var(--accent); padding: 0; font-size: 12px; }
.fm-search { margin: 0 14px 6px; width: calc(100% - 28px); padding: 5px 8px; border: 1px solid #dadce0; border-radius: 4px; font-size: 13px; }
.fm-list { max-height: 240px; overflow: auto; padding: 0 8px; }
.fm-item { display: flex; align-items: center; gap: 8px; padding: 3px 6px; font-size: 13px; border-radius: 4px; cursor: pointer; }
.fm-item:hover { background: #f1f3f4; }
.fm-item span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-count { color: #80868b; font-size: 11px; }
.fm-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 14px 0; border-top: 1px solid #eee; margin-top: 8px; }
.fv-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 14px;
  background: #3c4043; color: #fff; font-size: 13px;
}
.fv-banner button { background: transparent; color: #fff; border-color: #9aa0a6; }

/* ---------- コメント・リンク ---------- */
.comment-panel {
  position: absolute; z-index: 7; width: 280px; background: #fff; border-radius: 8px; font-size: 13px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .15), 0 8px 24px rgba(0, 0, 0, .12); cursor: default;
}
.cm-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px 4px 14px; color: var(--muted); font-size: 12px; }
.cm-head button { font-size: 12px; padding: 3px 8px; }
.cm-thread { max-height: 260px; overflow: auto; }
.cm-item { padding: 8px 14px; border-bottom: 1px solid #f1f3f4; }
.cm-meta { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.cm-meta i { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-style: normal; font-size: 11px; font-weight: 600; }
.cm-meta b { font-size: 13px; }
.cm-meta time { color: #80868b; font-size: 11px; flex: 1; }
.cm-meta button { border: none; background: none; color: #80868b; font-size: 11px; padding: 0 2px; }
.cm-meta button:hover { color: #c5221f; }
.cm-text { white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.cm-compose { padding: 10px 14px 12px; }
.cm-compose textarea {
  width: 100%; resize: vertical; min-height: 44px; border: 1px solid #dadce0; border-radius: 6px; padding: 6px 8px; font: inherit; font-size: 13px;
}
.cm-compose textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.cm-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.cm-actions button { font-size: 12px; padding: 4px 10px; }
.link-chip {
  position: absolute; z-index: 7; display: flex; align-items: center; gap: 6px; background: #fff; border-radius: 8px;
  padding: 6px 8px 6px 12px; box-shadow: 0 2px 6px rgba(0, 0, 0, .15), 0 4px 16px rgba(0, 0, 0, .1); font-size: 13px; max-width: 420px;
}
.link-chip a { color: #1155cc; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.link-chip button { font-size: 12px; padding: 3px 8px; }
.link-dialog {
  position: fixed; z-index: 46; width: 340px; background: #fff; border-radius: 10px; padding: 14px 16px 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .15), 0 8px 24px rgba(0, 0, 0, .15); display: grid; gap: 10px; font-size: 12px; color: var(--muted);
}
.link-dialog label { display: grid; gap: 4px; }
.link-dialog input { padding: 7px 9px; border: 1px solid #dadce0; border-radius: 5px; font-size: 13px; color: var(--text); }
.link-dialog input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.link-dialog input:disabled { background: #f1f3f4; }
.ld-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- グラフ ---------- */
.chart-layer { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 3; }
.chart-obj {
  position: absolute; background: #fff; border: 1px solid #dadce0; border-radius: 2px; cursor: move;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08); user-select: none;
}
.chart-obj.selected { outline: 2px solid var(--accent); }
.chart-body, .chart-body svg { width: 100%; height: 100%; display: block; }
.chart-tools { position: absolute; top: 6px; right: 6px; display: none; gap: 4px; }
.chart-obj.selected .chart-tools, .chart-obj:hover .chart-tools { display: flex; }
.chart-tools button { font-size: 12px; padding: 3px 8px; background: #fff; cursor: pointer; }
.chart-resize {
  position: absolute; right: -5px; bottom: -5px; width: 10px; height: 10px; background: #fff;
  border: 2px solid var(--accent); border-radius: 2px; cursor: nwse-resize; display: none;
}
.chart-obj.selected .chart-resize { display: block; }
.chart-editor {
  position: fixed; right: 0; top: 0; bottom: 0; width: 300px; z-index: 35; background: #fff;
  border-left: 1px solid var(--line); box-shadow: -4px 0 16px rgba(0, 0, 0, .08); padding: 0 18px 18px;
  display: flex; flex-direction: column; gap: 14px; font-size: 12px; color: var(--muted);
}
.ce-head { display: flex; justify-content: space-between; align-items: center; height: 52px; font-size: 16px; color: var(--text); font-weight: 600; border-bottom: 1px solid var(--line); margin: 0 -18px; padding: 0 12px 0 18px; }
.ce-head button { border: none; font-size: 20px; padding: 0 8px; }
.chart-editor label { display: grid; gap: 5px; }
.chart-editor select, .chart-editor input { padding: 7px 9px; border: 1px solid #dadce0; border-radius: 5px; font-size: 13px; color: var(--text); background: #fff; }
.ce-note { margin: 0; line-height: 1.6; }
button.danger { color: #c5221f; border-color: #f4c7c3; align-self: flex-start; }
button.danger:hover { background: #fce8e6; }
@media print { .chart-layer, .comment-panel, .link-chip { display: none !important; } }

/* ---------- 列幅・非表示・固定 ---------- */
.grid col.rowhead-col { width: var(--rowhead-w); }
.grid th { overflow: visible; }
.grid .hcol { padding: 0 !important; border-right: none !important; overflow: hidden; color: transparent; font-size: 0; }
.grid td.fr, .grid td.fc { background-color: #fff; }
.grid td.fr-last, .grid th.fr-last { border-bottom: 3px solid #c4c7c5; }
.grid td.fc-last, .grid th.fc-last { border-right: 3px solid #c4c7c5; }
.resize-guide { position: absolute; z-index: 9; pointer-events: none; }
.resize-guide.col { border-left: 2px dashed var(--accent); }
.resize-guide.row { border-top: 2px dashed var(--accent); }
.unhide-btn {
  position: absolute; z-index: 8; width: 14px; height: 14px; padding: 0 !important; min-width: 0 !important;
  border: 1px solid #c4c7c5 !important; border-radius: 3px !important; background: #fff; font-size: 0; cursor: pointer;
}
.unhide-btn::before { content: ""; position: absolute; inset: 3px; border: solid #5f6368; border-width: 0 2px 2px 0; transform: rotate(-45deg) scale(.7); }
.unhide-btn.col-right { right: -8px; top: 5px; }
.unhide-btn.col-left { left: -8px; top: 5px; }
.unhide-btn.col-left::before { transform: rotate(135deg) scale(.7); }
.unhide-btn.row-bottom { bottom: -8px; left: 16px; }
.unhide-btn.row-bottom::before { transform: rotate(45deg) scale(.7); }
.unhide-btn.row-top { top: -8px; left: 16px; }
.unhide-btn.row-top::before { transform: rotate(-135deg) scale(.7); }
.unhide-btn:hover { background: #e8f0fe; }

/* ---------- メニューバー ---------- */
.menubar { display: flex; gap: 2px; padding: 0 12px; height: 30px; align-items: flex-end; background: #fff; border-bottom: 1px solid #e3e3e3; }
.menubar button { border: none; background: transparent; padding: 4px 11px 5px; font-size: 13.5px; border-radius: 4px 4px 0 0; color: #1f1f1f; position: relative; }
.menubar button:hover { background: #f1f3f4; }
.menubar button[data-tab].on { color: #107c41; font-weight: 600; }
.menubar button[data-tab].on::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px; border-radius: 2px; background: #107c41; }
.menubar button.file-tab.on, .menubar button.file-tab:hover { background: #107c41; color: #fff; }
.menubar .spacer { flex: 1; }
.menubar .rb-min { font-size: 14px; color: #5f6368; padding: 2px 8px 4px; }
.toolbar { margin-top: 2px; }

/* ---------- 入力規則・条件付き書式 ---------- */
.grid td.dv-cb { text-align: center; }
.cb {
  display: inline-block; width: 14px; height: 14px; border: 2px solid #5f6368; border-radius: 2px;
  vertical-align: middle; cursor: pointer; position: relative; background: #fff;
}
.cb.on { background: #1a73e8; border-color: #1a73e8; }
.cb.on::after { content: ""; position: absolute; left: 3px; top: 0; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.grid td.dv-list { position: relative; padding-right: 18px; }
.dd-text { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.dd-arrow { position: absolute; right: 3px; top: 50%; width: 14px; height: 14px; margin-top: -7px; cursor: pointer; border-radius: 3px; }
.dd-arrow::after { content: ""; position: absolute; left: 3px; top: 4px; border: 4px solid transparent; border-top-color: #5f6368; }
.dd-arrow:hover { background: #e8eaed; }
.grid td.dv-invalid { position: relative; }
.grid td.dv-invalid::before { content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 7px 7px 0; border-color: transparent #d93025 transparent transparent; }
.dd-menu { min-width: 160px; }
.grid.no-grid td { border-color: transparent; }

/* ---------- 右側のパネル・ダイアログ ---------- */
.side-panel { overflow: auto; }
.side-body { display: flex; flex-direction: column; gap: 12px; }
.side-field { display: grid; gap: 5px; }
.side-field input, .side-field select, .side-field textarea, .side-body > input {
  padding: 7px 9px; border: 1px solid #dadce0; border-radius: 5px; font: inherit; font-size: 13px; color: var(--text); background: #fff;
}
.side-field textarea { resize: vertical; }
.side-check { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text); }
.side-label { color: var(--muted); font-size: 12px; }
.side-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.side-actions .danger { margin-right: auto; }
.cf-item { display: flex; gap: 10px; align-items: center; padding: 10px; border: 1px solid #e0e0e0; border-radius: 6px; cursor: pointer; color: var(--text); font-size: 12.5px; }
.cf-item:hover { background: #f8f9fa; }
.cf-item.here { border-color: var(--accent); }
.cf-sample { display: inline-block; padding: 3px 8px; border: 1px solid #e0e0e0; border-radius: 3px; font-size: 13px; }
.cf-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.cf-presets button { padding: 2px; border-radius: 4px; }
.cf-toggles { display: flex; gap: 6px; }
.cf-toggles button { width: 34px; font-weight: 700; }
.cf-toggles button:nth-child(2) { font-style: italic; }
.cf-toggles button:nth-child(3) { text-decoration: line-through; }
.cf-toggles button.on { background: #d3e3fd; border-color: #a8c7fa; }
.cf-color { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 12.5px; }
.cf-color input[type=color] { width: 36px; height: 26px; border: 1px solid #dadce0; border-radius: 4px; padding: 1px; background: #fff; }
.cf-preview { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.hist-item { border-bottom: 1px solid #f1f3f4; padding: 6px 0 8px; color: var(--text); }
.hist-item .cm-meta button { border: 1px solid #dadce0; border-radius: 4px; padding: 1px 8px; color: var(--text); }
.hist-what { font-size: 12.5px; cursor: pointer; word-break: break-all; }
.hist-what:hover { color: var(--accent); }
.kbd-table { border-collapse: collapse; font-size: 12.5px; color: var(--text); }
.kbd-table td { padding: 5px 4px; border-bottom: 1px solid #f1f3f4; vertical-align: top; }
kbd { font-family: inherit; background: #f1f3f4; border-radius: 4px; padding: 1px 6px; font-size: 12px; white-space: nowrap; }
.fn-item { padding: 8px 0; border-bottom: 1px solid #f1f3f4; color: var(--text); font-size: 12.5px; cursor: pointer; display: grid; gap: 3px; }
.fn-item:hover b { color: var(--accent); }
.fn-item code { color: var(--muted); font-size: 12px; }
.float-dialog {
  position: fixed; z-index: 46; right: 24px; top: 150px; width: 340px; background: #fff; border-radius: 10px; padding: 16px 18px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .15), 0 8px 24px rgba(0, 0, 0, .15); display: grid; gap: 10px; font-size: 12px; color: var(--muted);
}
.float-dialog > label:not(.side-check) { display: grid; gap: 4px; }
.float-dialog input:not([type=checkbox]):not([type=radio]), .float-dialog select { padding: 7px 9px; border: 1px solid #dadce0; border-radius: 5px; font-size: 13px; color: var(--text); background: #fff; }
.fd-title { font-size: 15px; font-weight: 600; color: var(--text); }
.fd-status { min-height: 16px; color: var(--accent); }
.fd-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.fd-radios { display: grid; gap: 4px; }

/* ---------- シートのタブ ---------- */
.tabbar { display: flex; align-items: center; gap: 4px; height: 36px; padding: 0 8px; background: var(--head-bg); border-top: 1px solid var(--line); }
.tabbar > button { width: 28px; height: 28px; padding: 0; border: none; background: transparent; font-size: 16px; color: #444746; border-radius: 50%; }
.tabbar > button:hover { background: #e1e5ea; }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tab {
  border: none; background: transparent; padding: 6px 16px; font-size: 13px; border-radius: 4px 4px 0 0; color: #444746;
  white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis;
}
.tab:hover { background: #e1e5ea; }
.tab.active { background: #fff; color: #0b57d0; font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.statusbar { border-top: none; }

/* ---------- 印刷のページ（プレビューと印刷で共通） ---------- */
.pp-page { position: relative; background: #fff; overflow: hidden; color: #000; font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif; }
.pp-body { position: absolute; display: flex; flex-direction: column; overflow: hidden; }
.pp-body > table { flex: none; }
.pp-hf { position: absolute; left: 0; right: 0; text-align: center; font-size: 9pt; color: #333; }
.pp-table { border-collapse: collapse; table-layout: fixed; font-size: 10pt; }
.pp-table td { padding: 0 4px; overflow: hidden; white-space: nowrap; vertical-align: bottom; text-overflow: clip; }
.pp-table th { background: #f1f3f4; color: #5f6368; font-weight: 400; font-size: 8pt; border: 1px solid #c4c7c5; text-align: center; padding: 0 2px; }
.pp-grid td { border: 1px solid #d0d0d0; }
.pp-table td.num { text-align: right; }
.pp-table td.bool { text-align: center; }
.pp-table td.err { color: #c5221f; text-align: center; }
.pp-table td.spilling { overflow: visible; }
.pp-table .spill { display: inline-block; overflow: hidden; white-space: nowrap; vertical-align: bottom; }

/* ---------- 印刷の設定とプレビュー ---------- */
.print-dialog { position: fixed; inset: 0; z-index: 48; display: flex; background: #e8eaed; }
.pd-side { width: 330px; flex: none; background: #fff; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.pd-head { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 18px 10px; font-size: 18px; font-weight: 600; }
.pd-count { font-size: 12px; font-weight: 400; color: var(--muted); }
.pd-form { flex: 1; overflow: auto; padding: 4px 18px 12px; display: flex; flex-direction: column; gap: 13px; font-size: 12px; color: var(--muted); }
.pd-form input:not([type=checkbox]), .pd-form select { padding: 6px 8px; border: 1px solid #dadce0; border-radius: 5px; font-size: 13px; color: var(--text); background: #fff; }
.pd-form input.bad { border-color: #d93025; background: #fce8e6; }
.pd-form .pp-num { width: 90px; }
.pp-btns { display: flex; gap: 6px; }
.pp-btns button { font-size: 12px; padding: 3px 9px; }
.pp-seg { display: inline-flex; border: 1px solid #dadce0; border-radius: 6px; overflow: hidden; width: max-content; }
.pp-seg button { border: none; border-radius: 0; padding: 5px 18px; }
.pp-seg button.on { background: #d3e3fd; color: #0b57d0; }
.pp-breaks { color: var(--text); line-height: 1.5; }
.pd-note { margin: 0 18px; font-size: 12px; color: var(--accent); }
.pd-note:empty { display: none; }
.pd-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.pd-preview { flex: 1; overflow: auto; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pd-preview .pp-page { flex: none; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); margin-bottom: 18px; }
.pd-preview > * { flex: none; }
.pp-label { font-size: 11px; color: var(--muted); }

/* 表の上の印: 印刷範囲・改ページ */
.print-area-mark { border: 2px dashed #5f6368; pointer-events: none; }
.page-break-mark { pointer-events: none; }
.page-break-mark.row { border-top: 2px dashed #1a73e8; }
.page-break-mark.col { border-left: 2px dashed #1a73e8; }
#printLayer > div { position: absolute; }

/* ---------- ログイン・招待 ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; background: #f0f4f9; padding: 24px; }
.auth-card { width: min(400px, 100%); background: #fff; border-radius: 16px; padding: 30px 32px 28px; box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 8px 30px rgba(0,0,0,.06); }
.auth-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--muted); margin-bottom: 18px; }
.auth-card h1 { font-size: 22px; margin: 0 0 6px; }
.auth-sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; line-height: 1.6; }
.auth-form { display: grid; gap: 14px; margin-top: 14px; }
.auth-field { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); }
.auth-field input { padding: 10px 12px; border: 1px solid #c4c7c5; border-radius: 8px; font-size: 15px; color: var(--text); }
.auth-field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.auth-form button.primary { padding: 10px; font-size: 15px; border-radius: 8px; margin-top: 4px; }
.auth-note { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.auth-error { margin-top: 14px; padding: 9px 12px; border-radius: 8px; background: #fce8e6; color: #c5221f; font-size: 13px; }
.auth-link { color: var(--accent); }
.auth-row { display: flex; gap: 14px; align-items: center; justify-content: space-between; }

/* ---------- 共有・アカウント・管理のダイアログ ---------- */
.modal-box.dlg { width: min(520px, 94vw); max-height: 88vh; overflow: auto; padding: 0; }
.modal-box.dlg.wide { width: min(760px, 96vw); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 6px; }
.dlg-head h2 { margin: 0; font-size: 19px; font-weight: 500; }
.dlg-close { border: none; font-size: 22px; padding: 0 6px; color: var(--muted); }
.dlg-body { padding: 6px 22px 20px; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.dlg-label { font-weight: 600; font-size: 13px; margin-top: 8px; color: var(--text); }
.dlg-note { margin: 0; color: var(--muted); font-size: 12px; }
.dlg-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; }
.dlg-actions.left { justify-content: flex-start; margin-top: 0; }
.dlg-body select, .dlg-body input:not([type=checkbox]) { padding: 7px 9px; border: 1px solid #dadce0; border-radius: 6px; font-size: 13px; background: #fff; color: var(--text); }
.share-add { display: flex; gap: 6px; }
.share-add select:first-child { flex: 1; min-width: 0; }
.share-list, .admin-list { display: flex; flex-direction: column; }
.share-row, .admin-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid #f1f3f4; }
.share-row > i, .admin-row > i { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-style: normal; font-weight: 600; flex: none; }
.share-who { flex: 1; min-width: 0; display: grid; }
.share-who span { color: var(--muted); font-size: 12px; }
.share-role { color: var(--muted); font-size: 12.5px; }
.share-link { display: flex; align-items: center; gap: 10px; }
.share-link select { flex: 1; }
.share-globe { width: 30px; height: 30px; border-radius: 50%; background: #e6f4ea; display: grid; place-items: center; }
.admin-row { flex-wrap: wrap; }
.admin-row.disabled { opacity: .55; }
.admin-row .muted, .muted { color: var(--muted); font-size: 12px; }
.admin-tools { display: flex; gap: 4px; flex-wrap: wrap; }
.admin-tools button { font-size: 11.5px; padding: 3px 8px; }
.invite-make { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.invite-make label { white-space: nowrap; }
.invite-result { background: #e8f0fe; border-radius: 8px; padding: 10px 12px; display: grid; gap: 8px; font-size: 12.5px; }
.invite-url { display: flex; gap: 6px; }
.invite-url input { flex: 1; font-family: "SF Mono", Menlo, monospace; font-size: 12px !important; }
.sheet-list .badge { font-size: 11.5px; color: #0b57d0; background: #e8f0fe; border-radius: 999px; padding: 1px 8px; white-space: nowrap; }

/* ---------- 共有ボタン・閲覧のみ ---------- */
.share-btn { border-radius: 999px; padding: 6px 16px; }
.ro-badge { font-size: 12px; background: #fef7e0; color: #a05a00; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.readonly #toolbar > *:not([data-cmd="find"]):not([data-cmd="print"]):not(#zoom):not(.sep) { opacity: .35; pointer-events: none; }
.readonly .cm-compose, .readonly #cmResolve, .readonly .cm-meta button, .readonly #linkEdit, .readonly #linkRemove,
.readonly .chart-tools, .readonly .chart-resize { display: none !important; }
.readonly .chart-obj { cursor: default; }

/* ---------- ファイル一覧の操作 ---------- */
.create { flex-wrap: wrap; }
.sheet-list a { position: relative; }
.file-icon { width: 20px; height: 22px; flex: none; border-radius: 3px; background: var(--green); position: relative; }
.file-icon::after { content: ""; position: absolute; inset: 6px 4px 5px; border: solid #fff; border-width: 1.5px 0; box-shadow: inset 0 3.5px 0 -2px #fff; }
.file-more { border: none; background: transparent; font-size: 18px; line-height: 1; width: 30px; height: 30px; padding: 0; border-radius: 50%; color: var(--muted); }
.file-more:hover { background: #e8eaed; }
.sheet-list .badge.green { background: #e6f4ea; color: #137333; }
.add-link { display: flex; gap: 8px; margin-top: 10px; }
.add-link input { flex: 1; padding: 7px 10px; border: 1px solid #dadce0; border-radius: 6px; font-size: 13px; }
.trash-toggle { margin-top: 24px; font-size: 13px; }
#trashBox { margin-top: 8px; }
.trash-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.trash-row .name { flex: 1; }
.trash-row .meta { font-size: 12px; color: var(--muted); }
.trash-row button { font-size: 12px; padding: 3px 10px; }

/* ---------- アカウント設定・メンバーと招待のページ ---------- */
.page { min-height: 100vh; background: #f8fafd; }
.page .topbar { background: #fff; }
.page-nav { display: flex; gap: 4px; margin-left: 16px; }
.page-nav a { color: var(--text); text-decoration: none; padding: 6px 12px; border-radius: 999px; font-size: 14px; white-space: nowrap; }
.page-nav a:hover { background: #f1f3f4; }
.page-nav a.on { background: #d3e3fd; color: #0b57d0; font-weight: 600; }
.page-main { max-width: 780px; margin: 0 auto; padding: 28px 20px 80px; }
.page-main h1 { font-size: 26px; font-weight: 500; margin: 0 0 20px; }
.pg-section { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 20px 24px; margin-bottom: 18px; display: flex; flex-direction: column; gap: 12px; }
.pg-section h2 { margin: 0; font-size: 17px; font-weight: 600; }
.pg-note { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.pg-field { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); max-width: 420px; }
.pg-field input { padding: 9px 11px; border: 1px solid #c4c7c5; border-radius: 8px; font-size: 14px; color: var(--text); }
.pg-field input:disabled { background: #f1f3f4; color: var(--muted); }
.pg-actions { display: flex; gap: 8px; }
.pg-meta { font-size: 12px; color: var(--muted); }
.pg-section .invite-make select { padding: 6px 8px; border: 1px solid #dadce0; border-radius: 6px; }
.admin-kind { font-weight: 600; min-width: 140px; }

/* ---------- Excel に合わせたセルの操作 ---------- */
textarea.editor { resize: none; overflow: hidden; white-space: pre; line-height: 1.6; font-family: inherit; padding-top: 1px; }
textarea.fx { resize: none; overflow: hidden; white-space: pre; line-height: 30px; padding-top: 0; padding-bottom: 0; font-family: inherit; }
textarea.fx:focus { white-space: pre-wrap; overflow: auto; }
.copy-mark {
  pointer-events: none;
  background-image: linear-gradient(90deg, #1a73e8 50%, transparent 50%), linear-gradient(90deg, #1a73e8 50%, transparent 50%),
    linear-gradient(0deg, #1a73e8 50%, transparent 50%), linear-gradient(0deg, #1a73e8 50%, transparent 50%);
  background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
  background-size: 8px 2px, 8px 2px, 2px 8px, 2px 8px;
  background-position: 0 0, 0 100%, 0 0, 100% 0;
  animation: marching-ants .6s linear infinite;
}
@keyframes marching-ants { to { background-position: 8px 0, -8px 100%, 0 -8px, 100% 8px; } }
.fill-preview { border: 2px dashed #5f6368; pointer-events: none; }
.overlay > .fill-handle { pointer-events: auto; background: var(--accent); border: 1px solid #fff; cursor: crosshair; z-index: 2; }
.readonly .fill-handle { display: none; }
.choice-list { display: grid; gap: 8px; }
.choice-list button { text-align: left; padding: 10px 14px; }
/* セルの書式設定 */
.fc-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.fc-tabs button { border: none; border-bottom: 3px solid transparent; border-radius: 0; padding: 8px 14px; background: transparent; }
.fc-tabs button.on { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
.fc-panes { min-height: 230px; padding: 12px 2px; }
.fc-pane { display: grid; gap: 12px; align-content: start; }
.fc-row { display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: 10px; font-size: 13px; }
.fc-row select, .fc-row input { max-width: 280px; }
.fc-num { width: 90px; }
.fc-borders { display: flex; gap: 6px; flex-wrap: wrap; }
.fc-borders button { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; }
.fc-borders button.on { background: #d3e3fd; border-color: #a8c7fa; }
.fc-borders svg { width: 22px; height: 22px; fill: none; stroke: currentColor; }
.fc-palette { display: grid; grid-template-columns: repeat(10, 24px); gap: 5px; }
.fc-palette button { width: 24px; height: 24px; padding: 0; border-radius: 4px; border: 1px solid rgba(0,0,0,.12); }
.fc-none { justify-self: start; }
.fc-preview { display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--line); padding-top: 12px; font-size: 12px; color: var(--muted); }
.fc-sample { flex: 1; border: 1px solid #c4c7c5; padding: 6px 10px; font-size: 10pt; color: var(--text); min-height: 32px; }

.ttc-preview { border-collapse: collapse; font-size: 12px; }
.ttc-preview td { border: 1px solid #dadce0; padding: 3px 8px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ほかのシートの参照・広がった結果 */
.grid td.loading { color: #80868b; font-style: italic; }
.spill-mark { border: 1px solid #4285f4; pointer-events: none; }

/* メールで招待 */
.invite-mail { display: flex; flex-direction: column; gap: 8px; }
.invite-mail .fc-row { display: grid; grid-template-columns: 80px 1fr; gap: 8px; align-items: start; }
.invite-mail textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 6px 8px; border: 1px solid #dadce0; border-radius: 6px; resize: vertical; }
.err-text { color: #d93025; }

/* リボン（ホーム以外のタブ） */
.ribbon {
  display: flex; align-items: stretch; gap: 0; margin: 6px 10px; padding: 4px 6px 2px; background: #f0f4f9; border-radius: 12px;
  min-height: 84px; overflow-x: auto; scrollbar-width: thin;
}
.ribbon[hidden] { display: none; }
.rb-group { display: flex; flex-direction: column; padding: 0 6px; border-right: 1px solid #d5d9de; flex: none; }
.rb-group:last-child { border-right: none; }
.rb-body { display: flex; align-items: flex-start; gap: 2px; flex: 1; }
.rb-col { display: flex; flex-direction: column; gap: 1px; }
.rb-title { text-align: center; font-size: 11px; color: #5f6368; padding: 2px 0 1px; white-space: nowrap; }
.rb-btn {
  display: flex; align-items: center; gap: 5px; border: none; background: transparent; border-radius: 4px;
  height: 22px; padding: 0 6px; font-size: 12px; color: #1f1f1f; white-space: nowrap; text-align: left;
}
.rb-btn:hover { background: #e1e5ea; }
.rb-btn.on { background: #d3e3fd; color: #0b57d0; }
.rb-btn:disabled { color: #80868b; background: transparent; cursor: default; }
.rb-btn .rb-icon { font-size: 13px; min-width: 16px; text-align: center; color: #107c41; font-weight: 600; }
.rb-btn.big { flex-direction: column; justify-content: flex-start; gap: 2px; height: 64px; min-width: 52px; max-width: 96px; padding: 4px 6px; text-align: center; }
.rb-btn.big .rb-icon { font-size: 22px; line-height: 28px; min-width: 0; }
.rb-btn.big .rb-label { white-space: normal; line-height: 1.2; font-size: 11.5px; }
.rb-check { width: 13px; height: 13px; border: 1px solid #747775; border-radius: 2px; font-size: 10px; line-height: 12px; text-align: center; color: #fff; }
.rb-check.on { background: #107c41; border-color: #107c41; }
.toolbar .tb-extra { display: contents; }
.toolbar button.tb-text { font-size: 12.5px; padding: 0 8px; color: #1f1f1f; display: inline-flex; white-space: nowrap; }
.toolbar u { text-decoration: underline; font-weight: 600; }

/* 右下: 表示の切り替えとズーム */
.statusbar .sb-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.statusbar #stats { overflow: hidden; text-overflow: ellipsis; }
.sb-views { display: flex; gap: 2px; padding-left: 8px; border-left: 1px solid #dadce0; }
.sb-views button, .sb-zoom button {
  border: none; background: transparent; border-radius: 4px; height: 22px; min-width: 26px; padding: 0 4px;
  display: inline-grid; place-items: center; color: #444746; font-size: 14px;
}
.sb-views button:hover, .sb-zoom button:hover { background: #e1e5ea; }
.sb-views button.on { background: #d3e3fd; color: #0b57d0; }
.sb-views svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.sb-zoom { display: flex; align-items: center; gap: 2px; }
.sb-zoom input[type=range] { width: 110px; accent-color: #5f6368; margin: 0 2px; }
.sb-zoom .sb-pct { font-size: 12px; min-width: 44px; justify-content: end; }

/* 改ページプレビュー */
#printLayer .pb-gray { background: rgba(120, 124, 130, .45); pointer-events: none; }
#printLayer .pb-frame { border: 3px solid #1a5fd0; pointer-events: none; box-sizing: border-box; }
#printLayer .pb-no {
  display: grid; place-items: center; pointer-events: none; overflow: hidden;
  font-size: 34px; font-weight: 700; color: rgba(26, 95, 208, .2); white-space: nowrap;
}
#printLayer .pb-break { pointer-events: none; }
#printLayer .pb-break.row { background: linear-gradient(#1a5fd0, #1a5fd0) center / 100% 2px no-repeat; }
#printLayer .pb-break.col { background: linear-gradient(#1a5fd0, #1a5fd0) center / 2px 100% no-repeat; }
#printLayer .pb-break.row:not(.manual) { background: repeating-linear-gradient(90deg, #1a5fd0 0 8px, transparent 8px 13px) center / 100% 2px no-repeat; }
#printLayer .pb-break.col:not(.manual) { background: repeating-linear-gradient(180deg, #1a5fd0 0 8px, transparent 8px 13px) center / 2px 100% no-repeat; }
#printLayer .pb-break.drag, #printLayer .pb-edge { pointer-events: auto; z-index: 4; }
#printLayer .pb-break.drag.row, #printLayer .pb-edge.top, #printLayer .pb-edge.bottom { cursor: row-resize; }
#printLayer .pb-break.drag.col, #printLayer .pb-edge.left, #printLayer .pb-edge.right { cursor: col-resize; }
#printLayer.dragging .pb-break, #printLayer.dragging .pb-edge { pointer-events: none; }
#printLayer .pb-ghost.frame { border: 3px dashed #1a5fd0; box-sizing: border-box; pointer-events: none; }
#printLayer .pb-ghost.line { background: #1a5fd0; opacity: .7; pointer-events: none; }
#printLayer .pb-tip { background: #fff; border: 1px solid #c4c7c5; border-radius: 6px; padding: 8px 12px; font-size: 12px; color: #444; box-sizing: border-box; height: auto !important; pointer-events: none; }

/* ページレイアウト */
.page-view { display: none; }
body.layout-view .page-view { display: block; flex: 1; overflow: auto; background: #e3e5e8; padding: 24px; position: relative; }
body.layout-view #wrap { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; flex: none; }
.pv-grid { display: grid; gap: 18px; width: max-content; margin: 0 auto; }
.pv-page { box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.pv-page .pp-table td { cursor: cell; }
.pv-page td.pv-sel { background-color: rgba(26, 115, 232, .12) !important; }
.pv-page td.pv-active { outline: 2px solid var(--accent); outline-offset: -2px; }
.pv-hf { cursor: pointer; border-radius: 4px; margin: 0 20%; padding: 4px 0; }
.pv-hf:hover { background: #f1f3f4; outline: 1px dashed #9aa0a6; }
.pv-hf-empty { color: #9aa0a6; font-size: 14px; font-weight: 600; opacity: 0; }
.pv-page:hover .pv-hf-empty { opacity: 1; }
.pv-blank { background: #f6f7f8; display: grid; place-items: center; color: #9aa0a6; font-size: 18px; font-weight: 600; cursor: pointer; }
.pv-blank:hover { background: #eef1f4; }
.pv-more { text-align: center; color: #5f6368; font-size: 12px; }
.pv-page .pp-table:not(.pp-grid) td { box-shadow: inset -1px -1px 0 #e6e6e6; }

/* ============================================================
   スマホ（幅 700px 以下）・指で操作する端末
   ============================================================ */
.touch .grid, .touch .tabbar, .touch .menubar { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.touch .fill-handle { display: none !important; }
.touch .ctx-item { height: 40px; }
@media (max-width: 700px) {
  /* 上の帯: タイトルを残して、ほかは小さく */
  .sheet > .topbar { gap: 6px; padding: 0 8px; height: 48px; }
  .sheet > .topbar .spacer { display: none; }
  .title { min-width: 0; width: auto; max-width: none; flex: 1 1 auto; font-size: 15px; }
  #sync, #users, #exportBtn { display: none !important; }
  .share-btn { padding: 6px 11px; font-size: 13px; }
  #addMineBtn { font-size: 12px; padding: 5px 8px; white-space: nowrap; }
  .ro-badge { white-space: nowrap; }
  /* タブとツールバーは横にスクロール */
  .menubar { overflow-x: auto; scrollbar-width: none; padding: 0 4px; }
  .menubar::-webkit-scrollbar, .toolbar::-webkit-scrollbar, .ribbon::-webkit-scrollbar { display: none; }
  .menubar button { flex: none; white-space: nowrap; padding: 4px 9px 6px; font-size: 13.5px; }
  .toolbar { flex-wrap: nowrap; overflow-x: auto; margin: 4px 6px; border-radius: 12px; min-height: 40px; scrollbar-width: none; }
  .toolbar > *, .toolbar .tb-extra > * { flex: none; }
  .toolbar button { min-width: 34px; height: 34px; }
  .ribbon { margin: 4px 6px; border-radius: 10px; scrollbar-width: none; }
  .fxbar .namebox { width: 60px; min-width: 60px; }
  .fn-assist { max-width: calc(100vw - 16px); }
  /* 右下: 倍率と表示の切り替えだけ */
  .statusbar { padding: 0 8px; gap: 6px; }
  #cellInfo { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .statusbar .sb-right { flex: none; gap: 4px; }
  .sb-zoom button { min-width: 22px; }
  .sb-zoom .sb-pct { min-width: 38px; }
  .statusbar #stats, .sb-zoom input[type=range] { display: none; }
  .sb-views { padding-left: 4px; }
  .tabbar { overflow-x: auto; scrollbar-width: none; }
  /* パネル・ダイアログは画面いっぱい */
  .chart-editor { width: 100%; box-sizing: border-box; }
  .float-dialog { left: 8px; right: 8px; width: auto; top: 90px; }
  .comment-panel { width: min(280px, calc(100vw - 24px)); }
  .modal-box.dlg { width: 96vw; max-height: 92vh; }
  .dlg-head { padding: 14px 16px 4px; }
  .dlg-body { padding: 6px 16px 16px; }
  .share-add { flex-wrap: wrap; }
  .share-add select:first-child { flex: 1 1 100%; }
  .share-link { min-width: 0; }
  .share-link select, .share-row select { min-width: 0; flex: 1 1 auto; max-width: 100%; }
  .share-who { min-width: 0; flex: 1 1 auto; }
  .ctx-menu { max-width: calc(100vw - 8px); max-height: calc(100vh - 16px); overflow-y: auto; }
  .print-dialog { flex-direction: column; }
  .pd-side { width: auto; max-height: 58vh; border-right: none; border-bottom: 1px solid var(--line); }
  .pd-preview { padding: 12px; }
  .pd-preview .pp-page { zoom: .42; }
  .page-view { padding: 12px !important; }
  /* ファイル一覧: 名前を 1 行目、更新者と日時を 2 行目に */
  .home-main { padding: 18px 12px 48px; }
  .sheet-list a { flex-wrap: wrap; row-gap: 2px; padding: 10px 6px 10px 12px; }
  .sheet-list .name { flex: 1 1 0; min-width: 0; white-space: normal; overflow-wrap: anywhere; }
  .sheet-list a::after { content: ''; order: 2; flex-basis: 100%; height: 0; }
  .sheet-list .file-more { order: 1; }
  .sheet-list .badge { order: 3; margin-left: 32px; }
  .sheet-list .meta { order: 4; flex-basis: 100%; padding-left: 32px; white-space: normal; }
  .sheet-list .badge + .meta { flex-basis: auto; padding-left: 0; }
  /* アカウント・管理のページ */
  .page .topbar { flex-wrap: wrap; height: auto; min-height: 52px; padding: 6px 10px; row-gap: 4px; }
  .page-nav { margin-left: 0; order: 3; width: 100%; overflow-x: auto; }
  .page-main { padding: 18px 12px 60px; }
  .page-main h1 { font-size: 22px; }
  .pg-section { padding: 16px 14px; }
  .invite-mail .fc-row { grid-template-columns: 1fr; }
  .invite-url { flex-wrap: wrap; }
  .admin-tools { width: 100%; display: flex; flex-wrap: wrap; gap: 6px; }
}

/* スマホ: 選択範囲のつまみ */
.overlay > .touch-handle {
  pointer-events: auto; touch-action: none; z-index: 3; box-sizing: border-box;
  border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.overlay > .touch-handle::before { content: ''; position: absolute; inset: -14px; border-radius: 50%; }
.overlay > .touch-handle.dragging { pointer-events: none; transform: scale(1.25); }
