/* Matrix green theme — inspired by matrix-themed-sprint-planner */

:root {
  --bg-0: #050a07;
  --bg-1: #0a120d;
  --bg-2: #101a14;
  --border-0: rgba(0, 255, 65, 0.14);
  --border-bright: rgba(0, 255, 65, 0.35);
  --text-0: #c8f5d8;
  --text-1: #7ddea0;
  --text-2: #4a9f68;
  --matrix-0: #00ff41;
  --matrix-1: #00cc34;
  --accent-0: #ff4fd8;
  --cta-0: #ff3b3b;
  --focus-ring: rgba(0, 255, 65, 0.4);
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
  --max-width: 48rem;
  --header-height: 3.5rem;
  --glow: 0 0 24px rgba(0, 255, 65, 0.25);
}

::selection {
  background: rgba(0, 255, 65, 0.25);
  color: #e8fff0;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-0);
  background:
    radial-gradient(ellipse 80% 55% at 50% -10%, rgba(0, 255, 65, 0.1), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(184, 75, 255, 0.08), transparent),
    var(--bg-0);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* CRT scanlines */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.025;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.35) 2px,
    rgba(0, 0, 0, 0.35) 4px
  );
}

/* Visible grid overlay (restored from Phase 1 layout; matrix-green tint) */
.site-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(0, 255, 65, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 65, 0.08) 1px, transparent 1px);
  background-size: 2rem 2rem;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 40%, black 20%, transparent 100%);
}

a {
  color: var(--matrix-0);
  text-decoration: none;
}

a:hover {
  color: var(--text-0);
  text-decoration: underline;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
  position: relative;
  z-index: 1;
}

.main-content {
  flex: 1;
  padding-top: 2.5rem;
  padding-bottom: 3rem;
}

/* ── Header ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(5, 10, 7, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-0);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  gap: 1rem;
}

.site-logo {
  color: var(--matrix-0);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.04em;
  text-shadow: var(--glow);
}

.site-logo:hover {
  text-decoration: none;
  color: var(--text-0);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  justify-content: flex-end;
}

.terminal-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-1);
  background: rgba(0, 255, 65, 0.06);
  border: 1px dashed var(--border-bright);
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
}

.terminal-hint:hover,
.terminal-hint:focus-visible {
  color: var(--matrix-0);
  border-color: var(--matrix-0);
  outline: none;
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.terminal-hint kbd {
  display: inline-block;
  font-family: inherit;
  font-size: inherit;
  color: var(--matrix-0);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  line-height: 1.2;
}

.site-nav a {
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-decoration: none;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--matrix-0);
  text-decoration: none;
}

.site-nav a.active {
  border-bottom-color: var(--matrix-0);
  text-shadow: 0 0 12px rgba(0, 255, 65, 0.3);
}

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border-0);
  padding: 1.5rem 0;
  background: rgba(5, 10, 7, 0.6);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.footer-copy {
  margin: 0;
  color: var(--text-2);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.footer-links a {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-1);
}

.footer-links a:hover {
  color: var(--matrix-0);
}

/* ── Hero ── */
.hero {
  text-align: center;
  padding: 1.5rem 0 3rem;
}

.profile-avatar {
  display: block;
  width: 7.5rem;
  height: 7.5rem;
  margin: 0 auto 1.25rem;
  border-radius: 4px;
  border: 2px solid var(--border-bright);
  box-shadow: 0 0 30px rgba(0, 255, 65, 0.15);
  object-fit: cover;
}

.hero-prompt {
  color: var(--matrix-0);
  margin: 0 0 0.75rem;
  text-shadow: var(--glow);
}

.hero h1 {
  margin: 0 0 0.5rem;
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--matrix-0);
  text-shadow: var(--glow);
}

.hero-email {
  display: inline-block;
  margin: 0 0 1.25rem;
  color: var(--text-1);
  font-size: 0.95rem;
}

.hero-email:hover {
  color: var(--matrix-0);
  text-decoration: none;
}

.hero-subhead {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  color: var(--text-0);
  max-width: 34rem;
  margin-left: auto;
  margin-right: auto;
}

.hero-support {
  margin: 0;
  color: var(--text-2);
}

/* ── Sections ── */
.section {
  margin-top: 3rem;
}

.section-title {
  margin: 0 0 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--matrix-0);
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border-bright);
  text-shadow: 0 0 16px rgba(0, 255, 65, 0.2);
}

.section-cta {
  margin: 1.25rem 0 0;
  font-size: 0.95rem;
}

.section-cta a {
  color: var(--accent-0);
}

.section-cta a:hover {
  color: var(--matrix-0);
}

/* ── Page headers ── */
.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  margin: 0 0 0.5rem;
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--matrix-0);
  text-shadow: var(--glow);
}

.page-lead {
  margin: 0;
  color: var(--text-1);
  font-size: 1.05rem;
}

/* ── Cards ── */
.card-grid {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  }
}

.card {
  background: var(--bg-1);
  border: 1px solid var(--border-0);
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: var(--border-bright);
}

.card-title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--matrix-0);
  letter-spacing: 0.04em;
}

.card-oneliner {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-1);
  flex: 1;
}

.card-points {
  margin: 0.5rem 0 0;
  padding-left: 1.15rem;
  font-size: 0.85rem;
  color: var(--text-2);
}

.card-points li {
  margin-bottom: 0.25rem;
}

.card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.card-links a {
  color: var(--accent-0);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-links a:hover {
  color: var(--matrix-0);
}

.badge-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-bottom: 0.25rem;
}

.badge-progress {
  background: rgba(255, 207, 90, 0.1);
  color: #ffcf5a;
  border: 1px solid rgba(255, 207, 90, 0.35);
}

.badge-link {
  border: 1px solid var(--border-0);
  color: var(--text-1);
  text-decoration: none;
}

.badge-link:hover {
  color: var(--matrix-0);
  border-color: var(--border-bright);
  text-decoration: none;
}

.card-primary-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.5rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border-0);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-0);
  text-decoration: none;
  width: fit-content;
}

.card-primary-cta:hover {
  color: var(--matrix-0);
  border-color: var(--border-bright);
  text-decoration: none;
}

.card a:focus-visible,
.card-primary-cta:focus-visible,
.badge-link:focus-visible,
.back-link:focus-visible,
.project-pager-link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ── Case studies ── */
.case-study {
  background: var(--bg-1);
  border: 1px solid var(--border-0);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.case-study-header h2 {
  margin: 0.5rem 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--matrix-0);
  letter-spacing: 0.04em;
}

.case-oneliner {
  margin: 0 0 0.75rem;
  color: var(--text-1);
}

.case-sections {
  display: grid;
  gap: 1.25rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px dashed var(--border-0);
}

.case-label {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  color: var(--matrix-0);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.case-section p {
  margin: 0;
  color: var(--text-1);
}

.case-section ul {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--text-2);
  font-size: 0.95rem;
}

.case-section li {
  margin-bottom: 0.35rem;
}

/* ── Post lists ── */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 0;
  border-bottom: 1px dashed var(--border-0);
}

.post-item:first-child {
  border-top: 1px dashed var(--border-0);
}

.post-item a {
  color: var(--text-0);
}

.post-item a:hover {
  color: var(--matrix-0);
}

.post-date {
  color: var(--text-2);
  font-size: 0.8rem;
  white-space: nowrap;
}

.post-list-full .post-item {
  align-items: flex-start;
  padding: 1.25rem 0;
}

.post-item-body {
  flex: 1;
  min-width: 0;
}

.post-excerpt {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: var(--text-2);
}

/* ── Blog article ── */
.blog-article-header {
  margin-bottom: 2rem;
}

.blog-meta {
  margin: 0 0 0.75rem;
  color: var(--text-2);
}

.blog-article h1 {
  margin: 0 0 0.75rem;
  font-family: var(--font-mono);
  font-size: clamp(1.25rem, 3.5vw, 1.75rem);
  color: var(--matrix-0);
  letter-spacing: 0.03em;
  text-shadow: var(--glow);
}

.blog-excerpt {
  margin: 0;
  color: var(--text-1);
  font-size: 1.05rem;
}

/* ── Prose ── */
.prose p {
  margin: 0 0 1rem;
  color: var(--text-1);
}

.prose p:last-child {
  margin-bottom: 0;
}

/* ── About ── */
.values-list {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--text-1);
}

.values-list li {
  margin-bottom: 0.5rem;
}

.values-list strong {
  color: var(--matrix-0);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  background: rgba(0, 255, 65, 0.06);
  border: 1px solid var(--border-0);
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  color: var(--text-1);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Contact ── */
.contact-cards {
  display: grid;
  gap: 1rem;
}

@media (min-width: 480px) {
  .contact-cards {
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  }
}

.contact-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--bg-1);
  border: 1px solid var(--border-0);
  border-radius: 10px;
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.contact-card:hover {
  border-color: var(--border-bright);
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.1);
  text-decoration: none;
}

.contact-label {
  color: var(--matrix-0);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.contact-value {
  font-size: 0.95rem;
  color: var(--text-0);
}

.contact-links {
  margin-bottom: 1.5rem;
}

.contact-form-intro {
  margin-bottom: 1rem;
}

.contact-cta {
  margin: 0.35rem 0 0;
  color: var(--text-1);
  font-size: 0.98rem;
  line-height: 1.55;
}

.contact-form-wrap {
  margin-bottom: 2rem;
}

.contact-form {
  background: var(--bg-1);
  border: 1px solid var(--border-0);
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  color: var(--matrix-0);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.form-input {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text-0);
  background: var(--bg-0);
  border: 1px solid var(--border-0);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
}

.form-input:focus {
  outline: none;
  border-color: var(--matrix-0);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-select {
  appearance: none;
  cursor: pointer;
}

.form-textarea {
  resize: vertical;
  min-height: 8rem;
  line-height: 1.5;
}

.form-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form-turnstile {
  margin-top: 0.25rem;
}

.form-submit {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-0);
  background: transparent;
  border: 1px solid var(--border-0);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  cursor: pointer;
}

.form-submit:hover {
  color: var(--matrix-0);
  border-color: var(--border-bright);
}

.form-submit:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.form-alert {
  margin-bottom: 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-0);
}

.form-alert p {
  margin: 0;
  color: var(--text-1);
}

.form-alert-success {
  background: rgba(0, 255, 65, 0.06);
  border-color: var(--border-bright);
}

.form-alert-error {
  background: rgba(255, 59, 59, 0.08);
  border-color: rgba(255, 59, 59, 0.35);
  color: #ffc4c4;
}

/* ── 404 ── */
.error-page {
  text-align: center;
  padding: 3rem 0;
}

.error-page h1 {
  margin: 0 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 3rem;
  color: var(--cta-0);
  text-shadow: 0 0 30px rgba(255, 59, 59, 0.3);
}

.project-pager {
  margin-top: 1.5rem;
  display: flex;
  justify-content: space-between;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.project-pager-link {
  flex: 1 1 15rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.8rem 0.9rem;
  border: 1px dashed var(--border-0);
  border-radius: 8px;
  color: var(--text-0);
  text-decoration: none;
}

.project-pager-link:hover {
  border-color: var(--border-bright);
  color: var(--matrix-0);
  text-decoration: none;
}

.project-pager-next {
  text-align: right;
  align-items: flex-end;
}

/* ── Site themes (terminal `theme` command) ── */
html[data-theme="matrix"] {
  --bg-0: #050a07;
  --bg-1: #0a120d;
  --bg-2: #101a14;
  --border-0: rgba(0, 255, 65, 0.14);
  --border-bright: rgba(0, 255, 65, 0.35);
  --text-0: #c8f5d8;
  --text-1: #7ddea0;
  --text-2: #4a9f68;
  --matrix-0: #00ff41;
  --matrix-1: #00cc34;
  --accent-0: #ff4fd8;
  --cta-0: #ff3b3b;
  --focus-ring: rgba(0, 255, 65, 0.4);
  --glow: 0 0 24px rgba(0, 255, 65, 0.25);
  --terminal-bg: #0a120d;
  --terminal-fg: #c8f5d8;
  --terminal-border: rgba(0, 255, 65, 0.35);
  --terminal-accent: #00ff41;
  --terminal-muted: #4a9f68;
}

html[data-theme="solarized-dark"] {
  --bg-0: #002b36;
  --bg-1: #073642;
  --bg-2: #0a4452;
  --border-0: rgba(131, 148, 150, 0.35);
  --border-bright: rgba(147, 161, 161, 0.55);
  --text-0: #fdf6e3;
  --text-1: #93a1a1;
  --text-2: #839496;
  --matrix-0: #2aa198;
  --matrix-1: #268bd2;
  --accent-0: #d33682;
  --cta-0: #dc322f;
  --focus-ring: rgba(42, 161, 152, 0.45);
  --glow: 0 0 20px rgba(42, 161, 152, 0.2);
  --terminal-bg: #073642;
  --terminal-fg: #eee8d5;
  --terminal-border: rgba(147, 161, 161, 0.45);
  --terminal-accent: #2aa198;
  --terminal-muted: #839496;
}

html[data-theme="high-contrast"] {
  --bg-0: #1e1e1e;
  --bg-1: #252526;
  --bg-2: #2d2d30;
  --border-0: rgba(255, 255, 255, 0.25);
  --border-bright: rgba(255, 255, 255, 0.55);
  --text-0: #ffffff;
  --text-1: #cccccc;
  --text-2: #9cdcfe;
  --matrix-0: #569cd6;
  --matrix-1: #4ec9b0;
  --accent-0: #c586c0;
  --cta-0: #f44747;
  --focus-ring: rgba(86, 156, 214, 0.55);
  --glow: none;
  --terminal-bg: #1e1e1e;
  --terminal-fg: #ffffff;
  --terminal-border: rgba(255, 255, 255, 0.45);
  --terminal-accent: #569cd6;
  --terminal-muted: #858585;
}

html[data-theme="nord"] {
  --bg-0: #2e3440;
  --bg-1: #3b4252;
  --bg-2: #434c5e;
  --border-0: rgba(136, 192, 208, 0.22);
  --border-bright: rgba(136, 192, 208, 0.45);
  --text-0: #eceff4;
  --text-1: #d8dee9;
  --text-2: #81a1c1;
  --matrix-0: #88c0d0;
  --matrix-1: #8fbcbb;
  --accent-0: #b48ead;
  --cta-0: #bf616a;
  --focus-ring: rgba(136, 192, 208, 0.45);
  --glow: 0 0 18px rgba(136, 192, 208, 0.18);
  --terminal-bg: #3b4252;
  --terminal-fg: #eceff4;
  --terminal-border: rgba(136, 192, 208, 0.4);
  --terminal-accent: #88c0d0;
  --terminal-muted: #616e88;
}

/* ── Terminal overlay (Ship A) ── */
.terminal-overlay {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 100;
  width: 32rem;
  height: 20rem;
  min-width: 18rem;
  min-height: 12rem;
  max-width: calc(100vw - 1.5rem);
  max-height: calc(100vh - 1.5rem);
  resize: both;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transform: translateY(0.5rem);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.terminal-overlay.is-open {
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0);
}

.terminal-overlay.is-positioned {
  right: auto;
  bottom: auto;
}

.terminal-overlay.is-docked-left {
  left: 0;
  top: 0;
  bottom: 0;
  right: auto;
  height: 100% !important;
  max-height: 100vh;
  min-height: 0;
  width: min(32rem, 42vw);
  min-width: 18rem;
  max-width: calc(100vw - 1rem);
  resize: horizontal;
  border-radius: 0;
}

.terminal-overlay.is-docked-right {
  right: 0;
  top: 0;
  bottom: 0;
  left: auto;
  height: 100% !important;
  max-height: 100vh;
  min-height: 0;
  width: min(32rem, 42vw);
  min-width: 18rem;
  max-width: calc(100vw - 1rem);
  resize: horizontal;
  border-radius: 0;
}

.terminal-overlay.is-docked-left .terminal-window {
  border-radius: 0 10px 10px 0;
  border-left: none;
  height: 100%;
}

.terminal-overlay.is-docked-right .terminal-window {
  border-radius: 10px 0 0 10px;
  border-right: none;
  height: 100%;
}

.terminal-overlay.is-docked-left.is-minimized,
.terminal-overlay.is-docked-right.is-minimized {
  height: auto !important;
  min-height: 0 !important;
  top: auto;
  bottom: 1.25rem;
}

.terminal-overlay.is-docked-left.is-minimized {
  left: 0;
}

.terminal-overlay.is-docked-right.is-minimized {
  right: 0;
}

.terminal-overlay.is-minimized {
  height: auto !important;
  min-height: 0 !important;
  resize: none;
}

.terminal-overlay.is-minimized .terminal-body {
  display: none;
}

.terminal-overlay.is-minimized .terminal-header {
  border-bottom: none;
}

.terminal-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.terminal-window {
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--terminal-border);
  border-radius: 10px;
  background: var(--terminal-bg);
  color: var(--terminal-fg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), var(--glow);
  overflow: hidden;
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--terminal-border);
  background: rgba(0, 0, 0, 0.15);
  user-select: none;
}

.terminal-title {
  flex: 1 1 auto;
  min-width: 0;
  cursor: grab;
  touch-action: none;
}

.terminal-overlay.is-dragging .terminal-title {
  cursor: grabbing;
}

.terminal-title {
  font-size: 0.78rem;
  color: var(--terminal-accent);
  text-shadow: var(--glow);
}

.terminal-window-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.terminal-chrome-btn {
  border: 1px solid var(--terminal-border);
  background: transparent;
  color: var(--terminal-fg);
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0;
  font-family: var(--font-mono);
}

.terminal-chrome-btn:hover,
.terminal-chrome-btn:focus-visible {
  color: var(--terminal-accent);
  border-color: var(--terminal-accent);
  outline: none;
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.terminal-chrome-btn[aria-pressed="true"] {
  color: var(--terminal-accent);
  border-color: var(--terminal-accent);
  background: rgba(0, 255, 65, 0.08);
}

.terminal-output {
  flex: 1 1 auto;
  min-height: 4rem;
  overflow-y: auto;
  padding: 0.65rem 0.75rem;
  font-size: 0.78rem;
  line-height: 1.45;
}

.terminal-line-help {
  color: var(--terminal-fg);
}

.terminal-line-help-desc {
  color: var(--terminal-muted);
  padding-left: 1.25rem;
}

.terminal-line {
  margin: 0 0 0.25rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.terminal-line-input {
  color: var(--terminal-accent);
}

.terminal-line-muted {
  color: var(--terminal-muted);
}

.terminal-line-error {
  color: var(--cta-0);
}

.terminal-input-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--terminal-border);
}

.terminal-prompt {
  color: var(--terminal-accent);
  font-size: 0.78rem;
}

.terminal-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--terminal-fg);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.15rem 0;
}

.terminal-input:focus {
  outline: none;
}

.terminal-input:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  border-radius: 4px;
}

.terminal-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.terminal-input-row.is-game-active .terminal-prompt {
  color: var(--terminal-muted);
}

/* Full-body game mode — output + input hidden; stage fills terminal body */
.terminal-body.is-game-mode .terminal-output,
.terminal-body.is-game-mode .terminal-input-row {
  display: none;
}

.terminal-game-stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0.5rem 0.75rem 0.75rem;
  background: var(--terminal-bg);
}

.terminal-game-hud {
  flex: 0 0 auto;
  width: 100%;
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  color: var(--terminal-accent);
  text-align: center;
}

.terminal-game-canvas-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

.terminal-game-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border: 1px solid var(--terminal-border);
  border-radius: 4px;
  image-rendering: pixelated;
}

@media (prefers-reduced-motion: reduce) {
  .terminal-overlay {
    transition: none;
    transform: none;
  }
}

/* Resize grip inherits from overflow:hidden + resize:both on .terminal-overlay */

/* ── Mobile ── */
@media (max-width: 480px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    height: auto;
    padding: 0.75rem 0;
  }

  .site-nav {
    width: 100%;
    justify-content: flex-start;
    gap: 0.5rem 0.85rem;
  }

  .site-nav a {
    font-size: 0.75rem;
  }

  .terminal-hint {
    font-size: 0.68rem;
    padding: 0.25rem 0.5rem;
  }
}
