:root {
  --bg: #101311;
  --ink: #e8e4db;
  --muted: #b3aea3;
  --accent: #ef6a58;
  --line: rgba(232, 228, 219, 0.16);
  --chip: #1b201d;
  --font: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
  background: var(--bg);
  color: var(--ink);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  touch-action: manipulation;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  background:
    radial-gradient(900px 420px at 50% -80px, rgba(239, 106, 88, 0.14), transparent 60%),
    var(--bg);
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--accent);
  color: #1a0d0b;
}

a {
  color: inherit;
  text-underline-offset: 0.18em;
}

a:hover { color: var(--accent); }

.skip {
  position: absolute;
  left: 12px;
  top: 8px;
  transform: translateY(-140%);
  background: var(--ink);
  color: var(--bg);
  padding: 8px 12px;
  z-index: 5;
}

.skip:focus { transform: none; }

.js body { overflow: hidden; }

.frame {
  width: min(42rem, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
}

.js .frame {
  height: 100dvh;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: lowercase;
  color: var(--muted);
}

.brand, .where {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.7em;
}

.brand { color: var(--ink); }

.mark {
  width: 0.62em;
  height: 1.05em;
  background: var(--accent);
  display: inline-block;
  animation: blink 1.1s steps(1) infinite;
}

#clock {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  min-width: 3.4em;
  text-align: right;
  visibility: hidden;
}

#clock.is-set { visibility: visible; }

main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.shell { display: none; }

.js .shell {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.identity {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 14px;
  flex: none;
  padding: 16px 2px 0;
}

.identity .id { margin: 0; min-width: 0; }

.identity .id p,
.identity h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.35;
}

.identity .place {
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.portrait {
  flex: none;
  width: 72px;
  height: 72px;
  margin: 0;
}

.avatar {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.js .static {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: normal;
}

.static h1,
.missing h1 {
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 1.25rem 0 0.4rem;
}

.static h2 {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.4rem 0 0.35rem;
}

.static p,
.missing p { margin: 0.35rem 0; }

.static .identity { margin-top: 1.15rem; }

.static .identity h1 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0;
}

.static .identity .place { margin: 0.12rem 0 0; }

.log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 22px 2px 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 228, 219, 0.28) transparent;
}

.line,
.entry,
.out p { margin: 0; }

.line + .line,
.out p + p { margin-top: 0.15rem; }

.gap { margin-top: 0.85rem !important; }

.entry {
  margin-top: 1.05rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45em;
  align-items: baseline;
}

.ps { color: var(--muted); white-space: nowrap; }
.dollar { color: var(--accent); }

.out { margin-top: 0.45rem; }

.log a,
.missing a,
.static a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.log a:hover,
.log a:focus-visible,
.missing a:hover,
.missing a:focus-visible,
.static a:hover,
.static a:focus-visible {
  background: var(--accent);
  color: #1a0d0b;
  text-decoration: none;
}

.line .mark,
.out .mark,
.cmd .mark {
  width: 0.55em;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.12em;
}

.out p,
.out a,
.line,
.static p,
.entry span:last-child,
.cmd {
  overflow-wrap: anywhere;
}

.bullet { color: var(--accent); }

.out p.item + p.item,
.static p.item { margin-top: 0.55rem; }

.hint {
  margin-top: 0.9rem;
  color: var(--muted);
}

.out button.inline {
  appearance: none;
  font: inherit;
  font-size: inherit;
  line-height: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.out button.inline:hover,
.out button.inline:focus-visible {
  background: var(--accent);
  color: #1a0d0b;
  text-decoration: none;
}

.shortcuts {
  display: flex;
  flex-wrap: wrap;
  flex-shrink: 0;
  min-width: 0;
  gap: 8px;
  padding: 14px 0 2px;
  border-top: 1px solid var(--line);
}

.shortcuts button {
  appearance: none;
  font: inherit;
  font-size: 14px;
  line-height: 1;
  color: var(--ink);
  background: transparent;
  border: 1px solid rgba(239, 106, 88, 0.45);
  border-radius: 2px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px 0 10px;
  cursor: pointer;
  white-space: nowrap;
}

.shortcuts button::before {
  content: "> ";
  color: var(--accent);
}

.shortcuts button[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(239, 106, 88, 0.1);
  box-shadow: 0 0 16px rgba(239, 106, 88, 0.32);
}

.shortcuts button:hover,
.shortcuts button:focus-visible,
.shortcuts button:active,
.shortcuts button[aria-pressed="true"]:hover,
.shortcuts button[aria-pressed="true"]:focus-visible,
.shortcuts button[aria-pressed="true"]:active {
  color: #1a0d0b;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 18px rgba(239, 106, 88, 0.48);
}

.shortcuts button:hover::before,
.shortcuts button:focus-visible::before,
.shortcuts button:active::before,
.shortcuts button[aria-pressed="true"]:hover::before,
.shortcuts button[aria-pressed="true"]:focus-visible::before,
.shortcuts button[aria-pressed="true"]:active::before {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.missing { padding-top: 1.5rem; }

@keyframes blink {
  50% { opacity: 0; }
}

@media (max-width: 640px) {
  .shortcuts {
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    scrollbar-width: none;
  }

  .shortcuts::-webkit-scrollbar { display: none; }

  .shortcuts button { flex: none; font-size: 13px; padding: 0 10px 0 8px; }

  .shortcuts.can-scroll.at-start:not(.at-end) {
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 2.4rem), transparent);
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 2.4rem), transparent);
  }

  .shortcuts.can-scroll.at-end:not(.at-start) {
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 2.4rem, #000 100%);
    mask-image: linear-gradient(90deg, transparent, #000 2.4rem, #000 100%);
  }

  .shortcuts.can-scroll:not(.at-start):not(.at-end) {
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 2.4rem, #000 calc(100% - 2.4rem), transparent);
    mask-image: linear-gradient(90deg, transparent, #000 2.4rem, #000 calc(100% - 2.4rem), transparent);
  }

  .portrait { width: 64px; height: 64px; }
  .identity { gap: 10px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .mark { animation: none; }
}

@media (prefers-contrast: more) {
  :root {
    --muted: #ddd8ce;
    --line: rgba(232, 228, 219, 0.55);
    --accent: #ff8a78;
  }
}
