* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --font-size-title: 16px;
  --font-size-heading: 13px;
  --font-size-subheading: 12px;
  --font-size-body: 13px;
  --font-size-meta: 11px;
}

body {
  font-family: 'IBM Plex Mono', monospace;
  line-height: 1.6;
  font-size: var(--font-size-body);
}

.page-wrapper {
  background-color: #f5f5f0;
  color: #2d8a2d;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.page-wrapper.dark-mode {
  background-color: #1a1a18;
  color: #4ade4a;
}

a {
  color: #2d8a2d;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.dark-mode a {
  color: #4ade4a;
}

a:hover {
  color: #1a5c1a;
}

.dark-mode a:hover {
  color: #6bee6b;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px;
}

/* Header */
header {
  margin-bottom: 60px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.site-title {
  font-size: var(--font-size-heading);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.site-title a {
  text-decoration: none;
}

nav {
  display: flex;
  gap: 24px;
  font-size: var(--font-size-subheading);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

nav a[aria-current="page"] {
  font-weight: 700;
  text-decoration-thickness: 2px;
}

/* Theme Toggle */
.theme-toggle {
  background: none;
  border: 1px solid #2d8a2d;
  color: #2d8a2d;
  font-family: inherit;
  font-size: 18px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dark-mode .theme-toggle {
  border-color: #4ade4a;
  color: #4ade4a;
}

.theme-toggle:hover {
  background-color: #2d8a2d;
  color: #f5f5f0;
}

.dark-mode .theme-toggle:hover {
  background-color: #4ade4a;
  color: #1a1a18;
}

/* Hero Image */
.hero-image {
  width: 100%;
  max-width: 900px;
  margin: 0 auto 60px;
  position: relative;
  overflow: hidden;
}

.hero-image img {
  width: 100%;
  height: auto;
  display: block;
}

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  margin-bottom: 80px;
}

@media (max-width: 768px) {
  .main-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }
}

.section-title,
.page-title {
  font-size: var(--font-size-title);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.section-title {
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid #2d8a2d;
}

.page-title {
  margin-bottom: 32px;
}

.page-content {
  margin-bottom: 80px;
}

.home-content {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.work-content {
  width: 100%;
}

.dark-mode .section-title {
  border-color: #4ade4a;
}

/* CS 180 */
.cs180-content,
.cs180-report {
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

.cs180-intro {
  margin-bottom: 48px;
}

.cs180-project-list {
  list-style: none;
}

.cs180-project-list li {
  border-bottom: 1px dashed #2d8a2d;
}

.dark-mode .cs180-project-list li {
  border-color: #4ade4a;
}

.cs180-project-link {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 24px;
  padding: 16px 0;
  text-decoration: none;
}

.cs180-project-link:hover .cs180-project-title {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cs180-project-number {
  font-size: var(--font-size-meta);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

.cs180-project-title {
  font-weight: 500;
}

.cs180-back-link {
  display: inline-block;
  margin-bottom: 32px;
  font-size: var(--font-size-subheading);
}

.cs180-report-header {
  display: block;
  margin-bottom: 32px;
}

.cs180-report-header .page-title {
  margin: 0;
}

.cs180-report-status {
  opacity: 0.7;
}

.cs180-report-body section {
  min-height: 160px;
  margin-bottom: 48px;
  scroll-margin-top: 24px;
}

.cs180-report-body h2 {
  margin-bottom: 20px;
  font-size: var(--font-size-heading);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cs180-report-body p + p,
.cs180-report-body p + .cs180-image-pair {
  margin-top: 1.5em;
}

.cs180-report-body img,
.cs180-report-body video {
  display: block;
  width: 100%;
  height: auto;
}

.cs180-image-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.cs180-report-body figcaption {
  margin-top: 8px;
  font-size: var(--font-size-meta);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

/* Project 1: one body-text line between report elements */
.cs180-project-1 {
  --report-gap: calc(var(--font-size-body) * 1.6);
}

.cs180-project-1 .cs180-back-link,
.cs180-project-1 .cs180-report-header {
  margin-bottom: var(--report-gap);
}

.cs180-project-1 .cs180-report-body section {
  min-height: 0;
  margin: 0;
}

.cs180-project-1 .cs180-report-body h2,
.cs180-project-1 .cs180-report-body p,
.cs180-project-1 .cs180-image-pair {
  margin: 0;
}

.cs180-project-1 .cs180-report-body section + section,
.cs180-project-1 .cs180-report-body section > * + * {
  margin-top: var(--report-gap);
}

.cs180-project-1 .cs180-image-pair {
  gap: var(--report-gap);
}

.cs180-project-1 .cs180-report-body figcaption {
  margin-top: var(--report-gap);
}

.cs180-dolly-zoom {
  width: calc((100% - 20px) / 2);
}

@media (max-width: 600px) {
  nav {
    gap: 16px;
  }

  .cs180-project-link {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .cs180-image-pair {
    grid-template-columns: 1fr;
  }

  .cs180-dolly-zoom {
    width: 100%;
  }
}

/* About Section */
.about-section p {
  margin-bottom: 16px;
}

.about-section .label,
.work-column-title {
  font-size: var(--font-size-heading);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.about-section .label {
  opacity: 0.7;
  margin-bottom: 4px;
}

.about-section .lore-intro {
  margin-bottom: 4px;
}

.about-section ul {
  list-style: none;
  margin-bottom: 24px;
}

.about-section li {
  padding-left: 16px;
  position: relative;
  margin-bottom: 8px;
}

.about-section li::before {
  content: "-";
  position: absolute;
  left: 0;
}

/* Work Page */
.work-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 40px;
  align-items: start;
}

.work-column-title {
  opacity: 0.7;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #2d8a2d;
}

.dark-mode .work-column-title {
  border-color: #4ade4a;
}

.work-list {
  list-style: none;
}

.work-list > li {
  padding: 12px 0;
  border-bottom: 1px dashed #2d8a2d;
}

.dark-mode .work-list > li {
  border-color: #4ade4a;
}

.experience-list > li:last-child,
.projects-list > li:last-child {
  border-bottom: none;
}

.work-item-title {
  display: block;
  font-size: var(--font-size-body);
  font-weight: 500;
}

.work-item-description {
  display: block;
  font-size: var(--font-size-body);
  margin-top: 4px;
}

.work-item-meta {
  font-size: var(--font-size-meta);
  letter-spacing: 0.05em;
  opacity: 0.6;
  margin-top: 4px;
}

.course-title {
  font-size: var(--font-size-body);
  margin-top: 4px;
}

.work-item-meta-uppercase {
  text-transform: uppercase;
}

.experience-trigger {
  width: 100%;
  position: relative;
  padding: 0 28px 0 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-align: left;
  cursor: pointer;
}

.experience-trigger:hover .work-item-title,
.experience-trigger:focus-visible .work-item-title {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.experience-trigger:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 4px;
}

.experience-open {
  position: absolute;
  top: 0;
  right: 0;
  font-size: 16px;
  line-height: 1;
}

.coursework-column {
  grid-column: 1 / -1;
}

.coursework-groups {
  display: grid;
  gap: 32px;
}

.coursework-group-title {
  font-size: var(--font-size-subheading);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.coursework-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  column-gap: 32px;
}

.coursework-list > li {
  padding: 10px 0;
}

.coursework-legend {
  font-size: var(--font-size-meta);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.6;
  margin-top: 24px;
}

@media (max-width: 900px) {
  .work-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .coursework-column {
    grid-column: auto;
  }

  .coursework-list {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

/* Bookshelf Section */
.bookshelf-section {
  margin-bottom: 80px;
}

.shelf-group-label {
  font-size: var(--font-size-subheading);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 16px;
  margin-top: 40px;
}

.shelf-group-label:first-of-type {
  margin-top: 0;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 16px;
}

@media (max-width: 600px) {
  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
  }
}

.book-cover {
  aspect-ratio: 2/3;
  background-color: #e8e8e0;
  border: 1px solid #2d8a2d;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  font-size: 9px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.3;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.dark-mode .book-cover {
  background-color: #2a2a26;
  border-color: #4ade4a;
}

.book-cover:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
  transition: transform 0.2s ease;
}

.book-cover:hover img {
  transform: scale(1.05);
}

.book-cover .title-fallback {
  position: relative;
  z-index: 1;
}

.book-cover.has-image .title-fallback {
  display: none;
}

.book-cover .badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 10px;
  background-color: #f5f5f0;
  padding: 2px 4px;
  line-height: 1;
  z-index: 2;
}

.dark-mode .book-cover .badge {
  background-color: #1a1a18;
}

/* Search Box */
.search-box {
  margin-bottom: 16px;
}

.search-box input {
  width: 100%;
  font-family: inherit;
  font-size: var(--font-size-body);
  padding: 10px 12px;
  background-color: #e8e8e0;
  border: 1px solid #2d8a2d;
  color: #2d8a2d;
  transition: all 0.2s ease;
}

.dark-mode .search-box input {
  background-color: #2a2a26;
  border-color: #4ade4a;
  color: #4ade4a;
}

.search-box input::placeholder {
  color: #2d8a2d;
  opacity: 0.5;
}

.dark-mode .search-box input::placeholder {
  color: #4ade4a;
  opacity: 0.5;
}

.search-box input:focus {
  outline: none;
  border-color: #2d8a2d;
  background-color: #f5f5f0;
}

.dark-mode .search-box input:focus {
  border-color: #4ade4a;
  background-color: #1a1a18;
}

/* Sort Controls */
.sort-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  align-items: center;
}

.sort-controls span {
  font-size: var(--font-size-meta);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

.sort-btn {
  font-family: inherit;
  font-size: var(--font-size-meta);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: none;
  border: 1px solid #2d8a2d;
  color: #2d8a2d;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dark-mode .sort-btn {
  border-color: #4ade4a;
  color: #4ade4a;
}

.sort-btn:hover {
  background-color: #2d8a2d;
  color: #f5f5f0;
}

.dark-mode .sort-btn:hover {
  background-color: #4ade4a;
  color: #1a1a18;
}

.sort-btn.active {
  background-color: #2d8a2d;
  color: #f5f5f0;
}

.dark-mode .sort-btn.active {
  background-color: #4ade4a;
  color: #1a1a18;
}

.book-count {
  font-size: var(--font-size-meta);
  opacity: 0.6;
  margin-left: auto;
}

/* Movie Shelf */
.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 16px;
}

@media (max-width: 600px) {
  .movie-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
  }
}

.movie-poster {
  aspect-ratio: 2/3;
  background-color: #e8e8e0;
  border: 1px solid #2d8a2d;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  font-size: 9px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.3;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.dark-mode .movie-poster {
  background-color: #2a2a26;
  border-color: #4ade4a;
}

.movie-poster:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.movie-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
  transition: transform 0.2s ease;
}

.movie-poster:hover img {
  transform: scale(1.05);
}

.movie-poster .title-fallback {
  position: relative;
  z-index: 1;
}

.movie-poster.has-image .title-fallback {
  display: none;
}

.movie-poster .badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 10px;
  background-color: #f5f5f0;
  padding: 2px 4px;
  line-height: 1;
  z-index: 2;
}

.dark-mode .movie-poster .badge {
  background-color: #1a1a18;
}

/* Scroll to Top */
.scroll-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  background-color: #2d8a2d;
  color: #f5f5f0;
  border: none;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 100;
}

.dark-mode .scroll-top {
  background-color: #4ade4a;
  color: #1a1a18;
}

.scroll-top.visible {
  opacity: 1;
  visibility: visible;
}

.scroll-top:hover {
  transform: translateY(-2px);
}

/* Review Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background-color: #f5f5f0;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
  border: 2px solid #2d8a2d;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.dark-mode .modal {
  background-color: #1a1a18;
  border-color: #4ade4a;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: #2d8a2d;
  font-size: 24px;
  cursor: pointer;
  font-family: inherit;
}

.dark-mode .modal-close {
  color: #4ade4a;
}

.modal-close:hover {
  opacity: 0.7;
}

.modal-cover {
  width: 120px;
  height: 180px;
  object-fit: cover;
  margin-bottom: 20px;
  border: 1px solid #2d8a2d;
}

.dark-mode .modal-cover {
  border-color: #4ade4a;
}

.modal-title {
  font-size: var(--font-size-title);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.modal-author {
  font-size: var(--font-size-subheading);
  opacity: 0.7;
  margin-bottom: 16px;
}

.modal-review {
  font-size: var(--font-size-body);
  line-height: 1.7;
  white-space: pre-line;
}

.modal-no-review {
  font-size: var(--font-size-body);
  opacity: 0.6;
  font-style: italic;
}

/* Footer */
footer {
  padding-top: 40px;
  border-top: 1px solid #2d8a2d;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  font-size: var(--font-size-subheading);
}

.dark-mode footer {
  border-color: #4ade4a;
}

.social-links {
  display: flex;
  gap: 24px;
}

/* Essays List */
.essays-list {
  list-style: none;
}

.essay-item {
  padding: 20px 0;
  border-bottom: 1px dashed #2d8a2d;
}

.dark-mode .essay-item {
  border-color: #4ade4a;
}

.essay-item:last-child {
  border-bottom: none;
}

.essay-title {
  font-size: var(--font-size-body);
  font-weight: 600;
  margin-bottom: 4px;
}

.essay-title a {
  text-decoration: none;
}

.essay-title a:hover {
  text-decoration: underline;
}

.essay-meta {
  font-size: var(--font-size-meta);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.6;
  margin-bottom: 8px;
}

.essay-review {
  font-size: var(--font-size-body);
  line-height: 1.6;
  opacity: 0.9;
}

.essay-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: var(--font-size-subheading);
}

/* Shelf Tabs */
.shelf-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 1px solid #2d8a2d;
}

.dark-mode .shelf-tabs {
  border-color: #4ade4a;
}

.shelf-tab {
  font-family: inherit;
  font-size: var(--font-size-title);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: none;
  border: none;
  color: #2d8a2d;
  padding: 12px 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  opacity: 0.6;
}

.dark-mode .shelf-tab {
  color: #4ade4a;
}

.shelf-tab:hover {
  opacity: 1;
}

.shelf-tab.active {
  opacity: 1;
}

.shelf-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: #2d8a2d;
}

.dark-mode .shelf-tab.active::after {
  background-color: #4ade4a;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.5s ease forwards;
  opacity: 0;
}

.fade-in:nth-child(1) { animation-delay: 0.1s; }
.fade-in:nth-child(2) { animation-delay: 0.2s; }
.fade-in:nth-child(3) { animation-delay: 0.3s; }
.fade-in:nth-child(4) { animation-delay: 0.4s; }

@media print {
  .page-wrapper,
  .page-wrapper.dark-mode {
    background: #fff;
    color: #000;
  }

  body > .page-wrapper > .container > header,
  footer,
  .cs180-back-link {
    display: none;
  }

  .container {
    max-width: none;
    padding: 0;
  }

  .page-content {
    margin-bottom: 0;
  }

  a,
  .dark-mode a {
    color: #000;
  }

  .fade-in {
    animation: none;
    opacity: 1;
  }
}
