/* =========================================================
   SaigonScience 98 — hệ thống giao diện kiểu Windows 98
   (primitives: tokens, window, title bar, button, field,
    menu, progress, scrollbar, dialog)
   ========================================================= */

:root {
  --face: #c0c0c0;
  --face-light: #dfdfdf;
  --hilite: #ffffff;
  --shadow: #808080;
  --dark: #0a0a0a;
  --navy: #000080;
  --blue: #1084d0;
  --teal: #008080;
  --tooltip: #ffffe1;
  --text: #000;
  --muted: #505050;

  --font-ui: "Be Vietnam Pro", Tahoma, "Segoe UI", system-ui, sans-serif;
  --font-pixel: "VT323", "Lucida Console", monospace;
  --font-mono: "IBM Plex Mono", Consolas, "Courier New", monospace;

  --raised: inset -1px -1px var(--dark), inset 1px 1px var(--hilite),
            inset -2px -2px var(--shadow), inset 2px 2px var(--face-light);
  --pressed: inset -1px -1px var(--hilite), inset 1px 1px var(--dark),
             inset -2px -2px var(--face-light), inset 2px 2px var(--shadow);
  --sunken: inset -1px -1px var(--hilite), inset 1px 1px var(--shadow),
            inset -2px -2px var(--face-light), inset 2px 2px var(--dark);
  --window-edge: inset -1px -1px var(--dark), inset 1px 1px var(--face-light),
                 inset -2px -2px var(--shadow), inset 2px 2px var(--hilite);
  --thin-sunken: inset -1px -1px var(--hilite), inset 1px 1px var(--shadow);
  --default-btn: inset -2px -2px var(--dark), inset 1px 1px var(--dark),
                 inset 2px 2px var(--hilite), inset -3px -3px var(--shadow),
                 inset 3px 3px var(--face-light);

  --dither: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='2' shape-rendering='crispEdges'%3E%3Crect width='2' height='2' fill='%23c0c0c0'/%3E%3Crect width='1' height='1' fill='%23fff'/%3E%3Crect x='1' y='1' width='1' height='1' fill='%23fff'/%3E%3C/svg%3E");
}

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--teal);
  color: var(--text);
  font: 400 14px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

::selection { background: var(--navy); color: #fff; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--navy); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Window ---------- */
.window {
  background: var(--face);
  box-shadow: var(--window-edge);
  padding: 3px;
}

/* ---------- Title bar ---------- */
.title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 26px;
  padding: 2px 3px 2px 6px;
  background: linear-gradient(90deg, var(--navy), var(--blue));
  color: #fff;
  user-select: none;
}
.title-bar__text {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font: 400 20px/1 var(--font-pixel);
  letter-spacing: .3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.title-bar__text > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.title-bar__controls { display: flex; gap: 2px; flex: none; }
.title-bar__controls .tb-btn:last-child { margin-left: 2px; }

.tb-btn {
  width: 20px; height: 18px;
  padding: 0; border: 0;
  background: var(--face);
  box-shadow: var(--raised);
  display: grid; place-items: center;
  color: #000;
}
.tb-btn:active { box-shadow: var(--pressed); }
.tb-btn:active > span { transform: translate(1px, 1px); }
.tb-btn:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }

.ico-min, .ico-max, .ico-close, .ico-restore { display: block; position: relative; }
.ico-min { width: 8px; height: 2px; background: #000; margin-top: 7px; }
.ico-max { width: 10px; height: 9px; border: 1px solid #000; border-top-width: 2px; }
.is-windowed .ico-max { width: 7px; height: 6px; margin: 3px 0 0 -3px; }
.is-windowed .ico-max::before {
  content: ""; position: absolute; width: 7px; height: 6px;
  border: 1px solid #000; border-top-width: 2px;
  top: -5px; left: 2px; background: var(--face);
  box-shadow: none;
}
.ico-close {
  width: 10px; height: 9px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='9' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h2v1h1v1h1v1h2V2h1V1h1V0h2v1H9v1H8v1H7v1H6v1h1v1h1v1h1v1h1v1H8V8H7V7H6V6H4v1H3v1H2v1H0V8h1V7h1V6h1V5h1V4H3V3H2V2H1V1H0z'/%3E%3C/svg%3E") no-repeat center;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 12px;
  border: 0;
  background: var(--face);
  box-shadow: var(--raised);
  color: #000;
  font: 500 13px/1.2 var(--font-ui);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}
.btn:active, .btn.is-pressed {
  box-shadow: var(--pressed);
  padding: 5px 11px 3px 13px;
}
.btn:focus-visible { outline: 1px dotted #000; outline-offset: -5px; }
.btn--default { box-shadow: var(--default-btn); font-weight: 700; }
.btn--default:active { box-shadow: var(--pressed), 0 0 0 1px var(--dark); }
.btn[disabled] { color: var(--shadow); text-shadow: 1px 1px 0 #fff; cursor: default; }

/* ---------- Fields ---------- */
.field {
  background: #fff;
  box-shadow: var(--sunken);
  padding: 2px;
}
.field input {
  border: 0; outline: 0; background: transparent;
  width: 100%;
  font-size: 14px;
}

/* ---------- Menus ---------- */
.menu { position: relative; }
.menu__label {
  border: 0; background: transparent;
  padding: 2px 8px; min-height: 24px;
  font-size: 13px;
}
.menu__label:hover, .menu__label[aria-expanded="true"] {
  background: var(--navy); color: #fff;
}
.menu__list {
  position: absolute; top: 100%; left: 0;
  z-index: 60;
  min-width: 220px;
  display: none;
  flex-direction: column;
  padding: 3px;
}
.menu__label[aria-expanded="true"] + .menu__list { display: flex; }
.menu__list button, .menu__list a {
  display: flex; justify-content: space-between; gap: 16px;
  border: 0; background: transparent; text-align: left;
  padding: 5px 20px 5px 24px;
  font-size: 13px; color: #000; text-decoration: none;
  cursor: pointer;
}
.menu__list button:hover, .menu__list a:hover,
.menu__list button:focus-visible, .menu__list a:focus-visible {
  background: var(--navy); color: #fff; outline: 0;
}
.menu__list hr, .start-menu hr {
  border: 0; height: 2px; margin: 3px 2px;
  box-shadow: inset 0 1px var(--shadow), inset 0 -1px var(--hilite);
}
.menu__hint { color: var(--muted); }
.menu__list button:hover .menu__hint { color: #fff; }

/* ---------- Progress ---------- */
.progress {
  height: 20px;
  padding: 3px;
  background: #fff;
  box-shadow: var(--sunken);
}
.progress__bar {
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(90deg, var(--navy) 0 9px, transparent 9px 11px);
  transition: width .4s steps(8);
}

/* ---------- Status bar ---------- */
.status-bar { display: flex; gap: 2px; margin-top: 2px; }
.status-bar__field {
  margin: 0;
  padding: 2px 8px;
  box-shadow: var(--thin-sunken);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-bar__grow { flex: 1; }

/* ---------- Scrollbars (Chromium / Safari) ---------- */
::-webkit-scrollbar { width: 16px; height: 16px; }
::-webkit-scrollbar-track { background: var(--dither); }
::-webkit-scrollbar-thumb { background: var(--face); box-shadow: var(--raised); }
::-webkit-scrollbar-corner { background: var(--face); }
::-webkit-scrollbar-button:single-button {
  display: block; width: 16px; height: 16px;
  background-color: var(--face);
  background-repeat: no-repeat;
  background-position: center;
  box-shadow: var(--raised);
}
::-webkit-scrollbar-button:single-button:active { box-shadow: var(--pressed); }
::-webkit-scrollbar-button:vertical:decrement {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' shape-rendering='crispEdges'%3E%3Cpath d='M7 5h1v1h1v1h1v1h1v1H4V8h1V7h1V6h1z'/%3E%3C/svg%3E");
}
::-webkit-scrollbar-button:vertical:increment {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' shape-rendering='crispEdges'%3E%3Cpath d='M4 6h7v1h-1v1H9v1H8v1H7V9H6V8H5V7H4z'/%3E%3C/svg%3E");
}
::-webkit-scrollbar-button:horizontal:decrement {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' shape-rendering='crispEdges'%3E%3Cpath d='M9 4h1v7H9v-1H8V9H7V8H6V7h1V6h1V5h1z'/%3E%3C/svg%3E");
}
::-webkit-scrollbar-button:horizontal:increment {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' shape-rendering='crispEdges'%3E%3Cpath d='M6 4h1v1h1v1h1v1h1v1H9v1H8v1H7v1H6z'/%3E%3C/svg%3E");
}
@supports (-moz-appearance: none) {
  * { scrollbar-color: var(--face) var(--face-light); }
}

/* ---------- Dialog ---------- */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, .18);
}
.modal[hidden] { display: none; }
.dialog {
  width: min(440px, 100%);
  animation: pop-in .16s steps(4) both;
}
.dialog__body {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 18px 16px 10px;
}
.dialog__icon { flex: none; font-size: 32px; line-height: 1; }
.dialog__text { font-size: 14px; }
.dialog__text p { margin: 0 0 8px; }
.dialog__text ul { margin: 0 0 8px; padding-left: 18px; }
.dialog__actions {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 8px;
  padding: 6px 12px 12px;
}
.dialog__actions .btn { min-width: 88px; }

@keyframes pop-in {
  from { transform: scale(.92); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
