:root {
  --green:     #4ade80;
  --green-2:   #86efac;
  --green-dim: #166534;
  --line:      rgba(74, 222, 128, 0.75);
  --bg:        #000;
  --cmd:       #60a5fa;
  --danger:    #f87171;
  --side:      300px;
  --radius:    12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--green);
  font-family: "SF Mono", Monaco, Inconsolata, "Roboto Mono", "Source Code Pro",
               Consolas, "Liberation Mono", Menlo, monospace;
}

button, input { font-family: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--cmd); }
a:hover { color: #93c5fd; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 18px 22px 10px;
  gap: 14px;
}

/* ── layout ─────────────────────────────────────────────── */
.shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  gap: 22px;
}

.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 6px 4px 0 2px;
}

/* ── identity ─────────────────────────────────────────────── */
.identity h1 {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--green);
  text-shadow:
    0 0 18px rgba(74, 222, 128, 0.5),
    0 0 40px rgba(74, 222, 128, 0.2);
}

.identity p {
  margin: 6px 0 18px;
  color: #9ca3af;
  font-size: 1.02rem;
}

/* ── portrait ─────────────────────────────────────────────── */
.portrait {
  position: relative;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #03140b;
  box-shadow:
    0 0 0 1px rgba(74, 222, 128, 0.15),
    0 18px 50px rgba(0, 0, 0, 0.45),
    inset 0 0 40px rgba(74, 222, 128, 0.07);
  aspect-ratio: 4 / 5;
  max-height: min(62vh, 560px);
}

.portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 15%;
  border-radius: inherit;
}

.portrait::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 65%, rgba(0, 0, 0, 0.35) 100%);
  pointer-events: none;
}

.me {
  align-self: center;
  margin-top: 16px;
  background: transparent;
  border: 1px solid rgba(74, 222, 128, 0.4);
  color: var(--green);
  border-radius: 20px;
  padding: 7px 18px;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  box-shadow: 0 0 14px rgba(74, 222, 128, 0.1);
  transition: background 0.18s, box-shadow 0.18s, color 0.18s;
}

.me:hover,
.me:focus-visible {
  background: rgba(74, 222, 128, 0.1);
  box-shadow: 0 0 22px rgba(74, 222, 128, 0.25);
  color: #fff;
  outline: none;
}

/* ── terminal window ─────────────────────────────────────── */
.term {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  background: #000;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(74, 222, 128, 0.08),
    0 24px 60px rgba(0, 0, 0, 0.5);
}

/* ── title bar with macOS traffic dots and tabs ───────────── */
.titlebar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 11px 14px 10px;
  border-bottom: 1px solid rgba(74, 222, 128, 0.18);
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

.titlebar.has-tabs {
  gap: 12px;
  padding: 8px 12px;
  min-height: 40px;
}

.dots {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-right: 14px;
}

.titlebar.has-tabs .dots {
  margin-right: 4px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-close   { background: #ff5f57; box-shadow: 0 0 4px rgba(255, 95, 87,  0.5); }
.dot-min     { background: #febc2e; box-shadow: 0 0 4px rgba(254, 188, 46, 0.5); }
.dot-max     { background: #28c840; box-shadow: 0 0 4px rgba(40,  200, 64, 0.5); }

.term-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}

/* Default state (single tab): clean borderless centered titlebar label */
.titlebar:not(.has-tabs) .term-tab {
  display: block;
  flex: 1;
  text-align: center;
  margin-right: 46px;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  color: rgba(74, 222, 128, 0.55);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  user-select: none;
  cursor: default;
}

.titlebar:not(.has-tabs) .term-tab .tab-icon {
  display: none;
}

/* Multi-tab mode: styled tab buttons */
.titlebar.has-tabs .term-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(74, 222, 128, 0.15);
  color: rgba(74, 222, 128, 0.65);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: all 0.18s ease;
  user-select: none;
  cursor: pointer;
  margin-right: 0;
}

.titlebar.has-tabs .term-tab:hover {
  background: rgba(74, 222, 128, 0.08);
  border-color: rgba(74, 222, 128, 0.35);
  color: var(--green-2);
}

.titlebar.has-tabs .term-tab.active {
  background: rgba(74, 222, 128, 0.14);
  border-color: rgba(74, 222, 128, 0.55);
  color: #fff;
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.15);
  font-weight: 500;
}

.titlebar.has-tabs .tab-icon {
  font-size: 0.85em;
  opacity: 0.9;
}

.tab-title {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-close {
  margin-left: 3px;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 0.72rem;
  color: #9ca3af;
  line-height: 1;
  transition: all 0.15s ease;
}

.tab-close:hover {
  color: #fff;
  background: rgba(239, 68, 68, 0.35);
}

/* ── panes ──────────────────────────────────────────────── */
.term-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.resume-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #050b07;
}

/* ── resume toolbar & viewer ────────────────────────────── */
.resume-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: rgba(74, 222, 128, 0.03);
  border-bottom: 1px solid rgba(74, 222, 128, 0.18);
  flex-shrink: 0;
}

.resume-doc-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.resume-doc-tag {
  background: #dc2626;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.resume-doc-name {
  font-size: 0.82rem;
  color: #e5e7eb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resume-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.resume-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: rgba(74, 222, 128, 0.08);
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: 6px;
  color: var(--green-2);
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none !important;
  transition: all 0.16s ease;
  cursor: pointer;
}

.resume-action-btn:hover {
  background: rgba(74, 222, 128, 0.2);
  border-color: rgba(74, 222, 128, 0.65);
  color: #fff;
}

.resume-close-btn {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.resume-close-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.7);
  color: #fff;
}

.resume-viewer-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
  background: #18181b;
}

.resume-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ── command chips ───────────────────────────────────────── */
.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(74, 222, 128, 0.18);
  background: rgba(255, 255, 255, 0.01);
}

.chips button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--green);
  font-size: 0.93rem;
  transition: color 0.12s;
}

.chips button:hover,
.chips button:focus-visible {
  color: #fff;
  text-decoration: underline;
  outline: none;
}

.sep {
  color: rgba(74, 222, 128, 0.35);
  margin: 0 9px;
  user-select: none;
}

/* ── screen / scroll area ────────────────────────────────── */
.screen {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 18px 18px;
  cursor: text;
  position: relative;
}

/* subtle scanline overlay */
.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.055) 2px,
    rgba(0, 0, 0, 0.055) 4px
  );
  pointer-events: none;
  z-index: 0;
}

.entry { margin: 0 0 16px; }

.cmd-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.prompt      { color: var(--cmd); white-space: nowrap; }
.prompt .user { color: var(--cmd); }
.prompt .host { color: var(--cmd); }
.prompt .path { color: var(--cmd); }

.typed {
  color: #ffffff;
  font-weight: 700;
}

.out {
  margin: 8px 0 0;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--green);
}

.out.error { color: var(--danger); }
.out a { text-decoration: underline; text-underline-offset: 2px; }

/* ── project card styles ─────────────────────────────────── */
.card-tech { color: var(--cmd); opacity: 0.9; }
.card-dim  { color: #6b7280; }

.card-btn {
  color: var(--green-2) !important;
  background: rgba(74, 222, 128, 0.07);
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: 4px;
  padding: 1px 5px;
  text-decoration: none !important;
  font-size: 0.9em;
  transition: background 0.15s, border-color 0.15s;
}

.card-btn:hover {
  background: rgba(74, 222, 128, 0.16);
  border-color: rgba(74, 222, 128, 0.6);
  color: #fff !important;
}

/* ── resume button ───────────────────────────────────────── */
.resume-btn {
  display: inline-block;
  margin-top: 4px;
  padding: 8px 20px;
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.45);
  border-radius: 8px;
  color: var(--green-2) !important;
  text-decoration: none !important;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.08);
}

.resume-btn:hover {
  background: rgba(74, 222, 128, 0.2);
  border-color: rgba(74, 222, 128, 0.75);
  color: #fff !important;
}

/* ── input caret row ─────────────────────────────────────── */
.caret-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 1.6em;
}

.caret-row form { flex: 1; display: flex; min-width: 0; }

.caret-row input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--cmd);
  font-size: 1rem;
  padding: 0;
  caret-color: var(--green);
}

.caret-row input::placeholder { color: #1d4ed8; opacity: 0.85; }

/* ── dock ────────────────────────────────────────────────── */
.dock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 4px 4px;
  min-height: 36px;
  position: relative;
  z-index: 10;
}

.music {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 0;
  color: var(--green);
  padding: 0;
  font-size: 0.95rem;
  cursor: pointer;
  user-select: none;
  transition: color 0.12s, text-shadow 0.18s;
}

.music svg { width: 14px; height: 14px; flex-shrink: 0; }
.music:hover { color: #fff; }

.music[aria-pressed="true"] {
  color: #a7f3d0;
  text-shadow: 0 0 12px rgba(74, 222, 128, 0.4);
}

.music[aria-pressed="true"] svg {
  color: var(--green);
  animation: pulse-music 1.3s ease-in-out infinite alternate;
}

@keyframes pulse-music {
  0%   { transform: scale(0.9); opacity: 0.85; filter: drop-shadow(0 0 2px rgba(74,222,128,0.4)); }
  100% { transform: scale(1.15); opacity: 1; filter: drop-shadow(0 0 8px rgba(74,222,128,0.8)); }
}

.clock {
  font-variant-numeric: tabular-nums;
  color: #e5e7eb;
  font-size: 0.95rem;
}

/* ── responsive ──────────────────────────────────────────── */
@media (max-width: 860px) {
  body { 
    padding: 10px; 
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }
  .shell {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: visible;
    flex: none;
  }
  .side {
    align-items: center;
    text-align: center;
    padding: 0;
  }
  .portrait {
    max-height: 280px;
    width: 220px;
    margin: 0 auto;
  }
  .term { 
    height: 65vh;
    min-height: 500px; 
    flex: none;
  }
  .identity h1 { font-size: 1.6rem; }
  .tab-title { max-width: 140px; }
  .titlebar:not(.has-tabs) .term-tab { margin-right: 0; }
  .resume-pane { min-height: 480px; }
  
  .dock {
    flex-direction: column;
    text-align: center;
    gap: 8px;
    margin-top: 8px;
  }
  .proj-grid {
    grid-template-columns: 1fr;
  }
}

/* ── project cards ───────────────────────────────────────── */
.proj-label {
  white-space: normal;
  margin: 0 0 14px;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(74, 222, 128, 0.5);
}

.proj-grid {
  white-space: normal;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.proj-card {
  position: relative;
  background: linear-gradient(180deg, #0f2317 0%, #08140d 100%);
  border: 1px solid rgba(74, 222, 128, 0.28);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(74, 222, 128, 0.12);
  transition: border-color 0.22s, box-shadow 0.22s, transform 0.22s, background 0.22s;
}

/* top accent bar */
.proj-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--green) 0%, rgba(96, 165, 250, 0.8) 100%);
  opacity: 0.8;
}

.proj-card:hover {
  background: linear-gradient(180deg, #142e1f 0%, #0b1c12 100%);
  border-color: rgba(74, 222, 128, 0.65);
  box-shadow: 0 0 30px rgba(74, 222, 128, 0.18), 0 12px 32px rgba(0, 0, 0, 0.7);
  transform: translateY(-3px);
}

.proj-card-inner {
  padding: 16px 18px;
}

.proj-card-top {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.proj-num {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: rgba(74, 222, 128, 0.6);
  flex-shrink: 0;
}

.proj-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  font-family: inherit;
  letter-spacing: 0.01em;
}

.proj-tech {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  background: rgba(96, 165, 250, 0.14);
  border: 1px solid rgba(96, 165, 250, 0.35);
  border-radius: 4px;
  color: #bae6fd;
  white-space: nowrap;
}

.proj-summary {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: #bbf7d0;
  line-height: 1.55;
}

.proj-detail {
  margin: 0 0 14px;
  font-size: 0.8rem;
  color: #d1d5db;
  line-height: 1.55;
}

.proj-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.proj-btn {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none !important;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.proj-btn-gh {
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.38);
  color: var(--green) !important;
}
.proj-btn-gh:hover {
  background: rgba(74, 222, 128, 0.25);
  border-color: rgba(74, 222, 128, 0.8);
  color: #fff !important;
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.2);
}

.proj-btn-demo {
  background: rgba(96, 165, 250, 0.12);
  border: 1px solid rgba(96, 165, 250, 0.38);
  color: #93c5fd !important;
}
.proj-btn-demo:hover {
  background: rgba(96, 165, 250, 0.25);
  border-color: rgba(96, 165, 250, 0.8);
  color: #fff !important;
  box-shadow: 0 0 12px rgba(96, 165, 250, 0.2);
}

/* ── portrait 3D tilt ────────────────────────────────────── */
.portrait {
  transform-style: preserve-3d;
  will-change: transform;
  cursor: pointer;
}

.portrait-glare {
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  pointer-events: none;
  transition: background 0.12s;
}

/* ── light mode ─────────────────────────────────────────── */
body.light-mode {
  --bg: #ffffff;
  --green: #065f46;
  --green-2: #047857;
  --line: rgba(6, 95, 70, 0.3);
  --cmd: #1d4ed8;
  --danger: #dc2626;
  color: var(--green);
}
body.light-mode .term {
  background: #f8fafc;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 24px 60px rgba(0, 0, 0, 0.1);
}
body.light-mode .portrait {
  background: #f1f5f9;
}
body.light-mode .identity h1 {
  text-shadow: none;
}
body.light-mode .titlebar {
  background: #e2e8f0;
  border-bottom: 1px solid #cbd5e1;
}
body.light-mode .titlebar.has-tabs .term-tab {
  background: transparent;
  color: #475569;
  border-color: transparent;
}
body.light-mode .titlebar.has-tabs .term-tab.active {
  background: #fff;
  color: #0f172a;
  border-color: #cbd5e1;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
body.light-mode .chips {
  background: #f1f5f9;
  border-bottom-color: #cbd5e1;
}
body.light-mode .proj-card {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
body.light-mode .proj-card:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}
body.light-mode .proj-name {
  color: #0f172a;
}
body.light-mode .proj-summary {
  color: #334155;
}
body.light-mode .proj-detail {
  color: #475569;
}
body.light-mode .typed, body.light-mode .out {
  color: #0f172a;
  font-weight: 500;
}
body.light-mode .clock, body.light-mode .tab-close, body.light-mode .resume-doc-name {
  color: #475569;
}
body.light-mode .theme-toggle {
  background: transparent;
  border: 0;
  font-size: 1.1rem;
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
body.light-mode .theme-toggle:hover {
  background: rgba(0,0,0,0.05);
}
.theme-toggle {
  background: transparent;
  border: 0;
  font-size: 1.1rem;
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.theme-toggle:hover {
  background: rgba(255,255,255,0.1);
}