/* =====================================================================
   WindowsRC (Really Chill Edition) - shared UI kit
   Used by the shell and by every app (apps include /os/ui.css).
   Themes are CSS variables keyed on <html data-theme="...">.
   ===================================================================== */

:root,
:root[data-theme="chilled"] {
  --face: #c0c0c0;
  --face-light: #dfdfdf;
  --face-hi: #ffffff;
  --face-shadow: #808080;
  --face-dark: #000000;
  --text: #000000;
  --text-disabled: #808080;
  --field: #ffffff;
  --field-text: #000000;
  --hilite: #1565c0;
  --hilite-text: #ffffff;
  --title-a: #1565c0;
  --title-b: #f06aa8;
  --title-text: #ffffff;
  --title-off-a: #808080;
  --title-off-b: #c9b2c0;
  --title-off-text: #dfdfdf;
  --desktop: #3a7bd5;
  --tooltip: #ffffe1;
  --accent: #f06aa8;
  --link: #1565c0;
}
:root[data-theme="blue"] {
  --face: #bccbdc; --face-light: #d9e3ee; --face-hi: #ffffff; --face-shadow: #6c7f95; --face-dark: #0d1b2a;
  --hilite: #0b3d91; --title-a: #0b3d91; --title-b: #3aa0e8;
  --title-off-a: #6c7f95; --title-off-b: #a9bccf; --title-off-text: #e3ebf3;
  --desktop: #2b6cb0; --accent: #3aa0e8; --link: #0b3d91;
}
:root[data-theme="pink"] {
  --face: #e6c8d7; --face-light: #f3e0ea; --face-hi: #fff5fa; --face-shadow: #a6738c; --face-dark: #3d0f25;
  --hilite: #b0185f; --title-a: #8e1450; --title-b: #f48fc4;
  --title-off-a: #a6738c; --title-off-b: #dcb6c9; --title-off-text: #fbeaf2;
  --desktop: #d9579a; --accent: #f06aa8; --link: #b0185f; --tooltip: #fff0f7;
}
:root[data-theme="classic"] {
  --hilite: #000080; --title-a: #000080; --title-b: #1084d0;
  --title-off-a: #808080; --title-off-b: #b5b5b5; --title-off-text: #c0c0c0;
  --desktop: #008080; --accent: #000080; --link: #0000ee;
}
:root[data-theme="hotdog"] {
  /* The legendary WindowsRC 3.1 "Hot Dog Stand". You asked for it. */
  --face: #ffff00; --face-light: #ffff80; --face-hi: #ffffff; --face-shadow: #c00000; --face-dark: #000000;
  --field: #ffff00; --hilite: #000000; --title-a: #ff0000; --title-b: #ff0000;
  --title-off-a: #c00000; --title-off-b: #c00000; --title-off-text: #ffff00;
  --desktop: #ffff00; --accent: #ff0000; --link: #ff0000;
}
:root[data-theme="midnight"] {
  --face: #3a3550; --face-light: #4d4766; --face-hi: #6e6790; --face-shadow: #221f30; --face-dark: #0b0a12;
  --text: #f1ecff; --text-disabled: #8a84a6; --field: #1c1a28; --field-text: #f1ecff;
  --hilite: #f06aa8; --hilite-text: #000000; --title-a: #3aa0e8; --title-b: #b0185f;
  --title-off-a: #221f30; --title-off-b: #4d4766; --title-off-text: #8a84a6;
  --desktop: #120f1f; --tooltip: #2a2640; --accent: #f06aa8; --link: #7fd8ff;
}

:root[data-theme="developer"] {
  /* Secret scheme unlocked with XYZZY: green phosphor terminal. */
  --face: #0c1a0c; --face-light: #163016; --face-hi: #2a5a2a; --face-shadow: #050d05; --face-dark: #000000;
  --text: #39ff14; --text-disabled: #1f7a12; --field: #000000; --field-text: #39ff14;
  --hilite: #39ff14; --hilite-text: #000000; --title-a: #003300; --title-b: #1f7a12;
  --title-off-a: #050d05; --title-off-b: #163016; --title-off-text: #1f7a12;
  --desktop: #000000; --tooltip: #0c1a0c; --accent: #39ff14; --link: #7dff5c;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body.ui, .ui {
  font-family: "Tahoma", "MS Sans Serif", "Microsoft Sans Serif", "Segoe UI", system-ui, sans-serif;
  font-size: 12px;
  color: var(--text);
  background: var(--face);
  -webkit-font-smoothing: none;
  -webkit-tap-highlight-color: transparent;
}

/* Classic bevels -------------------------------------------------------- */
.raised {
  background: var(--face);
  box-shadow: inset -1px -1px var(--face-dark), inset 1px 1px var(--face-hi),
              inset -2px -2px var(--face-shadow), inset 2px 2px var(--face-light);
}
.sunken {
  box-shadow: inset -1px -1px var(--face-hi), inset 1px 1px var(--face-shadow),
              inset -2px -2px var(--face-light), inset 2px 2px var(--face-dark);
}
.sunken-thin { box-shadow: inset -1px -1px var(--face-hi), inset 1px 1px var(--face-shadow); }
.raised-thin { box-shadow: inset -1px -1px var(--face-shadow), inset 1px 1px var(--face-hi); }

/* Buttons ---------------------------------------------------------------- */
.btn, button.btn {
  font: inherit;
  color: var(--text);
  background: var(--face);
  border: none;
  border-radius: 0;
  min-width: 75px;
  min-height: 23px;
  padding: 3px 12px;
  box-shadow: inset -1px -1px var(--face-dark), inset 1px 1px var(--face-hi),
              inset -2px -2px var(--face-shadow), inset 2px 2px var(--face-light);
  cursor: default;
  touch-action: manipulation;
}
.btn:active:not(:disabled), .btn.pressed {
  box-shadow: inset -1px -1px var(--face-hi), inset 1px 1px var(--face-dark),
              inset -2px -2px var(--face-light), inset 2px 2px var(--face-shadow);
  padding: 4px 11px 2px 13px;
}
.btn:focus-visible { outline: 1px dotted var(--text); outline-offset: -5px; }
.btn.default { box-shadow: inset 0 0 0 1px var(--face-dark), inset -2px -2px var(--face-dark), inset 2px 2px var(--face-hi), inset -3px -3px var(--face-shadow), inset 3px 3px var(--face-light); }
.btn:disabled { color: var(--text-disabled); text-shadow: 1px 1px var(--face-hi); }
.btn.small { min-width: 0; min-height: 0; padding: 1px 6px; }
.btn.icon-btn { min-width: 0; padding: 2px; display: inline-grid; place-items: center; }
.btn img { image-rendering: pixelated; vertical-align: middle; }

/* Toolbar buttons are flat until hovered */
.tool {
  font: inherit; color: var(--text); background: transparent; border: none; border-radius: 0;
  padding: 3px 5px; min-width: 24px; min-height: 22px; display: inline-flex; align-items: center; gap: 4px;
  cursor: default; touch-action: manipulation;
}
.tool:hover:not(:disabled) { box-shadow: inset -1px -1px var(--face-shadow), inset 1px 1px var(--face-hi); }
.tool:active:not(:disabled), .tool.active { box-shadow: inset -1px -1px var(--face-hi), inset 1px 1px var(--face-shadow); }
.tool.active { background: repeating-conic-gradient(var(--face-hi) 0 25%, var(--face) 0 50%) 0 0 / 2px 2px; }
.tool:disabled { color: var(--text-disabled); opacity: .6; }
.tool img { width: 16px; height: 16px; image-rendering: pixelated; }
.toolbar { display: flex; align-items: center; gap: 1px; padding: 2px; flex-wrap: wrap; }
.toolbar .sep { width: 2px; align-self: stretch; margin: 2px 3px; box-shadow: inset 1px 0 var(--face-shadow), inset -1px 0 var(--face-hi); }

/* Inputs ----------------------------------------------------------------- */
.field, input.field, textarea.field, select.field {
  font: inherit;
  color: var(--field-text);
  background: var(--field);
  border: none;
  border-radius: 0;
  padding: 3px 4px;
  min-height: 21px;
  box-shadow: inset -1px -1px var(--face-hi), inset 1px 1px var(--face-shadow),
              inset -2px -2px var(--face-light), inset 2px 2px var(--face-dark);
  outline: none;
}
textarea.field { resize: none; }
.field:disabled { background: var(--face); color: var(--text-disabled); }
select.field { appearance: none; -webkit-appearance: none; padding-right: 20px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text) 50%), linear-gradient(135deg, var(--text) 50%, transparent 50%);
  background-position: calc(100% - 9px) 50%, calc(100% - 5px) 50%; background-size: 4px 4px; background-repeat: no-repeat; }

label.check, label.radio { display: inline-flex; align-items: center; gap: 6px; cursor: default; }
label.check input, label.radio input { accent-color: var(--hilite); margin: 0; }

input[type="range"].slider { accent-color: var(--hilite); }

/* Group box --------------------------------------------------------------- */
/* A real border (not a box-shadow), so the legend cuts the etched line like WindowsRC 98 does. */
fieldset.group {
  margin: 8px 0; padding: 6px 10px 10px; min-width: 0;
  border: 1px solid var(--face-shadow);
  box-shadow: 1px 1px 0 var(--face-hi), inset 1px 1px 0 var(--face-hi);
}
fieldset.group > legend { padding: 0 3px; margin-left: -2px; }

/* Mouse pointer schemes (Control Panel > Mouse > Pointers). Applied on <html> by the shell and sdk.js. */
html.cur-paw, html.cur-paw * { cursor: url("/assets/cursors/paw.svg") 6 3, auto !important; }
html.cur-pawxl, html.cur-pawxl * { cursor: url("/assets/cursors/paw-xl.svg") 9 5, auto !important; }
html.cur-paw input:not([type=checkbox]):not([type=radio]):not([type=range]), html.cur-paw textarea,
html.cur-pawxl input:not([type=checkbox]):not([type=radio]):not([type=range]), html.cur-pawxl textarea { cursor: text !important; }

/* Window-ish surfaces ----------------------------------------------------- */
.panel { padding: 8px; }
.inset-box { background: var(--field); color: var(--field-text); overflow: auto;
  box-shadow: inset -1px -1px var(--face-hi), inset 1px 1px var(--face-shadow), inset -2px -2px var(--face-light), inset 2px 2px var(--face-dark); }

.statusbar { display: flex; gap: 2px; padding: 2px; }
.statusbar > * { flex: 1; padding: 2px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: inset -1px -1px var(--face-hi), inset 1px 1px var(--face-shadow); }
.statusbar > .fit { flex: 0 0 auto; }

/* Menu bar + dropdown menus (also used by OS.menubar in sdk.js) ----------- */
.menubar { display: flex; padding: 1px 2px; gap: 0; user-select: none; flex-wrap: wrap; }
.menubar > .mb-item { padding: 3px 7px; cursor: default; }
.menubar > .mb-item.open { box-shadow: inset -1px -1px var(--face-hi), inset 1px 1px var(--face-shadow); }
.menubar > .mb-item:hover:not(.open) { box-shadow: inset -1px -1px var(--face-shadow), inset 1px 1px var(--face-hi); }

.menu {
  position: fixed; z-index: 100000; min-width: 160px; padding: 2px; user-select: none;
  background: var(--face); color: var(--text);
  box-shadow: inset -1px -1px var(--face-dark), inset 1px 1px var(--face-light),
              inset -2px -2px var(--face-shadow), inset 2px 2px var(--face-hi), 2px 2px 0 rgba(0,0,0,.25);
}
.menu .mi { display: flex; align-items: center; gap: 6px; padding: 3px 18px 3px 4px; white-space: nowrap; cursor: default; position: relative; min-height: 20px; }
.menu .mi .mi-icon { width: 16px; height: 16px; flex: none; display: grid; place-items: center; image-rendering: pixelated; }
.menu .mi .mi-label { flex: 1; }
.menu .mi .mi-key { margin-left: 24px; }
.menu .mi.has-sub::after { content: ""; position: absolute; right: 6px; top: 50%; margin-top: -4px;
  border: 4px solid transparent; border-left-color: currentColor; border-right: 0; }
.menu .mi:hover:not(.disabled), .menu .mi.active { background: var(--hilite); color: var(--hilite-text); }
.menu .mi.disabled { color: var(--text-disabled); text-shadow: 1px 1px var(--face-hi); }
.menu .mi.disabled:hover { background: transparent; }
.menu .mi.checked .mi-icon::before { content: "✔"; font-size: 11px; }
.menu .mi.bold .mi-label { font-weight: bold; }
.menu .msep { height: 2px; margin: 3px 1px; box-shadow: inset 0 1px var(--face-shadow), inset 0 -1px var(--face-hi); }
.menu u, .menubar u { text-decoration: underline; }

/* Tabs --------------------------------------------------------------------- */
.tabs { display: flex; gap: 0; padding: 0 4px; position: relative; z-index: 1; flex-wrap: wrap; }
.tabs .tab { padding: 3px 10px 4px; margin-top: 2px; background: var(--face); cursor: default;
  box-shadow: inset 1px 1px var(--face-hi), inset -1px 0 var(--face-dark), inset -2px 0 var(--face-shadow); border-radius: 3px 3px 0 0; }
.tabs .tab.active { margin-top: 0; padding-bottom: 6px; margin-bottom: -2px; position: relative; z-index: 2; }
.tab-body { padding: 10px; box-shadow: inset -1px -1px var(--face-dark), inset 1px 1px var(--face-hi), inset -2px -2px var(--face-shadow); }

/* List view --------------------------------------------------------------- */
.listview { background: var(--field); color: var(--field-text); overflow: auto; user-select: none; }
.listview .row { display: flex; align-items: center; gap: 6px; padding: 1px 4px; white-space: nowrap; cursor: default; }
.listview .row img { width: 16px; height: 16px; image-rendering: pixelated; }
.listview .row.selected { background: var(--hilite); color: var(--hilite-text); }
.listview .row:focus-visible { outline: 1px dotted currentColor; outline-offset: -1px; }

/* Big icon grid (Explorer "Large Icons", desktop) */
.icon-grid { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 4px; padding: 6px; }
.icon-cell { width: 76px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 3px 2px; text-align: center; cursor: default; user-select: none; }
.icon-cell img { width: 32px; height: 32px; image-rendering: pixelated; }
.icon-cell span { padding: 0 2px; word-break: break-word; line-height: 1.2; }
.icon-cell.selected img { filter: drop-shadow(0 0 0 var(--hilite)) brightness(.7) sepia(1) hue-rotate(180deg) saturate(3); }
.icon-cell.selected span { background: var(--hilite); color: var(--hilite-text); }

/* Progress bar (segmented like 98) ---------------------------------------- */
.progress { height: 18px; padding: 2px; background: var(--face);
  box-shadow: inset -1px -1px var(--face-hi), inset 1px 1px var(--face-shadow); }
.progress > i { display: block; height: 100%; width: 0;
  background: repeating-linear-gradient(90deg, var(--hilite) 0 9px, transparent 9px 11px); transition: width .2s; }

/* Scrollbars -------------------------------------------------------------- */
.ui ::-webkit-scrollbar, body.ui::-webkit-scrollbar { width: 16px; height: 16px; }
.ui ::-webkit-scrollbar-track, body.ui::-webkit-scrollbar-track {
  background: repeating-conic-gradient(var(--face) 0 25%, var(--face-hi) 0 50%) 0 0 / 2px 2px; }
.ui ::-webkit-scrollbar-thumb, body.ui::-webkit-scrollbar-thumb { background: var(--face);
  box-shadow: inset -1px -1px var(--face-dark), inset 1px 1px var(--face-light), inset -2px -2px var(--face-shadow), inset 2px 2px var(--face-hi); }
.ui ::-webkit-scrollbar-corner, body.ui::-webkit-scrollbar-corner { background: var(--face); }
.ui ::-webkit-scrollbar-button:single-button, body.ui::-webkit-scrollbar-button:single-button {
  background-color: var(--face); display: block; height: 16px; width: 16px; background-repeat: no-repeat; background-position: center;
  box-shadow: inset -1px -1px var(--face-dark), inset 1px 1px var(--face-light), inset -2px -2px var(--face-shadow), inset 2px 2px var(--face-hi); }
.ui ::-webkit-scrollbar-button:single-button:vertical:decrement { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='4'%3E%3Cpath d='M3 0h1v1h1v1h1v1h1v1H0V3h1V2h1V1h1z'/%3E%3C/svg%3E"); }
.ui ::-webkit-scrollbar-button:single-button:vertical:increment { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='4'%3E%3Cpath d='M0 0h7v1H6v1H5v1H4v1H3V3H2V2H1V1H0z'/%3E%3C/svg%3E"); }
.ui ::-webkit-scrollbar-button:single-button:horizontal:decrement { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='7'%3E%3Cpath d='M3 0h1v7H3V6H2V5H1V4H0V3h1V2h1V1h1z'/%3E%3C/svg%3E"); }
.ui ::-webkit-scrollbar-button:single-button:horizontal:increment { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='7'%3E%3Cpath d='M0 0h1v1h1v1h1v1h1v1H3v1H2v1H1v1H0z'/%3E%3C/svg%3E"); }
.ui { scrollbar-color: var(--face-shadow) var(--face-light); }

/* Helpers ------------------------------------------------------------------ */
.row-flex { display: flex; gap: 6px; align-items: center; }
.col-flex { display: flex; flex-direction: column; gap: 6px; }
.grow { flex: 1; min-width: 0; min-height: 0; }
.right { margin-left: auto; }
.pixel { image-rendering: pixelated; }
.hidden { display: none !important; }
.mono { font-family: "Fixedsys", "Lucida Console", "Courier New", monospace; }
a.link { color: var(--link); }

/* Bigger touch targets on phones */
@media (pointer: coarse) {
  .btn { min-height: 32px; }
  .menu .mi { min-height: 34px; font-size: 14px; }
  .menubar > .mb-item { padding: 6px 10px; font-size: 13px; }
  .tool { min-width: 34px; min-height: 34px; }
  .field { min-height: 30px; font-size: 16px; } /* 16px stops iOS zooming on focus */
}
