/* Keep the Claude visual system; input is discrete only inside the opening story. */
.intro.intro-discrete { height: auto; }
.intro-discrete .intro-sticky { position: relative; height: 100svh; min-height: 540px; touch-action: pan-y pinch-zoom; }
.intro-visual { display: none; pointer-events: none; }
.intro-controls {
  position: absolute;
  z-index: 5;
  right: var(--gutter);
  bottom: max(24px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}
.intro-controls button, .intro-chapter-select {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: inherit;
  font: 500 13px/1.4 var(--font);
}
.intro-controls button:disabled { opacity: .32; cursor: default; }
.intro-controls button:not(:disabled):hover { border-color: var(--accent); }
.intro-controls svg { width: 17px; height: 17px; }
.intro-chapter-select { max-width: 170px; padding-inline: 13px 23px; text-overflow: ellipsis; cursor: pointer; }
.intro-chapter-select option { background: #0b0b0c; color: #f2f2f0; }
.intro-discrete .intro-hint { left: var(--gutter); transform: none; align-items: flex-start; text-align: left; }
.intro-discrete .intro-hint em { display: none; }
.intro-discrete .intro-hint i { height: 24px; }

/* Touch tablets also use ordinary vertical work reading, including landscape. */
@media (max-width: 960px), (hover: none) and (pointer: coarse) {
  .works { height: auto !important; }
  .works-pin { position: relative; top: auto; min-height: 0; overflow: visible; padding-top: clamp(72px, 12vw, 120px); }
  .works-track { width: auto; min-width: 0; flex-direction: column; gap: 44px; transform: none !important; will-change: auto; }
  .work-panel, .work-end { --pw: 100%; min-width: 0; max-width: 100%; }
  .works .ch-aside { display: none; }
  .work-end { border-left: 0; border-top: 1px solid var(--line); padding: 24px 0 0; }
  .panel-info > div, .case-nav-card > div { min-width: 0; }
  .panel-info h3, .panel-sub, .end-line { overflow-wrap: anywhere; }
  .cover > img, .cover-window .window img { object-fit: contain; object-position: center; }
  .cover-phone .phone img { object-fit: contain; }
  .work-panel .phone { width: auto; height: 88%; aspect-ratio: 1206 / 2622; top: 6%; }
  .work-panel .cover-duo .duo-main { object-fit: contain; }
  .motion .work-panel .panel-media { clip-path: none; }
}

@media (max-width: 860px), (hover: none) and (pointer: coarse) {
  .intro { --intro-header: 76px; }
  .intro-discrete .intro-sticky {
    display: grid;
    grid-template-rows: minmax(0, 1fr) var(--intro-copy-height, 230px) 44px;
    gap: 14px;
    height: 100svh;
    min-height: calc(var(--intro-copy-height, 230px) + var(--intro-header) + 102px + env(safe-area-inset-bottom));
    padding: calc(var(--intro-header) + 10px) var(--gutter) calc(16px + env(safe-area-inset-bottom));
    cursor: auto;
  }
  .intro-discrete .intro-visual { display: block; grid-row: 1; min-height: 0; width: 100%; }
  .intro-discrete canvas, .intro-glow { pointer-events: none; }
  .intro-discrete .intro-chapters {
    position: relative;
    grid-row: 2;
    inset: auto;
    width: 100%;
    height: var(--intro-copy-height, 230px);
    min-width: 0;
    z-index: 2;
  }
  .intro-discrete .chapter, .intro-discrete .chapter-final { width: 100%; bottom: 0; left: 0; right: auto; }
  .intro-discrete .chapter-year { font-size: clamp(48px, 13vw, 76px); line-height: .95; }
  .intro-discrete .chapter h2 { margin-top: 12px; font-size: clamp(24px, 6.2vw, 34px); line-height: 1.2; }
  .intro-discrete .chapter > p:last-child, .intro-discrete .chapter-final > p:not(.chapter-year) {
    display: block;
    max-width: none;
    margin-top: 12px;
    font-size: 14px;
    line-height: 1.6;
    overflow-wrap: anywhere;
  }
  .intro-discrete .chapter-final .chapter-year { font-size: 11px; line-height: 1.5; letter-spacing: .06em; }
  .intro-discrete .chapter-final h1 { margin-top: 10px; font-size: clamp(38px, 10.4vw, 64px); line-height: 1.08; }
  .intro-discrete .chapter-final .hero-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-top: 16px; }
  .intro-discrete .chapter-final .hero-actions > :first-child { grid-column: 1 / -1; }
  .intro-discrete .chapter-final .hero-actions .button { min-height: 44px; min-width: 0; padding: 8px 10px; font-size: 12px; line-height: 1.35; white-space: normal; }
  .intro-discrete .chapter-final .hero-actions svg { width: 16px; height: 16px; }
  .intro-discrete .intro-rail, .intro-discrete .intro-hint { display: none; }
  .intro-controls { position: relative; grid-row: 3; inset: auto; width: 100%; min-width: 0; gap: 8px; }
  .intro-controls .intro-prev { flex: 0 0 44px; padding: 0; }
  .intro-controls .intro-next { flex: 0 0 auto; padding-inline: 13px; }
  .intro-chapter-select { flex: 1 1 0; min-width: 0; max-width: none; width: 0; font-size: 12px; }
  .intro-progress { bottom: 0; }
  .facts { scroll-margin-top: 88px; }
  .graph-stage { height: clamp(360px, 65svh, 480px); min-height: 360px; min-width: 0; }
  .graph-stage canvas { max-width: 100%; touch-action: pan-y pinch-zoom; }
  .graph-tip { max-width: calc(100% - 16px); overflow-wrap: anywhere; }
  .graph-legend button { min-height: 44px; }
  .graph-hint { right: 14px; left: 14px; bottom: 12px; max-width: calc(100% - 28px); line-height: 1.55; }
  .braid, .braid-body, .b-item, .b-card { min-width: 0; max-width: 100%; }
  .braid-head { display: none; }
  .braid-body { position: relative; height: auto !important; min-height: 0 !important; padding-left: 28px; }
  .braid .b-item, .braid .b-item.lane-edu, .braid .b-item.lane-work, .braid .b-band { position: relative; inset: auto; height: auto; width: auto; margin: 0 0 32px; }
  .braid .b-card, .braid .lane-edu .b-card { max-width: none; margin: 0; padding: 0; text-align: left; transform: none; opacity: 1 !important; }
  .braid-spine { left: 5px; }
  .braid .tick, .braid .playhead, .braid .spine-fill, .braid .b-bar { display: none; }
  .braid .b-item::before { content: ""; position: absolute; left: -28px; top: 6px; width: 11px; height: 11px; border-radius: 50%; background: var(--ink); }
  .braid .b-item.lane-edu::before { background: var(--accent); }
  .braid .b-lane { display: inline-block; margin-bottom: 6px; font-size: 11px; letter-spacing: .14em; color: var(--muted); }
  .braid .lane-edu .b-lane { color: var(--accent); }
  .b-period, .b-role, .b-desc, .b-list, .b-works { overflow-wrap: anywhere; }
  .braid .b-band { background: none; }
  .b-band span { position: static; display: inline-block; max-width: 100%; transform: none; writing-mode: horizontal-tb; padding: 5px 12px; white-space: normal; }
}

@media (max-width: 860px) {
  .intro { --intro-header: 64px; }
  .site-header { flex-shrink: 0; padding-left: max(var(--gutter), env(safe-area-inset-left)); padding-right: max(var(--gutter), env(safe-area-inset-right)); }
  .main-nav { overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
}

@media (max-width: 640px) {
  .page, .page-hero, .case-hero, .case-body, .case-content, .case-section, .case-meta > div, .topic-main, .topic-side, .pub-card, .intent-contact { min-width: 0; }
  .page-hero h1, .case-hero h1 { font-size: clamp(34px, 10vw, 54px); overflow-wrap: anywhere; }
  .page-hero h1, .case-hero h1, .ch-title h2, #contact .ch-title h2 { word-break: normal; text-wrap: pretty; }
  .case-sub, .page-intro p, .pub-t, .pub-j, .pub-card h3, .pub-meta, .pub-summary, .case-meta dd, .question-block h2, .cv-sheet { overflow-wrap: anywhere; }
  .case-top { flex-wrap: wrap; gap: 8px 16px; }
  .case-pager { margin-left: auto; }
  .case-meta { gap: 20px; }
  .tag-list li { max-width: 100%; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }
  .status-pill { align-items: flex-start; }
  .status-pill i { margin-top: .55em; flex: none; }
  .cover-button { height: auto; min-height: 0; aspect-ratio: 16 / 11; }
  .case-yici .cover-button, .case-live-analysis .cover-button { height: auto; aspect-ratio: 4 / 5; }
  .cover-button .cover > img { object-fit: contain; object-position: center; }
  .cover-window .window img { object-fit: contain; }
  .cover-phone .phone { top: 6%; max-width: 44%; }
  .cover-live .live-shot { max-width: 56%; height: 88%; object-fit: contain; object-position: bottom right; }
  .cover-live .live-copy { padding: 20px; }
  .live-copy p { font-size: clamp(26px, 7vw, 40px); }
  .gallery, .feature-cards, .launch-card, .case-nav { grid-template-columns: minmax(0, 1fr); }
  .gallery-item, .gallery-item.is-portrait { height: auto; min-height: 0; max-height: none; aspect-ratio: auto; padding: 12px; }
  .gallery-item img, .gallery-item.is-portrait img { width: 100%; height: auto; max-height: none; object-fit: contain; }
  .gallery-item:hover img { transform: none; }
  .map-view img, .launch-card img { width: 100%; height: auto; object-fit: contain; }
  .segmented { display: flex; width: 100%; flex-wrap: wrap; border-radius: 18px; }
  .segmented button { flex: 1 1 auto; min-height: 44px; padding: 8px 10px; white-space: normal; }
  .launch-card, .question-block { padding: 24px 18px; }
  .launch-card .button, .question-links .button, .cv-actions .button { max-width: 100%; white-space: normal; line-height: 1.5; padding-block: 10px; }
  .case-nav-card, .case-nav-card.is-next { grid-template-columns: 76px minmax(0, 1fr); gap: 14px; }
  .case-nav-media img { object-fit: contain; }
  .case-nav-card h3 { overflow-wrap: anywhere; }
  .demo-window .window-bar { padding-inline: 12px; }
  .demo-body { padding: 18px 12px; }
  .feature-card { min-width: 0; }
  .feature-card p { overflow-wrap: anywhere; }
  .stepper li { grid-template-columns: 44px minmax(0, 1fr); padding-right: 0; }
  .intent-list li { grid-template-columns: 32px minmax(0, 1fr); }
  .mail-link { max-width: 100%; font-size: clamp(21px, 6vw, 28px); }
  .cv-sheet { padding: 24px 18px; }
  .footer-top, .footer-contact { min-width: 0; }
  .footer-contact > a { min-width: 0; overflow-wrap: anywhere; }
  .toast { max-width: calc(100% - 24px); bottom: calc(18px + env(safe-area-inset-bottom)); border-radius: 16px; text-align: center; }
  .palette { max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); margin-top: calc(16px + env(safe-area-inset-top)); }
  .palette-foot { gap: 8px 14px; flex-wrap: wrap; }
  .pal-hint { max-width: 28%; }
  .lightbox { height: 100dvh; padding: calc(68px + env(safe-area-inset-top)) 12px calc(84px + env(safe-area-inset-bottom)); }
  .lightbox figure { width: 100%; max-width: 100%; max-height: 100%; min-height: 0; }
  .lightbox img { min-height: 0; max-height: calc(100dvh - 200px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  .lightbox figcaption { max-width: 100%; font-size: 12px; text-align: center; overflow-wrap: anywhere; }
  .lb-close { top: calc(12px + env(safe-area-inset-top)); right: 12px; }
  .lb-prev, .lb-next { top: auto; bottom: calc(16px + env(safe-area-inset-bottom)); }
}

@media (max-width: 480px) {
  .identity { gap: 0; flex: 0 0 38px; }
  .identity-text { display: none; }
  .site-header { gap: 8px; justify-content: space-between; }
  .header-tools { gap: 4px; min-width: 0; }
  .header-tools .tool-button { min-height: 44px; min-width: 44px; padding-inline: 9px; }
  .header-tools .tool-button.icon-only, .header-tools .search-trigger { padding: 0; }
  .lang-switch { font-size: 12px; gap: 3px; }
  .intro-discrete .chapter-final h1 { font-size: clamp(36px, 10.3vw, 48px); }
}

@media (max-width: 860px) and (max-height: 650px) {
  .intro-discrete .intro-sticky { gap: 10px; padding-top: calc(var(--intro-header) + 6px); padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .intro-discrete .chapter-year { font-size: 44px; }
  .intro-discrete .chapter h2 { margin-top: 8px; font-size: 24px; }
  .intro-discrete .chapter > p:last-child, .intro-discrete .chapter-final > p:not(.chapter-year) { font-size: 13px; line-height: 1.5; margin-top: 9px; }
  .intro-discrete .chapter-final h1 { font-size: 36px; }
  .intro-discrete .chapter-final .hero-actions { margin-top: 12px; }
}

@media print {
  :root, :root[data-theme] {
    color-scheme: light;
    --bg: #fff; --surface: #fff; --ink: #111; --ink-2: #333; --muted: #555; --line: #ddd;
  }
  html, body { background: #fff !important; color: #111; }
  .page.cv-page { padding: 0 !important; }
  .cv-sheet { width: 100%; padding: 0 !important; border-radius: 0; background: #fff; overflow: visible; }
  .cv-sheet .cv-teaching p { font-size: 9.5pt; line-height: 1.65; }
}
