:root {
  color-scheme: dark;
  --ink: #d7e3dd;
  --muted: #8fa39d;
  --paper: #18272c;
  --panel: #1e3035;
  --panel-strong: #263b40;
  --line: #4d696a;
  --signal: #d5b66c;
  --signal-soft: #76653f;
  --danger: #c87969;
  --shadow: rgba(3, 9, 11, 0.6);
  --taskbar-height: 48px;
  font-family: "Lucida Console", "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }

body {
  background: #0c1518;
  color: var(--ink);
  font-size: 14px;
}

button, input, textarea { font: inherit; }
button { color: inherit; }

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(rgba(20, 38, 42, .9), rgba(8, 17, 20, .97)),
    repeating-linear-gradient(0deg, transparent 0 35px, rgba(143, 175, 166, .08) 36px);
}
.login-gate[hidden] { display: none; }
.login-gate-card { width: min(460px, 100%); padding: 34px; border: 1px solid #607a77; background: #142327; box-shadow: 16px 22px 50px rgba(0,0,0,.55); }
.login-gate-card .boot-mark { margin-bottom: 12px; }
.login-gate-card h1 { color: var(--signal); font-size: 22px; letter-spacing: .08em; }
.login-gate-card input[name="username"], #login-gate-username { text-transform: uppercase; }

.boot-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  background: #111d21;
  letter-spacing: 0.08em;
}

.boot-screen small { color: var(--muted); }
.boot-mark { color: var(--signal); font-size: 56px; font-weight: 800; letter-spacing: -0.14em; }
.boot-mark { font-size: clamp(28px, 5vw, 56px); letter-spacing: .04em; }

.desktop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 72% 28%, rgba(79, 111, 108, 0.2), transparent 35%),
    linear-gradient(145deg, #1b3034 0%, #132328 54%, #0f1d21 100%);
}

.desktop::before {
  content: "KT SYSTEMS / AUTHORIZED PERSONNEL";
  position: absolute;
  right: 4vw;
  bottom: 11vh;
  color: rgba(192, 215, 207, 0.07);
  font-size: clamp(16px, 2.1vw, 32px);
  letter-spacing: 0.18em;
  transform: rotate(-90deg) translateX(100%);
  transform-origin: right bottom;
}

.desktop-grid {
  position: absolute;
  inset: 0;
  opacity: 0.18;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(131, 165, 157, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(131, 165, 157, 0.18) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom right, black, transparent 75%);
}

.desktop-icons {
  position: absolute;
  z-index: 2;
  inset: 0 0 var(--taskbar-height);
  pointer-events: none;
}

.desktop-icon {
  position: absolute;
  width: 92px;
  min-height: 84px;
  border: 1px solid transparent;
  background: transparent;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 7px;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}
.desktop-icon:active { cursor: grabbing; }

.desktop-icon:hover, .desktop-icon:focus-visible {
  border-color: rgba(213, 182, 108, 0.55);
  background: rgba(213, 182, 108, 0.08);
  outline: none;
}

.app-glyph {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: #1b2d31;
  color: var(--signal);
  font-weight: 800;
  box-shadow: inset 0 0 0 3px #132125;
}

.desktop-icon span:last-child { font-size: 12px; text-shadow: 0 1px 2px #000; }

.window-layer { position: absolute; inset: 0 0 var(--taskbar-height); pointer-events: none; }

.os-window {
  position: absolute;
  z-index: 10;
  display: grid;
  grid-template-rows: 38px minmax(0, 1fr);
  min-width: 300px;
  min-height: 240px;
  width: min(var(--window-width, 700px), calc(100vw - 24px));
  height: min(var(--window-height, 520px), calc(100vh - var(--taskbar-height) - 24px));
  overflow: hidden;
  border: 1px solid #6b8581;
  background: var(--paper);
  box-shadow: 12px 18px 38px var(--shadow), inset 0 0 0 1px #101b1e;
  pointer-events: auto;
  resize: both;
}
.os-window[data-maximized="true"] { resize: none; }

.os-window[data-active="false"] { border-color: #3b5152; filter: saturate(0.72); }
.os-window[hidden] { display: none; }

.window-titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 10px;
  background: linear-gradient(#30484b, #23383c);
  border-bottom: 1px solid #0d181a;
  user-select: none;
  touch-action: none;
  cursor: move;
}

.window-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; letter-spacing: 0.08em; }
.window-controls { display: flex; align-self: stretch; }
.window-control { width: 40px; border: 0; border-left: 1px solid #172629; background: transparent; cursor: pointer; }
.window-control:hover { background: var(--signal-soft); }
.window-control.close:hover { background: #7e4039; }
.window-content { min-height: 0; height: calc(100% - 42px); overflow: auto; isolation: isolate; contain: layout paint style; background: linear-gradient(155deg, rgba(255,255,255,0.018), transparent 30%), var(--paper); }

.taskbar {
  position: absolute;
  z-index: 1000;
  inset: auto 0 0;
  height: var(--taskbar-height);
  display: flex;
  align-items: stretch;
  background: #101c20;
  border-top: 1px solid #506767;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.2);
}

.launcher-button {
  min-width: 116px;
  padding: 0 18px;
  border: 0;
  border-right: 1px solid #3f5556;
  background: #22373a;
  color: var(--signal);
  font-weight: 800;
  letter-spacing: 0.09em;
  cursor: pointer;
}

.launcher-button[aria-expanded="true"] { background: var(--signal-soft); color: #fff3cf; }
.task-list { flex: 1; min-width: 0; display: flex; align-items: stretch; gap: 2px; padding: 5px; overflow: auto hidden; }
.task-button { min-width: 120px; max-width: 190px; border: 1px solid #32494b; background: #18282c; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.task-button[data-active="true"] { border-color: var(--signal); background: #2e3e3c; }
.system-tray { display: flex; align-items: center; gap: 15px; padding: 0 16px; border-left: 1px solid #3f5556; font-size: 11px; color: var(--muted); }
.network-state.online { color: #9fc5a8; }
.network-state.offline { color: var(--danger); }

.launcher {
  position: absolute;
  z-index: 999;
  left: 8px;
  bottom: calc(var(--taskbar-height) + 8px);
  width: min(360px, calc(100vw - 16px));
  padding: 12px;
  border: 1px solid #607a77;
  background: rgba(20, 34, 38, 0.98);
  box-shadow: 10px 14px 30px var(--shadow);
}

.launcher-header { padding: 8px 10px 15px; color: var(--signal); border-bottom: 1px solid #3c5151; letter-spacing: 0.08em; }
.launcher-app { width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.launcher-app:hover { background: rgba(213, 182, 108, 0.1); }

.toast-layer { position: absolute; z-index: 1100; right: 16px; bottom: 62px; display: grid; gap: 8px; width: min(340px, calc(100vw - 32px)); }
.toast { padding: 12px 14px; border: 1px solid var(--signal-soft); background: #1c2c2f; box-shadow: 5px 8px 20px var(--shadow); }
.toast strong { display: block; margin-bottom: 5px; color: var(--signal); }

.app-panel { height: 100%; min-height: 0; display: flex; flex-direction: column; }
.app-toolbar { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 8px 12px; border-bottom: 1px solid #3b5151; background: #192a2e; }
.app-toolbar .spacer { flex: 1; }
.toolbar-button, .primary-button, .secondary-button {
  min-height: 32px;
  padding: 6px 11px;
  border: 1px solid #526b69;
  background: #23373a;
  cursor: pointer;
}
.toolbar-button[aria-pressed="true"], .primary-button { border-color: var(--signal); background: #514831; color: #fff0c7; }
.toolbar-button:hover, .secondary-button:hover { border-color: var(--signal); }
.app-scroll { flex: 1; min-height: 0; overflow: auto; padding: 18px; }
.app-status { color: var(--muted); font-size: 12px; }
.status-error { color: var(--danger); }
.status-good { color: #9fc5a8; }

.account-layout { display: grid; grid-template-columns: minmax(180px, 0.8fr) minmax(280px, 1.2fr); min-height: 100%; }
.identity-card { padding: 28px; border-right: 1px solid #3b5151; background: #152428; }
.identity-seal { width: 90px; height: 90px; display: grid; place-items: center; margin-bottom: 24px; border: 1px solid var(--signal); border-radius: 50%; color: var(--signal); font-size: 26px; }
.form-panel { padding: 28px; align-self: center; width: 100%; max-width: 520px; }
.field { display: grid; gap: 6px; margin: 0 0 14px; }
.field span { color: var(--muted); font-size: 11px; letter-spacing: 0.08em; }
.field input, .chat-compose textarea { width: 100%; border: 1px solid #4a6261; background: #101d20; color: var(--ink); padding: 10px; outline: none; }
.field input:focus, .chat-compose textarea:focus { border-color: var(--signal); }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }

.messages-layout { display: grid; grid-template-columns: 176px minmax(0, 1fr); min-height: 0; flex: 1; }
.thread-list { border-right: 1px solid #3b5151; padding: 10px; background: #152428; overflow: auto; }
.thread-card { width: 100%; padding: 10px; border: 1px solid transparent; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.thread-card.active { border-color: var(--signal-soft); background: #243537; }
.thread-card small { display: block; margin-top: 4px; color: var(--muted); }
.conversation { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.conversation-header { padding: 12px 16px; border-bottom: 1px solid #3b5151; }
.message-feed { min-height: 0; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.message { max-width: min(74%, 560px); padding: 10px 12px; border-left: 2px solid #647b78; background: #213337; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.mine { align-self: flex-end; border-left: 0; border-right: 2px solid var(--signal); background: #343a31; }
.message.npc { max-width: 88%; border-left-color: var(--signal); }
.message-meta { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 7px; color: var(--muted); font-size: 10px; }
.message-subject { margin-bottom: 7px; color: var(--signal); }
.chat-compose { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #3b5151; background: #152428; }
.chat-compose textarea { min-height: 42px; max-height: 100px; resize: vertical; }
.chat-compose button { flex: 0 0 auto; }
.mixchat-responses { display: grid; gap: 8px; padding: 12px 16px; border-top: 1px solid #3b5151; background: #152428; }
.mixchat-response { padding: 10px 12px; border: 1px solid #526b69; background: #24373a; color: var(--ink); text-align: left; cursor: pointer; }
.mixchat-response:hover, .mixchat-response:focus-visible { border-color: var(--signal); background: #393b30; outline: none; }
.empty-state { margin: auto; padding: 24px; color: var(--muted); text-align: center; }

.archive-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.archive-card { padding: 16px; border: 1px solid #3c5252; background: #1a2b2f; }
.archive-card h3 { margin: 0 0 8px; color: var(--signal); font-size: 13px; }
.archive-card p { line-height: 1.55; white-space: pre-wrap; }
.system-list { display: grid; gap: 8px; }
.system-row { display: grid; grid-template-columns: 170px 1fr; gap: 12px; padding: 10px; border-bottom: 1px solid #314747; }
.system-row dt { color: var(--muted); }
.system-row dd { margin: 0; overflow-wrap: anywhere; }
.save-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 18px; }
.save-card { padding: 16px; border: 1px solid #3c5252; background: #17282c; }
.save-card h3 { margin: 0 0 10px; color: var(--signal); }
.settings-list { display: grid; align-content: start; gap: 10px; }
.settings-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 18px; padding: 16px; border: 1px solid #354d4d; background: #17282c; }
.settings-row p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.settings-toggle { min-width: 66px; padding: 9px; border: 1px solid #526b69; background: #182629; cursor: pointer; }
.settings-toggle[aria-checked="true"] { border-color: var(--signal); background: #514831; color: #fff0c7; }
.clicker-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; }
.clicker-left { display: grid; place-items: center; align-content: start; gap: 14px; padding: 20px 24px 24px; text-align: center; }
.clicker-right { display: grid; grid-template-rows: auto minmax(0, 1fr) auto minmax(0, 1fr); border-left: 1px solid #3b5151; }
.clicker-section-title { margin: 12px 12px 0; color: var(--signal); font-size: 12px; letter-spacing: .12em; }
.clicker-upgrades { overflow: auto; padding: 12px; display: grid; align-content: start; gap: 10px; }
.clicker-upgrade { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid #354d4d; background: #17282c; }
.clicker-upgrade--maxed { opacity: 0.55; }
.clicker-upgrade-info p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.clicker-achievements { overflow: auto; padding: 12px; display: grid; align-content: start; gap: 8px; }
.clicker-achievement { padding: 10px; border: 1px solid #354d4d; background: #132225; opacity: .55; }
.clicker-achievement--unlocked { border-color: var(--signal); opacity: 1; }
.clicker-achievement p { margin: 5px 0; color: var(--muted); font-size: 12px; }
.clicker-points { color: var(--signal); font-size: clamp(24px, 5vw, 42px); }
.clicker-button { width: 150px; height: 150px; border: 4px double #91aaa3; border-radius: 50%; background: radial-gradient(circle at 38% 32%, #54716d, #213638 65%); color: #f3dfad; font-size: 22px; font-weight: 900; cursor: pointer; box-shadow: 0 10px 0 #101d20, 0 18px 28px rgba(0,0,0,.4); }
.clicker-button:active { transform: translateY(7px); box-shadow: 0 3px 0 #101d20; }
.clicker-streak { color: var(--signal); font-size: 12px; }
.clicker-streak--ready { color: #9fc5a8; font-weight: 800; }
.folder-name-input, .folder-card input, .folder-card select { border: 1px solid #4a6261; background: #101d20; color: var(--ink); padding: 9px; }
.folder-card { display: grid; gap: 12px; margin-bottom: 14px; padding: 14px; border: 1px solid #3c5252; background: #17282c; }
.folder-card-head { display: flex; gap: 8px; }
.folder-card-head input { flex: 1; min-width: 0; }
.folder-app-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.folder-app { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 8px; border: 1px solid #3e5655; background: #1b2d31; color: var(--ink); text-align: left; cursor: pointer; }
.folder-remove { padding: 8px; color: var(--danger); font-size: 18px; }

/* THEMES */
.theme-amber {
  --canvas: #100d07;
  --panel: #17130b;
  --toolbar: #261f12;
  --border: #4d3e23;
  --ink: #fae7cb;
  --muted: #bda37a;
  --signal: #ffb833;
  --accent: #d48e1a;
  --taskbar: #141009;
}
.theme-cyan {
  --canvas: #071118;
  --panel: #0c1c27;
  --toolbar: #142a3a;
  --border: #234f6d;
  --ink: #d0f0fa;
  --muted: #7caabf;
  --signal: #38efef;
  --accent: #1999b5;
  --taskbar: #09151e;
}
.theme-matrix {
  --canvas: #050e07;
  --panel: #0a170e;
  --toolbar: #112817;
  --border: #1f502d;
  --ink: #d4fad9;
  --muted: #7fba88;
  --signal: #33ff66;
  --accent: #1ebd4d;
  --taskbar: #07120a;
}

/* CRT SCANLINES OVERLAY */
.scanlines::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.25) 3px,
    rgba(0, 0, 0, 0.25) 4px
  );
  z-index: 9999;
  opacity: 0.7;
}

/* SCREEN GLITCH FX */
.screen-glitch {
  animation: crt-glitch 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}
@keyframes crt-glitch {
  0% { transform: translate(0); filter: brightness(1) contrast(1); }
  15% { transform: translate(-3px, 2px); filter: brightness(1.4) contrast(1.2) hue-rotate(90deg); }
  30% { transform: translate(3px, -2px); filter: brightness(0.8) hue-rotate(-90deg); }
  45% { transform: translate(-2px, -1px); filter: brightness(1.6) contrast(1.4); }
  60% { transform: translate(2px, 1px); filter: brightness(0.9); }
  80% { transform: translate(-1px, 2px); filter: brightness(1.2); }
  100% { transform: translate(0); filter: brightness(1) contrast(1); }
}
.clock-glitch {
  color: #ff3344 !important;
  font-weight: 900;
  text-shadow: 0 0 8px rgba(255, 51, 68, 0.8);
}

/* DESKTOP CONTEXT MENU */
.desktop-context-menu {
  position: absolute;
  z-index: 10000;
  min-width: 200px;
  background: var(--panel);
  border: 1px solid var(--signal);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  padding: 4px 0;
}
.desktop-context-menu button {
  background: transparent;
  border: 0;
  color: var(--ink);
  padding: 8px 14px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.05em;
  transition: background 100ms ease;
}
.desktop-context-menu button:hover {
  background: var(--toolbar);
  color: var(--signal);
}

/* KT SWEEPER MINI-GAME */
.sweeper-app { display: flex; flex-direction: column; background: var(--panel); }
.sweeper-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--toolbar);
  border-bottom: 1px solid var(--border);
}
.sweeper-diff-select, .events-select {
  background: var(--canvas);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 6px 10px;
  font-family: inherit;
  font-size: 11px;
}
.sweeper-stat-badge {
  background: var(--canvas);
  border: 1px solid var(--border);
  color: var(--signal);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.sweeper-face-btn, .sweeper-flag-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 5px 12px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
}
.sweeper-face-btn:hover, .sweeper-flag-btn:hover { border-color: var(--signal); color: var(--signal); }
.sweeper-flag-btn.active { background: var(--signal); color: var(--canvas); font-weight: bold; }
.sweeper-board-container {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: safe center;
  justify-content: safe center;
  padding: 16px;
  background: var(--canvas);
}
.sweeper-board {
  display: grid;
  gap: 2px;
  background: var(--border);
  padding: 4px;
  border: 2px solid var(--border);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.6);
}
.sweeper-cell {
  width: var(--sweeper-cell-size, 28px);
  height: var(--sweeper-cell-size, 28px);
  border: 1px solid #3c5457;
  background: #1c2e33;
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  padding: 0;
  transition: filter 80ms ease;
}
.sweeper-cell:hover:not(.revealed) { filter: brightness(1.25); border-color: var(--signal); }
.sweeper-cell.revealed {
  background: #0e1a1d;
  border-color: #1a2a2e;
  cursor: default;
}
.sweeper-cell.flagged { color: #ff3344; background: #2b1f22; border-color: #ff3344; font-weight: 900; }
.sweeper-cell.mine { background: #3b171c; color: #ff3344; }
.sweeper-cell.detonated { background: #ff3344; color: #fff; font-weight: 900; animation: detonated-flash 300ms alternate 3; }
@keyframes detonated-flash { from { background: #ff3344; } to { background: #ffe600; } }
.sweeper-cell[data-count="1"] { color: #3b82f6; }
.sweeper-cell[data-count="2"] { color: #10b981; }
.sweeper-cell[data-count="3"] { color: #ef4444; }
.sweeper-cell[data-count="4"] { color: #8b5cf6; }
.sweeper-cell[data-count="5"] { color: #f59e0b; }
.sweeper-cell[data-count="6"] { color: #06b6d4; }
.sweeper-cell[data-count="7"] { color: #ec4899; }
.sweeper-cell[data-count="8"] { color: #f97316; }
.sweeper-footer {
  padding: 10px 14px;
  background: var(--toolbar);
  border-top: 1px solid var(--border);
  display: grid;
  gap: 6px;
}
.sweeper-status-banner { font-size: 11px; letter-spacing: 0.08em; color: var(--muted); }
.sweeper-status-banner.status-success { color: #10b981; font-weight: bold; }
.sweeper-status-banner.status-error { color: #ef4444; font-weight: bold; }
.sweeper-stats-row { font-size: 11px; color: var(--muted); border-top: 1px solid #2d4246; padding-top: 4px; }

/* TERMINAL APP */
.terminal-app { display: flex; flex-direction: column; background: #0c1316; color: #d6f2e9; font-family: monospace; }
.terminal-output { flex: 1; overflow-y: auto; padding: 14px; display: grid; gap: 4px; font-size: 12px; line-height: 1.5; }
.terminal-line { word-break: break-word; white-space: pre-wrap; }
.terminal-line.line-command { color: var(--signal); font-weight: bold; }
.terminal-line.line-success { color: #33ff66; }
.terminal-line.line-error { color: #ff4d4d; }
.terminal-input-row {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  background: #070c0e;
  border-top: 1px solid var(--border);
}
.terminal-prompt { color: var(--signal); font-size: 12px; font-weight: bold; margin-right: 8px; white-space: nowrap; }
.terminal-input {
  flex: 1;
  background: transparent;
  border: 0;
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

/* EVENTS APP */
.events-app { display: flex; flex-direction: column; background: var(--panel); }
.events-body { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 14px; overflow-y: auto; }
.events-card { background: var(--canvas); border: 1px solid var(--border); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.events-section-title { font-size: 11px; letter-spacing: 0.12em; color: var(--signal); margin: 0; }
.events-desc { font-size: 11px; color: var(--muted); margin: 0; line-height: 1.4; }
.events-control-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.btn-active { border-color: var(--signal) !important; color: var(--signal) !important; }
.events-preset-list, .events-custom-list { display: grid; gap: 8px; }
.events-preset-row, .events-custom-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--toolbar);
  border: 1px solid var(--border);
}
.events-preset-info { display: grid; gap: 2px; }
.events-preset-info strong { font-size: 11px; color: var(--ink); }
.events-preset-info small { font-size: 10px; color: var(--muted); }
.events-row-actions { display: flex; gap: 6px; }
.btn-danger { color: #ff4d4d !important; border-color: #ff4d4d !important; }
.events-form { display: grid; gap: 8px; }
.events-input {
  background: var(--canvas);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 6px 10px;
  font-family: inherit;
  font-size: 11px;
}
.events-checkbox-wrap { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }

@media (max-width: 700px) {
  :root { --taskbar-height: 54px; }
  .desktop-icon { width: 82px; }
  .os-window { inset: 6px 6px auto !important; width: calc(100vw - 12px) !important; height: calc(100vh - var(--taskbar-height) - 12px) !important; min-width: 0; min-height: 0; resize: none; }
  .launcher-button { min-width: 92px; padding: 0 10px; }
  .system-tray { padding: 0 9px; gap: 7px; }
  .network-state { display: none; }
  .task-button { min-width: 54px; max-width: 88px; }
  .account-layout { grid-template-columns: 1fr; }
  .identity-card { display: none; }
  .form-panel { padding: 20px; }
  .messages-layout { grid-template-columns: 1fr; }
  .thread-list { display: flex; overflow-x: auto; max-height: 90px; border-bottom: 1px solid var(--line); }
  .thread-card { flex: 0 0 150px; }
  .message { max-width: 88%; }
  .clicker-body { grid-template-columns: 1fr; grid-template-rows: auto minmax(280px, 1fr); overflow: auto; }
  .clicker-left { min-height: 280px; padding-top: 18px; }
  .clicker-right { min-height: 520px; border-top: 1px solid #3b5151; border-left: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in 180ms ease-out; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
}

/* Workstation refinement: retain the original teal, brass and paper palette. */
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }
.login-gate { overflow-y: auto; align-items: safe center; }
.login-gate-card { border-top: 4px solid var(--signal); border-radius: 5px; }
.login-gate-card h1 { font-size: clamp(20px, 4vw, 28px); line-height: 1.25; }
.login-intro { color: var(--muted); line-height: 1.65; margin-bottom: 26px; }
.lab-return { display: inline-block; color: var(--muted); margin-top: 24px; padding: 10px 0; font-size: 12px; }
.os-window { border-radius: 6px 6px 2px 2px; grid-template-rows: 44px minmax(0, 1fr); }
.os-window[data-active="true"] { border-color: var(--signal); }
.window-content { height: 100%; min-width: 0; }
.window-titlebar .app-glyph { width: 28px; height: 28px; }
.window-control { width: 44px; }
.launcher { max-height: calc(100dvh - var(--taskbar-height) - 24px); overflow-y: auto; overscroll-behavior: contain; border-top: 3px solid var(--signal); border-radius: 5px; }
.launcher-search { width: 100%; min-height: 44px; padding: 10px; margin: 12px 0 6px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.launcher-app { min-height: 54px; border-radius: 3px; }
.show-desktop { flex: 0 0 44px; border: 0; border-right: 1px solid var(--line); background: var(--paper); color: var(--signal); font-size: 24px; cursor: pointer; }
.workstation-guide { padding: 12px 4px 4px; margin-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.6; }
.workstation-guide summary { min-height: 44px; padding-block: 10px; color: var(--signal); cursor: pointer; }
.events-navigation { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px; border-bottom: 1px solid var(--line); }
.events-navigation button { flex: 1; min-height: 44px; padding: 8px; background: #172b2d; color: var(--ink); border: 1px solid var(--line); border-radius: 5px; font-size: 11px; cursor: pointer; }
.events-navigation button[aria-pressed="true"] { color: var(--signal); border-color: var(--signal); background: #3b4030; }
.events-app .events-body { grid-template-columns: minmax(0, 1fr); }
.events-app [hidden] { display: none; }
.events-form { display: grid; gap: 10px; }
.events-form .events-input { width: 100%; min-width: 0; min-height: 44px; padding: 10px; border: 1px solid #59716c; border-radius: 5px; background: #142628; color: var(--ink); }
.events-form .events-input::placeholder { color: #a6b8b1; }
.events-control-row select { min-height: 44px; }

/* Workstation 02: a quiet desktop, separate session rail and application dock. */
:root { --desktop-rail: 72px; --taskbar-height: 60px; }
body { font-family: "Segoe UI", Arial, sans-serif; }
.workstation-bar { position: absolute; z-index: 1001; inset: 0 0 auto; height: var(--desktop-rail); display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 24px; border-bottom: 1px solid #54716b55; background: #101e22ec; }
.workstation-bar > div:first-child { display: grid; gap: 5px; }
.workstation-bar strong { color: var(--signal); font: 700 18px "Courier New", monospace; letter-spacing: .12em; }
.workstation-bar span { color: var(--muted); font: 10px "Courier New", monospace; letter-spacing: .08em; }
.workstation-session { display: flex; align-items: center; gap: 18px; }
#shutdown-button { min-height: 40px; padding: 10px 16px; border: 1px solid #6a7562; color: var(--signal); background: #293b39; border-radius: 5px; cursor: pointer; font: 11px "Courier New",monospace; }
.desktop { background: radial-gradient(ellipse at 80% 60%,#2e4a47 0,transparent 45%), linear-gradient(135deg,#192e34,#0c1c20); }
.desktop::before { display: none; }
.desktop-watermark { position: absolute; right: 9%; bottom: 20%; color: #bdd1bd30; pointer-events: none; }
.desktop-watermark > span { display: block; font: 800 clamp(70px,12vw,170px)/1 Arial,sans-serif; letter-spacing: -.09em; }
.desktop-watermark p { font: 22px/1.3 "Courier New",monospace; letter-spacing: -.03em; }
.desktop-icons { top: var(--desktop-rail); bottom: 86px; }
.desktop-icon { min-height: 86px; border-radius: 9px; gap: 8px; }
.desktop-icon .app-glyph { width: 44px; height: 44px; border-radius: 9px; color: #ecd39c; background: linear-gradient(145deg,#3a5350,#213633); border-color: #76908588; box-shadow: inset 0 1px #d7e3dd22,0 6px 14px #0003; }
.desktop-icon span:last-child { font-size: 12px; line-height: 1.25; }
.window-layer { top: var(--desktop-rail); bottom: 86px; }
.os-window { max-width: calc(100% - 12px); max-height: calc(100% - 12px); border-radius: 9px; box-shadow: 0 18px 60px #0008; }
.window-titlebar { background: #2b413f; }
.os-window[data-active="true"] .window-titlebar { background: linear-gradient(90deg,#4b513c,#29413f); }
.window-title { font: 600 12px "Courier New",monospace; letter-spacing: .08em; }
.taskbar { inset: auto 12px max(12px,env(safe-area-inset-bottom)); height: 58px; padding: 5px; border: 1px solid #647d6a88; border-radius: 10px; box-shadow: 0 10px 35px #0007; background: #132428f5; }
.launcher-button,.show-desktop,.task-button { border-radius: 5px; }
.launcher-button { font: 700 12px "Courier New",monospace; }
.launcher { left: 12px; bottom: 80px; max-height: calc(100dvh - var(--desktop-rail) - 100px); width: min(380px,calc(100% - 24px)); padding: 14px; border-radius: 10px; }
.launcher-header { font: 700 12px "Courier New",monospace; }
.launcher-app { border-bottom: 1px solid #51695e22; }
.launcher-app .app-glyph { border-radius: 6px; }
.app-toolbar { background: #213531; border-bottom-color: #5b706233; }
.primary-button,.secondary-button,.toolbar-button,.settings-toggle { border-radius: 5px; padding: 10px 14px; }
.field input,.chat-compose textarea { border-radius: 5px; }
.events-body { gap: 16px; padding: 18px; }
.events-card { border: 1px solid #77876866; border-radius: 8px; padding: 18px; background: #172a2b; }
.events-section-title { color: var(--signal); font: 11px "Courier New",monospace; }
.system-dialog { width: min(480px,calc(100vw - 24px)); padding: 28px; border: 1px solid var(--signal-soft); border-radius: 10px; color: var(--ink); background: #1b2e30; box-shadow: 0 30px 100px #000b; font: 14px/1.6 "Segoe UI",sans-serif; }
.system-dialog::backdrop { background: #071316b8; backdrop-filter: blur(5px); }
.system-dialog h2 { color: var(--signal); font-size: 30px; line-height: 1.15; margin: 12px 0; }
@media (max-width:700px), (max-height:500px) and (pointer:coarse) {
  :root { --desktop-rail: 56px; --taskbar-height: calc(54px + env(safe-area-inset-bottom)); }
  .workstation-bar { padding: 8px 12px; }
  .workstation-bar strong { font-size: 14px; }
  .workstation-bar > div:first-child span,.workstation-session > span { display: none; }
  #shutdown-button { min-height: 44px; padding: 8px 10px; }
  .desktop-icons { bottom: var(--taskbar-height); }
  .window-layer { bottom: var(--taskbar-height); }
  .taskbar { inset: auto 0 0; border-radius: 0; height: var(--taskbar-height); padding: 3px 3px env(safe-area-inset-bottom); }
  .launcher { bottom: calc(var(--taskbar-height) + 6px); max-height: calc(100dvh - var(--desktop-rail) - var(--taskbar-height) - 18px); }
  .events-body { grid-template-columns: 1fr; overflow: auto; }
  .desktop-watermark { display: none; }
}
.app-toolbar { flex-wrap: wrap; }
.app-scroll, .window-content, .message-feed { overscroll-behavior: contain; }
.task-button { flex-shrink: 0; }
.taskbar { padding-bottom: env(safe-area-inset-bottom); }
.toast-layer { pointer-events: none; }
@media (pointer: coarse) {
  .sweeper-board { --sweeper-cell-size: 44px; flex-shrink: 0; }
  .sweeper-board-container { min-height: 160px; }
  .sweeper-app { overflow-y: auto; }
  button, .toolbar-button, .primary-button, .secondary-button { min-height: 44px; }
  input, select, textarea { font-size: 16px; }
}
@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) {
  :root { --taskbar-height: calc(54px + env(safe-area-inset-bottom)); }
  .desktop { top: env(safe-area-inset-top); left: env(safe-area-inset-left); right: env(safe-area-inset-right); }
  .desktop-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); align-content: start; gap: 6px; padding: 12px; overflow-y: auto; pointer-events: auto; }
  .desktop-icon { position: static; width: 100%; min-height: 84px; touch-action: pan-y; }
  .os-window { inset: 6px 6px auto !important; width: calc(100% - 12px) !important; height: calc(100% - 12px) !important; min-width: 0; min-height: 0; resize: none; }
  .window-control[aria-label^="Maximize"] { display: none; }
  .launcher-button { min-width: 92px; padding: 0 10px; font-size: 11px; }
  .system-tray { padding: 0 8px; }
  .network-state { display: none; }
  .task-button { min-width: 76px; max-width: 100px; }
  .messages-layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .thread-list { display: flex; overflow-x: auto; max-height: 90px; border-bottom: 1px solid var(--line); }
  .thread-card { flex: 0 0 150px; }
  .account-layout { grid-template-columns: 1fr; }
  .identity-card { display: none; }
  .app-scroll, .form-panel { padding: 14px; }
  .login-gate { padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .login-gate-card { padding: 22px; }
}
@media (max-height: 500px) {
  .login-gate-card { width: min(720px, 100%); padding: 18px 24px; }
  .login-gate-card .boot-mark { display: none; }
  .login-intro { margin: 6px 0 14px; }
  .login-gate-card h1 { margin: 8px 0; }
  .lab-return { margin-top: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
