:root {
  --bg: #000;
  --fg: #e6e6e6;
  --dim: #8a8a8a;
  --line: #242424;
  --muted: #1c1c1c;
  --panel: 32px;
  --dash: 56px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --vvh: 100dvh;
}

* { box-sizing: border-box }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  overflow: hidden;
}
button, input { font: inherit; color: inherit; background: none; border: 0 }
button { cursor: pointer }
a { color: #d0d0d0 }
a:hover { color: #fff }
::selection { background: #333; color: #fff }

.boot {
  position: fixed; inset: 0; background: #000; z-index: 50;
  padding: 28px 18px;
  font-size: 13px; color: #cfcfcf;
  overflow: auto;
  display: flex; flex-direction: column; gap: 16px;
}
.boot pre { margin: 0; white-space: pre-wrap }
.boot__skip {
  align-self: flex-start;
  border: 1px solid #333;
  border-radius: 999px;
  padding: 8px 16px;
  color: #aaa;
  font: inherit;
  font-size: 12px;
  transition: border-color .2s ease, color .2s ease, transform .2s ease, background .2s ease;
}
.boot__skip:hover { border-color: #666; color: #fff; background: #0d0d0d; transform: translateY(-1px) }
.boot__skip:active { transform: translateY(0) scale(.97) }

.os {
  height: var(--vvh);
  display: grid;
  grid-template-rows: calc(var(--panel) + var(--safe-t)) 1fr auto;
}
.os.is-off { visibility: hidden }
[hidden] { display: none !important }

.panel {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: var(--safe-t) 12px 0;
  height: calc(var(--panel) + var(--safe-t));
  border-bottom: 1px solid #111;
  font-size: 12px;
  color: #c8c8c8;
  z-index: 30;
}
.panel__left { display: flex; align-items: center; gap: 8px }
.panel__act, .panel__app {
  padding: 4px 12px;
  border-radius: 999px;
  color: #c8c8c8;
  transition: background .18s ease, color .18s ease;
}
.panel__act:hover, .panel__app:hover { color: #fff; background: #141414 }
.panel__act:active, .panel__app:active { background: #1c1c1c }
.panel__clock { justify-self: center; letter-spacing: .04em }
.panel__tray { display: flex; gap: 12px; color: #8d8d8d; justify-self: end }

.desk {
  position: relative;
  min-height: 0;
  background: #000;
}

.overview {
  position: absolute;
  inset: calc(var(--panel) + var(--safe-t)) 0 var(--safe-b);
  background: #000;
  z-index: 25;
  padding: 28px 18px 80px;
  overflow: auto;
  animation: ov-in .22s cubic-bezier(.22,1,.36,1) both;
}
@keyframes ov-in {
  from { opacity: 0; transform: scale(.985) }
  to { opacity: 1; transform: none }
}
.overview__hint {
  margin: 0 0 18px;
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #666;
}
.overview__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 12px;
  max-width: 560px;
}
.overview__grid button {
  border: 1px solid #222;
  border-radius: 16px;
  padding: 18px 8px;
  font-size: 12px;
  color: #cfcfcf;
  transition: border-color .18s ease, background .18s ease, transform .22s cubic-bezier(.22,1,.36,1);
}
.overview__grid button:hover { border-color: #444; background: #0a0a0a; transform: translateY(-3px) }
.overview__grid button:active { transform: translateY(0) scale(.97) }
.overview__close {
  margin-top: 22px;
  padding: 8px 16px;
  border: 1px solid #1e1e1e;
  border-radius: 999px;
  color: #666;
  font-size: 12px;
  transition: color .18s ease, border-color .18s ease;
}
.overview__close:hover { color: #ccc; border-color: #444 }

.win {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,.8);
  min-width: 280px;
  min-height: 200px;
  animation: win-in .22s ease both;
}
@keyframes win-in {
  from { opacity: 0 }
  to { opacity: 1 }
}
.win.is-min { display: none }
.win.is-front { z-index: 8 }
.win--term {
  width: min(760px, calc(100% - 32px));
  height: min(78%, 680px);
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  z-index: 5;
}
.win--term.is-max {
  left: 16px; right: 16px; top: 12px; bottom: 12px;
  width: auto; height: auto;
  transform: none;
}
.win--files {
  width: min(420px, calc(100% - 32px));
  height: min(52%, 420px);
  left: 24px;
  top: 24px;
  z-index: 6;
}

.win__bar {
  flex: 0 0 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 14px;
  border-bottom: 1px solid var(--muted);
  font-size: 12px;
  color: #9a9a9a;
  user-select: none;
  cursor: grab;
  touch-action: none;
}
.win__btns { display: flex; gap: 8px }
.win__btns button {
  width: 22px; height: 22px;
  border: 1px solid #3a3a3a;
  border-radius: 50%;
  font-size: 11px;
  color: #888;
  display: grid;
  place-items: center;
  transition: color .16s ease, border-color .16s ease, background .16s ease, transform .16s ease;
}
.win__btns button:hover { color: #fff; border-color: #666; background: #141414; transform: scale(1.08) }
.win__btns button:active { transform: scale(.92) }

.term {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.term__out {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 18px 8px;
  font-size: 13px;
  line-height: 1.5;
  -webkit-overflow-scrolling: touch;
}
.term__out .err { color: #bdbdbd }
.term__out .dim { color: var(--dim) }
.term__out a { word-break: break-all }
.term__row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 18px calc(12px + var(--safe-b));
  border-top: 1px solid #111;
}
.ps1 { color: #fff; font-size: 13px; white-space: nowrap; flex: 0 0 auto }
#cmd {
  flex: 1;
  min-width: 0;
  outline: none;
  font-size: 16px;
  padding: 8px 0;
  caret-color: #e8e8e8;
}
.fetch {
  display: grid;
  gap: 16px;
  margin: 6px 0 18px;
  justify-items: start;
}
@media (min-width: 560px) {
  .fetch { grid-template-columns: auto 1fr; align-items: center; }
}
.fetch__mark {
  font-size: 22px;
  letter-spacing: .28em;
  color: #ddd;
  padding: 8px 0;
}
.fetch__info {
  margin: 0;
  text-align: left;
  font-size: 12.5px;
  color: #c8c8c8;
  line-height: 1.5;
  white-space: pre;
}
.line { margin: 2px 0 }
.line .p { color: #fff }

.files {
  flex: 1;
  overflow: auto;
  padding: 8px;
}
.files button {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  border-radius: 10px;
  font-size: 13px;
  transition: background .16s ease, padding-left .16s ease;
}
.files button:hover { background: #0f0f0f; padding-left: 16px }
.files .mark { color: #777; font-size: 11px }

.dash {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 8px calc(8px + var(--safe-b));
  z-index: 20;
}
.dash button {
  min-width: 52px;
  height: 44px;
  padding: 0 16px;
  border: 1px solid #333;
  border-radius: 999px;
  background: #0a0a0a;
  font-size: 11px;
  color: #cfcfcf;
  transition: border-color .18s ease, color .18s ease, background .18s ease, transform .22s cubic-bezier(.22,1,.36,1);
}
.dash button:hover { border-color: #555; color: #fff; background: #111; transform: translateY(-3px) }
.dash button:active { transform: translateY(0) scale(.95) }
.dash button.is-on { border-color: #666; color: #fff; background: #131313 }

.chips {
  display: none;
}

@media (max-width: 720px) {
  .panel__app { display: none }
  .panel__tray span:nth-child(1),
  .panel__tray span:nth-child(2) { display: none }

  .dash { display: none }

  .os {
    grid-template-rows: calc(var(--panel) + var(--safe-t)) 1fr auto auto;
  }

  .win--term,
  .win--term.is-max,
  .win--files {
    position: absolute;
    inset: 8px 0 0;
    width: auto; height: auto;
    left: 0; right: 0; top: 8px; bottom: 0;
    transform: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    min-height: 0;
  }
  .win__bar { cursor: default }
  .win__btns button[data-win="min"],
  .win__btns button[data-win="max"] { display: none }

  .ava { width: 120px; height: 120px }
  .term__out { padding: 14px 14px 6px; font-size: 12.5px }
  .term__row {
    padding: 6px 12px 8px;
    border-top: 1px solid #1a1a1a;
    background: #000;
  }
  .ps1 { font-size: 12px }
  #cmd { font-size: 16px; padding: 10px 0 }

  .chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 0 12px calc(10px + var(--safe-b));
    -webkit-overflow-scrolling: touch;
  }
  .chips button {
    flex: 0 0 auto;
    border: 1px solid #222;
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 12px;
    color: #cfcfcf;
    transition: border-color .16s ease, color .16s ease, background .16s ease, transform .16s ease;
  }
  .chips button:active { border-color: #555; color: #fff; background: #121212; transform: scale(.95) }

  .overview__grid { grid-template-columns: repeat(3, 1fr) }
}

@media (min-width: 721px) {
  #cmd { font-size: 13px; padding: 6px 0 }
  .term__row { border-top: 0; padding: 4px 18px 16px }
}

@media (prefers-reduced-motion: reduce) {
  .win, .overview { animation: none !important }
  .dash button, .overview__grid button, .files button,
  .win__btns button, .panel__act, .panel__app, .boot__skip,
  .chips button { transition: none !important }
}
