.window {
    position: absolute; left: 0; top: 0; width: var(--w); height: var(--h);
    transform: translate3d(var(--x), var(--y), 0); transform-origin: 0 0;
    display: flex; flex-direction: column; min-width: 0;
    border-radius: 18px; overflow: hidden; background: var(--window); color: var(--fg);
    box-shadow: 0 0 0 .5px rgb(0 0 0 / 55%), inset 0 0 0 1px rgb(255 255 255 / 9%), 0 12px 34px rgb(0 0 0 / 34%);
    outline: none; container-type: size; will-change: transform; --side: 0px; --bar: 52px;
    transition: box-shadow .2s;
}
.window.is-focused { box-shadow: 0 0 0 .5px rgb(0 0 0 / 70%), inset 0 0 0 1px rgb(255 255 255 / 14%), 0 30px 80px rgb(0 0 0 / 60%), 0 8px 22px rgb(0 0 0 / 38%); }
.window.is-morphing { transition: transform .3s var(--ease), width .3s var(--ease), height .3s var(--ease); }
.window[data-mode='maximized'] { border-radius: 0; }

/* macOS 27 chrome: no title strip. Traffic lights, a bold title, and glass capsules float over the content. */
.window-bar { position: absolute; inset: 0 0 auto 0; z-index: 2; height: var(--bar); display: flex; align-items: center; gap: 12px; padding: 0 12px 0 20px; touch-action: none; }
.traffic { display: flex; gap: 9px; flex: none; width: 60px; }
.tl { width: 14px; height: 14px; border-radius: 50%; background: var(--fill-2); box-shadow: inset 0 0 0 .5px rgb(0 0 0 / 22%); position: relative; cursor: pointer; }
.tl::before { content: ''; position: absolute; inset: -6px -4px; }
.window.is-focused .tl-close, .traffic:hover .tl-close { background: #ff5f57; }
.window.is-focused .tl-min, .traffic:hover .tl-min { background: #febc2e; }
.window.is-focused .tl-zoom, .traffic:hover .tl-zoom { background: #28c840; }
.tl::after { content: ''; position: absolute; inset: 0; margin: auto; opacity: 0; background: rgb(0 0 0 / 55%); }
.traffic:hover .tl::after { opacity: 1; }
.tl-close::after { width: 8px; height: 8px; clip-path: polygon(10% 0, 50% 40%, 90% 0, 100% 10%, 60% 50%, 100% 90%, 90% 100%, 50% 60%, 10% 100%, 0 90%, 40% 50%, 0 10%); }
.tl-min::after { width: 8px; height: 1.800px; border-radius: 1px; }
.tl-zoom::after { width: 7px; height: 7px; clip-path: polygon(0 0, 70% 0, 0 70%, 0 0, 100% 30%, 100% 100%, 30% 100%, 100% 30%); }
.window-lead { display: flex; align-items: center; gap: 8px; flex: none; margin-left: max(0px, calc(var(--side) - 78px)); }
.window-lead:empty { margin-left: max(-12px, calc(var(--side) - 90px)); }
.window-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--fg-2); pointer-events: none; }
.window.is-focused .window-title { color: var(--fg); }
.window-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.window-done, .window-home { display: none; }
.window-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; padding-top: var(--bar); }
.window[data-chrome='sidebar'] .window-body { padding-top: 0; }
.window-shield { position: absolute; inset: var(--bar) 0 0; z-index: 3; }
.window.is-focused .window-shield { display: none; }
.is-dragging iframe { pointer-events: none; }
.window-error { padding: 28px; color: var(--fg-2); }

.grip { position: absolute; z-index: 4; touch-action: none; }
.grip-n, .grip-s { left: 20px; right: 20px; height: 7px; cursor: ns-resize; }
.grip-e, .grip-w { top: 20px; bottom: 20px; width: 7px; cursor: ew-resize; }
.grip-n { top: 0; } .grip-s { bottom: 0; } .grip-e { right: 0; } .grip-w { left: 0; }
.grip-ne, .grip-nw, .grip-se, .grip-sw { width: 24px; height: 24px; z-index: 5; }
.grip-nw { width: 15px; height: 15px; }
.grip-ne { top: 0; right: 0; cursor: nesw-resize; } .grip-sw { bottom: 0; left: 0; cursor: nesw-resize; }
.grip-nw { top: 0; left: 0; cursor: nwse-resize; } .grip-se { bottom: 0; right: 0; cursor: nwse-resize; }
.window[data-mode='maximized'] .grip { display: none; }

/* Toolbar controls: glass capsules, as in the macOS 27 Finder. */
.tool, .tool-group { height: 34px; border-radius: 17px; background: color-mix(in srgb, var(--fg) 8%, transparent); box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 rgb(255 255 255 / 8%); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.tool { min-width: 34px; padding: 0 11px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--fg-2); cursor: pointer; text-decoration: none; transition: background .15s, color .15s; }
.tool:hover { background: color-mix(in srgb, var(--fg) 15%, transparent); color: var(--fg); }
.tool:disabled { opacity: .4; pointer-events: none; }
.tool-round { padding: 0; width: 34px; }
.tool-round[aria-pressed='true'] { background: var(--accent); color: #fff; }
.tool-group { display: inline-flex; align-items: center; padding: 3px; gap: 1px; }
.tool-group .tool { height: 28px; min-width: 34px; padding: 0 9px; border-radius: 14px; background: none; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.tool-group .tool:hover { background: color-mix(in srgb, var(--fg) 10%, transparent); }
.tool-group .tool[aria-pressed='true'] { background: color-mix(in srgb, var(--fg) 18%, transparent); color: var(--fg); }
.tool-primary { background: var(--accent); color: #fff !important; box-shadow: none; }

/* Phone: every window is a full-screen app. */
:root[data-device='phone'] .window { inset: var(--menubar) 0 0 0; width: 100%; height: auto; transform: none; border-radius: 22px 22px 0 0; box-shadow: none; animation: app-open .38s var(--ease); --bar: 50px; }
@keyframes app-open { from { opacity: 0; transform: scale(.9); border-radius: 40px; } }
:root[data-device='phone'] .window-bar { padding: 0 10px 0 4px; gap: 6px; }
:root[data-device='phone'] .window-lead, :root[data-device='phone'] .window-lead:empty { margin-left: 0; }
:root[data-device='phone'] .traffic, :root[data-device='phone'] .grip, :root[data-device='phone'] .window-shield { display: none; }
:root[data-device='phone'] .window-done { display: inline-flex; align-items: center; gap: 0; height: 40px; padding: 0 8px 0 2px; color: var(--accent); font-size: 16px; cursor: pointer; flex: none; }
:root[data-device='phone'] .window-title { font-size: 16px; color: var(--fg); padding-right: 6px; }
:root[data-device='phone'] .window-body { padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
:root[data-device='phone'] .window-home { display: block; position: absolute; left: 0; right: 0; bottom: 0; height: calc(22px + env(safe-area-inset-bottom)); z-index: 6; cursor: pointer; background: var(--window); }
:root[data-device='phone'] .window-home::after { content: ''; position: absolute; left: 50%; top: 9px; width: 134px; height: 5px; border-radius: 3px; background: var(--fg); opacity: .85; transform: translateX(-50%); }
:root[data-device='phone'] .tool span { display: none; }
