:root {
  --ink: #111111;
  --sub: #666666;
  --muted: #8a8a8a;
  --line: #e4e4e4;
  --soft: #f5f5f3;
  --bg: #ffffff;
  --danger: #9d2525;
  --success: #23613c;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Serif TC", serif;
  line-height: 1.7;
}

body.is-admin {
  background: #f7f7f5;
}

img {
  max-width: 100%;
}

a {
  color: inherit;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

.serif-italic {
  font-family: "Playfair Display", serif;
  font-style: italic;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  transform: translateY(-180%);
  padding: 0.55rem 0.85rem;
  background: var(--ink);
  color: #fff;
}

.skip-link:focus {
  transform: translateY(0);
}

/* Original floating navigation treatment. */
.float-nav {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 30;
  display: flex;
  max-width: calc(100vw - 2rem);
  gap: 0.9rem;
  overflow-x: auto;
  padding: 0.45rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 5px 24px rgba(0, 0, 0, 0.04);
  backdrop-filter: blur(8px);
  font-size: 0.8rem;
  white-space: nowrap;
}

.float-nav a {
  font-family: "Playfair Display", serif;
  font-style: italic;
  text-decoration: none;
}

.float-nav a:hover {
  text-decoration: underline;
}

/* Poster homepage: preserve the original positions and scale. */
.poster-outer {
  position: relative;
  max-width: none;
  margin: 0;
  padding: 0 3vw;
}

.poster {
  position: relative;
  width: 100%;
  min-height: 100svh;
  aspect-ratio: 27 / 30;
  container-type: inline-size;
}

.corner-logo {
  position: absolute;
  z-index: 2;
  top: clamp(1rem, 2.5vw, 2rem);
  right: clamp(1rem, 3vw, 2.5rem);
  width: clamp(64px, 8vw, 112px);
  height: auto;
}

.p-item {
  position: absolute;
  margin: 0;
  white-space: nowrap;
}

.p-title {
  top: 9%;
  left: 11%;
  font-size: 11cqw;
  line-height: 1;
}

.p-photo {
  top: 22%;
  left: 11%;
  width: 30%;
  height: 24%;
  overflow: hidden;
  border: 1px solid #dddddd;
  background: #f2f2f2;
}

.p-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.p-whatsup {
  top: 37%;
  right: 4%;
  font-size: 9cqw;
  line-height: 1;
}

.p-cat {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  font-family: "Playfair Display", serif;
  font-size: 3.6cqw;
  font-style: italic;
}

.p-cat.active {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

.p-cat.rot {
  transform: rotate(-90deg);
  transform-origin: left top;
}

.p-app {
  top: 61%;
  left: 29%;
}

.p-else {
  top: 75%;
  left: 73%;
}

.p-project {
  top: 74%;
  left: 40%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  font-family: "Playfair Display", serif;
  font-size: 10cqw;
  font-style: italic;
  line-height: 1;
}

.p-boardgame {
  top: 83%;
  left: 24%;
}

.p-video {
  top: 84%;
  left: 68%;
}

.content-wrap,
section.page {
  width: min(100% - 3rem, 700px);
  margin: 0 auto;
  padding: 5rem 0;
}

.list-wrap {
  width: min(100% - 3rem, 700px);
  margin: 0 auto;
  padding: 3rem 0 5rem;
}

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--line);
}

.list-head .current {
  color: var(--sub);
  font-family: "Playfair Display", serif;
  font-size: 1.3rem;
  font-style: italic;
}

.list-head .current b {
  color: var(--ink);
  font-weight: 600;
}

.data-note {
  color: var(--muted);
  font-family: "Noto Serif TC", serif;
  font-size: 0.72rem;
  font-style: normal;
}

.project-list {
  min-height: 8rem;
}

.project-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.2rem;
  align-items: start;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
}

.project-row h3 {
  margin: 0.15rem 0 0.3rem;
  font-family: "Playfair Display", serif;
  font-size: 1.3rem;
  font-style: italic;
}

.project-row p {
  max-width: 570px;
  margin: 0;
  color: var(--sub);
  font-size: 0.92rem;
}

.project-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  color: #8a8a8a;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.67rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-dot {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}

.status-dot::before {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.project-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-top: 0.25rem;
  white-space: nowrap;
}

.text-link,
.project-actions a {
  color: var(--sub);
  font-size: 0.82rem;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.text-link:hover,
.project-actions a:hover {
  color: var(--ink);
}

.empty-note,
.loading-note {
  color: var(--sub);
  font-size: 0.92rem;
}

section.page {
  border-top: 1px solid var(--line);
}

.section-eyebrow {
  display: block;
  margin-bottom: 0.6rem;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.section-title {
  margin: 0 0 1.2rem;
  font-family: "Playfair Display", serif;
  font-size: clamp(2.1rem, 6vw, 3.4rem);
  font-style: italic;
  line-height: 1.1;
}

.lead-copy {
  color: #343434;
  font-size: 1.02rem;
}

.capability-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 2rem;
  border: 1px solid var(--line);
  background: var(--line);
}

.capability {
  min-height: 150px;
  padding: 1.3rem;
  background: var(--bg);
}

.capability span {
  display: block;
  margin-bottom: 1.3rem;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.68rem;
}

.capability h2,
.capability h3 {
  margin: 0 0 0.35rem;
  font-family: "Playfair Display", serif;
  font-size: 1.25rem;
  font-style: italic;
  font-weight: 600;
}

.capability p {
  margin: 0;
  color: var(--sub);
  font-size: 0.86rem;
}

.contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  margin-top: 1.3rem;
  font-size: 0.95rem;
}

.contact-row a {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

footer {
  padding: 2.5rem 1rem 5rem;
  color: var(--sub);
  font-size: 0.8rem;
  text-align: center;
}

footer p {
  margin: 0;
}

.footer-logo {
  display: block;
  width: 88px;
  height: auto;
  margin: 0 auto 0.6rem;
}

/* Shared secondary-page layout. */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(100% - 3rem, 1080px);
  margin: 0 auto;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
}

.brand-link {
  font-family: "Playfair Display", serif;
  font-size: 1.1rem;
  font-style: italic;
  text-decoration: none;
}

.page-nav {
  display: flex;
  margin-left: auto;
  gap: 1.1rem;
  color: var(--sub);
  font-size: 0.82rem;
}

.page-nav a {
  text-decoration: none;
}

.header-logo {
  display: block;
  flex: none;
}

.header-logo img {
  display: block;
  width: 44px;
  height: 44px;
}

.page-nav a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.detail-shell,
.lab-shell {
  width: min(100% - 3rem, 1080px);
  margin: 0 auto;
  padding: clamp(4rem, 8vw, 8rem) 0 6rem;
}

.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(380px, 1.1fr);
  gap: clamp(2rem, 7vw, 7rem);
  align-items: end;
}

.detail-number {
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.detail-title {
  margin: 0.8rem 0 1.2rem;
  font-family: "Playfair Display", serif;
  font-size: clamp(3.5rem, 9vw, 8.4rem);
  font-style: italic;
  font-weight: 600;
  line-height: 0.92;
  overflow-wrap: anywhere;
}

.detail-summary {
  max-width: 630px;
  margin: 0;
  color: var(--sub);
  font-size: clamp(1rem, 2vw, 1.2rem);
}

.detail-cover {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--soft);
}

.detail-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.4rem;
  margin: 1.1rem 0 0;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.detail-body {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(300px, 0.7fr);
  gap: clamp(2rem, 9vw, 9rem);
  margin-top: clamp(4rem, 8vw, 8rem);
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.detail-copy h2,
.detail-highlights h2 {
  margin: 0 0 1.2rem;
  font-family: "Playfair Display", serif;
  font-size: 1.7rem;
  font-style: italic;
}

.detail-copy p {
  margin: 0;
  color: #343434;
  font-size: 1rem;
  white-space: pre-line;
}

.detail-highlights ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.detail-highlights li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
  color: var(--sub);
  font-size: 0.9rem;
}

.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 2rem;
  padding: 0.72rem 1.15rem;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font-size: 0.88rem;
  text-decoration: none;
}

.primary-link:hover {
  background: #333333;
}

.not-found {
  min-height: 55vh;
  padding-top: 5rem;
}

.lab-intro {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: clamp(2rem, 8vw, 8rem);
  align-items: end;
  margin-bottom: 5rem;
}

.lab-title {
  margin: 0;
  font-family: "Playfair Display", serif;
  font-size: clamp(4rem, 12vw, 9rem);
  font-style: italic;
  line-height: 0.85;
}

.lab-intro p {
  margin: 0;
  color: var(--sub);
  font-size: 1rem;
}

.lab-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
}

.lab-card {
  min-height: 330px;
  padding: 1.5rem;
  border-right: 1px solid var(--line);
}

.lab-card:last-child {
  border-right: 0;
}

.lab-card .index {
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.68rem;
}

.lab-card h2 {
  margin: 6rem 0 0.7rem;
  font-family: "Playfair Display", serif;
  font-size: 2rem;
  font-style: italic;
}

.lab-card p {
  margin: 0;
  color: var(--sub);
  font-size: 0.9rem;
}

.exploring-label {
  display: inline-block;
  margin-top: 1rem;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Admin */
.admin-shell {
  width: min(100% - 2rem, 1080px);
  margin: 0 auto;
  padding: 3rem 0 6rem;
}

.admin-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.admin-heading h1 {
  margin: 0;
  font-family: "Playfair Display", serif;
  font-size: clamp(2.6rem, 7vw, 5rem);
  font-style: italic;
  line-height: 1;
}

.admin-heading p {
  max-width: 500px;
  margin: 0;
  color: var(--sub);
  font-size: 0.9rem;
}

.compact-section-title {
  font-size: 2rem;
}

.back-to-projects {
  margin-top: 4rem;
}

.panel {
  padding: clamp(1.2rem, 4vw, 2rem);
  border: 1px solid var(--line);
  background: #fff;
}

.login-panel {
  max-width: 520px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

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

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--sub);
  font-size: 0.78rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid #cccccc;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
}

.field textarea {
  min-height: 110px;
  resize: vertical;
}

.field-checkbox {
  justify-content: end;
}

.field-checkbox label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  cursor: pointer;
}

.field-checkbox input {
  width: auto;
  margin: 0;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
  margin-top: 1.2rem;
}

.button {
  padding: 0.6rem 1rem;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-size: 0.86rem;
}

.button.secondary {
  background: transparent;
  color: var(--ink);
}

.button.danger {
  border-color: var(--danger);
  background: transparent;
  color: var(--danger);
}

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

.message {
  margin: 1rem 0;
  padding: 0.7rem 0.85rem;
  border-left: 3px solid var(--ink);
  background: var(--soft);
  font-size: 0.84rem;
}

.message.error {
  border-left-color: var(--danger);
  color: var(--danger);
}

.message.success {
  border-left-color: var(--success);
  color: var(--success);
}

.admin-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.65fr) minmax(0, 1.35fr);
  gap: 1rem;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 780px;
  overflow: auto;
}

.admin-project {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.7rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line);
}

.admin-project strong,
.admin-project small {
  display: block;
}

.admin-project small {
  color: var(--muted);
}

.admin-project button {
  align-self: center;
  padding: 0;
  border: 0;
  background: none;
  color: var(--sub);
  cursor: pointer;
  font-size: 0.8rem;
  text-decoration: underline;
}

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .float-nav {
    right: 0.65rem;
    bottom: 0.65rem;
    max-width: calc(100vw - 1.3rem);
  }

  .float-nav {
    left: 0.65rem;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.2rem 1rem;
  }

  .float-nav a {
    padding: 0.55rem 0;
  }

  /* Mobile poster: same pieces, re-composed for a portrait screen. */
  .poster-outer {
    padding: 0;
  }

  .poster {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    align-content: center;
    row-gap: 0;
    aspect-ratio: auto;
    min-height: 100svh;
    padding: 4.5rem 7cqw 6rem;
  }

  .p-item {
    position: static;
  }

  .p-title {
    grid-column: 1 / -1;
    grid-row: 1;
    font-size: 14.5cqw;
  }

  .p-photo {
    grid-column: 1 / 6;
    grid-row: 2;
    width: 100%;
    height: auto;
    margin-top: 7cqw;
    aspect-ratio: 4 / 3;
  }

  .p-whatsup {
    grid-column: 3 / -1;
    grid-row: 3;
    justify-self: end;
    margin-top: 5cqw;
    font-size: 10.5cqw;
  }

  .p-cat {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0.35rem;
    font-size: 6cqw;
  }

  /* Vertical text that occupies real layout space, so it can sit in the grid. */
  .p-cat.rot {
    transform: rotate(180deg);
    transform-origin: center;
    writing-mode: vertical-rl;
  }

  .p-app {
    grid-column: 2 / 5;
    grid-row: 4;
    justify-self: start;
    margin-top: 12cqw;
  }

  .p-else {
    grid-column: 6;
    grid-row: 4 / 6;
    align-self: end;
    justify-self: end;
  }

  .p-project {
    grid-column: 1 / -1;
    grid-row: 5;
    justify-self: center;
    padding: 0.4rem 0;
    font-size: 17cqw;
  }

  .p-boardgame {
    grid-column: 1;
    grid-row: 5 / 7;
    align-self: start;
    justify-self: start;
    margin-top: 12cqw;
  }

  .p-video {
    grid-column: 4 / -1;
    grid-row: 6;
    justify-self: end;
  }

  .project-row {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  .project-actions {
    flex-direction: row;
    gap: 1.4rem;
    padding-top: 0;
  }

  /* Taller hit areas for thumbs without changing the look. */
  .project-actions a,
  .text-link,
  .contact-row a {
    display: inline-block;
    padding: 0.55rem 0;
  }

  section.page {
    padding: 3.5rem 0;
  }

  .capability {
    min-height: auto;
  }

  .capability span {
    margin-bottom: 0.6rem;
  }

  .contact-row {
    flex-direction: column;
    gap: 0;
  }

  .page-header {
    flex-wrap: wrap;
  }

  .capability-grid,
  .detail-hero,
  .detail-body,
  .lab-intro,
  .admin-workspace {
    grid-template-columns: 1fr;
  }

  .detail-title {
    font-size: clamp(3.3rem, 20vw, 6rem);
  }

  .detail-hero {
    align-items: start;
  }

  .detail-cover {
    grid-row: 1;
  }

  .lab-grid {
    grid-template-columns: 1fr;
  }

  .lab-card {
    min-height: auto;
    padding: 1.5rem 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .lab-card h2 {
    margin-top: 3rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .content-wrap,
  section.page,
  .list-wrap,
  .page-header,
  .detail-shell,
  .lab-shell {
    width: min(100% - 2rem, 1080px);
  }

  .page-header {
    gap: 0.6rem;
  }

  .brand-link {
    font-size: 1rem;
  }

  .page-nav {
    gap: 0.6rem;
    font-size: 0.75rem;
  }

  .header-logo img {
    width: 36px;
    height: 36px;
  }

  .capability-grid {
    grid-template-columns: 1fr;
  }

  .list-head {
    align-items: flex-start;
  }
}

@media (max-width: 360px) {
  .float-nav {
    gap: 0.4rem;
    padding: 0.2rem 0.7rem;
    font-size: 0.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
