:root {
  color-scheme: dark;
  --bg: #17130f;
  --paper: #211c17;
  --panel: #2a241e;
  --panel-2: #332b24;
  --ink: #f1e7d2;
  --muted: #a99b82;
  --line: #5a4b3b;
  --line-soft: #3d342b;
  --bronze: #b88755;
  --gold: #d1b06f;
  --wine: #6f2732;
  --moss: #596948;
  --blue: #6f8292;
  --shadow: rgba(0, 0, 0, 0.38);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

.shell {
  min-height: 100dvh;
  padding: 0;
  background:
    linear-gradient(135deg, rgba(209, 176, 111, 0.07), transparent 32%),
    linear-gradient(315deg, rgba(111, 39, 50, 0.13), transparent 44%),
    var(--bg);
}

.terminal {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 100%;
  height: 100dvh;
  margin: 0 auto;
  border: 0;
  border-radius: 0;
  background: var(--paper);
  box-shadow: 0 22px 68px var(--shadow);
  overflow: hidden;
}

.terminal::before,
.terminal::after {
  content: "";
  position: absolute;
  z-index: 1;
  width: 112px;
  height: 112px;
  pointer-events: none;
  opacity: 0.24;
  background:
    linear-gradient(45deg, transparent 46%, var(--bronze) 48%, transparent 50%),
    linear-gradient(-45deg, transparent 46%, var(--bronze) 48%, transparent 50%);
}

@media (max-width: 760px) {
  .terminal::before,
  .terminal::after {
    display: none;
  }
}

.terminal::before {
  top: 14px;
  right: 14px;
}

.terminal::after {
  left: 14px;
  bottom: 14px;
  transform: rotate(180deg);
}

.topbar,
.status {
  position: relative;
  z-index: 2;
  display: grid;
  align-items: center;
  min-height: 46px;
  background: linear-gradient(180deg, #2b241d, #211b16);
}

.topbar {
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
}

.traffic {
  display: none;
  align-items: center;
}

.crest {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border: 1px solid var(--bronze);
  border-radius: 50%;
  color: var(--gold);
  background: #1a1511;
  font-size: 12px;
  font-weight: 700;
}

.dot {
  display: none;
}

.promptline {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--ink);
  font-size: 13px;
}

.promptline .muted {
  color: var(--muted);
}

.promptline .at {
  color: var(--bronze);
  padding: 0 5px;
}

.promptline .path {
  color: var(--gold);
  margin-left: 12px;
  margin-right: 8px;
}

.net {
  display: none;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.top-actions::-webkit-scrollbar {
  display: none;
}

.share-button {
  min-height: 34px;
  padding: 0 10px;
  border-color: #9c754d;
  background: #423124;
  color: var(--gold);
  white-space: nowrap;
}

.share-button[hidden] {
  display: none;
}

.mode-button {
  min-height: 34px;
  padding: 0 9px;
  border-color: var(--line-soft);
  background: #2b2119;
  color: var(--ink);
  white-space: nowrap;
}

.mode-button[hidden] {
  display: none;
}

.desktop {
  position: relative;
  z-index: 2;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
}

.pane {
  display: none;
  min-width: 0;
  border-right: 1px solid var(--line-soft);
  background:
    linear-gradient(180deg, rgba(184, 135, 85, 0.08), transparent 42%),
    #1c1713;
  padding: 14px;
  overflow: auto;
}

.pane-title {
  color: var(--gold);
  font-size: 12px;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.topic-list {
  display: grid;
  gap: 7px;
}

.topic-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  padding: 9px;
  text-align: left;
  cursor: pointer;
}

.topic-item:hover,
.topic-item.active {
  border-color: var(--line);
  background: #29221c;
}

.topic-item strong {
  color: var(--ink);
  font-weight: 700;
}

.topic-item small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.editor-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  background:
    linear-gradient(rgba(241, 231, 210, 0.035) 50%, transparent 50%),
    #18140f;
  background-size: 100% 34px;
}

.editor-wrap::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(184, 135, 85, 0.2);
  border-radius: 8px;
  pointer-events: none;
}

#editor {
  position: absolute;
  inset: 0;
  z-index: 5;
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  border: 0;
  outline: 0;
  padding: 16px;
  color: var(--ink);
  background:
    linear-gradient(rgba(241, 231, 210, 0.035) 50%, transparent 50%),
    #18140f;
  background-size: 100% 34px;
  caret-color: var(--gold);
  line-height: 1.62;
  font-size: 14px;
  tab-size: 2;
}

#editor[hidden] {
  display: none;
}

#editor[readonly] {
  caret-color: transparent;
}

.boot {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  background: rgba(23, 19, 15, 0.94);
  padding: 14px;
}

.boot[hidden] {
  display: none;
}

.login {
  width: min(430px, calc(100vw - 28px));
  display: grid;
  gap: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(209, 176, 111, 0.06), transparent 48%),
    var(--panel);
  padding: 16px;
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.3);
}

.brand {
  display: flex;
  gap: 13px;
  align-items: center;
  margin-bottom: 4px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--bronze);
  border-radius: 50%;
  color: var(--gold);
  background: #19130f;
  font-weight: 700;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #17120e;
  color: var(--ink);
  outline: 0;
  padding: 11px 12px;
  font-size: 16px;
}

input:focus {
  border-color: var(--bronze);
  box-shadow: 0 0 0 2px rgba(184, 135, 85, 0.16);
}

button {
  min-height: 40px;
  border: 1px solid #8b6845;
  border-radius: 7px;
  background: #3b2c20;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
}

button:hover {
  background: #463425;
}

.command {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 6;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #17120e;
  color: var(--gold);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.command[hidden] {
  display: none;
}

.command input {
  border: 0;
  background: transparent;
  padding: 8px 0;
  color: var(--ink);
  box-shadow: none;
}

.share-view {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #18140f;
}

.share-view[hidden] {
  display: none;
}

.share-meta {
  border-bottom: 1px solid var(--line-soft);
  color: var(--gold);
  padding: 13px 18px;
}

.share-view pre {
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  padding: 20px;
  line-height: 1.62;
}

.normal-desktop,
.nerd-shell {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.normal-desktop[hidden],
.nerd-shell[hidden] {
  display: none;
}

.normal-desktop {
  overflow: hidden;
  background: #1b1611;
}

.normal-desktop[data-wallpaper="walnut"] {
  background:
    linear-gradient(135deg, rgba(209, 176, 111, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(111, 39, 50, 0.12), transparent 48%),
    #1b1611;
}

.normal-desktop[data-wallpaper="moss"] {
  background:
    linear-gradient(135deg, rgba(142, 151, 105, 0.16), transparent 34%),
    linear-gradient(315deg, rgba(65, 79, 51, 0.42), transparent 48%),
    #151a12;
}

.normal-desktop[data-wallpaper="wine"] {
  background:
    linear-gradient(135deg, rgba(177, 112, 94, 0.16), transparent 34%),
    linear-gradient(315deg, rgba(76, 23, 34, 0.5), transparent 48%),
    #1d1113;
}

.normal-desktop[data-wallpaper="blue"] {
  background:
    linear-gradient(135deg, rgba(127, 148, 160, 0.18), transparent 34%),
    linear-gradient(315deg, rgba(41, 55, 68, 0.5), transparent 48%),
    #11171b;
}

.desktop-canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}

.file-icon {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 7px;
  width: 76px;
  min-height: 86px;
  padding: 8px 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: center;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.file-icon:hover,
.file-icon.selected {
  border-color: rgba(209, 176, 111, 0.4);
  background: rgba(31, 24, 18, 0.72);
}

.file-icon span:last-child {
  max-width: 76px;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.2;
}

.file-paper {
  display: grid;
  place-items: center;
  width: 42px;
  height: 52px;
  border: 1px solid rgba(209, 176, 111, 0.6);
  border-radius: 5px;
  background: linear-gradient(180deg, #3a2b20, #241b15);
  color: var(--gold);
  font-size: 11px;
}

.file-window {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 4;
  display: grid;
  grid-template-rows: auto 1fr;
  width: calc(100% - 16px);
  height: calc(100% - 16px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #18140f;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.38);
  overflow: hidden;
}

.file-window[hidden] {
  display: none;
}

.file-window-top {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  min-height: 78px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
  background: #2a2119;
}

.file-window-top strong {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.file-window-top div {
  display: flex;
  gap: 8px;
  width: 100%;
}

.file-window-top button {
  flex: 1;
  min-height: 30px;
  padding: 0 10px;
}

#desktopEditor {
  width: 100%;
  height: 100%;
  resize: none;
  border: 0;
  outline: 0;
  padding: 16px;
  background: #17120e;
  color: var(--ink);
  line-height: 1.58;
}

.nerd-shell {
  display: grid;
  grid-template-rows: 1fr auto auto;
  background: #070908;
  color: #d9f5d6;
}

.terminal-output {
  overflow: auto;
  padding: 13px;
  white-space: pre-wrap;
  line-height: 1.55;
}

.terminal-output div {
  min-height: 1.35em;
}

.terminal-form {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 4px;
  min-height: 64px;
  padding: 7px 12px;
  border-top: 1px solid #223226;
  background: #0b100d;
}

.terminal-actions {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 7px 10px;
  border-top: 1px solid #172219;
  background: #090d0b;
  scrollbar-width: none;
}

.terminal-actions::-webkit-scrollbar {
  display: none;
}

.terminal-actions button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 10px;
  border-color: #253827;
  background: #101a13;
  color: #b7e9ad;
}

#terminalPrompt {
  color: #8ccf7a;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#terminalInput {
  border: 0;
  background: transparent;
  color: #e9ffe3;
  padding: 9px 0;
  box-shadow: none;
}

.context-menu {
  position: fixed;
  z-index: 20;
  display: grid;
  width: min(210px, calc(100vw - 16px));
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #211a14;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.42);
}

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

.context-menu button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 0 9px;
}

.context-menu button:hover {
  background: #33271f;
}

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

.status {
  grid-template-columns: auto auto auto;
  gap: 12px;
  padding: 7px 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

#mode {
  color: var(--gold);
}

#dirty {
  color: #d8a46a;
}

#message {
  grid-column: 1 / -1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: left;
}

@media (min-width: 761px) {
  .shell {
    min-height: 100vh;
    padding: 18px;
  }

  .terminal {
    width: min(1180px, 100%);
    height: calc(100vh - 36px);
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .topbar {
    grid-template-columns: auto 1fr auto;
    gap: 14px;
    padding: 0 16px;
  }

  .traffic {
    display: flex;
  }

  .promptline {
    font-size: 14px;
  }

  .net {
    display: block;
  }

  .top-actions {
    justify-content: flex-end;
    gap: 10px;
  }

  .share-button {
    min-height: 32px;
    padding: 0 12px;
  }

  .mode-button {
    min-height: 32px;
    padding: 0 11px;
  }

  .desktop {
    grid-template-columns: 230px 1fr;
  }

  .pane {
    display: block;
  }

  .editor-wrap::before {
    inset: 12px;
  }

  #editor {
    padding: 24px;
    font-size: 15px;
  }

  .boot {
    padding: 18px;
  }

  .file-window {
    left: min(120px, 8vw);
    top: min(80px, 8vh);
    width: min(720px, calc(100% - 34px));
    height: min(520px, calc(100% - 34px));
  }

  .file-window-top {
    align-items: center;
    flex-direction: row;
    min-height: 42px;
    padding: 0 12px;
  }

  .file-window-top div {
    width: auto;
  }

  .file-window-top button {
    flex: 0 0 auto;
  }

  .terminal-output {
    padding: 16px 18px;
  }

  .terminal-form {
    grid-template-columns: auto 1fr;
    gap: 8px;
    min-height: 42px;
    padding: 0 14px;
  }

  .terminal-actions {
    padding: 8px 14px;
  }

  #terminalPrompt {
    max-width: 260px;
  }

  .status {
    grid-template-columns: auto auto auto 1fr;
    padding: 0 16px;
    font-size: 12px;
  }

  #message {
    grid-column: auto;
    text-align: right;
  }
}
