/* Desktop apps: Start-menu search, app windows (Files, Settings, Updates, Calculator, Terminal) and the screensaver.
   Built in the same window language as the main bundle's windows. */

/* ---------- Start menu ---------- */
.start-menu { width:320px; max-height:calc(100dvh - 104px); overflow:auto; overscroll-behavior:contain; }
.start-search { position:relative; display:flex; align-items:center; margin:0 0 4px; }
.start-search-icon { position:absolute; left:9px; width:18px; height:18px; pointer-events:none; }
.start-search input { width:100%; height:36px; padding:6px 10px 6px 34px; border:1px solid #8b9bb2; border-radius:4px; background:#fff; color:var(--ink); font:inherit; font-size:12px; box-shadow:inset 1px 1px #c3cdda; }
.start-search input:focus-visible { outline:3px solid #ec982e; outline-offset:1px; }
.start-search input::placeholder { color:#7b889b; }
.start-results-count { color:#687b94; font-size:10px; padding:0 4px; }
.start-results-count:empty { display:none; }
.start-results { display:grid; gap:1px; padding:2px 0 6px; }
.start-section-title { margin:8px 6px 3px; color:#708099; font:10px Consolas, monospace; letter-spacing:.09em; text-transform:uppercase; }
.start-result { display:flex; align-items:center; gap:10px; width:100%; padding:7px 8px; border-radius:3px; background:transparent; text-align:left; }
.start-result:hover, .start-result:focus-visible { background:#dce6f4; }
.start-result-icon { flex:none; width:28px; height:28px; }
.start-result-text { display:grid; gap:2px; min-width:0; }
.start-result-text strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:12px; }
.start-result-text small { overflow:hidden; margin:0; color:#6b7c92; font:9px/1.3 Consolas, monospace; text-overflow:ellipsis; white-space:nowrap; }
.start-results-empty { padding:6px 8px 4px; color:#687b94; font-size:11px; line-height:1.45; }
.start-menu.is-searching > button, .start-menu.is-searching > a, .start-menu.is-searching > .start-apps { display:none; }
.start-apps { border-top:1px solid #d0d9e4; margin-top:4px; padding-bottom:4px; }
.start-app-grid { display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:2px; }
.start-app { display:grid; justify-items:center; gap:4px; padding:8px 4px; border-radius:3px; background:transparent; font-size:10px; text-align:center; }
.start-app:hover { background:#dce6f4; }
.start-app-icon { width:30px; height:30px; }

@media (width<=759px) {
  .start-menu { left:6px; right:6px; width:auto; }
  .start-search input { font-size:16px; }
}

/* ---------- App windows ---------- */
.app-window { z-index:15; top:84px; left:50%; transform:translate(-50%); }
.app-window .window-status { font-size:10px; }
.app-body { display:flex; flex-direction:column; min-height:0; background:#f3f6fa; }
.task-app-icon { flex-shrink:0; width:21px; height:21px; }
.task-app-name { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.app-button { border:1px solid #a3b6d1; border-radius:4px; padding:7px 11px; color:#244a88; background:linear-gradient(#fff,#e5edf8); box-shadow:inset 0 1px #fff; font-size:11px; font-weight:700; }
.app-button:hover { background:#dce9fa; }

/* ---------- File Explorer ---------- */
.files-window { width:min(900px, 100vw - 220px); height:min(580px, 100dvh - 150px); }
.files-toolbar { display:flex; align-items:center; gap:5px; padding:7px 10px; border-bottom:1px solid #d2dbe6; background:#eff2f6; }
.files-nav { width:30px; height:28px; border:1px solid #a4b3c6; border-radius:3px; background:linear-gradient(#fbfcff,#e2e8f0); font-size:14px; box-shadow:inset 1px 1px #fff; }
.files-nav:disabled { opacity:.45; }
.files-address { display:flex; flex:1; flex-wrap:nowrap; align-items:center; gap:2px; min-width:0; height:30px; margin-left:4px; padding:0 6px; overflow-x:auto; border:1px solid #a7b4c6; border-radius:3px; background:#fff; box-shadow:inset 1px 1px #c3cdda; }
.files-crumb { flex:none; padding:3px 6px; border-radius:3px; background:transparent; font-size:11px; }
.files-crumb:hover { background:#dce6f4; }
.files-crumb[aria-current] { font-weight:700; }
.files-sep { color:#8592a6; font-size:11px; }
.files-layout { display:grid; grid-template-columns:190px minmax(0,1fr) 250px; flex:1; min-height:0; }
.files-tree { overflow:auto; padding:8px 6px; border-right:1px solid #c7d1df; background:#e8edf5; }
.files-tree-item { display:flex; align-items:center; gap:7px; width:100%; padding:5px 6px 5px calc(6px + var(--depth) * 14px); border-radius:3px; background:transparent; font-size:11px; text-align:left; }
.files-tree-item:hover { background:#dbe5f2; }
.files-tree-item[aria-current] { background:#d3e1f6; color:#193c79; font-weight:700; }
.files-tree-item span:last-child { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.files-tree-icon { flex:none; width:18px; height:18px; }
.files-pane { display:flex; flex-direction:column; min-width:0; min-height:0; background:#fff; }
.files-columns, .files-row { display:grid; grid-template-columns:minmax(0,1.6fr) minmax(0,.8fr) minmax(0,1fr); gap:10px; align-items:center; }
.files-columns { padding:6px 12px; border-bottom:1px solid #d7dde6; background:#f5f7fa; color:#687b92; font-size:10px; }
.files-list { flex:1; min-height:0; overflow:auto; padding:4px; }
.files-list:focus-visible { outline:3px solid #ec982e; outline-offset:-3px; }
.files-row { padding:6px 8px; border:1px solid transparent; border-radius:3px; cursor:default; font-size:11px; user-select:none; }
.files-row:hover { background:#eef3fa; }
.files-row[aria-selected="true"] { background:#d3e1f6; border-color:#aabfe0; }
.files-row:focus-visible { outline:2px solid #ec982e; outline-offset:-2px; }
.files-name { display:flex; align-items:center; gap:8px; min-width:0; }
.files-name strong { overflow:hidden; font-weight:400; text-overflow:ellipsis; white-space:nowrap; }
.files-icon { flex:none; width:24px; height:24px; }
.files-type, .files-extra { overflow:hidden; color:#687b92; font:10px/1.3 Consolas, monospace; text-overflow:ellipsis; white-space:nowrap; }
.files-details { display:flex; flex-direction:column; gap:8px; overflow:auto; padding:16px 14px; border-left:1px solid #d2dbe6; background:#f5f7fa; font-size:11px; line-height:1.5; }
.files-details-icon { width:46px; height:46px; }
.files-details h3 { font-size:15px; line-height:1.25; }
.files-details p { margin:0; }
.files-details-type { color:#687b92; font:10px/1.4 Consolas, monospace; }
.files-details-lead { font-weight:700; }
.files-badge { align-self:flex-start; padding:2px 6px; border:1px solid #c3cfdf; border-radius:3px; background:#fff; color:#3e5677; font:9px Consolas, monospace; }
.files-tags { display:flex; flex-wrap:wrap; gap:4px; }
.files-tags span { padding:1px 6px; border-radius:9px; background:#e1e8f2; font-size:10px; }
.files-outline { margin:0; padding-left:16px; color:#4a5a70; }
.files-actions { display:flex; flex-wrap:wrap; gap:6px; margin-top:4px; }
.files-open, .files-link { border:1px solid #a3b6d1; border-radius:4px; padding:6px 9px; color:#244a88; background:linear-gradient(#fff,#e5edf8); box-shadow:inset 0 1px #fff; font-size:11px; font-weight:700; }
.files-open:hover, .files-link:hover { background:#dce9fa; }

@media (width<=1050px) {
  .files-window { width:calc(100vw - 160px); }
  .files-layout { grid-template-columns:160px minmax(0,1fr); grid-template-rows:minmax(0,1fr) auto; }
  .files-details { grid-column:1 / -1; max-height:190px; border-top:1px solid #d2dbe6; border-left:0; }
}
@media (width<=759px) {
  .os-window.app-window { width:calc(100vw - 24px); height:calc(100dvh - 122px); max-height:calc(100dvh - 122px); top:62px !important; }
  .app-window .window-body { max-height:none; }
  .files-layout { grid-template-columns:minmax(0,1fr); }
  .files-tree { display:none; }
  .files-columns { display:none; }
  .files-row { grid-template-columns:minmax(0,1fr) auto; padding:9px 8px; }
  .files-type { display:none; }
  .files-details { max-height:40%; }
}

/* ---------- Settings ---------- */
.settings-window { width:min(520px, 100vw - 40px); height:min(620px, 100dvh - 150px); }
.settings-form { flex:1; overflow:auto; padding:16px 18px; }
.settings-group { margin:0 0 12px; padding:12px 14px 14px; border:1px solid #c8d4e3; border-radius:4px; background:#fff; }
.settings-group legend { padding:0 4px; font-size:13px; font-weight:700; }
.settings-hint { margin:0 0 9px; color:#687b92; font-size:11px; }
.settings-options { display:flex; flex-wrap:wrap; gap:6px; }
.settings-option { position:relative; display:flex; align-items:center; gap:7px; padding:7px 11px 7px 8px; border:1px solid #b5c3d6; border-radius:4px; background:linear-gradient(#fff,#eef2f7); cursor:pointer; font-size:12px; }
.settings-option:hover { background:#e6eef9; }
.settings-option:has(input:checked) { border-color:#5a7dc5; background:#d9e5f7; box-shadow:inset 0 0 0 1px #5a7dc5; font-weight:700; }
.settings-option:has(input:focus-visible) { outline:3px solid #ec982e; outline-offset:2px; }
.settings-option input { margin:0; accent-color:#2448df; }
.has-swatches .settings-option { flex-direction:column; align-items:flex-start; gap:5px; padding:6px; }
.has-swatches .settings-option input { position:absolute; top:10px; left:10px; }
.settings-swatch { display:block; width:96px; height:56px; border:1px solid #6c809c; border-radius:3px; }
.settings-footer { display:flex; flex-wrap:wrap; justify-content:space-between; align-items:center; gap:10px; padding-top:4px; }
.settings-footer .settings-hint { margin:0; }
.settings-row { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin-top:10px; font-size:12px; }
.settings-row select { padding:5px 8px; border:1px solid #a7b4c6; border-radius:3px; background:#fff; color:inherit; font:inherit; }

/* Wallpapers. Blueprint is the original desktop background. */
.settings-swatch[data-wallpaper="blueprint"] { background:radial-gradient(at 60% 0, #a7bbd1, #0000 70%), linear-gradient(135deg, #7894b3, #4e729c); }
.settings-swatch[data-wallpaper="dusk"], html[data-wallpaper="dusk"] .desktop { background:radial-gradient(at 70% 100%, #f3a66f, #0000 60%), linear-gradient(160deg, #3b3f75, #8a5a8f 60%, #d98a6c); }
.settings-swatch[data-wallpaper="meadow"], html[data-wallpaper="meadow"] .desktop { background:radial-gradient(at 30% 0, #e8f0c8, #0000 65%), linear-gradient(150deg, #8fb17f, #4f7f62); }
.settings-swatch[data-wallpaper="graphite"], html[data-wallpaper="graphite"] .desktop { background:radial-gradient(at 50% 0, #59616d, #0000 70%), linear-gradient(135deg, #3a4049, #1f2329); }

/* Text size scales the content of windows, not the window chrome, so windows keep their size. */
html[data-text-size="115"] :is(.window-body > *, .welcome-body > *, #case-content > *, .start-menu > *) { zoom:1.15; }
html[data-text-size="130"] :is(.window-body > *, .welcome-body > *, #case-content > *, .start-menu > *) { zoom:1.3; }

/* Reduced motion, chosen in Settings or requested by the system. */
html[data-motion="reduce"] *, html[data-motion="reduce"] ::before, html[data-motion="reduce"] ::after { animation-duration:.001ms !important; animation-iteration-count:1 !important; transition:none !important; scroll-behavior:auto !important; }
html[data-motion="reduce"] :is(.stats-animate, .stats-animate .composition-bar span, .stats-animate .project-meter span) { opacity:1; transform:none; }

/* Dark theme. Window chrome and content are inverted as a whole so every existing window follows,
   then media and artwork are inverted back to their true colours. */
html[data-theme="dark"] { color-scheme:dark; }
html[data-theme="dark"] body { background:#141b26; }
html[data-theme="dark"] .desktop { box-shadow:inset 0 0 0 100vmax #0b1220a0; }
html[data-theme="dark"] :is(.os-window, .desktop-menu, .taskbar, .start-menu) { filter:invert(1) hue-rotate(180deg); }
html[data-theme="dark"] .os-window { box-shadow:0 18px 48px #e9d2b470, 0 3px 0 #e1cbb050; }
html[data-theme="dark"] :is(.os-window, .desktop-menu, .taskbar, .start-menu) :is(img, video, canvas, svg, .featured-capture, .desktop-logo, .settings-swatch) { filter:invert(1) hue-rotate(180deg); }
html[data-theme="dark"] :is(.os-window, .desktop-menu, .taskbar, .start-menu) :is(.featured-capture, .desktop-logo) :is(img, svg) { filter:none; }
html[data-theme="dark"] .desktop-icon > span:last-child { color:#eef3fa; }

/* ---------- Updates ---------- */
.updates-window { width:min(620px, 100vw - 40px); height:min(600px, 100dvh - 150px); }
.updates-toolbar { display:flex; flex-wrap:wrap; gap:5px; padding:8px 12px; border-bottom:1px solid #d2dbe6; background:#eff2f6; }
.updates-filter { padding:5px 10px; border:1px solid #b5c3d6; border-radius:12px; background:#fff; font-size:11px; }
.updates-filter:hover { background:#e6eef9; }
.updates-filter[aria-pressed="true"] { border-color:#5a7dc5; background:#d3e1f6; color:#193c79; font-weight:700; }
.updates-scroll { flex:1; min-height:0; overflow:auto; padding:6px 18px 18px; }
.updates-empty { padding:20px 4px; color:#687b92; }
.updates-month h3 { position:sticky; top:-6px; z-index:1; margin:0 -18px; padding:10px 18px 6px; background:#f3f6fa; color:#708099; font:10px Consolas, monospace; letter-spacing:.09em; text-transform:uppercase; }
.updates-list { margin:0; padding:0; list-style:none; }
.updates-item { display:grid; grid-template-columns:54px minmax(0,1fr); gap:12px; padding:10px 0 10px; border-bottom:1px solid #dfe5ed; }
.updates-date { padding-top:2px; color:#4f607a; font:11px Consolas, monospace; }
.updates-body { min-width:0; font-size:12px; line-height:1.45; }
.updates-body h4 { margin:3px 0 2px; font-size:13px; }
.updates-meta { display:flex; flex-wrap:wrap; gap:4px; margin:0; }
.updates-badge { padding:1px 6px; border:1px solid #c3cfdf; border-radius:3px; background:#fff; color:#3e5677; font:9px Consolas, monospace; text-transform:uppercase; }
.updates-badge.is-release { border-color:#97c2a2; background:#e3f3e6; color:#2d6a3e; }
.updates-badge.is-status { border-color:#e1c27e; background:#fbf2dc; color:#7a5a17; }
.updates-badge.is-journal { border-color:#a9bde3; background:#e5ecfa; color:#2c4f93; }
.updates-badge.is-added { border-color:#d7b2cf; background:#f8e9f4; color:#7c3a6c; }
.updates-change, .updates-detail { margin:2px 0 0; color:#4a5a70; overflow-wrap:anywhere; }
.updates-detail { display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
.updates-from { text-decoration:line-through; text-decoration-color:#9aa6b8; }
.updates-link { display:inline-block; margin-top:5px; padding:0; background:none; color:#244a88; font-size:11px; font-weight:700; text-decoration:underline; text-underline-offset:2px; }
.updates-current { margin-top:16px; padding:10px 12px; border:1px solid #c8d4e3; border-radius:4px; background:#fff; font-size:12px; }
.updates-current summary { cursor:pointer; font-weight:700; }
.updates-status-list { display:grid; gap:2px; margin:8px 0 0; padding:0; list-style:none; }
.updates-status-list li { display:flex; flex-wrap:wrap; justify-content:space-between; gap:4px 12px; padding:4px 0; border-bottom:1px dashed #dfe5ed; }
.updates-status-name { padding:0; background:none; color:#244a88; text-align:left; text-decoration:underline; text-underline-offset:2px; }
.updates-status-value { color:#4f607a; font:10px/1.6 Consolas, monospace; }

/* ---------- Calculator ---------- */
.calc-window { width:300px; height:auto; top:110px; left:calc(50% + 180px); }
.calc-window .app-body { padding:12px; gap:10px; background:#e4e9f0; }
.calc-screen { display:grid; justify-items:end; gap:2px; min-height:78px; padding:10px 12px; border:1px solid #8b9bb2; border-radius:3px; background:#e9f3d9; box-shadow:inset 1px 1px 3px #6d7f5a40; }
.calc-expression { min-height:15px; color:#5f6d58; font:11px Consolas, monospace; }
.calc-display { max-width:100%; overflow:hidden; color:#1f2a1a; font:600 32px/1.15 Consolas, monospace; text-overflow:ellipsis; white-space:nowrap; }
.calc-display.is-long { font-size:22px; line-height:1.6; }
.calc-display.is-error { font-size:16px; line-height:2.3; }
.calc-pad { display:grid; grid-template-columns:repeat(4, minmax(0,1fr)); gap:6px; }
.calc-key { height:44px; border:1px solid #8a97ab; border-radius:4px; background:linear-gradient(#fbfcff,#dfe5ee); color:#263448; font-size:17px; box-shadow:inset 1px 1px #fff, 0 1px #4d5c7133; }
.calc-key:hover { background:#fff; }
.calc-key.is-op { background:linear-gradient(#f3f6fb,#cfd9e8); font-weight:700; }
.calc-key.is-clear { color:#9a3f22; font-size:14px; }
.calc-key.is-equals { grid-column:1 / -1; border-color:#203480; background:linear-gradient(#5875e6,#2448df); color:#fff; }
.calc-key.is-pressed, .calc-key:active { box-shadow:inset 1px 1px #7c8a9d; translate:0 1px; }
@media (width<=1050px) { .calc-window { left:50%; } }
@media (width<=759px) {
  .os-window.app-window.calc-window { height:auto; }
  .calc-key { height:52px; }
}

/* ---------- Terminal ---------- */
.terminal-window { width:min(700px, 100vw - 40px); height:min(460px, 100dvh - 150px); top:130px; }
.terminal-window .app-body { background:#1d2735; }
.term-screen { flex:1; min-height:0; overflow:auto; padding:10px 12px 14px; color:#d9e3ef; font:12px/1.5 Consolas, "Cascadia Mono", Menlo, monospace; cursor:text; }
.term-out { margin:0; white-space:pre-wrap; overflow-wrap:anywhere; font:inherit; }
.term-out.is-error { color:#ffb199; }
.term-echo { color:#f5f8fc; }
.term-prompt { color:#9fe08f; font-weight:700; white-space:nowrap; }
.term-link { color:#9cc7ff; text-decoration:underline; }
.term-line { display:flex; align-items:baseline; gap:8px; }
.term-input { flex:1; min-width:0; padding:0; border:0; outline:0; background:transparent; color:#f5f8fc; font:inherit; caret-color:#f5d470; }
.term-line:focus-within .term-prompt { text-decoration:underline; text-underline-offset:3px; text-decoration-color:#f5d470; }
html[data-theme="dark"] .terminal-window .term-screen { filter:invert(1) hue-rotate(180deg); }
@media (width<=759px) { .term-screen { font-size:11px; } .term-input { font-size:16px; } }

/* ---------- Screensaver ---------- */
.screensaver { position:fixed; inset:0; z-index:99990; background:#070b13; cursor:none; animation:screensaver-in .6s ease; }
.screensaver-canvas { display:block; width:100%; height:100%; }
.screensaver-hint { position:absolute; left:50%; bottom:22px; transform:translate(-50%); margin:0; padding:6px 12px; border-radius:4px; background:#0b1220b0; color:#c8d4e6; font-size:12px; white-space:nowrap; animation:screensaver-hint 4s ease forwards; }
.screensaver.is-still .screensaver-hint { animation:none; opacity:.8; }
@keyframes screensaver-in { from { opacity:0; } }
@keyframes screensaver-hint { 0%, 70% { opacity:.85; } 100% { opacity:0; } }
html[data-motion="reduce"] .screensaver { animation:none; }
@media print { .screensaver { display:none !important; } }
