:root {
  color-scheme: light;
  --cream: #fff9ee;
  --cream-deep: #f5ead8;
  --ink: #173024;
  --muted: #647168;
  --line: #d9d0c2;
  --accent: #ef4c23;
  --accent-dark: #c93614;
  --screen-radius: 10px;
  --screen-gutter: clamp(24px, 2.8vw, 40px);
  font-family: Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: #466f2b url("/static/meadow-backplate.jpg") center / cover fixed no-repeat;
  color: var(--ink);
  overscroll-behavior-y: none;
}

html {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: none;
}

body {
  overflow: visible;
}

button,
textarea,
a {
  font: inherit;
}

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

button {
  color: inherit;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  transform: translateY(-180%);
  transition: transform 160ms ease;
}

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

.experience {
  position: relative;
  width: 100%;
  height: 280dvh;
  isolation: isolate;
}

.stage {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #466f2b url("/static/meadow-backplate.jpg") center / cover no-repeat;
  overscroll-behavior: auto;
}

.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(24, 53, 23, 0.02), rgba(15, 36, 16, 0.12)),
    radial-gradient(circle at 50% 44%, transparent 52%, rgba(11, 29, 13, 0.16));
}

.scene-backdrop {
  position: absolute;
  inset: -4%;
  z-index: 0;
  background: url("/static/meadow-backplate.jpg") center / cover no-repeat;
  transform: scale(1.08);
  transform-origin: center;
  will-change: transform;
}

.scene-host {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
}

.scene-3d .scene-host {
  pointer-events: auto;
}

.scene-loaded .scene-host {
  opacity: 1;
}

.scene-webgl,
.scene-css3d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.scene-webgl {
  z-index: 1;
  pointer-events: none;
}

.scene-css3d {
  z-index: 2;
  pointer-events: auto;
  overflow: hidden;
}

.mobile-scene {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: max(100vw, 177.68dvh);
  aspect-ratio: 1672 / 941;
  transform: translate(-50%, -50%);
  transition: opacity 180ms ease;
}

.mobile-backdrop {
  position: absolute;
  inset: 0;
  background: url("/static/meadow-monitor-v2.png") center / 100% 100% no-repeat;
}

.scene-3d .mobile-scene {
  visibility: hidden;
  opacity: 0;
}

.scene-fallback .scene-backdrop,
.scene-mobile .scene-backdrop {
  display: none;
}

.monitor-screen {
  position: absolute;
  top: 27.1%;
  left: 21.8%;
  width: 36.2%;
  height: 36.9%;
  overflow: hidden;
  border-radius: 3px;
  background: var(--cream);
  clip-path: polygon(0 0, 96.5% 0, 98% 93%, 3% 100%);
  transform: rotate(-3.25deg);
  box-shadow: inset 0 0 28px rgba(128, 80, 35, 0.035);
}

.scene-3d .monitor-screen {
  top: 0;
  left: 0;
  width: 1280px;
  height: 720px;
  border-radius: var(--screen-radius);
  clip-path: none;
  box-shadow: inset 0 0 42px rgba(73, 51, 28, 0.05);
  transform: none;
  backface-visibility: hidden;
  pointer-events: auto;
}

.scene-3d .monitor-screen[data-interactive="true"] {
  pointer-events: auto;
}

.screen-bar {
  position: absolute;
  inset: 0 0 auto;
  z-index: 10;
  height: clamp(30px, 3.2vw, 44px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 var(--screen-gutter);
  border-bottom: 1px solid rgba(23, 48, 36, 0.14);
  background: rgba(255, 249, 238, 0.97);
}

.brand-button,
.close-screen,
.back-button,
.chat-tools button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.brand-button {
  justify-self: start;
  padding: 0;
  color: var(--accent);
  font-size: clamp(10px, 1vw, 15px);
  font-weight: 900;
}

.screen-bar p {
  margin: 0;
  color: var(--muted);
  font-size: clamp(8px, 0.75vw, 11px);
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.close-screen {
  justify-self: end;
  display: none;
  padding: 5px 7px;
  color: var(--muted);
  font-size: 11px;
}

.screen-view {
  position: absolute;
  inset: 0;
  display: none;
  padding-top: clamp(30px, 3.2vw, 44px);
  background:
    radial-gradient(circle at 78% 40%, rgba(239, 76, 35, 0.08), transparent 24%),
    var(--cream);
}

.screen-view.is-active {
  display: block;
}

.home-view {
  grid-template-columns: minmax(0, 1.08fr) minmax(260px, 0.92fr);
  grid-template-rows: 1fr;
  gap: clamp(24px, 4vw, 64px);
  padding-right: var(--screen-gutter);
  padding-left: var(--screen-gutter);
}

.home-view.is-active {
  display: grid;
}

.home-copy {
  align-self: center;
  min-width: 0;
  padding: 0 0 6px clamp(0px, 2vw, 28px);
}

.eyebrow {
  margin: 0 0 clamp(4px, 0.7vw, 9px);
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: clamp(7px, 0.75vw, 11px);
  font-weight: 800;
}

.home-copy h1 {
  margin: 0;
  font-size: clamp(32px, 3.6vw, 58px);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.intro {
  max-width: 31em;
  margin: clamp(12px, 1.5vw, 22px) 0 0;
  color: #4d5d54;
  font-size: clamp(11px, 1.05vw, 15px);
  line-height: 1.75;
}

.home-actions {
  display: flex;
  gap: clamp(6px, 0.8vw, 10px);
  margin-top: clamp(14px, 1.8vw, 25px);
}

.solid-button,
.outline-button,
.about-footer button {
  min-width: clamp(68px, 7vw, 108px);
  min-height: clamp(25px, 2.8vw, 39px);
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: clamp(8px, 0.8vw, 12px);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.solid-button {
  border: 1px solid var(--accent-dark);
  background: var(--accent);
  color: #fff;
}

.outline-button {
  border: 1px solid var(--ink);
  background: transparent;
}

.solid-button:hover,
.about-footer button:hover,
#sendButton:hover {
  background: var(--accent-dark);
}

.outline-button:hover {
  background: var(--ink);
  color: #fff;
}

button:active,
a:active {
  transform: translateY(1px);
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(239, 76, 35, 0.48);
  outline-offset: 2px;
}

.portrait-block {
  position: relative;
  align-self: center;
  justify-self: end;
  width: min(100%, 420px);
  height: min(72%, 490px);
  min-height: 300px;
  margin-right: clamp(0px, 1.2vw, 16px);
  border-radius: 6px;
  background: #ead8ca;
}

.portrait-block::before {
  content: "";
  position: absolute;
  inset: 9% -5% -5% 8%;
  z-index: -1;
  border-radius: inherit;
  background: rgba(239, 76, 35, 0.11);
}

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

.about-view,
.chat-view {
  padding-right: var(--screen-gutter);
  padding-left: var(--screen-gutter);
}

.view-heading,
.chat-heading {
  height: clamp(60px, 7vw, 92px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.view-heading h2,
.chat-heading h2 {
  margin: 0;
  font-size: clamp(18px, 2vw, 31px);
  line-height: 1.1;
}

.back-button,
.chat-tools button {
  padding: 6px 8px;
  color: #526158;
  font-size: clamp(8px, 0.75vw, 11px);
}

.about-view.is-active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.about-content {
  min-height: 0;
  overflow-y: auto;
  padding: clamp(12px, 1.4vw, 20px) 1px clamp(14px, 1.6vw, 22px);
  overscroll-behavior: contain;
}

.about-summary {
  max-width: 82em;
  margin: 0 0 clamp(12px, 1.3vw, 18px);
  color: #4d5d54;
  font-size: clamp(9px, 0.85vw, 13px);
  line-height: 1.65;
}

.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
  gap: clamp(18px, 2.5vw, 34px);
}

.profile-section {
  min-width: 0;
  border-top: 1px solid var(--ink);
}

.profile-section h3 {
  margin: 0;
  padding: clamp(7px, 0.75vw, 10px) 0;
  color: var(--accent-dark);
  font-size: clamp(9px, 0.82vw, 12px);
}

.profile-item {
  display: grid;
  grid-template-columns: minmax(92px, 0.34fr) minmax(0, 1fr);
  gap: clamp(8px, 1vw, 14px);
  padding: clamp(7px, 0.82vw, 11px) 0;
  border-top: 1px solid var(--line);
}

.projects-section .profile-item {
  grid-template-columns: minmax(120px, 0.35fr) minmax(0, 1fr);
}

.profile-item strong,
.profile-item p {
  margin: 0;
  font-size: clamp(8px, 0.74vw, 11px);
  line-height: 1.5;
}

.profile-item p {
  color: #526158;
}

.about-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(12px, 1.4vw, 20px);
  padding-top: clamp(12px, 1.3vw, 18px);
}

.about-footer p {
  margin: 0 auto 0 0;
  color: #59675f;
  font-size: clamp(7px, 0.7vw, 10px);
}

.about-footer button {
  border: 1px solid var(--accent-dark);
  background: var(--accent);
  color: #fff;
}

.chat-view.is-active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.chat-heading {
  height: clamp(60px, 7vw, 92px);
}

.chat-tools {
  display: flex;
  gap: 4px;
}

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: clamp(8px, 1vw, 14px) 1px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.message {
  width: min(76%, 760px);
  margin-bottom: clamp(6px, 0.8vw, 10px);
}

.message-label {
  margin-bottom: 3px;
  color: #59675f;
  font-size: clamp(7px, 0.65vw, 9px);
  font-weight: 700;
}

.message-body {
  padding: clamp(7px, 0.8vw, 11px);
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.72);
  font-size: clamp(8px, 0.78vw, 12px);
  line-height: 1.55;
  white-space: pre-wrap;
}

.user-message {
  margin-left: auto;
}

.user-message .message-label {
  text-align: right;
}

.user-message .message-body {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.suggestions button {
  min-height: clamp(22px, 2.2vw, 30px);
  padding: 4px 8px;
  border: 1px solid var(--accent-dark);
  border-radius: 4px;
  background: transparent;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: clamp(7px, 0.66vw, 10px);
  font-weight: 700;
}

.suggestions button:hover {
  background: #fff0e6;
}

.loading-message .message-body {
  display: grid;
  gap: 5px;
}

.loading-bar {
  width: 100%;
  height: 5px;
  border-radius: 2px;
  background: linear-gradient(90deg, #f1e8da, #dccfbd, #f1e8da);
  background-size: 220% 100%;
  animation: loading 1.25s ease-in-out infinite;
}

.loading-bar:nth-child(2) { width: 82%; }
.loading-bar:nth-child(3) { width: 58%; }

@keyframes loading {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

.composer {
  padding: clamp(7px, 0.9vw, 12px) 0 clamp(8px, 1vw, 14px);
  border-top: 1px solid var(--line);
}

.composer label {
  display: block;
  margin-bottom: 4px;
  color: #59675f;
  font-size: clamp(7px, 0.65vw, 9px);
  font-weight: 700;
}

.composer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: end;
}

textarea {
  width: 100%;
  min-height: clamp(28px, 3vw, 40px);
  max-height: 80px;
  resize: none;
  padding: 7px 9px;
  border: 1px solid #887f73;
  border-radius: 4px;
  outline: none;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font-size: clamp(8px, 0.78vw, 12px);
  line-height: 1.4;
}

textarea::placeholder {
  color: #626e66;
}

textarea:focus {
  border-color: var(--accent-dark);
  box-shadow: 0 0 0 2px rgba(239, 76, 35, 0.16);
}

#sendButton {
  min-width: clamp(44px, 4.8vw, 70px);
  min-height: clamp(28px, 3vw, 40px);
  padding: 0 10px;
  border: 1px solid var(--accent-dark);
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: clamp(8px, 0.75vw, 11px);
  font-weight: 800;
}

#sendButton:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.form-status {
  min-height: 11px;
  margin: 3px 0 0;
  color: #a92f18;
  font-size: clamp(7px, 0.65vw, 9px);
}

@media (max-width: 767px) and (pointer: coarse) {
  :root {
    --screen-gutter: 16px;
  }

  .experience {
    height: 100dvh;
  }

  .stage {
    position: relative;
  }

  .mobile-scene {
    left: calc(50% + 97px);
    width: 950px;
  }

  .screen-bar {
    height: 26px;
    padding: 0 10px;
  }

  .screen-bar p {
    font-size: 7px;
  }

  .screen-view {
    padding-top: 26px;
  }

  .home-view {
    grid-template-columns: minmax(0, 1.35fr) 92px;
    gap: 0 12px;
    padding-right: 16px;
    padding-left: 16px;
  }

  .home-copy h1 {
    font-size: 25px;
  }

  .intro {
    max-width: 26em;
    font-size: 8px;
  }

  .home-actions {
    margin-top: 8px;
  }

  .solid-button,
  .outline-button {
    min-width: 67px;
    min-height: 24px;
    padding: 4px 8px;
    font-size: 8px;
  }

  .portrait-block {
    width: 92px;
    height: 124px;
    min-height: 0;
    margin-right: 0;
  }

  body.screen-open {
    height: 100dvh;
    overflow: hidden;
    background: var(--cream);
  }

  .screen-open .skip-link {
    display: none;
  }

  .screen-open .stage {
    position: fixed;
    inset: 0;
    z-index: 80;
  }

  .screen-open .mobile-scene {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    transform: none;
  }

  .screen-open .mobile-backdrop {
    display: none;
  }

  .screen-open .monitor-screen {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    clip-path: none;
    transform: none;
    box-shadow: none;
  }

  .screen-open .screen-bar {
    height: 48px;
    padding: 0 16px;
  }

  .screen-open .screen-bar p {
    font-size: 10px;
  }

  .screen-open .close-screen {
    display: block;
  }

  .screen-open .screen-view {
    padding-top: 48px;
  }

  .screen-open .home-view {
    grid-template-columns: minmax(0, 1fr) 132px;
    gap: 18px;
    padding: 22px;
    padding-top: 64px;
  }

  .screen-open .home-copy h1 {
    font-size: clamp(34px, 10vw, 48px);
  }

  .screen-open .intro {
    max-width: 30em;
    font-size: 14px;
  }

  .screen-open .solid-button,
  .screen-open .outline-button {
    min-width: 88px;
    min-height: 40px;
    padding: 8px 12px;
    font-size: 13px;
  }

  .screen-open .portrait-block {
    width: 132px;
    height: 188px;
  }

  .screen-open .about-view,
  .screen-open .chat-view {
    padding-right: 18px;
    padding-left: 18px;
  }

  .screen-open .profile-grid {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .screen-open .about-content {
    padding-top: 18px;
  }

  .screen-open .about-summary {
    font-size: 13px;
  }

  .screen-open .profile-section h3,
  .screen-open .profile-item strong,
  .screen-open .profile-item p {
    font-size: 12px;
  }

  .screen-open .profile-item,
  .screen-open .projects-section .profile-item {
    grid-template-columns: 112px minmax(0, 1fr);
    padding: 12px 0;
  }

  .screen-open .about-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .screen-open .view-heading h2,
  .screen-open .chat-heading h2 {
    font-size: 24px;
  }

  .screen-open .message-label,
  .screen-open .composer label,
  .screen-open .form-status {
    font-size: 11px;
  }

  .screen-open .message-body,
  .screen-open textarea,
  .screen-open #sendButton {
    font-size: 14px;
  }

  .screen-open .suggestions button {
    min-height: 34px;
    font-size: 12px;
  }

  .screen-open textarea,
  .screen-open #sendButton {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .experience {
    height: 100dvh;
  }
}
