/**
 * Interfejs pulpitu, terminala i okna przeglądarki BARCOO.
 */

:root {
  color-scheme: dark;
  --desktop-fallback: #151821;
  --window-border: rgba(255, 255, 255, 0.20);
  --window-border-active: rgba(255, 255, 255, 0.48);
  --chrome: rgba(28, 31, 38, 0.96);
  --chrome-2: rgba(19, 21, 26, 0.97);
  --terminal: rgba(8, 10, 13, 0.95);
  --text: #f3f5f7;
  --muted: #98a2ad;
  --accent: #80cbc4;
  --accent-strong: #a7ffeb;
  --error: #ff8a80;
  --success: #b9f6ca;
  --warning: #ffe082;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.48), 0 4px 16px rgba(0, 0, 0, 0.32);
  --titlebar-height: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--desktop-fallback);
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

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

.desktop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  background-color: var(--desktop-fallback);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

.desktop::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 50% 30%, transparent 0 30%, rgba(0,0,0,.13) 70%, rgba(0,0,0,.36) 100%),
    linear-gradient(180deg, rgba(255,255,255,.025), rgba(0,0,0,.12));
  pointer-events: none;
}

.desktop::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: .055;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.72'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.desktop-icons {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.desktop-icon {
  width: 82px;
  padding: 7px 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: white;
  background: transparent;
  cursor: grab;
  display: grid;
  justify-items: center;
  gap: 6px;
  text-shadow: 0 1px 5px rgba(0,0,0,.82);
  touch-action: none;
  pointer-events: auto;
  position: absolute;
  left: 0;
  top: 0;
  user-select: none;
  will-change: left, top;
}

.desktop-icon.is-dragging {
  cursor: grabbing;
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.28);
}

.desktop-icon:hover,
.desktop-icon:focus-visible {
  border-color: rgba(255,255,255,.22);
  background: rgba(255,255,255,.09);
  outline: none;
}

.desktop-icon:active { background: rgba(255,255,255,.15); }

.browser-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: rgba(235, 244, 248, .96);
  background: linear-gradient(155deg, rgba(39, 48, 58, .96), rgba(14, 18, 23, .94));
  border: 1px solid rgba(255,255,255,.20);
  box-shadow: 0 8px 24px rgba(0,0,0,.32), inset 0 1px 0 rgba(255,255,255,.12);
}

.browser-icon svg { width: 34px; height: 34px; }

.desktop-icon-label {
  max-width: 78px;
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}

.wallpaper-switch {
  position: fixed;
  top: max(14px, calc(var(--safe-top) + 10px));
  right: max(14px, calc(var(--safe-right) + 10px));
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255,255,255,.26);
  border-radius: 50%;
  color: rgba(255,255,255,.88);
  background: rgba(10,12,16,.42);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 26px rgba(0,0,0,.16);
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
  z-index: 4;
  touch-action: manipulation;
}

.wallpaper-switch:hover,
.wallpaper-switch:focus-visible {
  background: rgba(10,12,16,.68);
  border-color: rgba(255,255,255,.52);
  outline: none;
}

.wallpaper-switch:active { transform: scale(.94); }
.wallpaper-switch svg { width: 18px; height: 18px; }

.window {
  position: absolute;
  left: 50%;
  top: 50%;
  min-width: 300px;
  min-height: 260px;
  max-width: calc(100vw - 8px);
  max-height: calc(100vh - 8px);
  transform: translate(-50%, -50%);
  border: 1px solid var(--window-border);
  border-radius: 11px;
  overflow: hidden;
  background: var(--terminal);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.15);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
  user-select: none;
  z-index: 10;
  transition: border-color .15s ease, box-shadow .15s ease, opacity .15s ease;
  contain: layout paint;
}

.window[hidden] { display: none !important; }

.window.is-active {
  border-color: var(--window-border-active);
  box-shadow: 0 29px 92px rgba(0, 0, 0, 0.56), 0 5px 19px rgba(0, 0, 0, 0.37);
}

.window:not(.is-active) { opacity: .965; }
.window.is-moving, .window.is-resizing { transition: none; }

.terminal-window {
  width: min(860px, calc(100vw - 48px));
  height: min(540px, calc(100vh - 64px));
}

.browser-window {
  left: 5vw;
  top: 7vh;
  transform: none;
  width: 70vw;
  height: 70vh;
  min-width: 360px;
  min-height: 300px;
  background: #e8eaed;
}

.titlebar {
  height: var(--titlebar-height);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 10px 0 12px;
  background: linear-gradient(180deg, rgba(39,42,50,.99), rgba(24,27,33,.99));
  border-bottom: 1px solid rgba(255,255,255,.10);
  cursor: grab;
  touch-action: none;
}

.titlebar:active { cursor: grabbing; }

.window-mark {
  justify-self: start;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.38);
  background: rgba(255,255,255,.10);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.18);
}

.window-title {
  justify-self: center;
  max-width: min(62vw, 520px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .012em;
  color: rgba(255,255,255,.88);
  pointer-events: none;
}

.window-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 7px;
}

.window-lock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.42);
  pointer-events: none;
}

.window-lock svg { width: 12px; height: 12px; }

.window-control {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: rgba(255,255,255,.72);
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.window-control:hover,
.window-control:focus-visible {
  color: white;
  background: rgba(255,255,255,.12);
  outline: none;
}

.window-control.close:hover,
.window-control.close:focus-visible { background: #c42b1c; }
.window-control svg { width: 15px; height: 15px; }

.terminal {
  position: absolute;
  inset: var(--titlebar-height) 0 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background:
    linear-gradient(rgba(255,255,255,.015) 1px, transparent 1px) 0 0 / 100% 3px,
    var(--terminal);
  cursor: text;
  user-select: text;
}

.terminal-output {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 22px 24px 6px;
  scrollbar-color: rgba(255,255,255,.22) transparent;
  scrollbar-width: thin;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.terminal-output::-webkit-scrollbar { width: 10px; }
.terminal-output::-webkit-scrollbar-track { background: transparent; }
.terminal-output::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.19);
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}

.line, .command-row, .input-row, .info-row {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: clamp(12px, 1.45vw, 14px);
  line-height: 1.62;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.line { color: var(--text); }
.line + .line { margin-top: 2px; }
.line.system { color: var(--muted); }
.line.accent { color: var(--accent-strong); }
.line.error { color: var(--error); }
.line.success { color: var(--success); }
.line.warning { color: var(--warning); }
.line.blank { min-height: .7em; }
.line.trace-row {
  min-width: max-content;
  white-space: pre;
  overflow-wrap: normal;
}

.info-row {
  display: grid;
  grid-template-columns: minmax(118px, 29%) 1fr;
  gap: 12px;
  color: var(--text);
}

.info-label { color: var(--muted); }
.info-value { min-width: 0; }

.terminal-link {
  color: var(--accent-strong);
  text-decoration: none;
  border-bottom: 1px dotted rgba(167,255,235,.58);
}

.terminal-link:hover,
.terminal-link:focus-visible {
  color: white;
  border-bottom-color: white;
  outline: none;
}

.command-row {
  display: flex;
  gap: .6ch;
  margin-top: 12px;
  color: var(--text);
}

.prompt {
  flex: 0 0 auto;
  color: var(--accent);
  font-weight: 600;
}

.input-shell {
  flex: 0 0 auto;
  padding: 2px 24px calc(20px + var(--safe-bottom));
}

.input-row {
  display: flex;
  align-items: flex-start;
  gap: .6ch;
  min-height: 24px;
}

#commandInput {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  outline: 0;
  color: var(--text);
  caret-color: var(--accent-strong);
  background: transparent;
  font: inherit;
  line-height: inherit;
  appearance: none;
  -webkit-appearance: none;
}

#commandInput:disabled { opacity: .55; }

#commandInput::selection,
.terminal-output ::selection {
  color: HighlightText;
  background: Highlight;
}

.browser-shell {
  position: absolute;
  inset: var(--titlebar-height) 0 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #e8eaed;
}

.browser-toolbar {
  flex: 0 0 auto;
  height: 46px;
  padding: 7px 9px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  background: #f1f3f4;
  border-bottom: 1px solid #cfd3d7;
  color: #303134;
  user-select: none;
}

.browser-toolbar-button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: #4f555b;
  cursor: pointer;
  touch-action: manipulation;
}

.browser-toolbar-button:hover,
.browser-toolbar-button:focus-visible {
  background: rgba(60,64,67,.10);
  outline: none;
}

.browser-toolbar-button svg { width: 17px; height: 17px; }

.address-bar {
  min-width: 0;
  height: 32px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 17px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #3c4043;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(60,64,67,.08);
  font-size: 13px;
}

.address-bar svg { flex: 0 0 auto; width: 14px; height: 14px; color: #5f6368; }
.address-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.browser-content {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: white;
}

.browser-content iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: white;
  touch-action: auto;
}

.activation-shield {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  cursor: default;
  background: transparent;
}

.browser-window:not(.is-active) .activation-shield { display: block; }

.iframe-note {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 2;
  transform: translateX(-50%);
  max-width: calc(100% - 28px);
  padding: 8px 11px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.35;
  color: #303134;
  background: rgba(255,255,255,.92);
  box-shadow: 0 4px 18px rgba(0,0,0,.18);
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}

.browser-content.is-loading .iframe-note { opacity: 1; }

.resize-handle {
  position: absolute;
  z-index: 8;
  touch-action: none;
}
.resize-handle[data-dir="n"] { top: -3px; left: 12px; right: 12px; height: 10px; cursor: ns-resize; }
.resize-handle[data-dir="s"] { bottom: -3px; left: 12px; right: 12px; height: 12px; cursor: ns-resize; }
.resize-handle[data-dir="e"] { top: 12px; right: -3px; bottom: 12px; width: 12px; cursor: ew-resize; }
.resize-handle[data-dir="w"] { top: 12px; left: -3px; bottom: 12px; width: 12px; cursor: ew-resize; }
.resize-handle[data-dir="ne"] { top: -3px; right: -3px; width: 18px; height: 18px; cursor: nesw-resize; }
.resize-handle[data-dir="nw"] { top: -3px; left: -3px; width: 18px; height: 18px; cursor: nwse-resize; }
.resize-handle[data-dir="se"] { right: -3px; bottom: -3px; width: 30px; height: 30px; cursor: nwse-resize; }
.resize-handle[data-dir="sw"] { left: -3px; bottom: -3px; width: 18px; height: 18px; cursor: nesw-resize; }

.resize-handle[data-dir="se"]::after {
  content: "";
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 10px;
  height: 10px;
  opacity: .38;
  border-right: 1px solid white;
  border-bottom: 1px solid white;
  box-shadow: 3px 3px 0 -2px rgba(255,255,255,.65);
  pointer-events: none;
}

.browser-window .resize-handle[data-dir="se"]::after {
  border-color: #4f555b;
  box-shadow: 3px 3px 0 -2px rgba(79,85,91,.65);
}

.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;
}

@media (max-width: 640px) {
  :root { --titlebar-height: 42px; }

  .desktop-icon { width: 72px; }
  .browser-icon { width: 44px; height: 44px; }
  .browser-icon svg { width: 34px; height: 34px; }

  .terminal-window {
    width: calc(100vw - 20px);
    height: min(72svh, 620px);
    min-width: 280px;
    min-height: 240px;
  }

  .browser-window {
    left: 6px;
    top: max(8px, var(--safe-top));
    transform: none;
    width: calc(100vw - 12px);
    height: min(80svh, 760px);
    min-width: 280px;
    min-height: 280px;
  }

  .window {
    max-width: calc(100vw - 8px);
    max-height: calc(100svh - 8px);
    border-radius: 9px;
  }

  .terminal-output { padding: 18px 16px 4px; }
  .input-shell { padding: 2px 16px calc(16px + var(--safe-bottom)); }
  .window-lock span { display: none; }
  .wallpaper-switch { width: 36px; height: 36px; }
  .browser-toolbar { grid-template-columns: auto minmax(0, 1fr) auto; padding-inline: 6px; gap: 5px; }
  .address-bar { padding-inline: 10px; font-size: 12px; }
  .info-row { grid-template-columns: 105px 1fr; gap: 8px; }
}

@media (max-width: 380px) {
  .browser-toolbar-button { width: 28px; height: 28px; }
  .address-bar { height: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

/* Okno mapy OpenStreetMap */
.map-window {
  left: auto;
  right: 4vw;
  top: 18vh;
  transform: none;
  width: min(460px, calc(100vw - 24px));
  height: min(360px, calc(100vh - 24px));
  min-width: 300px;
  min-height: 260px;
  background: #e8eaed;
}

.map-shell {
  position: absolute;
  inset: var(--titlebar-height) 0 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #e8eaed;
  color: #303134;
}

.map-content {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #dfe5e8;
}

.map-content iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #dfe5e8;
  touch-action: auto;
}

.map-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #3c4043;
  background: linear-gradient(145deg, #eef2f4, #d9e0e4);
  font: 600 13px/1.45 Inter, ui-sans-serif, system-ui, sans-serif;
  text-align: center;
  transition: opacity .2s ease, visibility .2s ease;
}

.map-content:not(.is-loading) .map-loading {
  opacity: 0;
  visibility: hidden;
}

.map-status {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid #cfd3d7;
  background: #f1f3f4;
  color: #4f555b;
  font-size: 11px;
  line-height: 1.3;
}

.map-status span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-status a {
  flex: 0 0 auto;
  color: #245c74;
  text-decoration: none;
  font-weight: 600;
}

.map-status a:hover,
.map-status a:focus-visible {
  text-decoration: underline;
  outline: none;
}

.map-window:not(.is-active) .activation-shield { display: block; }

/* Pasek postępu komendy detect */
.progress-row {
  margin: 8px 0 4px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: clamp(12px, 1.45vw, 14px);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
  color: var(--muted);
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  background: rgba(255,255,255,.055);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transition: width .22s ease;
}

.progress-row.is-complete .progress-meta { color: var(--success); }
.progress-row.is-error .progress-meta { color: var(--error); }

@media (max-width: 640px) {
  .map-window {
    left: 6px;
    right: auto;
    top: max(12px, calc(var(--safe-top) + 8px));
    width: calc(100vw - 12px);
    height: min(58svh, 520px);
    min-width: 280px;
    min-height: 260px;
  }

  .map-status {
    min-height: 46px;
    align-items: flex-start;
  }

  .map-status span {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}

/* Menu kontekstowe pulpitu i terminala */
.context-menu {
  position: fixed;
  z-index: 10000;
  width: min(260px, calc(100vw - 16px));
  padding: 7px;
  border: 1px solid rgba(255,255,255,.20);
  border-radius: 10px;
  color: #f4f7f8;
  background: rgba(28,31,38,.98);
  box-shadow: 0 18px 54px rgba(0,0,0,.54), inset 0 1px 0 rgba(255,255,255,.06);
  backdrop-filter: blur(22px) saturate(1.18);
  -webkit-backdrop-filter: blur(22px) saturate(1.18);
  user-select: none;
  touch-action: manipulation;
}

.context-menu[hidden] { display: none !important; }

.context-menu-heading {
  padding: 8px 10px 7px;
  color: rgba(255,255,255,.48);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .035em;
}

.context-menu-items {
  display: grid;
  gap: 2px;
}

.context-menu-item {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  color: inherit;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  line-height: 1.25;
}

.context-menu-item:hover,
.context-menu-item:focus-visible {
  outline: none;
  background: rgba(255,255,255,.105);
}

.context-menu-item:active { background: rgba(255,255,255,.16); }
.context-menu-item svg { width: 17px; height: 17px; color: var(--accent); }
.context-menu-shortcut { color: rgba(255,255,255,.35); font-size: 10px; }

.desktop-toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, calc(var(--safe-bottom) + 16px));
  z-index: 10001;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 24px));
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 9px;
  color: #f4f7f8;
  background: rgba(23,26,32,.94);
  box-shadow: 0 12px 36px rgba(0,0,0,.4);
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
}

.desktop-toast[hidden] { display: none !important; }

/* Okno pogody Open-Meteo */
.weather-window {
  left: auto;
  right: 2.2vw;
  top: 4vh;
  transform: none;
  width: min(680px, calc(100vw - 24px));
  height: min(760px, calc(100vh - 24px));
  min-width: 360px;
  min-height: 360px;
  background: #101722;
}

.weather-shell {
  position: absolute;
  inset: var(--titlebar-height) 0 0;
  min-height: 0;
  overflow: hidden;
  color: #edf4f7;
  background:
    radial-gradient(circle at 88% 3%, rgba(99,196,210,.18), transparent 33%),
    radial-gradient(circle at 8% 22%, rgba(89,117,224,.16), transparent 29%),
    linear-gradient(158deg, #172331 0%, #101720 48%, #0d141c 100%);
}

.weather-scroll {
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.22) transparent;
  overscroll-behavior: contain;
  touch-action: pan-y;
  user-select: text;
}

.weather-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.weather-scroll::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(255,255,255,.20);
  background-clip: padding-box;
}

.weather-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  padding: 28px;
  color: rgba(240,248,250,.92);
  background:
    radial-gradient(circle at 50% 42%, rgba(111,205,220,.17), transparent 32%),
    linear-gradient(158deg, #172331, #0d141c);
  text-align: center;
  transition: opacity .22s ease, visibility .22s ease;
}

.weather-loading-symbol {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 24px;
  color: #9fe6ee;
  background: rgba(255,255,255,.05);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 18px 46px rgba(0,0,0,.22);
  font-size: 42px;
  animation: weather-float 1.8s ease-in-out infinite;
}

.weather-loading strong { font-size: 15px; }
.weather-loading small { max-width: 390px; color: rgba(255,255,255,.54); line-height: 1.45; }
.weather-shell:not(.is-loading) .weather-loading { opacity: 0; visibility: hidden; }
.weather-shell.is-error .weather-loading-symbol { color: #ffb4ab; animation: none; }

@keyframes weather-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.weather-hero {
  position: relative;
  overflow: hidden;
  min-height: 190px;
  padding: 22px;
  border: 1px solid rgba(255,255,255,.115);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(81,168,190,.24), rgba(65,92,154,.16) 55%, rgba(255,255,255,.04)),
    rgba(255,255,255,.035);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), 0 18px 48px rgba(0,0,0,.16);
}

.weather-hero::after {
  content: "";
  position: absolute;
  right: -58px;
  top: -74px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(174,238,243,.21), transparent 66%);
  pointer-events: none;
}

.weather-place {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.weather-place-name {
  min-width: 0;
  font-size: clamp(18px, 3vw, 27px);
  font-weight: 760;
  letter-spacing: -.025em;
}

.weather-place-meta {
  margin-top: 4px;
  color: rgba(237,244,247,.57);
  font-size: 11px;
  line-height: 1.45;
}

.weather-updated {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 999px;
  color: rgba(237,244,247,.58);
  background: rgba(5,10,15,.18);
  font-size: 10px;
}

.weather-now {
  position: relative;
  z-index: 1;
  margin-top: 18px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.weather-main-symbol {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 12px 20px rgba(0,0,0,.22));
  font-family: "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  font-size: 58px;
  line-height: 1;
}

.weather-temperature {
  font-size: clamp(48px, 8vw, 72px);
  font-weight: 270;
  line-height: .92;
  letter-spacing: -.07em;
}

.weather-condition {
  margin-top: 8px;
  color: rgba(237,244,247,.82);
  font-size: 14px;
  font-weight: 650;
}

.weather-feels {
  margin-top: 4px;
  color: rgba(237,244,247,.52);
  font-size: 11px;
}

.weather-today-range {
  display: grid;
  gap: 5px;
  min-width: 108px;
  padding-left: 16px;
  border-left: 1px solid rgba(255,255,255,.11);
  color: rgba(237,244,247,.68);
  font-size: 11px;
}

.weather-today-range strong { color: #fff; font-size: 15px; }

.weather-section { margin-top: 16px; }
.weather-section-title {
  margin: 0 0 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: rgba(237,244,247,.68);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .085em;
  text-transform: uppercase;
}
.weather-section-title small { color: rgba(237,244,247,.34); font-size: 9px; font-weight: 600; letter-spacing: .04em; }

.weather-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.weather-metric {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.085);
  border-radius: 13px;
  background: rgba(255,255,255,.035);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035);
}

.weather-metric-label {
  overflow: hidden;
  color: rgba(237,244,247,.48);
  font-size: 10px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weather-metric-value {
  margin-top: 7px;
  color: #f5fbfc;
  font-size: 17px;
  font-weight: 710;
  letter-spacing: -.025em;
}

.weather-metric-note {
  margin-top: 3px;
  min-height: 13px;
  color: rgba(237,244,247,.37);
  font-size: 9px;
  line-height: 1.3;
}

.weather-panel {
  padding: 15px;
  border: 1px solid rgba(255,255,255,.085);
  border-radius: 15px;
  background: rgba(255,255,255,.03);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}

.weather-temperature-chart {
  height: 88px;
  margin: 2px 0 11px;
  overflow: hidden;
}

.weather-temperature-chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.weather-chart-grid { stroke: rgba(255,255,255,.07); stroke-width: 1; }
.weather-chart-line { fill: none; stroke: #8ce3eb; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.weather-chart-area { fill: url(#weatherChartGradient); opacity: .38; }
.weather-chart-dot { fill: #d7fbff; stroke: #16242d; stroke-width: 1.5; }
.weather-chart-label { fill: rgba(237,244,247,.5); font: 8px Inter, ui-sans-serif, sans-serif; }

.weather-hourly {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(74px, 1fr);
  gap: 7px;
  overflow-x: auto;
  padding: 2px 1px 7px;
  scrollbar-width: thin;
  touch-action: pan-x;
}

.weather-hour-card {
  padding: 9px 7px;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 11px;
  background: rgba(255,255,255,.025);
  text-align: center;
}

.weather-hour-time { color: rgba(237,244,247,.47); font-size: 9px; }
.weather-hour-icon { margin: 7px 0 5px; font: 23px/1 "Apple Color Emoji", "Segoe UI Emoji", sans-serif; }
.weather-hour-temp { font-size: 14px; font-weight: 730; }
.weather-hour-rain { margin-top: 5px; color: #83d8ec; font-size: 9px; }

.weather-days { display: grid; gap: 7px; }
.weather-day {
  min-height: 51px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 86px 34px minmax(90px, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(255,255,255,.055);
  border-radius: 11px;
  background: rgba(255,255,255,.022);
}
.weather-day-name { font-size: 11px; font-weight: 650; }
.weather-day-date { margin-top: 2px; color: rgba(237,244,247,.38); font-size: 9px; }
.weather-day-icon { font: 24px/1 "Apple Color Emoji", "Segoe UI Emoji", sans-serif; text-align: center; }
.weather-day-details { min-width: 0; color: rgba(237,244,247,.51); font-size: 9px; line-height: 1.45; }
.weather-day-temp { display: flex; gap: 8px; font-size: 13px; white-space: nowrap; }
.weather-day-temp strong { color: #fff; }
.weather-day-temp span { color: rgba(237,244,247,.44); }

.weather-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.weather-detail-list { display: grid; gap: 8px; }
.weather-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(255,255,255,.055);
  color: rgba(237,244,247,.51);
  font-size: 10px;
}
.weather-detail-row:last-child { padding-bottom: 0; border-bottom: 0; }
.weather-detail-row strong { color: rgba(247,252,253,.92); font-size: 11px; text-align: right; }

.air-quality-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  padding: 6px 9px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
  background: rgba(255,255,255,.035);
  font-size: 10px;
}
.air-quality-dot { width: 8px; height: 8px; border-radius: 50%; background: #91e6b1; box-shadow: 0 0 12px currentColor; }
.air-quality-badge.is-fair .air-quality-dot { background: #e5dd75; }
.air-quality-badge.is-moderate .air-quality-dot { background: #f3b45d; }
.air-quality-badge.is-poor .air-quality-dot { background: #ef7c6e; }
.air-quality-badge.is-very-poor .air-quality-dot { background: #c983df; }
.air-quality-badge.is-extreme .air-quality-dot { background: #9b4b5c; }

.weather-attribution {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: rgba(237,244,247,.33);
  font-size: 9px;
  line-height: 1.4;
}
.weather-attribution a { color: rgba(158,225,233,.68); text-decoration: none; }
.weather-attribution a:hover, .weather-attribution a:focus-visible { color: white; text-decoration: underline; outline: none; }

.weather-error-card {
  max-width: 480px;
  margin: 40px auto;
  padding: 22px;
  border: 1px solid rgba(255,138,128,.24);
  border-radius: 15px;
  color: rgba(255,255,255,.78);
  background: rgba(255,138,128,.07);
  line-height: 1.55;
  text-align: center;
}
.weather-error-card strong { display: block; margin-bottom: 7px; color: #ffb4ab; }

@media (max-width: 760px) {
  .weather-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .weather-detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .context-menu { width: min(250px, calc(100vw - 12px)); }

  .weather-window {
    left: 6px;
    right: auto;
    top: max(8px, var(--safe-top));
    width: calc(100vw - 12px);
    height: min(88svh, 820px);
    min-width: 280px;
    min-height: 340px;
  }

  .weather-scroll { padding: 13px; }
  .weather-hero { min-height: 178px; padding: 17px; border-radius: 15px; }
  .weather-now { grid-template-columns: 62px minmax(0, 1fr); gap: 12px; }
  .weather-main-symbol { width: 60px; height: 60px; font-size: 47px; }
  .weather-temperature { font-size: 52px; }
  .weather-today-range { grid-column: 1 / -1; grid-template-columns: repeat(3, 1fr); padding: 10px 0 0; border-left: 0; border-top: 1px solid rgba(255,255,255,.11); }
  .weather-day { grid-template-columns: 70px 30px minmax(70px, 1fr) auto; gap: 7px; padding-inline: 8px; }
  .weather-day-details { overflow: hidden; text-overflow: ellipsis; }
  .weather-attribution { flex-direction: column; gap: 4px; }
}

@media (max-width: 390px) {
  .weather-metrics { gap: 7px; }
  .weather-metric { padding: 10px; }
  .weather-day { grid-template-columns: 62px 28px minmax(52px, 1fr) auto; }
  .weather-day-details { font-size: 8px; }
  .weather-day-temp { gap: 5px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .weather-loading-symbol { animation: none; }
}

/* v9 — dodatkowe ikony pulpitu, zaznaczanie terminala i Sudoku */
.desktop-app-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: rgba(241, 249, 251, .96);
  border: 1px solid rgba(255,255,255,.20);
  box-shadow: 0 8px 24px rgba(0,0,0,.32), inset 0 1px 0 rgba(255,255,255,.13);
}
.desktop-app-icon svg { width: 36px; height: 36px; }
.weather-desktop-symbol {
  color: #e9fbff;
  background: linear-gradient(150deg, rgba(39, 105, 130, .96), rgba(21, 42, 67, .96));
}
.sudoku-desktop-symbol {
  color: #edf6ff;
  background: linear-gradient(150deg, rgba(76, 73, 126, .97), rgba(28, 30, 55, .97));
}

.terminal,
.terminal-output,
.terminal-output * {
  -webkit-user-select: text;
  user-select: text;
}
.terminal-output {
  cursor: text;
  -webkit-touch-callout: default;
}
.input-shell,
.input-shell * {
  -webkit-user-select: text;
  user-select: text;
}

.sudoku-window {
  left: 52%;
  top: 50%;
  width: min(560px, calc(100vw - 28px));
  height: min(720px, calc(100vh - 28px));
  min-width: 320px;
  min-height: 470px;
  background: rgba(12, 15, 22, .97);
}
.sudoku-shell {
  position: absolute;
  inset: var(--titlebar-height) 0 0;
  min-height: 0;
  padding: clamp(10px, 2.2vh, 18px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  color: #eef4f7;
  background:
    radial-gradient(circle at 15% 0%, rgba(93, 116, 182, .16), transparent 35%),
    linear-gradient(180deg, rgba(23,27,38,.99), rgba(11,13,19,.99));
  user-select: none;
  touch-action: pan-y;
}
.sudoku-toolbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 9px;
  align-items: end;
}
.sudoku-level-label {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: rgba(238,244,247,.58);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.sudoku-level-label select,
.sudoku-action,
.sudoku-check {
  min-height: 36px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 9px;
  color: #eef6f9;
  background: rgba(255,255,255,.055);
  outline: none;
  touch-action: manipulation;
}
.sudoku-level-label select {
  width: 100%;
  padding: 0 30px 0 10px;
  cursor: pointer;
}
.sudoku-level-label select:focus,
.sudoku-action:focus-visible,
.sudoku-check:focus-visible {
  border-color: rgba(139, 222, 232, .65);
  box-shadow: 0 0 0 3px rgba(128,203,196,.13);
}
.sudoku-action,
.sudoku-check {
  padding: 0 13px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}
.sudoku-action:hover,
.sudoku-check:hover { background: rgba(255,255,255,.10); }
.sudoku-timer {
  min-width: 68px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 9px;
  color: #a7ffeb;
  background: rgba(0,0,0,.20);
  font: 700 14px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.sudoku-game-area {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(250px, 1fr) 48px;
  gap: 11px;
  align-items: center;
  justify-content: center;
}
.sudoku-board {
  width: min(100%, calc(100vh - 190px));
  max-width: 540px;
  aspect-ratio: 1;
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  overflow: hidden;
  border: 2px solid rgba(225,241,247,.72);
  border-radius: 8px;
  background: rgba(4, 7, 12, .86);
  box-shadow: 0 18px 48px rgba(0,0,0,.28);
  touch-action: manipulation;
}
.sudoku-cell {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid rgba(225,241,247,.16);
  border-bottom: 1px solid rgba(225,241,247,.16);
  display: grid;
  place-items: center;
  color: #a9f3fa;
  background: rgba(255,255,255,.015);
  cursor: pointer;
  font: 650 clamp(15px, 3.5vmin, 29px)/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  transition: background .1s ease, color .1s ease;
  touch-action: manipulation;
}
.sudoku-cell:nth-child(3n) { border-right-color: rgba(225,241,247,.52); }
.sudoku-cell:nth-child(9n) { border-right: 0; }
.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) { border-bottom-color: rgba(225,241,247,.52); }
.sudoku-cell:nth-child(n+73) { border-bottom: 0; }
.sudoku-cell.is-given {
  color: #f4f7f8;
  background: rgba(255,255,255,.055);
  font-weight: 780;
}
.sudoku-cell.is-related { background: rgba(103, 177, 197, .075); }
.sudoku-cell.is-same-number { background: rgba(128, 203, 196, .15); }
.sudoku-cell.is-selected {
  color: #071014;
  background: #9be7ef;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.55);
}
.sudoku-cell.is-invalid {
  color: #ffb4ab;
  background: rgba(255, 86, 76, .16);
}
.sudoku-cell:focus-visible {
  position: relative;
  z-index: 2;
  outline: 2px solid #fff;
  outline-offset: -2px;
}
.sudoku-keypad {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.sudoku-keypad button {
  width: 46px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 9px;
  color: #dff8fb;
  background: rgba(255,255,255,.055);
  cursor: pointer;
  font: 700 16px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  touch-action: manipulation;
}
.sudoku-keypad button:hover,
.sudoku-keypad button:focus-visible {
  background: rgba(128,203,196,.17);
  border-color: rgba(128,203,196,.42);
  outline: none;
}
.sudoku-keypad .sudoku-erase { color: #ffd3ce; }
.sudoku-footer {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}
.sudoku-status {
  min-width: 0;
  color: rgba(238,244,247,.64);
  font-size: 11px;
  line-height: 1.4;
}
.sudoku-status.is-success { color: #b9f6ca; }
.sudoku-status.is-error { color: #ffb4ab; }

@media (max-width: 640px) {
  .desktop-app-icon { width: 44px; height: 44px; }
  .desktop-app-icon svg { width: 33px; height: 33px; }
  .sudoku-window {
    left: 6px;
    top: max(8px, var(--safe-top));
    transform: none;
    width: calc(100vw - 12px);
    height: min(92svh, 760px);
    min-width: 280px;
    min-height: 450px;
  }
  .sudoku-shell { padding: 10px; gap: 9px; }
  .sudoku-toolbar { grid-template-columns: minmax(0, 1fr) auto; }
  .sudoku-timer { grid-column: 2; grid-row: 1; align-self: start; }
  .sudoku-action { grid-column: 2; grid-row: 1; margin-top: 42px; }
  .sudoku-game-area {
    grid-template-columns: 1fr;
    align-content: center;
  }
  .sudoku-board { width: min(100%, calc(100svh - 275px)); }
  .sudoku-keypad {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
  }
  .sudoku-keypad button { width: auto; height: 39px; }
  .sudoku-footer { grid-template-columns: 1fr; gap: 7px; }
  .sudoku-check { width: 100%; }
}

@media (max-width: 380px) {
  .sudoku-cell { font-size: 17px; }
  .sudoku-board { width: min(100%, calc(100svh - 300px)); }
}
.sudoku-board-loading {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  display: grid;
  place-items: center;
  padding: 24px;
  color: rgba(238,244,247,.62);
  font-size: 12px;
  text-align: center;
}
