:root { --taskbar-h: 30px; }

/* ─── Win98 tooltip ──────────────────────────────────────────────────────── */
.win98-tooltip {
  display: none;
  position: fixed;
  z-index: 99999;
  overflow: hidden; /* clip container — same pattern as .dropdown */
  pointer-events: none;
}
.win98-tooltip-inner {
  background: #ffffe1;
  border: 1px solid #000;
  padding: 2px 4px;
  font-size: 11px;
  font-family: 'Pixelated MS Sans Serif', sans-serif;
  color: #000;
  white-space: nowrap;
}
.win98-tooltip-inner.animate-open {
  animation: slide-down 100ms steps(8, end) both;
}

/* Disable smooth scrolling globally — Windows 98 rule: all scrolling must be instant */
html { scroll-behavior: auto; }
* { scroll-behavior: auto !important; }

/* Fix duplicate scrollbar arrows — hide the wrong sub-buttons at each end */
::-webkit-scrollbar-button:vertical:start:increment,
::-webkit-scrollbar-button:vertical:end:decrement,
::-webkit-scrollbar-button:horizontal:start:increment,
::-webkit-scrollbar-button:horizontal:end:decrement { display: none !important; }

body { margin: 0; padding: 0; overflow: hidden; height: 100vh; background: teal; font-family: 'Pixelated MS Sans Serif', sans-serif; }
#viewport { position: relative; width: 100%; height: calc(100% - var(--taskbar-h)); overflow: hidden; }
#viewport > .window { position: absolute; visibility: hidden; box-sizing: border-box; }

/* ─── Desktop ─────────────────────────────────────────────────────────────── */
#desktop {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px; padding: 10px;
  z-index: 0;
  pointer-events: auto;
}
.desktop-icon {
  display: flex; flex-direction: column; align-items: center;
  width: 72px; gap: 4px;
  padding: 4px;
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
}
.desktop-icon.selected .desktop-icon-img  { outline: 1px dotted #fff; background: navy; }
.desktop-icon.selected .desktop-icon-label { background: navy; color: #fff; outline: 1px dotted #fff; outline-offset: -1px; }
.desktop-icon-img {
  width: 32px; height: 32px;
  background: silver;
  box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #fff,
              inset -2px -2px grey,   inset 2px 2px #dfdfdf;
  flex-shrink: 0;
}
.desktop-icon-label {
  font-size: 11px; color: #fff; text-align: center;
  text-shadow: 1px 1px #000;
  word-break: break-word; line-height: 1.2;
  max-width: 72px;
}
/* Override min-width for minimized windows so the animate can shrink them */
.window.minimized { min-width: 0 !important; min-height: 0 !important; }
/* Minimized title text ellipsis */
.minimized .title-bar-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100px; }

/* ─── Taskbar ─────────────────────────────────────────────────────────────── */
#taskbar {
  position: fixed; bottom: 0; left: 0; width: 100%;
  height: var(--taskbar-h); z-index: 10000;
  background: silver;
  border-top: 1px solid #dfdfdf;
  box-shadow: inset 0 1px #fff;
  display: flex; align-items: center; gap: 2px;
  padding: 2px 2px; box-sizing: border-box;
}
#start-btn {
  display: inline-flex; align-items: center; gap: 2px;
  height: 22px; padding: 0 4px; font-weight: bold;
  white-space: nowrap; flex-shrink: 0; min-width: 0;
}
/* Replaceable start icon — swap --start-icon-url to change the image */
:root { --start-icon-url: url('img/start-icon.png'); }
.start-icon {
  display: inline-block; width: 14px; height: 14px;
  flex-shrink: 0;
  background: var(--start-icon-url) center/contain no-repeat;
}
#taskbar-sep {
  width: 1px; height: 18px; flex-shrink: 0;
  box-shadow: inset -1px 0 #808080, inset 1px 0 #fff;
  margin: 0 2px;
}
#taskbar-tasks { flex: 1; display: flex; align-items: center; gap: 2px; overflow: hidden; }

/* Window buttons in the taskbar tasks area */
.taskbar-task-btn {
  height: 22px; width: 160px;
  padding: 0 6px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  text-align: left; font-size: 11px;
  font-family: 'Pixelated MS Sans Serif', sans-serif;
}
/* Pressed/active state while window is focused */
.taskbar-task-btn[aria-pressed="true"] {
  font-weight: bold;
  box-shadow: inset -1px -1px #fff, inset 1px 1px #0a0a0a,
              inset -2px -2px #dfdfdf, inset 2px 2px grey;
}
#taskbar-tray {
  display: flex; align-items: stretch;
  height: calc(var(--taskbar-h) - 4px);
}
#taskbar-clock {
  display: flex; align-items: center; padding: 0 8px;
  font-size: 11px; white-space: nowrap;
  font-family: 'Pixelated MS Sans Serif', sans-serif;
  box-shadow: inset -1px -1px #fff, inset 1px 1px #808080;
}

/* ─── WM windows ──────────────────────────────────────────────────────────── */.title-bar { cursor: default; -webkit-user-select: none; user-select: none; }.wm-resize-handle { position: absolute; z-index: 1; }
.wm-resize-handle[data-dir="n"]  { top: 0;    left: 8px;    right: 8px;   height: 4px; cursor: n-resize;  }
.wm-resize-handle[data-dir="s"]  { bottom: 0; left: 8px;    right: 8px;   height: 4px; cursor: s-resize;  }
.wm-resize-handle[data-dir="e"]  { top: 8px;  bottom: 8px;  right: 0;     width:  4px; cursor: e-resize;  }
.wm-resize-handle[data-dir="w"]  { top: 8px;  bottom: 8px;  left: 0;      width:  4px; cursor: w-resize;  }
.wm-resize-handle[data-dir="ne"] { top: 0;    right: 0;     width: 8px;   height: 8px; cursor: ne-resize; }
.wm-resize-handle[data-dir="nw"] { top: 0;    left: 0;      width: 8px;   height: 8px; cursor: nw-resize; }
.wm-resize-handle[data-dir="se"] { bottom: 0; right: 0;     width: 8px;   height: 8px; cursor: se-resize; }
.wm-resize-handle[data-dir="sw"] { bottom: 0; left: 0;      width: 8px;   height: 8px; cursor: sw-resize; }
/* Strip window chrome during WM animations — only title bar remains visible */
.wm-transitioning {
  background: transparent !important;
  box-shadow: none !important;
}

/* Notepad window: flex column so window-body fills remaining height */
#win-notepad { display: flex; flex-direction: column; }
#win-notepad > .window-body { flex: 1; min-height: 0; overflow: hidden; }
.field-row { margin-bottom: 6px; }

/* ─── Menu bar ────────────────────────────────────────────────────────────── */
.menu-bar { display: flex; background: silver; padding: 2px 0; border-bottom: 1px solid grey; position: relative; }
.menu-item { position: relative; }
.menu-item > button {
  background: none; border: none; box-shadow: none; min-width: unset;
  padding: 2px 6px; font-size: 11px; cursor: default;
}
.menu-item > button:focus { outline: none; }
.menu-item.open > button {
  background: navy; color: #fff;
  box-shadow: none;
}
/* Dropdown: .dropdown = cutout (overflow:hidden), .dropdown-inner = sliding card */
@keyframes slide-down {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0); }
}
.dropdown {
  display: none; position: absolute; top: 100%; left: 0;
  z-index: 100; min-width: 140px;
  overflow: hidden; /* clipping vessel only — no background here */
}
.menu-item.open > .dropdown { display: block; }
.dropdown-inner {
  padding: 2px 0;
  background: silver;
  box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #fff,
              inset -2px -2px grey, inset 2px 2px #dfdfdf;
}
.menu-item.open > .dropdown > .dropdown-inner {
  animation: slide-down 100ms steps(8, end) both;
  /* 'both' fill-mode: applies 'from' before first tick → card hidden before animation starts */
}
.menu-item.open > .dropdown > .dropdown-inner.animate-open {
  animation: slide-down 100ms steps(8, end) both;
}
.menu-item.open > .dropdown > .dropdown-inner:not(.animate-open) {
  animation: none;
}
.dropdown-item {
  display: block; width: calc(100% - 4px); margin: 0 2px;
  box-sizing: border-box; text-align: left;
  background: none; border: none; box-shadow: none;
  min-width: unset; padding: 3px 18px;
  font-size: 11px; cursor: default;
}
.dropdown-item:hover { background: navy; color: #fff; box-shadow: none; }
.dropdown-item:disabled { color: grey; }
.dropdown-separator { border: none; border-top: 1px solid grey; margin: 3px 4px; }

/* Unit input row: number input + unit select side by side */
.unit-input-row { display: flex; gap: 2px; align-items: center; }
/* 98.css .field-row-stacked *+* adds margin-top to every adjacent sibling, including
   the select next to the input — reset it so they stay on the same baseline */
.unit-input-row * + * { margin-top: 0; }
/* line-height:2 from 98.css inflates input[type=number] beyond its height:22px — reset it */
.unit-input-row input  { flex: 1; min-width: 0; line-height: normal; height: 22px; }
.unit-input-row select { flex: 0 0 auto; width: 70px; height: 22px; }
/* Override 98.css navy focus highlight — Win98 selects don't invert the box itself */
.unit-input-row select:focus        { background-color: #fff; color: #222; }
.unit-input-row select:focus option { background-color: #fff; color: #222; }
/* Pressed appearance while dropdown is open (select retains :focus while open) */
.unit-input-row select:focus {
  box-shadow: inset -1px -1px #fff, inset 1px 1px #0a0a0a,
              inset -2px -2px #dfdfdf, inset 2px 2px grey;
}

/* ─── Toolbar ─────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: 2px;
  background: silver; padding: 2px 4px;
  border-bottom: 1px solid grey;
}
.toolbar button { min-width: unset; padding: 2px 8px; font-size: 11px; }
.toolbar-separator { width: 1px; height: 22px; background: grey; margin: 0 4px; box-shadow: 1px 0 #fff; }

/* ─── Panel layout ────────────────────────────────────────────────────────── */
#panel-layout {
  --left-width: 260px;
  --bottom-height: 80px;
  display: flex; flex-direction: column;
  height: 100%;
}
#panel-top-row {
  display: flex; flex: 1; min-height: 40px; overflow: hidden;
}
#panel-left {
  flex: 0 0 var(--left-width); min-width: 120px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: inset -1px -1px #fff, inset 1px 1px grey,
              inset -2px -2px #dfdfdf, inset 2px 2px #0a0a0a;
  background: #fff;
}
#panel-right {
  flex: 1; min-width: 100px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: inset -1px -1px #fff, inset 1px 1px grey,
              inset -2px -2px #dfdfdf, inset 2px 2px #0a0a0a;
  background: #fff;
}
#panel-bottom {
  flex: 0 0 var(--bottom-height); min-height: 40px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: inset -1px -1px #fff, inset 1px 1px grey,
              inset -2px -2px #dfdfdf, inset 2px 2px #0a0a0a;
  background: #fff;
}
/* Inner scroll area — margin: 2px reserves bevel pixels so content never overlaps shadow */
.panel-content {
  flex: 1; overflow: auto; padding: 6px;
  margin: 2px;
  box-sizing: border-box;
}
#results-scroll {
  flex: 1; overflow: auto;
  margin: 0 2px 2px 2px;
}
/* Splitters */
.splitter-v {
  flex: 0 0 4px; cursor: col-resize;
  background: silver;
  box-shadow: inset -1px 0 #0a0a0a, inset 1px 0 #fff;
}
.splitter-h {
  flex: 0 0 4px; cursor: row-resize;
  background: silver;
  box-shadow: inset 0 -1px #0a0a0a, inset 0 1px #fff;
}
.splitter-v:hover, .splitter-h:hover { background: #b0b0b0; }
/* Status bar fields */
#sb-hover { flex-grow: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sb-time  { flex: 0 0 90px; text-align: center; }
#sb-status { flex: 0 0 100px; text-align: center; }

/* Canvas inside geometry panel */
#canvas-container { flex: 1; overflow: hidden; margin: 2px; }
#canvas-container canvas { display: block; }
/* Results panel heading */
#results-heading {
  flex: 0 0 auto; margin: 2px 2px 0 2px; padding: 1px 6px;
  font-size: 11px; font-weight: bold; border-bottom: 1px solid grey;
}

/* ─── Excel 97 results grid ───────────────────────────────────────────────── */
#results-grid { display: inline-block; min-width: 100%; }
#eg-table { border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 11px; font-family: inherit; }
#eg-table thead { position: sticky; top: 0; z-index: 2; }
.eg-corner, .eg-col-hdr {
  background: #d4d0c8; border: 1px solid #808080; border-top: none; border-left: none;
  text-align: center; padding: 1px 4px;
  box-shadow: inset -1px -1px #808080, inset 1px 1px #fff;
  -webkit-user-select: none; user-select: none; white-space: nowrap; overflow: hidden;
}
.eg-corner { position: sticky; left: 0; z-index: 3; min-width: 30px; border-left: 1px solid #808080; }
.eg-col-hdr { position: relative; }
#eg-table thead tr th:first-child { border-top: 1px solid #808080; }
#eg-table thead tr th { border-top: 1px solid #808080; }
.eg-row-hdr {
  background: #d4d0c8; border: 1px solid #808080; border-top: none; border-left: 1px solid #808080;
  text-align: center; padding: 1px 4px;
  box-shadow: inset -1px -1px #808080, inset 1px 1px #fff;
  position: sticky; left: 0; z-index: 1;
  -webkit-user-select: none; user-select: none; white-space: nowrap;
}
#eg-table tbody tr:first-child .eg-row-hdr,
#eg-table tbody tr:first-child td { border-top: 1px solid #d0d0d0; }
#eg-table tbody td { border: 1px solid #d0d0d0; border-top: none; border-left: none; padding: 1px 4px; background: #fff; white-space: nowrap; }
#eg-table tbody td:first-child + td { border-left: 1px solid #d0d0d0; }
.eg-col-resize {
  position: absolute; right: -2px; top: 0; bottom: 0; width: 5px;
  cursor: col-resize; z-index: 1;
}
