/* SPDX-License-Identifier: Apache-2.0 */
/* Bun OS shell: Material 3 Expressive roles from /m3.css, no framework. */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}
body {
  font: 14px / 1.45 var(--md-ref-typeface-plain, "Google Sans Flex", Roboto, system-ui, sans-serif);
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface);
  display: grid;
  grid-template-rows: 44px 1fr;
  -webkit-font-smoothing: antialiased;
}
button,
input,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: 0;
  background: none;
}
:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}
.mi {
  display: inline-grid;
  place-items: center;
  width: 1.25em;
  height: 1.25em;
  font-size: 20px;
  flex: none;
  line-height: 1;
  user-select: none;
}
.material-symbols-rounded {
  font-family: "Material Symbols Rounded";
  font-weight: 400;
  font-style: normal;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  direction: ltr;
  font-feature-settings: "liga";
  -webkit-font-feature-settings: "liga";
  font-variation-settings:
    "FILL" 1,
    "wght" 400,
    "GRAD" 0,
    "opsz" 24;
}
.grow {
  flex: 1;
  min-width: 0;
}
.mono {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}
.muted {
  color: var(--md-sys-color-on-surface-variant);
}

/* Wallpaper */
.desk {
  position: relative;
  overflow: hidden;
  grid-row: 2;
  background:
    radial-gradient(
      900px 600px at 15% 10%,
      color-mix(in srgb, var(--md-sys-color-primary) 28%, transparent),
      transparent 70%
    ),
    radial-gradient(
      800px 600px at 90% 85%,
      color-mix(in srgb, var(--md-sys-color-tertiary) 26%, transparent),
      transparent 70%
    ),
    radial-gradient(
      700px 500px at 80% 10%,
      color-mix(in srgb, var(--md-sys-color-secondary) 18%, transparent),
      transparent 70%
    ),
    var(--md-sys-color-surface-container-low);
}

/* Top bar */
.topbar {
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: color-mix(in srgb, var(--md-sys-color-surface-container) 88%, transparent);
  backdrop-filter: blur(18px);
  z-index: 1000;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--md-sys-shape-corner-full);
}
.brand:hover,
.tbtn:hover {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}
.clock {
  font-variant-numeric: tabular-nums;
  padding: 0 8px;
  color: var(--md-sys-color-on-surface-variant);
}
.tbtn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--md-sys-shape-corner-full);
  flex: none;
}

/* Desktop icons */
.icons {
  position: absolute;
  inset: 12px auto auto 12px;
  display: grid;
  gap: 8px;
  grid-auto-flow: row;
}
.dicon {
  display: grid;
  justify-items: center;
  gap: 6px;
  width: 88px;
  padding: 10px 4px;
  border-radius: var(--md-sys-shape-corner-large);
  font-size: 12px;
  text-shadow: 0 1px 2px color-mix(in srgb, var(--md-sys-color-surface) 80%, transparent);
}
.dicon:hover {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 10%, transparent);
}
.licon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--md-sys-shape-corner-large-increased, 20px);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}
.licon .mi {
  font-size: 26px;
}

/* Dock */
.dock {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  max-width: calc(100vw - 16px);
  overflow-x: auto;
  background: color-mix(in srgb, var(--md-sys-color-surface-container-high) 86%, transparent);
  backdrop-filter: blur(22px);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-extra-large);
  box-shadow: 0 8px 28px rgb(0 0 0 / 0.22);
}
.dbtn {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--md-sys-shape-corner-large);
  flex: none;
  transition:
    transform var(--md-sys-motion-duration-short4, 200ms) cubic-bezier(0.2, 1.4, 0.4, 1),
    background-color 120ms;
}
.dbtn .mi {
  font-size: 24px;
}
.dbtn:hover {
  background: var(--md-sys-color-secondary-container);
  transform: translateY(-4px) scale(1.08);
}
.dbtn.launch {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-radius: var(--md-sys-shape-corner-extra-large);
}
.dbtn.running::after {
  content: "";
  position: absolute;
  bottom: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--md-sys-color-primary);
}
.dbtn.current {
  background: var(--md-sys-color-secondary-container);
}
.dsep {
  width: 1px;
  height: 28px;
  background: var(--md-sys-color-outline-variant);
  margin: 0 2px;
}

/* Windows */
.win {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 320px;
  min-height: 220px;
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-extra-large);
  overflow: hidden;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.18);
  animation: pop var(--md-sys-motion-duration-medium2, 300ms) cubic-bezier(0.2, 1.2, 0.3, 1);
}
.win.active {
  box-shadow: 0 16px 48px rgb(0 0 0 / 0.34);
  border-color: var(--md-sys-color-outline);
}
.win[hidden] {
  display: none;
}
.win.maximized {
  inset: 0 0 82px 0 !important;
  width: auto !important;
  height: auto !important;
  border-radius: 0;
  border-width: 0;
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(10px);
  }
}
.win-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 14px;
  background: var(--md-sys-color-surface-container);
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.win-title {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.win-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--md-sys-shape-corner-full);
}
.win-btn:hover {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 10%, transparent);
}
.win-btn.close:hover {
  background: var(--md-sys-color-error);
  color: var(--md-sys-color-on-error);
}
.win-body {
  flex: 1;
  min-height: 0;
  position: relative;
}
.win-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  touch-action: none;
}
.fill {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.appframe {
  border: 0;
  width: 100%;
  flex: 1;
  background: #fff;
}
.empty {
  padding: 24px;
  color: var(--md-sys-color-on-surface-variant);
  text-align: center;
}

/* Shared controls */
.fld {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--md-sys-shape-corner-full);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-highest);
  min-width: 0;
}
.fld:focus {
  outline: 2px solid var(--md-sys-color-primary);
  border-color: transparent;
}
.btn.wide {
  width: 100%;
  margin: 8px 0;
}
.chip {
  height: 32px;
  padding: 0 14px;
  border-radius: var(--md-sys-shape-corner-small);
  border: 1px solid var(--md-sys-color-outline);
}
.chip:hover {
  background: var(--md-sys-color-secondary-container);
}
.seg {
  display: inline-flex;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-full);
  overflow: hidden;
  margin: 8px 12px;
  align-self: flex-start;
}
.segb {
  height: 34px;
  padding: 0 16px;
}
.segb[aria-selected="true"] {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-weight: 600;
}
.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* Files */
.files,
.browser,
.store,
.engine,
.editor-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.files-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.files-main {
  display: flex;
  flex: 1;
  min-height: 0;
}
.places {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  width: 150px;
  border-right: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-low);
}
.place {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--md-sys-shape-corner-full);
  text-align: left;
}
.place:hover {
  background: var(--md-sys-color-secondary-container);
}
.files-list {
  flex: 1;
  overflow: auto;
  padding: 6px;
}
.frow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--md-sys-shape-corner-medium);
}
.frow:hover {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 6%, transparent);
}
.frow.sel {
  background: var(--md-sys-color-secondary-container);
}
.fname {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fsize {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.files-status {
  padding: 6px 14px;
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
  border-top: 1px solid var(--md-sys-color-outline-variant);
}
.editor {
  flex: 1;
  border: 0;
  resize: none;
  padding: 14px;
  background: var(--md-sys-color-surface);
  font:
    13px/1.5 ui-monospace,
    "Cascadia Code",
    Consolas,
    monospace;
  tab-size: 2;
  outline: none;
  min-height: 0;
}
.engine .editor {
  flex: 1.2;
}
.engine-out {
  flex: 1;
  margin: 0;
  padding: 12px 14px;
  overflow: auto;
  background: var(--md-sys-color-surface-container-lowest, var(--md-sys-color-surface-container-low));
  border-top: 1px solid var(--md-sys-color-outline-variant);
  font:
    12.5px/1.5 ui-monospace,
    Consolas,
    monospace;
  white-space: pre-wrap;
}
.err {
  color: var(--md-sys-color-error);
}

/* Terminal */
.term {
  flex: 1;
  position: relative;
  background: #11111b;
  color: #e6e1e9;
  overflow: hidden;
  padding: 8px 10px;
}
.term-screen {
  margin: 0;
  font:
    14px/1.2 ui-monospace,
    "Cascadia Code",
    Consolas,
    monospace;
  white-space: pre;
}
.term-sink {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  padding: 0;
}
.term-probe {
  position: absolute;
  visibility: hidden;
  font:
    14px/1.2 ui-monospace,
    "Cascadia Code",
    Consolas,
    monospace;
}

/* Browser */
.btabs {
  display: flex;
  gap: 4px;
  padding: 6px 8px 0;
  background: var(--md-sys-color-surface-container);
  overflow-x: auto;
  align-items: center;
}
.btab {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 200px;
  min-width: 100px;
  padding: 6px 6px 6px 14px;
  border-radius: var(--md-sys-shape-corner-medium) var(--md-sys-shape-corner-medium) 0 0;
  cursor: pointer;
}
.btab[aria-selected="true"] {
  background: var(--md-sys-color-surface);
  font-weight: 500;
}
.btab-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btab-x {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
}
.btab-x:hover {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 14%, transparent);
}
.bviews {
  flex: 1;
  position: relative;
  min-height: 0;
}
.bview {
  position: absolute;
  inset: 0;
  display: flex;
}
.bview[hidden] {
  display: none;
}
.bframe {
  border: 0;
  flex: 1;
  width: 100%;
  background: #fff;
}
.bhome {
  margin: auto;
  max-width: 520px;
  padding: 24px;
  text-align: center;
}
.bhome h2 {
  font-size: 32px;
  font-weight: 500;
  margin: 0 0 8px;
}
.bmarks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}

/* Store */
.store-list {
  flex: 1;
  overflow: auto;
  padding: 8px 12px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-content: start;
}
.scard {
  padding: 14px;
  border-radius: var(--md-sys-shape-corner-large);
  background: var(--md-sys-color-surface-container);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sname {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.sdesc {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sact {
  display: flex;
  gap: 6px;
  margin-top: auto;
  padding-top: 6px;
  flex-wrap: wrap;
}
.store-list .btn.wide {
  grid-column: 1 / -1;
}

/* Details */
.detail {
  padding: 24px;
  overflow: auto;
  flex: 1;
}
.detail h2 {
  font-size: 28px;
  font-weight: 500;
  margin: 0 0 8px;
}
.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 20px;
  margin: 16px 0 0;
}
.kv dt {
  color: var(--md-sys-color-on-surface-variant);
}
.kv dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.swatches {
  display: flex;
  gap: 10px;
  margin: 8px 0 16px;
  flex-wrap: wrap;
}
.swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--md-sys-color-surface);
  box-shadow: 0 0 0 1px var(--md-sys-color-outline);
}

/* Launcher */
.launcher {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: start center;
  padding: 10vh 16px 16px;
  background: color-mix(in srgb, var(--md-sys-color-scrim, #000) 45%, transparent);
  backdrop-filter: blur(10px);
}
.launcher[hidden] {
  display: none;
}
.lbox {
  width: min(880px, 100%);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: var(--md-sys-shape-corner-extra-large);
  background: var(--md-sys-color-surface-container-high);
  box-shadow: 0 24px 64px rgb(0 0 0 / 0.4);
  animation: pop 260ms cubic-bezier(0.2, 1.2, 0.3, 1);
}
.lsearch {
  height: 52px;
  padding: 0 22px;
  border-radius: var(--md-sys-shape-corner-full);
  border: 0;
  background: var(--md-sys-color-surface-container-highest);
  font-size: 18px;
}
.lgrid {
  overflow: auto;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
}
.ltile {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 6px;
  padding: 12px 6px;
  border-radius: var(--md-sys-shape-corner-large);
  text-align: center;
  min-height: 110px;
}
.ltile:hover,
.ltile:focus-visible {
  background: var(--md-sys-color-secondary-container);
}
.lname {
  font-weight: 500;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.lsub {
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 720px) {
  .places {
    display: none;
  }
  .icons {
    grid-template-columns: repeat(3, 1fr);
    right: 12px;
  }
  .win-resize {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Launcher sections, packages, inspector */
.lhead {
  margin: 10px 4px 0;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 600;
}
.lsection {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
}
.lgrid {
  display: block;
}
.pkg-head {
  display: flex;
  gap: 12px;
  align-items: center;
}
.pkg-head .licon {
  width: 48px;
  height: 48px;
  font-weight: 700;
  font-size: 13px;
  flex: none;
}
.pkg-bar {
  width: 100%;
  height: 6px;
  accent-color: var(--md-sys-color-primary);
}
.pkg-status {
  font-size: 12px;
}
.ins-out {
  flex: 1;
  overflow: auto;
  padding: 12px 16px;
}
.ins-card {
  padding: 8px 12px;
  margin: 6px 0;
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface-container);
}
.ins-out .kv {
  margin: 0;
}
.ins-out dd {
  overflow-wrap: anywhere;
}
.store > .seg {
  flex: none;
}

/* Accessibility: forced-colors outline, 44px touch targets on coarse pointers, skip link. */
@media (forced-colors: active) {
  :focus-visible {
    outline-color: CanvasText;
  }
  .win {
    border-color: CanvasText;
  }
}
@media (pointer: coarse) {
  .tbtn,
  .win-btn,
  .btab-x,
  .fld,
  .btn,
  .segb {
    min-height: 44px;
    min-width: 44px;
  }
  .dbtn {
    width: 52px;
    height: 52px;
  }
}
.skip {
  position: fixed;
  left: 8px;
  top: -60px;
  z-index: 5000;
  padding: 10px 16px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}
.skip:focus {
  top: 8px;
}

md-linear-progress {
  width: 100%;
}
md-tabs {
  flex: none;
}
md-linear-progress[hidden] {
  display: none;
}

/* Workspaces and layout marker in the top bar (Omarchy-style) */
.wsbar {
  display: flex;
  gap: 2px;
  margin-left: 12px;
}
.ws {
  min-width: 24px;
  height: 24px;
  border-radius: var(--md-sys-shape-corner-full);
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
}
.ws.occ {
  color: var(--md-sys-color-on-surface);
  font-weight: 600;
}
.ws.cur {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}
.ws:hover:not(.cur) {
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 10%, transparent);
}
.tbtn.layout {
  font-size: 14px;
}
.win.tiled {
  transition:
    left 160ms,
    top 160ms,
    width 160ms,
    height 160ms;
  border-radius: var(--md-sys-shape-corner-large);
}
@media (max-width: 720px) {
  .wsbar {
    display: none;
  }
}

/* Calculator, activity, treemap, media */
.calc {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 12px;
  gap: 8px;
}
.calc-hist {
  min-height: 1.4em;
  text-align: right;
  font-size: 13px;
}
.calc-out {
  display: block;
  text-align: right;
  font-size: 36px;
  font-variant-numeric: tabular-nums;
  overflow-x: auto;
  padding: 4px 8px;
}
.calc-pad {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.calc-key {
  border-radius: var(--md-sys-shape-corner-large);
  background: var(--md-sys-color-surface-container-high);
  font-size: 20px;
  min-height: 48px;
}
.calc-key.op {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}
.calc-key:hover {
  filter: brightness(1.1);
}
.activity {
  padding: 16px;
  overflow: auto;
  flex: 1;
}
.act-table {
  width: 100%;
  border-collapse: collapse;
}
.act-table th,
.act-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.treemap {
  position: relative;
  flex: 1;
  margin: 8px;
}
.tm-cell {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid var(--md-sys-color-surface);
  border-radius: 8px;
  color: #fff;
  padding: 6px;
  text-align: left;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}
.tm-cell:hover {
  filter: brightness(1.25);
}
.media-stage {
  flex: 1;
  display: grid;
  place-items: center;
  background: #000;
  min-height: 0;
}
.media-stage video,
.media-stage img {
  max-width: 100%;
  max-height: 100%;
}
.media-stage audio {
  width: 90%;
}

.ficon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex: none;
}
.place .ficon {
  width: 22px;
  height: 22px;
}
.brand img {
  border-radius: 6px;
}
.pkg-head .licon img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.vm-stage {
  flex: 1;
  background: #000;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: auto;
}
.vm-screen {
  white-space: pre;
  font: 14px monospace;
  line-height: 1;
  color: #ccc;
}
.vm-screen > div {
  white-space: pre;
  font-family: monospace;
}
.vm-screen canvas {
  display: block;
  image-rendering: pixelated;
}
