:root {
  --desk-bg: #7b82a5;
  --frame: #bdb9ae;
  --frame-light: #ffffff;
  --frame-mid: #dcdad5;
  --frame-dark: #8b8b8b;
  --frame-deep: #5e5e5e;
  --title-bg: #6a5da8;
  --title-hi: #8e81cb;
  --title-lo: #4b3f7f;
  --title-fg: #ffffff;
  --term-bg: #ffffff;
  --term-fg: #000000;
  --term-dim: #3a3a3a;
  --link: #2f2a20;
  --rule: #8b8b8b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 1.1rem;
  color: var(--term-fg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 22%),
    var(--desk-bg);
  font-family: "Lucida Console", "Lucida Sans Typewriter", "Lucida Typewriter", "Nimbus Mono PS", monospace;
}

a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px dotted #4b4b4b;
}

a:hover,
a:focus-visible {
  outline: none;
  border-bottom-style: solid;
}

.terminal-window {
  position: relative;
  width: min(980px, 100%);
  margin: 0 auto;
  border: 2px solid var(--frame-deep);
  background: var(--frame);
  box-shadow:
    inset 1px 1px 0 var(--frame-light),
    inset -1px -1px 0 var(--frame-dark),
    4px 4px 0 rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

.terminal-window::before {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  top: 24px;
  height: 1px;
  background: rgba(255, 255, 255, 0.22);
  pointer-events: none;
}

.terminal-chrome,
.terminal-header,
.terminal-body,
.terminal-footer {
  position: relative;
}

.terminal-chrome {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 24px;
  padding: 3px;
  border-bottom: 1px solid var(--title-lo);
  background: var(--title-bg);
  color: var(--title-fg);
  box-shadow:
    inset 1px 1px 0 var(--title-hi),
    inset -1px -1px 0 var(--title-lo);
}

.chrome-group {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.chrome-group.right {
  margin-left: auto;
  gap: 0;
  align-items: stretch;
}

.chrome-divider {
  width: 1px;
  margin: 0 2px;
  background: var(--title-lo);
  box-shadow: 1px 0 0 rgba(220, 173, 194, 0.32);
}

.motif-btn {
  position: relative;
  width: 20px;
  height: 18px;
  background: var(--title-bg);
  border-top: 1px solid rgba(220, 173, 194, 0.82);
  border-left: 1px solid rgba(220, 173, 194, 0.82);
  border-right: 1px solid var(--title-lo);
  border-bottom: 1px solid var(--title-lo);
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.18);
}

.motif-btn::before {
  content: "";
  position: absolute;
  box-sizing: border-box;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.motif-btn.menu::before {
  width: 9px;
  height: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.58);
  border-left: 1px solid rgba(255, 255, 255, 0.58);
  border-right: 1px solid rgba(87, 37, 59, 0.78);
  border-bottom: 1px solid rgba(87, 37, 59, 0.78);
  background: transparent;
}

.motif-btn.indicator::before {
  width: 4px;
  height: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.58);
  border-left: 1px solid rgba(255, 255, 255, 0.58);
  border-right: 1px solid rgba(87, 37, 59, 0.78);
  border-bottom: 1px solid rgba(87, 37, 59, 0.78);
  background: transparent;
}

.motif-btn.maximize::before {
  width: 12px;
  height: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.62);
  border-left: 1px solid rgba(255, 255, 255, 0.62);
  border-right: 1px solid rgba(87, 37, 59, 0.82);
  border-bottom: 1px solid rgba(87, 37, 59, 0.82);
  background: transparent;
}

.dot { display: none; }

.terminal-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 146px);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  pointer-events: none;
  font-size: 12px;
  color: var(--title-fg);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
  text-align: center;
}

.terminal-header {
  display: flex;
  align-items: center;
  padding: 0.3rem 0.7rem;
  background: var(--frame);
  border-top: 1px solid var(--frame-light);
  border-left: 1px solid var(--frame-light);
  border-right: 1px solid var(--frame-dark);
  border-bottom: 1px solid var(--frame-dark);
}

.terminal-header p {
  margin: 0;
  flex: 1 1 auto;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #2f2f2f;
  font-size: 0.84rem;
}

.terminal-body {
  margin: 0.5rem;
  padding: 0.55rem 0.7rem;
  line-height: 1.1;
  background: var(--term-bg);
  color: var(--term-fg);
  border-top: 2px solid var(--frame-dark);
  border-left: 2px solid var(--frame-light);
  border-right: 2px solid var(--frame-dark);
  border-bottom: 2px solid var(--frame-light);
}

.prompt,
.entry-row,
.entry-meta,
.markdown-body p,
.markdown-body li,
.markdown-body blockquote {
  text-shadow: none;
}

.entry-meta {
  margin: 0;
  color: var(--term-dim);
}

.prompt {
  margin: 0.35rem 0;
  color: var(--term-fg);
  white-space: pre-wrap;
}

.entry-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.2rem 0;
  flex-wrap: wrap;
}

.entry-row.short { gap: 0.7rem; }

.entry-row.long {
  display: grid;
  grid-template-columns: 10ch 2ch 10ch 6ch 11ch 5ch 1fr;
  gap: 0.55rem;
  align-items: center;
}

.entry-mode,
.entry-links,
.entry-owner,
.entry-size,
.entry-date,
.entry-time {
  color: var(--term-dim);
  white-space: nowrap;
}

.entry-size { text-align: right; }
.entry-name { min-width: 0; }

.icon {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
  vertical-align: middle;
}

.cursor {
  animation: blink 1s step-end infinite;
}

.terminal-footer {
  margin: 0.5rem;
  margin-top: 0;
  padding: 0.35rem 0.7rem 0.45rem;
  color: #272727;
  font-size: 0.8rem;
  border-top: 1px solid var(--rule);
  background: var(--frame-mid);
}

.terminal-footer p { margin: 0.15rem 0; }

.terminal-content h2,
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 0.2rem 0 0.7rem;
}

.markdown-body code {
  padding: 0.05rem 0.22rem;
  background: #ededed;
  border: 1px solid #b3b3b3;
}

.markdown-body pre {
  overflow-x: auto;
  padding: 0.7rem;
  border: 1px solid #8c8c8c;
  background: #f5f5f5;
}

.markdown-body pre code {
  border: 0;
  background: none;
  padding: 0;
}

.markdown-body table {
  display: block;
  width: max-content;
  min-width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 0.8rem 0;
}

.markdown-body th,
.markdown-body td {
  padding: 0.45rem 0.65rem;
  border: 1px solid #8c8c8c;
  text-align: left;
  vertical-align: top;
}

.markdown-body thead th {
  background: #e1e1e1;
}

.markdown-body tbody tr:nth-child(even) {
  background: #f0f0f0;
}

.markdown-body iframe,
.markdown-body video,
.markdown-body img,
.markdown-body .asciinema-player {
  max-width: 100%;
}

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

@media (max-width: 700px) {
  body { padding: 0.55rem; }

  .terminal-title {
    font-size: 11px;
    max-width: calc(100% - 96px);
  }

  .motif-btn {
    width: 12px;
    height: 13px;
  }

  .motif-btn.menu::before {
    width: 6px;
    height: 3px;
  }

  .motif-btn.indicator::before {
    width: 3px;
    height: 3px;
  }

  .motif-btn.maximize::before {
    width: 8px;
    height: 5px;
  }

  .terminal-header,
  .terminal-body,
  .terminal-footer {
    margin-left: 0.35rem;
    margin-right: 0.35rem;
  }

  .entry-row.long {
    grid-template-columns: 11ch 1fr;
    gap: 0.35rem;
    font-size: 0.85rem;
  }

  .entry-row.long .entry-mode,
  .entry-row.long .entry-links,
  .entry-row.long .entry-owner,
  .entry-row.long .entry-size,
  .entry-row.long .entry-time {
    display: none;
  }

  .entry-row.long .entry-date { grid-column: 1; }
  .entry-row.long .entry-name { grid-column: 2; }
}

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