/* Circuit OS surfaces follow Glassy UI's dock, panel, menu and control patterns. */
body:has(.desktop-shell) {
  --os-ink: #24232a;
  --os-panel: rgba(246, 244, 239, .89);
  --os-glass: rgba(248, 244, 236, .32);
  --os-stroke: rgba(255, 255, 255, .58);
  --os-control: rgba(255, 255, 255, .42);
  --os-shadow: 0 20px 75px #130f2066, inset 0 1px 0 #fff6;
  --os-accent: #286be6;
}
body:has(.desktop-shell.os-dark) {
  --os-ink: #f3f3f8;
  --os-panel: rgba(36, 36, 46, .94);
  --os-glass: rgba(30, 32, 45, .57);
  --os-stroke: rgba(255, 255, 255, .25);
  --os-control: rgba(255, 255, 255, .11);
}
.desktop-shell:before { content: none; }
.desktop-space { filter: none; }
.desktop-space::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: #000;
  opacity: calc(1 - var(--desktop-brightness, 1));
}
.desktop-menu {
  position: relative;
  z-index: 100;
  height: 32px;
  gap: 4px;
  background: linear-gradient(#1e160c50, #1e160c28);
  border-color: #ffffff29;
  color: #fff;
  backdrop-filter: blur(12px) saturate(135%);
}
.desktop-menu > b { padding-inline: 7px; font-size: 11px; }
.desktop-menu > :is(button, a) {
  display: inline-grid;
  place-items: center;
  min-height: 26px;
  padding-inline: 8px;
  border-radius: 6px;
}
.desktop-menu > :is(button, a):hover, .desktop-menu > button[aria-expanded="true"] { background: #ffffff30; }
.desktop-menu > .desktop-clock { flex: 0 0 auto; margin-left: 0; }
.desktop-menu > .shop-link { margin-left: 0; }
.desktop-menu > button[data-app] { display: none; }
.desktop-menu > button[aria-label="Search apps"] { margin-left: auto; }
.desktop-icons { display: none; }
.desktop-dock {
  --dock-icon: clamp(34px, 3.3vw, 49px);
  gap: clamp(4px, .5vw, 9px);
  padding: 8px 12px 11px;
  bottom: 9px;
  border-radius: 23px;
  background: linear-gradient(155deg, #fff5, transparent 70%), var(--os-glass);
  border: 1px solid var(--os-stroke);
  backdrop-filter: blur(18px) saturate(150%);
  box-shadow: 0 9px 28px #1c142747, inset 0 1px 1px #fffa;
}
.desktop-dock button {
  width: var(--dock-icon);
  min-width: var(--dock-icon);
  height: var(--dock-icon);
  border: 0;
  border-radius: 23%;
}
.desktop-dock button img { width: 100%; height: 100%; }
.desktop-dock button:is(:hover,:focus-visible)::after {
  opacity: 1;
  background: var(--os-panel);
  color: var(--os-ink);
  border: 1px solid var(--os-stroke);
  border-radius: 8px;
}
.desktop-dock button[data-app="trash"] { margin-left: 8px; }
.os-window, .desktop-shell.os-dark .os-window, .launchpad, .os-control-centre,
.os-overview, .os-menu-panel {
  color: var(--os-ink);
  background: var(--os-panel);
  border: 1px solid var(--os-stroke);
  border-radius: 16px;
  backdrop-filter: blur(18px) saturate(145%);
  box-shadow: var(--os-shadow);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.os-window:not(.is-front) { box-shadow: 0 12px 36px #1a15283d; }
.os-window .window-header, .desktop-shell.os-dark .window-header {
  position: relative;
  gap: 8px;
  height: 40px;
  color: inherit;
  background: var(--os-control);
  border-bottom: 1px solid #8883;
}
.window-header strong { position: absolute; inset-inline: 84px; text-align: center; }
.window-header button { flex: 0 0 13px; height: 13px; }
.os-window:not(.is-front) .window-header button:not(:hover) { filter: saturate(.3); }
.os-window .window-body { height: calc(100% - 40px); scrollbar-width: thin; }
.window-body :is(input:not([type="range"],[type="color"],[type="checkbox"]), textarea, select),
.launchpad input {
  border: 1px solid var(--os-stroke);
  background: var(--os-control);
  color: var(--os-ink);
  border-radius: 10px;
}
.window-body :is(.os-action,.paint-tools button,.finder-sidebar button,.browser-shortcuts a),
.os-control-centre :is(.os-control-tiles button,.os-sound-actions button),
.os-overview button, .os-menu-panel button {
  border-radius: 10px;
  color: inherit;
}
.os-menu-panel { padding: 5px; }
.os-menu-panel button:is(:hover,:focus-visible), .finder-sidebar button.selected {
  color: white;
  background: var(--os-accent);
}
.os-control-centre :is(input[type="range"],input[type="checkbox"]), .window-body input[type="range"] {
  accent-color: var(--os-accent);
}
.os-control-tiles button[aria-pressed="true"] { outline: 2px solid var(--os-accent); }
.os-control-centre::backdrop, .launchpad::backdrop, .os-overview::backdrop { background: #16122039; }
@media (max-width: 760px) {
  .desktop-dock { bottom: max(8px, env(safe-area-inset-bottom)); overflow: auto hidden; }
  .desktop-menu { gap: 1px; padding-inline: 4px; }
  .desktop-menu > :is(a,button) { padding-inline: 5px; }
  .desktop-menu > .desktop-clock { display: none; }
  .desktop-menu > a { margin-left: 0; }
  .desktop-menu > button[aria-label="Search apps"] { display: inline-grid; }
}
@media (prefers-reduced-transparency: reduce) {
  body:has(.desktop-shell) { --os-panel: #f6f4ef; --os-glass: #e4ded4; }
  body:has(.desktop-shell.os-dark) { --os-panel: #24242e; --os-glass: #24242e; }
  .desktop-menu, .desktop-dock, .os-window, .os-menu-panel, .launchpad, .os-control-centre, .os-overview {
    backdrop-filter: none;
  }
  .desktop-menu { background: #29262b; }
}
@media (prefers-reduced-motion: reduce) {
  .desktop-dock button, .os-window, .launchpad, .os-control-centre, .os-overview { animation: none; transition: none; }
}
.browser-address { display: flex; gap: 8px; align-items: center; }
.browser-address input { flex: 1; min-width: 0; padding: 7px 10px; }
.browser-address-status:not(:empty) { padding: 4px 12px; }

.desktop-dock.uses-glassy-dock {
  background: none;
  border: 0;
  padding: 0;
  box-shadow: none;
  backdrop-filter: none;
}
.circuit-glass-dock {
  --lg-dock-icon-size: var(--dock-icon);
  --lg-dock-gap: clamp(3px, .48vw, 8px);
}
.desktop-dock .lg-dock-item {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  transform: none;
}
.desktop-dock .lg-dock-item::before,
.desktop-dock .lg-dock-item::after { display: none; }
.desktop-dock .lg-dock-item.app-running > .lg-dock-dot { opacity: 1; }
.desktop-dock .lg-dock-item img[src*="/apple/"] { object-fit: contain; }
.circuit-glass-controls { padding: 12px; display: grid; gap: 12px; margin-bottom: 12px; }
.circuit-glass-control {
  display: grid;
  grid-template-columns: minmax(88px,auto) minmax(0,1fr);
  align-items: center;
  gap: 14px;
}
.circuit-glass-control .lg-switch { justify-self: end; }
@media (max-width: 760px) {
  .desktop-dock.uses-glassy-dock { max-width: calc(100vw - 14px); }
  .desktop-dock .lg-dock-label { display: none; }
}

.desktop-menu > .shop-link { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }

.os-menu-panel{position:fixed;z-index:1000}.os-control-centre{background:linear-gradient(135deg,#ffffff45,transparent),var(--os-glass);backdrop-filter:blur(24px) saturate(145%);border:1px solid #ffffff70;box-shadow:0 18px 60px #10132145,inset 0 1px #ffffff75;border-radius:24px}.os-wallpapers button[aria-pressed=true]{outline:2px solid var(--os-accent);outline-offset:2px}
body:has(.desktop-shell),.desktop-shell,.os-control-centre,.os-menu-panel,.launchpad,.os-overview{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif}
.desktop-shell :is(button,input,select),.os-control-centre :is(button,input){font-family:inherit}
dialog.os-control-centre[open]{position:fixed;inset:40px 12px auto auto;z-index:12000;display:grid;gap:14px;padding:18px;margin:0;max-height:calc(100dvh - 56px);overflow:auto;width:min(360px,calc(100vw - 24px));box-sizing:border-box}
.os-control-centre[open]>*,.os-control-centre[open] .os-control-tiles{margin:0}.os-control-centre[open] .os-wallpapers{margin-bottom:12px}
.os-control-centre[open] .os-control-tiles button{min-height:54px}.os-control-centre button:focus-visible{outline:2px solid var(--os-accent)}
.os-about .os-links img{width:16px;height:16px;border-radius:4px;margin:0}.os-about .os-links a{gap:6px}.os-about .os-links{display:flex;flex-wrap:wrap;gap:8px}.os-about .os-links a{display:inline-flex;align-items:center;padding:7px 14px;background:var(--os-control);color:var(--os-ink);border:1px solid var(--os-stroke);border-radius:9px;box-shadow:0 1px 3px #0002;font-size:13px;font-weight:500}

/* Circuit OS only. The phone launcher shares the desktop icon set. */
.desktop-shell [hidden]{display:none!important}
.os-launcher{display:none}
.os-window{animation:none}
.window-header:active{cursor:grabbing}
.window-header:is(:hover,:focus-within)>button{color:#25232a}
.window-header>button:focus-visible{outline:2px solid var(--os-accent);outline-offset:3px}
.desktop-shell :focus-visible,.launchpad :focus-visible,.os-overview :focus-visible,.os-control-centre :focus-visible,.os-menu-panel :focus-visible{
 outline:2px solid #79abff;outline-offset:3px
}
.os-window,.launchpad,.os-control-centre,.os-overview,.os-menu-panel{color-scheme:light}
body:has(.desktop-shell.os-dark) :is(.os-window,.launchpad,.os-control-centre,.os-overview,.os-menu-panel){color-scheme:dark}
.os-fallback{padding:12px 20px;border:1px solid #ffffff55;border-radius:12px}
.os-fallback h2{font-size:17px}
.os-fallback ul{margin:8px 0 0;padding-left:20px}
.os-fallback a{display:block;text-decoration:underline;padding:4px 0}
::view-transition-old(root),::view-transition-new(root){animation-duration:180ms;animation-timing-function:ease-out}
@supports not (backdrop-filter: blur(1px)){
 body:has(.desktop-shell){--os-panel:#f6f4ef;--os-glass:#eae5df}
 body:has(.desktop-shell.os-dark){--os-panel:#24242e;--os-glass:#24242e}
 .desktop-menu{background:#222636}
}
@media(max-width:760px){
 .desktop-shell{min-height:100dvh;padding-top:env(safe-area-inset-top);overflow:hidden}
 .desktop-menu{height:48px;padding-inline:max(7px,env(safe-area-inset-left)) max(7px,env(safe-area-inset-right));gap:3px;overflow-x:auto;scrollbar-width:none}
 .desktop-menu>:is(button,a){flex:none;min-height:44px;padding-inline:8px;white-space:nowrap}
 .desktop-menu>button[aria-label="Search apps"]{margin-left:auto}
 .desktop-dock{display:none!important}
 .desktop-boot{gap:16px;padding:16px;text-align:center}
 .desktop-boot h1{font-size:36px}
 .desktop-boot p,.desktop-boot>a{font-size:15px}
 .desktop-boot button,.desktop-boot>a{min-height:44px;display:grid;place-items:center}
 .os-launcher{
  display:grid;grid-template-columns:repeat(4,minmax(0,1fr));align-content:start;gap:14px 6px;
  position:absolute;inset:calc(48px + env(safe-area-inset-top)) 0 0;
  padding:18px max(8px,env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left));
  overflow:auto;overscroll-behavior:contain
 }
 .os-launcher button{display:grid;justify-items:center;align-content:start;gap:6px;min-height:70px;border-radius:12px;padding:4px;color:white;font:600 12px/1.25 system-ui,sans-serif;text-shadow:0 1px 4px #090a23}
 .os-launcher button span{display:grid;place-items:center;width:48px;height:48px}
 .os-launcher img{width:100%;height:100%;object-fit:contain}
 .os-launcher:has(+.has-front-window){visibility:hidden}
 .window-space{inset:calc(48px + env(safe-area-inset-top)) 0 env(safe-area-inset-bottom)}
 .window-space .os-window:not(.is-front){display:none}
 .window-space .os-window.is-front{
  inset:4px 5px!important;width:calc(100% - 10px)!important;height:calc(100% - 8px)!important;
  min-width:0;min-height:0;max-width:none;max-height:none;resize:none
 }
 .window-space .os-window .window-header{height:48px;gap:3px;padding-inline:6px;cursor:default;touch-action:auto}
 .window-space .os-window .window-header>button{min-width:44px;height:44px;font-size:16px;color:inherit;background:var(--os-control)}
 .window-header strong{inset-inline:102px 8px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}
 .window-header [data-maximize]{display:none}
 .window-space .os-window .window-body{height:calc(100% - 48px);overscroll-behavior:contain}
 .os-window input:not([type=range],[type=color],[type=checkbox]),.os-window textarea,.launchpad input{font-size:16px}
 dialog.os-control-centre[open]{top:calc(52px + env(safe-area-inset-top));max-height:calc(100dvh - 64px - env(safe-area-inset-top) - env(safe-area-inset-bottom))}
}

@media(hover:hover) and (pointer:fine) and (prefers-reduced-motion:no-preference){
 .desktop-dock button img{scale:var(--os-dock-scale,1);transform-origin:center bottom;transition:scale .14s ease-out}
}

@media(max-width:760px){
 .window-space .os-window.is-front{box-sizing:border-box}
 .os-launcher button{background:#080d2870}
 .os-launcher button:active{background:#081334b8}
 .desktop-shell .finder-body{grid-template-columns:minmax(100px,33%) minmax(0,1fr)}
 .desktop-shell .browser-address{flex-wrap:wrap}
}
@media(max-width:760px){
 .desktop-shell{min-height:0;box-sizing:border-box}
 .desktop-space{height:100%}
}
@media(max-width:760px){
 .desktop-shell{padding-top:0}
 .desktop-space{position:absolute;inset:env(safe-area-inset-top) 0 0;height:auto;min-height:0}
 .window-space,.os-launcher{top:48px;height:auto}
 .window-space .os-window.is-front{width:auto!important;height:auto!important}
}
