/* Unicorn Sheets. The app follows the theme; the grid itself stays white like paper, so colors look the same as in Excel. */
html, body { height: 100%; overflow: hidden; }
body { display: grid; grid-template-rows: auto auto auto 1fr auto; }
.top { display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.top .home { border: 0; background: none; padding: 2px; border-radius: 10px; }
.top .home:hover { background: var(--surface-2); }
.doc-name { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.doc-name input { font: 600 18px 'Fredoka', sans-serif; border: 1px solid transparent; background: none; color: var(--text); padding: 2px 6px; border-radius: 8px; max-width: 460px; }
.doc-name input:hover, .doc-name input:focus { border-color: var(--line); background: var(--surface-2); outline: none; }
.doc-name span { font-size: 12px; padding-left: 7px; }
.early { background: linear-gradient(135deg, #fef3c7, #fce7f3); color: #9a3412; border-color: #fcd34d; }
[data-theme="galaxy"] .early, [data-theme="midnight"] .early { background: #3b2a12; color: #fde68a; border-color: #92400e; }
.file-btns { display: flex; gap: 6px; align-items: center; }
.u-btn.sm { padding: 6px 12px; font-size: 13.5px; border-radius: 10px; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; z-index: 30; min-width: 250px; display: grid; }
.menu button { text-align: left; border: 0; background: none; padding: 8px 12px; border-radius: 10px; font-weight: 700; color: var(--text); }
.menu button:hover { background: var(--surface-2); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
.menu.ctx { position: fixed; z-index: 60; min-width: 220px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); align-items: center; }
.grp { display: flex; gap: 2px; align-items: center; padding-right: 8px; border-right: 1px solid var(--line); }
.grp:last-child { border-right: 0; }
.toolbar button, .toolbar .color { min-width: 30px; height: 32px; border: 1px solid transparent; background: none; border-radius: 8px; font: 800 13.5px 'Nunito', sans-serif; display: inline-grid; place-items: center; color: var(--text); padding: 0 6px; position: relative; cursor: pointer; }
.toolbar button:hover, .toolbar .color:hover { background: var(--surface); border-color: var(--line); }
.toolbar button.on { background: var(--glow); border-color: var(--accent); }
.toolbar select { height: 32px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; font: 700 12.5px 'Nunito', sans-serif; padding: 0 4px; max-width: 150px; }
.color { font-weight: 900; text-decoration: underline 3px var(--accent-2); }
.color input { position: absolute; inset: auto 0 0 0; width: 100%; height: 6px; opacity: 0; cursor: pointer; }
.search { margin-left: auto; }
.search input { height: 32px; width: 170px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 10px; padding: 0 10px; font: 700 13px 'Nunito', sans-serif; }
.search span { font-size: 12px; font-weight: 800; min-width: 40px; text-align: center; }

.fbar { display: flex; align-items: center; gap: 8px; padding: 5px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
#nameBox { width: 110px; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--text); font: 800 13px 'Nunito', sans-serif; padding: 0 8px; text-align: center; }
.fx { font: italic 800 14px Georgia, serif; color: var(--accent); padding: 0 4px; }
#fbar { flex: 1; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: 600 14px 'Consolas', 'Cascadia Mono', monospace; padding: 0 10px; }
#fbar:focus, #nameBox:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }

.grid { position: relative; min-height: 0; background: #fff; }
.scroller { position: absolute; inset: 0; overflow: auto; }
.view { position: sticky; top: 0; left: 0; overflow: hidden; z-index: 1; user-select: none; font: 14.5px/1.2 Calibri, 'Segoe UI', Arial, sans-serif; color: #111827; }
.spacer { pointer-events: none; }
.pane { position: absolute; overflow: hidden; }
.c { position: absolute; box-sizing: border-box; border-right: 1px solid #e5e7eb; border-bottom: 1px solid #e5e7eb; padding: 0 5px; white-space: nowrap; overflow: hidden; display: flex; align-items: flex-end; padding-bottom: 3px; background: #fff; }
.c.wrap { white-space: pre-wrap; word-break: break-word; line-height: 1.25; }
.c.vt { align-items: flex-start; padding-top: 3px; } .c.vm { align-items: center; padding-bottom: 0; }
.c.over { overflow: visible; z-index: 1; background: transparent; }
.c.over > span { background: inherit; }
.c.num { justify-content: flex-end; } .c.mid { justify-content: center; } .c.lft { justify-content: flex-start; }
.c.err { color: #dc2626; font-weight: 700; }
.c > span { overflow: hidden; text-overflow: clip; max-width: 100%; }
.c.over > span { overflow: visible; max-width: none; }
.hd { position: absolute; box-sizing: border-box; background: #f6f3fc; color: #6b6290; font: 700 12px 'Nunito', sans-serif; display: grid; place-items: center; border-right: 1px solid #ddd6f3; border-bottom: 1px solid #ddd6f3; }
.hd.on { background: #e9defe; color: #5b21b6; }
.hd.all { background: #ede7fb; }
.fz-x { position: absolute; top: 0; width: 2px; background: #c4b5fd; z-index: 4; }
.fz-y { position: absolute; left: 0; height: 2px; background: #c4b5fd; z-index: 4; }
.selbox { position: absolute; border: 2px solid #8b5cf6; background: rgba(139, 92, 246, .08); z-index: 3; pointer-events: none; }
.actbox { position: absolute; border: 2px solid #7c3aed; z-index: 3; pointer-events: none; }
.handle { position: absolute; width: 8px; height: 8px; background: #7c3aed; border: 1.5px solid #fff; z-index: 5; cursor: crosshair; }
.fillbox { position: absolute; border: 2px dashed #8b5cf6; z-index: 3; pointer-events: none; }
.refbox { position: absolute; border: 2px dashed #ec4899; background: rgba(236, 72, 153, .07); z-index: 3; pointer-events: none; }
.copybox { position: absolute; border: 2px dashed #10b981; z-index: 3; pointer-events: none; }
.findhit { position: absolute; background: rgba(6, 182, 212, .22); outline: 2px solid #06b6d4; z-index: 2; pointer-events: none; }
.editor { position: absolute; z-index: 10; border: 2px solid #7c3aed; box-shadow: 0 6px 18px rgba(76, 44, 160, .25); font: 14.5px/1.2 Calibri, 'Segoe UI', Arial, sans-serif; padding: 3px 5px; resize: none; outline: none; background: #fff; color: #111827; overflow: hidden; white-space: pre; }
.fn-help { position: absolute; z-index: 11; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); font: 700 12.5px 'Nunito', sans-serif; padding: 6px 10px; max-width: 420px; }
.fn-help b { color: var(--accent); }
.fn-help .opt { display: block; padding: 3px 6px; border-radius: 6px; cursor: pointer; }
.fn-help .opt.on, .fn-help .opt:hover { background: var(--glow); }

.tabsbar { display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--surface); border-top: 1px solid var(--line); min-height: 40px; }
.addsheet { width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-weight: 900; }
.tabs { display: flex; gap: 4px; overflow-x: auto; max-width: 60vw; align-self: stretch; align-items: stretch; }
.tab { border: 0; border-bottom: 3px solid transparent; background: none; padding: 0 14px; font: 800 13.5px 'Nunito', sans-serif; color: var(--muted); white-space: nowrap; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); background: var(--surface-2); }
.tab input { font: inherit; width: 120px; border: 1px solid var(--accent); border-radius: 6px; padding: 2px 6px; background: var(--surface); color: var(--text); }
.tabsbar .grow { flex: 1; }
.stats { font-size: 12.5px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.stats b { color: var(--text); margin-left: 3px; margin-right: 10px; }

.recover { position: fixed; left: 50%; top: 150px; transform: translateX(-50%); z-index: 40; background: var(--surface); border: 1px solid var(--accent); border-radius: 14px; padding: 12px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; box-shadow: var(--shadow); max-width: 640px; }
.modal { position: fixed; inset: 0; background: rgba(10, 5, 30, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-box { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 22px 24px; width: min(640px, 100%); box-shadow: var(--shadow); max-height: 86vh; overflow: auto; }
.modal-box h2 { margin-bottom: 8px; }
.modal-box label { display: flex; gap: 8px; align-items: center; font-weight: 700; margin: 6px 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.tpls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.tpl { border: 1px solid var(--line); background: var(--surface-2); border-radius: 14px; padding: 14px 10px; text-align: center; }
.tpl:hover { border-color: var(--accent); }
.tpl div { font-size: 30px; } .tpl b { display: block; margin-top: 4px; } .tpl small { color: var(--muted); font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 56px; transform: translateX(-50%) translateY(160px); background: var(--sidebar); color: var(--sidebar-text); padding: 10px 18px; border-radius: 14px; font-weight: 800; transition: transform .25s; z-index: 80; max-width: 80vw; }
.toast.show { transform: translateX(-50%) translateY(0); }
.print-area { display: none; }
@media print {
  @page { margin: 0.5in; }
  body { display: block; overflow: visible; background: #fff; }
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block; font: 10.5pt/1.25 Calibri, 'Segoe UI', Arial, sans-serif; color: #111; }
  .print-area h3 { font: 700 13pt 'Segoe UI', sans-serif; margin: 0 0 6pt; }
  .print-area table { border-collapse: collapse; }
  .print-area td { border: 0.5pt solid #d1d5db; padding: 2pt 5pt; white-space: nowrap; vertical-align: bottom; }
  .print-area td.wrap { white-space: pre-wrap; }
  .print-area .sheet + .sheet { break-before: page; }
}
