.table-sheet { box-sizing:border-box; width:min(1180px,calc(100vw - 28px)); height:min(820px,calc(100dvh - 40px)); max-width:none; max-height:none; padding:0; border:1px solid var(--line); border-radius:10px; background:var(--paper); color:var(--ink); overflow:hidden; font:12px/1.35 var(--font-body,sans-serif); }
.table-sheet[open] { display:flex; flex-direction:column; }
.table-sheet::backdrop { background:#101a2a75; }
.table-sheet * { box-sizing:border-box; }
.table-sheet { -webkit-touch-callout:none; -webkit-user-select:none; user-select:none; }
.table-sheet :is(input,textarea,select,[contenteditable=true],[contenteditable=plaintext-only]),.table-sheet :is([contenteditable=true],[contenteditable=plaintext-only]) * { -webkit-touch-callout:default; -webkit-user-select:text; user-select:text; }
.sheet-viewport img { -webkit-user-drag:none; }
.table-sheet [hidden] { display:none!important; }
.table-sheet button,.table-sheet input,.table-sheet select { font:inherit; color:inherit; }
.table-sheet button { cursor:pointer; }
.table-sheet button:disabled { opacity:.35; cursor:default; }
.table-sheet button:focus-visible,.table-sheet input:focus-visible,.table-sheet select:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
.sheet-heading { display:flex; align-items:center; gap:8px; padding:8px 12px; border-bottom:1px solid var(--line); flex:none; min-height:42px; }
.sheet-heading strong { display:flex; align-items:center; gap:7px; font-size:14px; margin-right:auto; }
.table-sheet svg { width:17px; height:17px; flex:none; }
.sheet-help,.sheet-close { display:flex; align-items:center; justify-content:center; gap:5px; border:0; background:transparent; padding:5px; min-width:30px; min-height:28px; }
.sheet-close { font-size:23px!important; line-height:1; }
.sheet-ribbon { display:flex; gap:0; align-items:center; flex:none; overflow-x:auto; overflow-y:hidden; padding:5px 6px; border-bottom:1px solid var(--line); background:var(--bg); scrollbar-width:thin; }
.sheet-tool-group { display:flex; gap:2px; align-items:center; flex:none; padding:0 5px; border-right:1px solid var(--line); }
.sheet-tool-group:last-child { border:0; }
.sheet-tool-group button { position:relative; display:flex; align-items:center; justify-content:center; flex:none; width:28px; height:29px; border:1px solid transparent; border-radius:4px; background:transparent; padding:5px; }
.sheet-tool-group button:hover,.sheet-tool-group button[aria-pressed=true] { background:color-mix(in srgb,var(--accent) 12%,var(--paper)); border-color:color-mix(in srgb,var(--accent) 25%,var(--line)); color:var(--accent); }
.sheet-tool-label { position:absolute; width:1px; height:1px; clip-path:inset(50%); overflow:hidden; white-space:nowrap; }
.sheet-color { display:flex; flex-direction:column; align-items:center; justify-content:center; width:28px; height:29px; position:relative; font-size:16px; font-weight:700; border:1px solid transparent; border-radius:4px; }
.sheet-color input { width:20px; height:6px; padding:0; border:0; background:transparent; cursor:pointer; }
.sheet-color input::-webkit-color-swatch-wrapper { padding:0; }
.sheet-color input::-webkit-color-swatch { border:0; }
.sheet-tool-group select { max-width:112px; height:28px; padding:3px 5px; border:1px solid var(--line); border-radius:4px; background:var(--paper); font-size:11px; }
.sheet-formula-bar { display:flex; align-items:stretch; gap:0; flex:none; border-bottom:1px solid var(--line); min-height:32px; }
.sheet-formula-bar input { background:var(--paper); border:0; padding:6px 8px; border-radius:0; min-width:0; outline-offset:-2px; }
.sheet-formula-bar [data-sheet-address] { width:104px; border-right:1px solid var(--line); text-align:center; flex:none; }
.sheet-formula-bar label { width:34px; display:grid; place-items:center; flex:none; font:italic 16px Georgia,serif; color:var(--muted); }
.sheet-formula-bar [data-sheet-formula] { flex:1; }
.sheet-filter-bar { display:flex; flex:none; align-items:center; gap:8px; padding:5px 10px; border-bottom:1px solid var(--line); font-size:11px; }
.sheet-filter-bar input { width:190px; min-width:0; height:27px; padding:4px 7px; border:1px solid var(--line); border-radius:4px; background:var(--paper); }
.sheet-filter-bar button { padding:4px 7px; border:1px solid var(--line); border-radius:4px; background:var(--paper); white-space:nowrap; }
.sheet-filter-bar span { color:var(--muted); margin-left:auto; white-space:nowrap; }
.sheet-viewport { flex:1; min-height:100px; overflow:auto; overscroll-behavior:contain; position:relative; background:var(--paper); outline:none; }
.sheet-grid { table-layout:fixed; border-collapse:separate; border-spacing:0; min-width:0; margin:0; font-size:12px; line-height:1.35; }
.sheet-grid th,.sheet-grid td { padding:4px 7px; border:0; border-right:1px solid var(--line); border-bottom:1px solid var(--line); height:28px; min-height:28px; vertical-align:middle; overflow-wrap:anywhere; background:var(--paper); }
.sheet-grid td { position:relative; white-space:pre-wrap; user-select:none; touch-action:pan-x pan-y; }
.sheet-grid td p,.sheet-grid td div { margin:0; padding:0; line-height:inherit; }
.sheet-grid td img { max-width:100%; height:auto; max-height:180px; }
.sheet-grid td.is-selected { background-image:linear-gradient(color-mix(in srgb,var(--accent) 9%,transparent),color-mix(in srgb,var(--accent) 9%,transparent)); }
.sheet-grid td.is-active { outline:2px solid var(--accent); outline-offset:-2px; z-index:1; }
.sheet-grid [data-sheet-fill] { position:absolute; right:-1px; bottom:-1px; width:8px; height:8px; background:var(--accent); border:1px solid var(--paper); cursor:crosshair; z-index:2; touch-action:none; }
.sheet-grid td[contenteditable=true] { user-select:text; cursor:text; background:var(--paper); outline:2px solid var(--accent); outline-offset:-2px; }
.sheet-grid td.sheet-error { color:#b93838; }
.sheet-heading-cell { font-weight:700; }
.sheet-grid th { padding:0; background:var(--bg); color:var(--muted); position:relative; user-select:none; font-weight:400; }
.sheet-grid thead th { position:sticky; top:0; z-index:3; height:27px; }
.sheet-grid tbody th { position:sticky; left:0; z-index:2; width:38px; }
.sheet-grid .sheet-corner { left:0; z-index:4; }
.sheet-grid th button { border:0; border-radius:0; width:100%; height:100%; min-height:27px; padding:3px; background:transparent; color:inherit; font-size:11px; }
.sheet-grid th button.is-selected { background:color-mix(in srgb,var(--accent) 15%,var(--bg)); color:var(--accent); font-weight:700; }
.sheet-grid [data-sheet-resize] { position:absolute; right:-3px; top:0; bottom:0; width:7px; z-index:4; cursor:col-resize; touch-action:none; }
.sheet-popover { position:absolute; z-index:10; width:204px; padding:4px; border:1px solid var(--line); border-radius:6px; background:var(--paper); box-shadow:0 5px 20px #101a2a22; }
.sheet-popover button { display:flex; align-items:center; justify-content:space-between; width:100%; border:0; padding:6px 8px; background:transparent; text-align:left; border-radius:3px; }
.sheet-popover button:hover { background:var(--bg); }
.sheet-popover kbd { font:10px/1.3 var(--font-body,sans-serif); color:var(--muted); }
.editor-table-context { position:fixed; z-index:90; max-height:calc(100dvh - 16px); overflow:auto; -webkit-touch-callout:none; user-select:none; font:12px/1.35 var(--font-body,sans-serif); }
.editor-table-context button { justify-content:flex-start; gap:8px; color:var(--ink); font:inherit; }
.editor-table-context button:disabled { opacity:.35; }
.editor-table-context button:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
.editor-table-context svg { width:16px; height:16px; flex:none; }
.sheet-key-help { position:absolute; top:42px; right:8px; width:min(390px,calc(100% - 16px)); max-height:calc(100% - 105px); overflow:auto; z-index:9; border:1px solid var(--line); border-radius:6px; background:var(--paper); padding:12px; box-shadow:0 5px 20px #101a2a22; }
.sheet-key-help dl { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1.1fr); gap:5px 8px; margin:9px 0; font-size:11px; }
.sheet-key-help dd { margin:0; color:var(--muted); }
.sheet-key-help p { font-size:10px; line-height:1.5; color:var(--muted); margin:8px 0 0; }
.sheet-footer { display:flex; align-items:center; gap:7px; flex:none; min-height:46px; padding:7px 10px; border-top:1px solid var(--line); background:var(--paper); }
.sheet-footer>div { flex:1; min-width:0; display:flex; flex-wrap:wrap; gap:2px 12px; font-size:11px; }
.sheet-selection-status { color:var(--muted); }
.sheet-message { color:var(--accent); }
.sheet-footer button { flex:none; padding:6px 10px; min-height:31px; border:1px solid var(--line); border-radius:5px; background:var(--paper); }
.sheet-footer button.primary { background:var(--accent); color:var(--paper); border-color:var(--accent); }
@media(max-width:650px) {
  .table-sheet { width:100vw; height:100dvh; border:0; border-radius:0; margin:0; }
  .sheet-heading { padding:7px 10px; padding-top:max(7px,env(safe-area-inset-top)); }
  .sheet-ribbon { padding:5px 3px; }
  .sheet-tool-group { padding:0 4px; }
  .sheet-tool-group button { width:34px; height:34px; }
  .sheet-color { width:32px; height:34px; }
  .sheet-formula-bar input { font-size:16px; }
  .sheet-formula-bar [data-sheet-address] { width:78px; font-size:12px; }
  .sheet-filter-bar { flex-wrap:wrap; gap:5px; }
  .sheet-filter-bar span { display:none; }
  .sheet-filter-bar input { flex:1; width:0; font-size:16px; height:32px; }
  .sheet-grid { font-size:13px; }
  .sheet-grid td { min-height:32px; height:32px; padding:5px 7px; }
  .sheet-grid td[contenteditable=true] { font-size:16px; }
  .sheet-footer { padding-bottom:max(7px,env(safe-area-inset-bottom)); gap:5px; }
  .sheet-footer>div { font-size:10px; }
  .sheet-footer button { min-height:36px; padding:6px 8px; }
}
