:root {
  color-scheme: light;
  --bg: #f5f6fb;
  --panel: #ffffff;
  --panel-soft: #f8f9fd;
  --panel-strong: #eef0f7;
  --text: #1d2433;
  --muted: #687086;
  --faint: #8f96a8;
  --border: #dfe2eb;
  --border-strong: #cdd2df;
  --primary: #6d4aff;
  --primary-strong: #5634e8;
  --primary-soft: rgba(109, 74, 255, .11);
  --accent: #13b899;
  --danger: #d94962;
  --warning: #e89a22;
  --shadow-sm: 0 2px 10px rgba(26, 31, 48, .08);
  --shadow-md: 0 16px 45px rgba(26, 31, 48, .18);
  --header-height: 66px;
  --menu-height: 34px;
  --toolbar-height: 46px;
  --formula-height: 36px;
  --footer-height: 38px;
  --row-header-width: 48px;
  --cell-width: 112px;
  --cell-height: 28px;
  --radius: 10px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0f18;
  --panel: #141722;
  --panel-soft: #191d2a;
  --panel-strong: #202536;
  --text: #f2f3f8;
  --muted: #a6adbf;
  --faint: #777f94;
  --border: #2a3041;
  --border-strong: #394155;
  --primary: #8d70ff;
  --primary-strong: #a089ff;
  --primary-soft: rgba(141, 112, 255, .18);
  --accent: #2bd6b3;
  --danger: #ff6e82;
  --warning: #f4b251;
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, .28);
  --shadow-md: 0 18px 50px rgba(0, 0, 0, .48);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    color-scheme: dark;
    --bg: #0d0f18;
    --panel: #141722;
    --panel-soft: #191d2a;
    --panel-strong: #202536;
    --text: #f2f3f8;
    --muted: #a6adbf;
    --faint: #777f94;
    --border: #2a3041;
    --border-strong: #394155;
    --primary: #8d70ff;
    --primary-strong: #a089ff;
    --primary-soft: rgba(141, 112, 255, .18);
    --accent: #2bd6b3;
    --danger: #ff6e82;
    --warning: #f4b251;
    --shadow-sm: 0 2px 12px rgba(0, 0, 0, .28);
    --shadow-md: 0 18px 50px rgba(0, 0, 0, .48);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select { font: inherit; color: inherit; }
button { border: 0; }
button, select, input[type="color"] { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

.noscript { padding: 20px; background: #fff3cd; color: #5d4400; text-align: center; }
.app-shell { width: 100%; height: 100%; display: grid; grid-template-rows: var(--header-height) var(--menu-height) var(--toolbar-height) var(--formula-height) minmax(0, 1fr) var(--footer-height); background: var(--bg); }

.app-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--border); min-width: 0; z-index: 30; }
.brand-area { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; flex: 0 0 auto; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: linear-gradient(145deg, #7e5cff, #4e2cd4); color: white; box-shadow: 0 8px 22px rgba(91, 57, 221, .25); }
.brand-mark svg { width: 25px; height: 25px; fill: currentColor; stroke: none; }
.brand-mark .brand-mark-accent { fill: #2ce0b8; }
.brand-text { font-size: 18px; font-weight: 780; letter-spacing: -.4px; }
.brand-text span { color: var(--primary); }
.document-meta { min-width: 0; max-width: 470px; }
.workbook-name { width: min(390px, 35vw); max-width: 100%; border: 1px solid transparent; border-radius: 7px; background: transparent; padding: 4px 7px; font-weight: 650; line-height: 1.2; outline: none; cursor: text; text-overflow: ellipsis; }
.workbook-name:hover { border-color: var(--border); }
.workbook-name:focus { border-color: var(--primary); background: var(--panel-soft); box-shadow: 0 0 0 3px var(--primary-soft); }
.save-line { display: flex; align-items: center; gap: 6px; padding-left: 7px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.save-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.save-dot.saving { background: var(--warning); }
.save-dot.error { background: var(--danger); }
.privacy-chip { padding: 2px 7px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-strong); font-weight: 650; }
.header-actions { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.header-separator, .tool-separator, .formula-separator { width: 1px; align-self: stretch; background: var(--border); margin: 4px 3px; }
.header-button, .icon-button, .tool-button, .footer-icon-button, .zoom-display { display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; background: transparent; color: var(--muted); transition: background .14s, color .14s, transform .14s; }
.header-button:hover, .icon-button:hover, .tool-button:hover, .footer-icon-button:hover, .zoom-display:hover { background: var(--panel-strong); color: var(--text); }
.header-button:active, .icon-button:active, .tool-button:active { transform: translateY(1px); }
.text-button { height: 36px; padding: 0 11px; gap: 7px; font-weight: 600; }
.text-button svg { width: 18px; height: 18px; }
.icon-button { width: 36px; height: 36px; }
.compact-menu-wrap { position: relative; }
.compact-menu { position: absolute; right: 0; top: calc(100% + 7px); min-width: 190px; padding: 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); z-index: 100; }
.compact-menu button { width: 100%; text-align: left; padding: 9px 11px; border-radius: 7px; background: transparent; }
.compact-menu button:hover, .compact-menu button[aria-checked="true"] { background: var(--primary-soft); color: var(--primary-strong); }

.menu-bar { display: flex; align-items: center; padding: 0 11px; gap: 1px; background: var(--panel); border-bottom: 1px solid var(--border); z-index: 25; }
.menu-root > button { height: 28px; padding: 0 10px; border-radius: 6px; background: transparent; font-size: 13px; color: var(--text); }
.menu-root > button:hover, .menu-root > button.active { background: var(--panel-strong); }
.dropdown-layer { position: fixed; z-index: 200; min-width: 250px; max-width: 330px; padding: 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); }
.menu-item { width: 100%; min-height: 34px; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 7px; padding: 5px 9px; border-radius: 7px; background: transparent; text-align: left; }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--primary-soft); color: var(--primary-strong); outline: none; }
.menu-item:disabled { opacity: .42; cursor: not-allowed; }
.menu-item svg { width: 17px; height: 17px; }
.menu-item .shortcut { color: var(--faint); font-size: 11px; margin-left: 15px; }
.menu-item .checkmark { font-size: 13px; text-align: center; }
.menu-separator { height: 1px; background: var(--border); margin: 5px 4px; }
.menu-label { padding: 5px 9px 3px; color: var(--faint); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; font-weight: 750; }

.toolbar { display: flex; align-items: center; gap: 4px; padding: 5px 9px; background: var(--panel-soft); border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; z-index: 20; scrollbar-width: thin; }
.tool-group { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.tool-button { width: 32px; height: 32px; }
.tool-button.active { background: var(--primary-soft); color: var(--primary-strong); }
.tool-button svg { width: 18px; height: 18px; }
.text-tool { width: auto; min-width: 42px; font-size: 11px; font-weight: 650; }
.format-button { font-family: Georgia, serif; font-size: 15px; }
.zoom-display { height: 30px; min-width: 55px; padding: 0 6px; font-size: 12px; }
.tool-select { height: 30px; min-width: 112px; padding: 0 28px 0 9px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel); outline: none; }
.tool-select:focus { border-color: var(--primary); }
.color-tool { position: relative; width: 34px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--muted); }
.color-tool:hover { background: var(--panel-strong); color: var(--text); }
.color-tool input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }
.color-icon { font-weight: 700; font-family: Georgia, serif; }
.color-preview { position: absolute; left: 7px; right: 7px; bottom: 4px; height: 3px; border-radius: 3px; background: #1d2433; }
.fill-tool .color-preview { background: #ffffff; border: 1px solid var(--border); }
.fill-tool svg { width: 18px; height: 18px; }
.fx-symbol { font-family: Georgia, serif; font-weight: 700; font-style: italic; }

.formula-bar { display: flex; align-items: center; background: var(--panel); border-bottom: 1px solid var(--border); min-width: 0; }
.name-box { width: 86px; height: 100%; display: flex; align-items: center; padding: 0 11px; font-size: 12px; font-weight: 650; color: var(--muted); cursor: text; }
.name-box:focus { outline: 2px solid var(--primary); outline-offset: -2px; }
.formula-symbol { width: 36px; text-align: center; font-family: Georgia, serif; font-style: italic; font-weight: 700; color: var(--muted); }
.formula-input { flex: 1; height: 100%; border: 0; background: transparent; outline: none; padding: 0 10px 0 0; cursor: text; }
.formula-input:focus { box-shadow: inset 0 -2px var(--primary); }

.sheet-workspace { min-width: 0; min-height: 0; overflow: hidden; background: var(--bg); }
.grid-scroller { width: 100%; height: 100%; overflow: auto; position: relative; outline: none; background: var(--panel); }
.sheet-grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: max-content; min-width: 100%; background: var(--panel); transform-origin: top left; }
.sheet-grid th, .sheet-grid td { height: var(--cell-height); min-height: var(--cell-height); border: 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 0; position: relative; overflow: hidden; }
.sheet-grid thead th { position: sticky; top: 0; z-index: 8; height: 30px; background: var(--panel-strong); color: var(--muted); font-size: 11px; font-weight: 620; text-align: center; user-select: none; }
.sheet-grid .corner-cell { position: sticky; left: 0; top: 0; z-index: 12; width: var(--row-header-width); min-width: var(--row-header-width); background: var(--panel-strong); }
.sheet-grid .row-header { position: sticky; left: 0; z-index: 7; width: var(--row-header-width); min-width: var(--row-header-width); background: var(--panel-strong); color: var(--muted); text-align: center; font-size: 11px; font-weight: 550; user-select: none; }
.sheet-grid .column-header { width: var(--cell-width); min-width: var(--cell-width); max-width: var(--cell-width); }
.sheet-grid td { width: var(--cell-width); min-width: var(--cell-width); max-width: var(--cell-width); background: var(--panel); cursor: cell; }
.cell-content { width: 100%; height: 100%; display: flex; align-items: center; padding: 2px 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; line-height: 1.15; }
.cell-content.wrap { white-space: normal; overflow-wrap: anywhere; }
.sheet-grid td.selected { background: color-mix(in srgb, var(--primary) 9%, var(--panel)); }
.sheet-grid td.selection-top { box-shadow: inset 0 2px var(--primary); }
.sheet-grid td.selection-bottom { box-shadow: inset 0 -2px var(--primary); }
.sheet-grid td.selection-left::before, .sheet-grid td.selection-right::after { content: ""; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--primary); z-index: 3; }
.sheet-grid td.selection-left::before { left: 0; }
.sheet-grid td.selection-right::after { right: 0; }
.sheet-grid td.active-cell { overflow: visible; }
.sheet-grid td.active-cell::after { content: ""; position: absolute; inset: -1px; border: 2px solid var(--primary); pointer-events: none; z-index: 4; }
.sheet-grid td.active-cell::before { content: ""; position: absolute; width: 6px; height: 6px; right: -4px; bottom: -4px; background: var(--primary); border: 1px solid var(--panel); z-index: 5; }
.sheet-grid th.header-selected { background: var(--primary-soft); color: var(--primary-strong); }
.sheet-grid td.formula-error .cell-content { color: var(--danger); font-weight: 650; }
.sheet-grid.freeze-first-row tbody tr:first-child td { position: sticky; top: 30px; z-index: 5; box-shadow: inset 0 -2px var(--border-strong); }
.sheet-grid.freeze-first-row tbody tr:first-child .row-header { z-index: 9; }
.sheet-grid.freeze-first-col tbody td:nth-child(2), .sheet-grid.freeze-first-col thead th:nth-child(2) { position: sticky; left: var(--row-header-width); z-index: 6; box-shadow: inset -2px 0 var(--border-strong); }
.sheet-grid.freeze-first-col thead th:nth-child(2) { z-index: 10; }
.cell-editor-wrap { position: absolute; z-index: 50; border: 2px solid var(--primary); background: var(--panel); box-shadow: var(--shadow-sm); }
.cell-editor { width: 100%; height: 100%; min-width: 110px; border: 0; outline: 0; padding: 2px 5px; background: var(--panel); color: var(--text); cursor: text; }

.app-footer { display: flex; align-items: center; justify-content: space-between; min-width: 0; background: var(--panel); border-top: 1px solid var(--border); }
.sheet-tabs-area { min-width: 0; display: flex; align-items: stretch; height: 100%; }
.footer-icon-button { width: 38px; height: 100%; border-radius: 0; border-right: 1px solid var(--border); }
.footer-icon-button svg { width: 18px; height: 18px; }
.sheet-tabs { display: flex; align-items: stretch; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.sheet-tab { position: relative; min-width: 92px; max-width: 180px; display: flex; align-items: center; justify-content: center; padding: 0 15px; background: transparent; color: var(--muted); border-right: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-tab:hover { background: var(--panel-soft); color: var(--text); }
.sheet-tab[aria-selected="true"] { color: var(--primary-strong); background: var(--primary-soft); font-weight: 650; }
.sheet-tab[aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--primary); }
.status-area { height: 100%; display: flex; align-items: center; gap: 14px; padding: 0 12px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.selection-status { font-weight: 560; }
.formula-status { color: var(--danger); }
.version-chip { padding: 2px 7px; border-radius: 999px; background: var(--panel-strong); color: var(--faint); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(7, 9, 15, .55); backdrop-filter: blur(4px); z-index: 500; }
.modal { position: fixed; left: 50%; top: 50%; width: min(660px, calc(100vw - 28px)); max-height: min(760px, calc(100vh - 28px)); transform: translate(-50%, -50%); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-md); z-index: 510; overflow: hidden; }
.modal.wide { width: min(920px, calc(100vw - 28px)); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 19px 21px 14px; border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 2px 0 0; font-size: 20px; letter-spacing: -.3px; }
.modal-eyebrow { color: var(--primary-strong); text-transform: uppercase; font-size: 10px; font-weight: 800; letter-spacing: .09em; }
.modal-body { padding: 20px 21px; overflow: auto; }
.modal-footer { min-height: 58px; display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding: 10px 20px; background: var(--panel-soft); border-top: 1px solid var(--border); }
.primary-button, .secondary-button, .danger-button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 15px; border-radius: 9px; font-weight: 650; text-decoration: none; }
.primary-button { background: var(--primary); color: white; box-shadow: 0 7px 20px rgba(109, 74, 255, .22); }
.primary-button:hover { background: var(--primary-strong); }
.secondary-button { background: var(--panel-strong); color: var(--text); }
.secondary-button:hover { background: var(--border-strong); }
.danger-button { background: color-mix(in srgb, var(--danger) 13%, var(--panel)); color: var(--danger); }
.form-field { display: grid; gap: 7px; margin-bottom: 15px; }
.form-field label { font-size: 12px; font-weight: 650; color: var(--muted); }
.text-input, .search-input, .form-select { width: 100%; height: 40px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel); padding: 0 11px; outline: none; cursor: text; }
.text-input:focus, .search-input:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.modal-grid { display: grid; gap: 14px; }
.quick-guide { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.guide-card { padding: 14px; background: var(--panel-soft); border: 1px solid var(--border); border-radius: 11px; }
.guide-card h3 { margin: 0 0 6px; font-size: 14px; }
.guide-card p { margin: 0; color: var(--muted); line-height: 1.55; font-size: 12px; }
.info-callout { padding: 13px 14px; border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border)); border-radius: 10px; background: var(--primary-soft); color: var(--text); line-height: 1.55; }
.warning-callout { border-color: color-mix(in srgb, var(--warning) 40%, var(--border)); background: color-mix(in srgb, var(--warning) 11%, var(--panel)); }
.privacy-list { margin: 12px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.75; }
.function-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.function-item { padding: 10px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel-soft); }
.function-item code { color: var(--primary-strong); font-weight: 700; }
.function-item small { display: block; color: var(--muted); margin-top: 4px; }
.local-toolbar { display: flex; gap: 9px; margin-bottom: 14px; }
.workbook-list { display: grid; gap: 8px; }
.workbook-card { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--panel); }
.workbook-card:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); box-shadow: var(--shadow-sm); }
.workbook-card-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; background: var(--primary-soft); color: var(--primary-strong); }
.workbook-card-title { font-weight: 680; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workbook-card-meta { margin-top: 4px; color: var(--muted); font-size: 11px; }
.workbook-card-actions { display: flex; gap: 4px; }
.empty-state { text-align: center; padding: 38px 15px; color: var(--muted); }
.empty-state svg { width: 42px; height: 42px; margin-bottom: 9px; color: var(--faint); }
.about-hero { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.about-logo { width: 70px; height: 70px; border-radius: 19px; box-shadow: var(--shadow-sm); }
.about-hero h3 { margin: 0; font-size: 24px; }
.about-hero p { margin: 5px 0 0; color: var(--muted); }
.about-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 15px 0; }
.about-stat { padding: 10px; border: 1px solid var(--border); border-radius: 9px; text-align: center; background: var(--panel-soft); }
.about-stat strong { display: block; font-size: 13px; }
.about-stat span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.sheet-list-menu { display: grid; gap: 6px; }
.sheet-list-menu button { width: 100%; padding: 10px 11px; text-align: left; border-radius: 8px; background: var(--panel-soft); }
.sheet-list-menu button:hover { background: var(--primary-soft); color: var(--primary-strong); }

.toast-region { position: fixed; right: 16px; bottom: 54px; display: grid; gap: 8px; z-index: 1000; pointer-events: none; }
.toast { min-width: 250px; max-width: 380px; display: flex; align-items: flex-start; gap: 9px; padding: 11px 13px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); color: var(--text); animation: toast-in .2s ease-out; pointer-events: auto; }
.toast.success { border-left: 4px solid var(--accent); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--primary); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 900px) {
  .header-button span { display: none; }
  .header-button { width: 36px; padding: 0; }
  .brand-text { display: none; }
  .document-meta { max-width: calc(100vw - 290px); }
  .workbook-name { width: 100%; }
  .status-area { gap: 7px; }
  .selection-status { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
}

@media (max-width: 620px) {
  :root { --header-height: 58px; }
  .app-header { padding: 6px 8px; }
  .brand-mark { width: 34px; height: 34px; }
  .document-meta { max-width: calc(100vw - 230px); }
  .privacy-chip, #openLocalBtn, .header-separator { display: none; }
  .menu-bar { overflow-x: auto; }
  .menu-root > button { padding: 0 8px; }
  .status-area .formula-status, .version-chip { display: none; }
  .quick-guide, .function-list { grid-template-columns: 1fr; }
  .about-stats { grid-template-columns: 1fr; }
  .modal-body { padding: 16px; }
}

@media print {
  body { overflow: visible; background: white; }
  .app-header, .menu-bar, .toolbar, .formula-bar, .app-footer { display: none !important; }
  .app-shell { display: block; height: auto; }
  .sheet-workspace, .grid-scroller { overflow: visible; height: auto; }
  .sheet-grid { zoom: 1 !important; }
  .sheet-grid th { position: static !important; }
  .sheet-grid .row-header, .sheet-grid .corner-cell { position: static !important; }
  .sheet-grid td.selected { background: transparent; }
  .sheet-grid td.active-cell::after, .sheet-grid td.active-cell::before { display: none; }
}
.sheet-grid.hide-gridlines td,
.sheet-grid.hide-gridlines th { border-color: transparent; }

/* LumeSheets 0.2.0 — institutional flows, install controls and richer formatting */
.install-button { min-height:38px; padding:0 14px; gap:8px; color:#fff; background:linear-gradient(135deg,var(--primary),var(--primary-strong)); box-shadow:0 8px 22px rgba(109,74,255,.24); font-weight:750; }
.install-button:hover { color:#fff; background:linear-gradient(135deg,var(--primary-strong),var(--primary)); }
.install-button[data-installed="true"] { background:var(--panel-strong); color:var(--muted); box-shadow:none; }
.institutional-button { border:1px solid var(--border); background:var(--panel); }
.language-button { min-width:66px; height:36px; padding:0 9px; gap:6px; border-radius:8px; background:transparent; color:var(--muted); }
.language-button:hover { background:var(--panel-strong); color:var(--text); }
.locale-label { font-size:11px; font-weight:760; letter-spacing:.02em; }
.font-family-select { min-width:94px; }
.font-size-select { min-width:66px; width:66px; padding-right:20px; }
.file-tools .tool-button { color:var(--text); }
.modal.institutional { width:min(980px,calc(100vw - 34px)); max-height:min(820px,calc(100vh - 28px)); border-radius:20px; }
.modal.institutional .modal-header { padding:23px 25px 18px; }
.modal.institutional .modal-header h2 { font-size:24px; letter-spacing:-.45px; }
.modal.institutional .modal-body { padding:24px 25px; }
.modal.institutional .modal-footer { min-height:70px; padding:12px 25px; background:var(--panel); }
.modal.bug-modal { width:min(820px,calc(100vw - 34px)); }
.modal.donate-modal { width:min(760px,calc(100vw - 34px)); }
.modal.about-modal { width:min(1040px,calc(100vw - 34px)); max-height:min(940px,calc(100vh - 24px)); }
.modal-footer.split-footer { justify-content:space-between; }
.modal-footer .footer-group { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.primary-button svg,.secondary-button svg,.danger-button svg { width:18px; height:18px; }
.primary-button.large,.secondary-button.large { min-height:44px; padding:0 19px; border-radius:11px; }
.secondary-button.outline { background:var(--panel); border:1px solid var(--border); }
.secondary-button.outline:hover { border-color:var(--primary); color:var(--primary-strong); background:var(--primary-soft); }
.institutional-intro { margin:0 0 14px; color:var(--muted); line-height:1.65; font-size:14px; }
.info-row { display:flex; align-items:center; justify-content:space-between; gap:14px; min-height:52px; padding:0 15px; border:1px solid var(--border); border-radius:12px; background:var(--panel-soft); }
.info-row strong { font-size:13px; }
.info-row a { color:var(--primary-strong); font-weight:730; text-decoration:none; }
.info-row a:hover { text-decoration:underline; }
.tech-panel { margin-top:12px; border:1px solid var(--border); border-radius:13px; background:var(--panel-soft); overflow:hidden; }
.tech-panel-header { padding:14px 15px 8px; font-weight:730; }
.tech-report { margin:0; min-height:250px; max-height:355px; overflow:auto; padding:0 15px 15px; color:var(--muted); font:12px/1.55 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; white-space:pre-wrap; overflow-wrap:anywhere; }
.privacy-note { margin-top:12px; display:flex; gap:10px; align-items:flex-start; padding:12px 13px; border:1px solid color-mix(in srgb,var(--primary) 38%,var(--border)); border-radius:11px; background:var(--primary-soft); color:var(--primary-strong); font-size:12px; line-height:1.5; }
.privacy-note svg { flex:0 0 auto; width:18px; height:18px; }
.about-top { display:flex; align-items:center; justify-content:space-between; gap:20px; padding-bottom:20px; border-bottom:1px solid var(--border); }
.about-identity { display:flex; align-items:center; gap:18px; min-width:0; }
.about-identity .about-logo { width:76px; height:76px; margin:0; border-radius:18px; }
.about-identity h3 { margin:0; font-size:27px; letter-spacing:-.45px; }
.about-identity p { margin:5px 0 0; color:var(--muted); }
.about-badges { display:flex; justify-content:flex-end; flex-wrap:wrap; gap:8px; }
.about-badge { padding:7px 11px; border:1px solid color-mix(in srgb,var(--primary) 55%,var(--border)); border-radius:999px; color:var(--primary-strong); font-size:10px; font-weight:800; letter-spacing:.06em; }
.about-feature-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin-top:20px; }
.about-feature-card { min-height:176px; padding:17px; border:1px solid var(--border); border-radius:14px; background:var(--panel-soft); }
.about-feature-card h4 { margin:0 0 9px; font-size:14px; }
.about-feature-card p,.about-feature-card ul { margin:0; color:var(--muted); line-height:1.62; font-size:12px; }
.about-feature-card ul { padding-left:18px; }
.feature-icon { width:38px; height:38px; display:grid; place-items:center; margin-bottom:12px; border-radius:11px; background:var(--primary-soft); color:var(--primary-strong); font-size:20px; }
.about-link-strip { margin-top:16px; display:flex; align-items:center; justify-content:space-between; gap:12px; padding:13px 15px; border:1px solid color-mix(in srgb,var(--primary) 55%,var(--border)); border-radius:12px; background:var(--primary-soft); }
.about-link-strip a { color:var(--primary-strong); font-weight:750; text-decoration:none; }
.about-link-strip span { color:var(--muted); font-size:11px; }
.about-info-grid { display:grid; grid-template-columns:1.05fr 1.05fr 1.15fr 1.25fr; margin-top:18px; border-top:1px solid var(--border); border-bottom:1px solid var(--border); }
.about-info-item { min-width:0; padding:16px 15px; border-right:1px solid var(--border); }
.about-info-item:first-child { padding-left:0; }
.about-info-item:last-child { border-right:0; padding-right:0; }
.about-info-item small { display:block; margin-bottom:8px; color:var(--faint); font-size:9px; font-weight:800; letter-spacing:.08em; text-transform:uppercase; }
.about-info-item strong,.about-info-item a,.about-info-item span { display:block; color:var(--text); font-size:12px; line-height:1.55; overflow-wrap:anywhere; text-decoration:none; }
.about-info-item a:hover { color:var(--primary-strong); }
.about-more { margin-top:17px; padding:15px 16px; border:1px solid var(--border); border-radius:13px; background:var(--panel-soft); }
.about-more-title { margin-bottom:11px; color:var(--muted); font-size:10px; font-weight:800; text-transform:uppercase; letter-spacing:.08em; }
.about-more-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px 24px; }
.about-more-item { display:flex; align-items:flex-start; gap:8px; color:var(--muted); font-size:12px; line-height:1.5; }
.about-more-item::before { content:"✓"; color:var(--primary-strong); font-weight:800; }
.donate-hero { text-align:center; padding:0 20px 18px; }
.donate-heart { width:74px; height:74px; display:grid; place-items:center; margin:0 auto 15px; border-radius:20px; background:#f9d7e4; color:#f04578; }
.donate-heart svg { width:35px; height:35px; stroke-width:1.7; }
.donate-hero h3 { margin:0; font-size:25px; letter-spacing:-.4px; }
.donate-hero p { max-width:600px; margin:10px auto 0; color:var(--muted); line-height:1.65; }
.donate-explain { display:grid; gap:10px; }
.donate-card { display:grid; grid-template-columns:42px minmax(0,1fr); align-items:center; gap:13px; padding:14px; border:1px solid var(--border); border-radius:13px; background:var(--panel-soft); color:var(--muted); line-height:1.55; }
.donate-card-icon { width:40px; height:40px; display:grid; place-items:center; border-radius:11px; background:var(--primary-soft); color:var(--primary-strong); }
.donate-support-title { margin:18px 0 10px; font-size:14px; }
.donate-support-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:9px; }
.donate-support-item { display:flex; align-items:center; gap:9px; min-height:54px; padding:10px; border:1px solid var(--border); border-radius:12px; background:var(--panel-soft); font-size:12px; }
.donate-support-item span:first-child { width:31px; height:31px; display:grid; place-items:center; flex:0 0 auto; border-radius:9px; background:var(--primary-soft); color:var(--primary-strong); }
.install-help { display:grid; gap:12px; }
.install-state { display:flex; gap:12px; align-items:flex-start; padding:14px; border:1px solid var(--border); border-radius:12px; background:var(--panel-soft); }
.install-state svg { flex:0 0 auto; color:var(--primary-strong); }
.install-state h3 { margin:0 0 5px; font-size:14px; }
.install-state p { margin:0; color:var(--muted); line-height:1.55; font-size:12px; }
@media (max-width:1180px) { .institutional-button span,.file-header-button span{display:none}.institutional-button,.file-header-button{width:36px;padding:0} }
@media (max-width:900px) { .install-button span{display:none}.install-button{width:38px;padding:0}.file-header-button{display:none}.about-feature-grid{grid-template-columns:1fr}.about-info-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.about-info-item{border-bottom:1px solid var(--border)}.about-info-item:nth-child(2){border-right:0}.donate-support-grid{grid-template-columns:repeat(2,minmax(0,1fr))} }
@media (max-width:620px) { .institutional-button{display:none}.language-button{width:36px;min-width:36px;padding:0}.locale-label{display:none}.modal.institutional .modal-header,.modal.institutional .modal-body,.modal.institutional .modal-footer{padding-left:16px;padding-right:16px}.about-top{align-items:flex-start;flex-direction:column}.about-badges{justify-content:flex-start}.about-info-grid,.about-more-grid,.donate-support-grid{grid-template-columns:1fr}.about-info-item{padding-left:0;border-right:0}.modal-footer.split-footer{align-items:stretch;flex-direction:column}.modal-footer .footer-group{width:100%}.modal-footer .footer-group>*{flex:1} }

/* LumeSheets 0.3.0 — localized numbers, cell sizing, palettes and native grid menus */
.currency-select { min-width: 104px; width: 104px; }
.native-color-input { position: fixed; left: -20px; top: -20px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.color-tool { border: 0; background: transparent; cursor: pointer; }
.color-tool .color-preview { position: absolute; left: 7px; right: 7px; bottom: 3px; height: 3px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--border-strong) 70%, transparent); }
.color-palette { width: 260px; }
.color-palette-title { padding: 7px 8px 9px; color: var(--muted); font-size: 11px; font-weight: 750; }
.color-swatch-grid { display: grid; grid-template-columns: repeat(7, 28px); gap: 6px; padding: 2px 8px 10px; }
.color-swatch { width: 28px; height: 28px; padding: 3px; border-radius: 7px; background: transparent; border: 1px solid transparent; }
.color-swatch:hover, .color-swatch.active { border-color: var(--primary); background: var(--primary-soft); }
.color-swatch span { display: block; width: 100%; height: 100%; border-radius: 5px; background: var(--swatch); border: 1px solid rgba(0,0,0,.16); box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.color-palette-actions { padding-top: 5px; border-top: 1px solid var(--border); }
.menu-item.compact { min-height: 32px; }

.sheet-grid .column-header, .sheet-grid .row-header { overflow: visible; }
.header-label { pointer-events: none; }
.col-resize-handle { position: absolute; right: -4px; top: 0; width: 8px; height: 100%; z-index: 20; cursor: col-resize; }
.row-resize-handle { position: absolute; left: 0; right: 0; bottom: -4px; height: 8px; z-index: 20; cursor: row-resize; }
.col-resize-handle:hover::after, .row-resize-handle:hover::after { content: ""; position: absolute; background: var(--primary); }
.col-resize-handle:hover::after { top: 0; bottom: 0; left: 3px; width: 2px; }
.row-resize-handle:hover::after { left: 0; right: 0; top: 3px; height: 2px; }
body.resizing-column, body.resizing-column * { cursor: col-resize !important; user-select: none !important; }
body.resizing-row, body.resizing-row * { cursor: row-resize !important; user-select: none !important; }
.cell-size-tools .text-tool { min-width: 38px; padding: 0 6px; font-size: 11px; font-weight: 700; }

.function-picker-modal { width: min(720px, calc(100vw - 30px)); }
.function-picker-list { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; max-height: 360px; overflow: auto; margin: 12px 0; }
.function-picker-item { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 10px 12px; text-align: left; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-soft); }
.function-picker-item:hover { border-color: var(--primary); background: var(--primary-soft); }
.function-picker-item code { min-width: 78px; color: var(--primary-strong); font-weight: 800; }
.function-picker-item span { color: var(--muted); font-size: 11px; }

.formula-input:focus, .cell-editor:focus { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--primary) 65%, transparent); }

@media (max-width: 900px) {
  .currency-select { width: 82px; min-width: 82px; }
  .cell-size-tools { display: none; }
  .function-picker-list { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 560px) { .function-picker-list { grid-template-columns: 1fr; } }


/* LumeSheets 0.5.0 — responsive UI, embedded brand icons and documentation */
.menu-bar { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; white-space: nowrap; }
.menu-bar::-webkit-scrollbar { display: none; }
.dropdown-layer {
  max-height: calc(100vh - 12px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.dropdown-layer::-webkit-scrollbar { width: 8px; }
.dropdown-layer::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--panel); }
.dropdown-layer .menu-label { position: sticky; top: -6px; z-index: 2; background: var(--panel); }

.toolbar { overflow-x: hidden; scrollbar-width: none; }
.toolbar::-webkit-scrollbar { display: none; }
.toolbar-overflow-wrap { display: none; margin-left: auto; position: sticky; right: 5px; z-index: 4; padding-left: 5px; background: linear-gradient(90deg, transparent, var(--panel-soft) 34%); }
.toolbar-more-button { background: var(--panel); border: 1px solid var(--border); box-shadow: 0 3px 10px rgba(20,24,40,.08); }

.theme-button { position: relative; overflow: visible; isolation: isolate; }
.theme-icon-stage { display: grid; place-items: center; width: 22px; height: 22px; }
.theme-glyph { width: 20px; height: 20px; transform-origin: center; }
.theme-click-ring { position: absolute; inset: 4px; z-index: -1; border-radius: 50%; border: 2px solid var(--primary); opacity: 0; transform: scale(.45); }
.theme-button.theme-changing .theme-icon-stage { animation: themeGlyphSwap .48s cubic-bezier(.2,.8,.2,1); }
.theme-button.theme-changing .theme-click-ring { animation: themeRing .52s ease-out; }
.theme-button[data-theme="light"] .theme-glyph { color: #e3a008; }
.theme-button[data-theme="dark"] .theme-glyph { color: #8d6cff; }
.theme-button[data-theme="auto"] .theme-glyph { color: var(--muted); }
@keyframes themeGlyphSwap { 0% { transform: rotate(-35deg) scale(.72); opacity:.35 } 55% { transform: rotate(18deg) scale(1.16); opacity:1 } 100% { transform: rotate(0) scale(1); opacity:1 } }
@keyframes themeRing { 0% { opacity:.42; transform:scale(.35) } 100% { opacity:0; transform:scale(1.75) } }
@media (prefers-reduced-motion: reduce) { .theme-button.theme-changing .theme-icon-stage,.theme-button.theme-changing .theme-click-ring { animation:none; } }

.about-logo-fallback { width:76px; height:76px; display:none; place-items:center; flex:0 0 auto; border-radius:18px; background:linear-gradient(145deg,#7e5cff,#4e2cd4); color:#fff; font-size:38px; box-shadow:0 8px 22px rgba(91,57,221,.22); }
.about-logo[hidden] + .about-logo-fallback { display:grid !important; }

.command-palette-modal { width:min(650px,calc(100vw - 24px)); }
.command-list { display:grid; gap:5px; max-height:min(430px,55vh); overflow:auto; margin-top:12px; padding:2px; }
.command-item { width:100%; min-height:44px; display:flex; align-items:center; justify-content:space-between; gap:15px; padding:9px 12px; border:1px solid transparent; border-radius:9px; background:transparent; color:var(--text); text-align:left; }
.command-item:hover,.command-item.active { border-color:color-mix(in srgb,var(--primary) 38%,var(--border)); background:var(--primary-soft); color:var(--primary-strong); }
.command-item kbd { min-width:70px; color:var(--faint); font:11px/1.2 ui-monospace,SFMono-Regular,Consolas,monospace; text-align:right; }
.command-hint { margin-right:auto; color:var(--faint); font-size:11px; }

@media (max-width: 1450px) {
  .cell-size-tools,.responsive-alignment-tools,.responsive-utility-tools { display:none; }
  .toolbar-overflow-wrap { display:flex; }
}
@media (max-width: 1160px) {
  .responsive-number-tools,.responsive-zoom-tools { display:none; }
}
@media (max-width: 900px) {
  .app-header { padding-left:9px; padding-right:9px; }
  .document-meta { max-width:42vw; }
  .workbook-name { width:34vw; }
}
@media (max-width: 720px) {
  .responsive-font-tools { display:none; }
  .file-tools [data-action="import"],.file-tools [data-action="exportMenu"],.file-tools [data-action="save"] { display:none; }
  .privacy-chip { display:none; }
  .document-meta { max-width:36vw; }
  .workbook-name { width:32vw; }
}
@media (max-width: 520px) {
  .brand-mark { width:32px;height:32px;border-radius:9px; }
  .document-meta { max-width:40vw; }
  .save-line { font-size:10px; }
  .language-button { display:none; }
  .core-format-tools [data-action="strike"],
  .core-format-tools [data-action="borders"],
  .core-format-tools [data-action="textColorMenu"],
  .core-format-tools [data-action="fillColorMenu"] { display:none; }
  .modal { width:calc(100vw - 12px); max-height:calc(100vh - 12px); border-radius:13px; }
  .dropdown-layer { min-width:min(280px,calc(100vw - 12px)); max-width:calc(100vw - 12px); }
}

/* Hide separators that belong to toolbar groups collapsed into More tools. */
@media (max-width: 1450px) {
  .tool-separator:has(+ .responsive-alignment-tools),
  .responsive-alignment-tools + .tool-separator,
  .tool-separator:has(+ .cell-size-tools),
  .cell-size-tools + .tool-separator,
  .tool-separator:has(+ .responsive-utility-tools) { display:none; }
}
@media (max-width: 1160px) {
  .tool-separator:has(+ .responsive-zoom-tools),
  .responsive-zoom-tools + .tool-separator,
  .tool-separator:has(+ .responsive-number-tools),
  .responsive-number-tools + .tool-separator { display:none; }
}
@media (max-width: 720px) {
  .tool-separator:has(+ .responsive-font-tools),
  .responsive-font-tools + .tool-separator { display:none; }
}

.about-logo-inline{width:76px;height:76px;display:grid;place-items:center;flex:0 0 auto;border-radius:18px;overflow:hidden;box-shadow:0 8px 22px rgba(91,57,221,.22)}
.about-logo-inline svg{display:block;width:100%;height:100%}
