/* ============================================================
   naru.blog — Design System
   DESIGN.md 準拠 / tha.jp/works 参考
   ============================================================ */

/* ── Design Tokens ── */
:root {
  /* Typography */
  --font-heading: 'Inter', 'Noto Sans JP', system-ui, sans-serif;
  --font-body: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;

  /* Type Scale (DESIGN.md Fluid Typography) */
  --text-xs:  clamp(0.75rem, calc(0.70rem + 0.25vw), 0.875rem);   /* 12→14px */
  --text-sm:  clamp(0.875rem, calc(0.83rem + 0.22vw), 1.00rem);   /* 14→16px */
  --text-base: clamp(1.00rem, calc(0.91rem + 0.45vw), 1.25rem);   /* 16→20px */
  --text-lg:  clamp(1.25rem, calc(1.14rem + 0.57vw), 1.56rem);    /* 20→25px */
  --text-xl:  clamp(1.56rem, calc(1.42rem + 0.71vw), 1.95rem);    /* 25→31px */
  --text-2xl: clamp(1.95rem, calc(1.78rem + 0.89vw), 2.44rem);    /* 31→39px */

  /* Spacing (8px grid) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  /* Container */
  --container-text: 680px;
  --container-std: 1080px;
  --container-wide: 1280px;
  --container-px: clamp(16px, 5vw, 80px);

  /* Dark palette (Visualizer / Chat) */
  --dark-bg: #09090B;
  --dark-surface: #18181B;
  --dark-border: #3F3F46;
  --dark-text: #FAFAFA;
  --dark-text-sub: #A1A1AA;
  --dark-text-mute: #71717A;

  /* Warm light palette (About / Note / Contact) — tha.jp inspired */
  --warm-bg: #E8E3DD;
  --warm-surface: #F2EEEA;
  --warm-card: #FFFFFF;
  --warm-border: #D5D0CA;
  --warm-text: #1A1A1A;
  --warm-text-sub: #6B6560;
  --warm-text-mute: #9E9890;

  /* Motion */
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 100ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;
}

/* ── Reset & Base ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--dark-bg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.75;
  letter-spacing: 0.02em;
  color: var(--dark-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* iOS 自動ズーム抑制（input の font-size が 16px 未満だとズームする） */
input[type="text"],
input[type="email"],
input[type="search"],
textarea {
  font-size: max(16px, var(--text-sm));
}

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

/* キーボードフォーカス可視化（マウスクリックでは出ない） */
:focus-visible {
  outline: 2px solid rgba(139, 92, 246, 0.7);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(139, 92, 246, 0.7);
  outline-offset: 3px;
}

/* 選択範囲の見た目 */
::selection {
  background: rgba(139, 92, 246, 0.35);
  color: #fff;
}

/* ============================================================
   Header
   ============================================================ */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(9, 9, 11, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  transition: background var(--duration-slow) var(--ease-out);
}

.logo {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--dark-text);
  opacity: 0.8;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.logo:hover { opacity: 1; }

.header-nav {
  display: flex;
  gap: var(--space-6);
}

.header-nav a {
  color: var(--dark-text);
  text-decoration: none;
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  opacity: 0.4;
  transition: opacity var(--duration-normal) var(--ease-out);
  padding: var(--space-2) var(--space-1);
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}

.header-nav a:hover { opacity: 0.9; }
.header-nav a:focus-visible { opacity: 1; }

/* ============================================================
   Content Blocks — 共通
   ============================================================ */
.content-section {
  position: relative;
  z-index: 10;
}

.block {
  width: 100%;
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.block-inner {
  max-width: var(--container-std);
  width: 100%;
  padding: var(--space-20) var(--container-px);
}

/* ============================================================
   Block: Visualizer (Music Player) — 暗いまま
   ============================================================ */
.block--visualizer {
  min-height: auto;
  padding: 0;
  background: var(--dark-bg);
}

#visualizer-section {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#controls {
  position: absolute;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: var(--space-3) var(--space-6);
  border-radius: 9999px;
  border: 1px solid rgba(255,255,255,0.06);
}

#controls button {
  background: none;
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: var(--text-sm);
  transition: background var(--duration-normal) var(--ease-out);
  display: flex;
  align-items: center;
  justify-content: center;
}

#controls button:hover { background: rgba(255,255,255,0.08); }

#track-name {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--dark-text-sub);
  opacity: 0.6;
}

#time-display {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--dark-text-mute);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Block: About — 温かいライト。ツリー＋鳥が一画面でまとまるよう
   画面高さ（100svh）を確保し、ヘッダー高さ分のクリアランスを持たせる
   ============================================================ */
.block--about {
  background: var(--warm-bg);
  color: var(--warm-text);
  position: relative;
  overflow: hidden;
  min-height: 100svh;
  /* ヘッダー(fixed)の高さ分、内側に安全余白を */
  padding-top: clamp(64px, 8vh, 96px);
  padding-bottom: clamp(32px, 5vh, 64px);
}

#about-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  opacity: 0.55;
}

.block--about .block-inner {
  position: relative;
  z-index: 3;
  /* 100svh の中で縦方向にも余裕をもたせつつ収める */
  padding-top: 0;
  padding-bottom: 0;
}

.block--about .about-label {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--warm-text-mute);
  margin-bottom: var(--space-12);
}

.about-profile {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  margin-bottom: var(--space-7);
}

.about-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.about-avatar:hover {
  transform: scale(1.04);
  box-shadow: 0 6px 20px rgba(120, 70, 30, 0.22);
}
.about-avatar.is-feeding {
  animation: avatar-feed 0.32s ease;
}
@keyframes avatar-feed {
  0%   { transform: scale(1); }
  40%  { transform: scale(0.92) rotate(-4deg); }
  100% { transform: scale(1); }
}

.block--about h2 {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: #2a2622;
  margin-bottom: var(--space-2);
}

.about-title {
  font-size: var(--text-xs);
  color: #8a827a;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
}

.about-bio {
  font-size: var(--text-sm);
  line-height: 2.0;
  color: #5a544d;
  max-width: 52ch;
  letter-spacing: 0.02em;
  margin-bottom: var(--space-8);
  padding-left: var(--space-4);
  border-left: 1px solid rgba(120, 100, 80, 0.18);
}

.about-links {
  display: flex;
  gap: var(--space-6);
  flex-wrap: wrap;
  margin-top: var(--space-2);
}

/* 餌ボタン — 温かみのあるガラスピル */
.about-actions {
  margin-top: var(--space-3);
}
.about-feed-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid rgba(120, 80, 40, 0.25);
  background: linear-gradient(180deg, rgba(255, 248, 235, 0.85), rgba(255, 236, 210, 0.75));
  color: var(--warm-text);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(120, 70, 30, 0.12),
              inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.about-feed-btn:hover {
  background: linear-gradient(180deg, rgba(255, 250, 240, 0.95), rgba(255, 228, 195, 0.85));
  box-shadow: 0 6px 18px rgba(120, 70, 30, 0.18),
              inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.about-feed-btn:active,
.about-feed-btn.is-pressed {
  transform: scale(0.96);
  box-shadow: 0 2px 8px rgba(120, 70, 30, 0.18),
              inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.about-feed-ico {
  font-size: 1.1em;
  line-height: 1;
}

.about-links a {
  color: var(--warm-text);
  text-decoration: none;
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 500;
  opacity: 0.4;
  border-bottom: 1px solid var(--warm-border);
  padding-bottom: 2px;
  transition: opacity var(--duration-normal) var(--ease-out);
  min-height: 48px;
  display: inline-flex;
  align-items: center;
}

.about-links a:hover { opacity: 0.8; }

/* ============================================================
   Block: Note — tha.jp/works 的ウォームライト
   ============================================================ */
.block--note {
  background: var(--warm-surface);
  color: var(--warm-text);
}

.block--note .block-inner {
  max-width: var(--container-wide);
  padding: var(--space-20) var(--container-px);
}

.block--note .note-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-8);
}

.block--note .note-header h2 {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--warm-text-mute);
}

.block--note .note-header a {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--warm-text-sub);
  text-decoration: none;
  transition: color var(--duration-normal) var(--ease-out);
  min-height: 48px;
  display: inline-flex;
  align-items: center;
}

.block--note .note-header a:hover { color: var(--warm-text); }

.note-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

.note-card {
  background: var(--warm-card);
  border-radius: 16px;
  overflow: hidden;
  transition: transform var(--duration-slow) var(--ease-out),
              box-shadow var(--duration-slow) var(--ease-out);
  text-decoration: none;
  color: inherit;
  display: block;
}

.note-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08),
              0 2px 4px -2px rgba(0, 0, 0, 0.06);
}

.note-card:focus-visible {
  outline: 2px solid rgba(139, 92, 246, 0.7);
  outline-offset: 2px;
}

.note-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--warm-bg);
  overflow: hidden;
}

.note-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-slow) var(--ease-out);
}

.note-card:hover .note-thumb img {
  transform: scale(1.03);
}

.note-card-body {
  padding: var(--space-4) var(--space-4) var(--space-6);
}

.note-card-body h3 {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.75;
  color: var(--warm-text);
}

.note-card-body .note-date {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  color: var(--warm-text-mute);
  margin-top: var(--space-2);
}

/* ============================================================
   Block: Contact — ウォームライト
   ============================================================ */
.block--contact {
  background: var(--warm-bg);
  color: var(--warm-text);
  min-height: 50vh;
  text-align: center;
}

.block--contact h2 {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--warm-text-sub);
  margin-bottom: var(--space-6);
}

.block--contact a {
  color: var(--warm-text);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid var(--warm-border);
  padding-bottom: 4px;
  transition: opacity var(--duration-normal) var(--ease-out),
              border-color var(--duration-normal) var(--ease-out);
  opacity: 0.5;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
}

.block--contact a:hover {
  opacity: 1;
  border-color: var(--warm-text);
}

/* ============================================================
   Block: Retro Chat — 暗いまま（レトロ感を維持）
   ============================================================ */
.block--chat {
  background: var(--dark-surface);
  color: #ccc;
  font-family: 'MS PGothic', 'Osaka', 'Hiragino Kaku Gothic ProN', monospace;
  min-height: 80vh;
}

.block--chat .block-inner {
  max-width: var(--container-std);
}

.rc-header {
  border-bottom: 1px solid var(--dark-border);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-4);
}

.rc-title {
  font-size: var(--text-base);
  font-weight: bold;
  color: #e44;
  letter-spacing: 0.05em;
}

.rc-title small {
  font-weight: normal;
  font-size: var(--text-xs);
  color: var(--dark-text-mute);
  margin-left: var(--space-2);
}

.rc-desc {
  font-size: var(--text-xs);
  color: var(--dark-text-mute);
  margin-top: var(--space-1);
}

/* 入室フォーム */
.rc-enter {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.rc-enter-label {
  font-size: var(--text-xs);
  color: var(--dark-text-sub);
}

.rc-enter input[type="text"] {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-family: inherit;
  background: var(--dark-bg);
  border: 1px solid var(--dark-border);
  border-radius: 8px;
  color: var(--dark-text);
  width: 160px;
  height: 48px;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.rc-enter input[type="text"]:focus {
  outline: none;
  border-color: #8B5CF6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.rc-enter button {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-family: inherit;
  background: var(--dark-surface);
  border: 1px solid var(--dark-border);
  border-radius: 8px;
  color: var(--dark-text);
  cursor: pointer;
  height: 48px;
  min-width: 80px;
  transition: background var(--duration-normal) var(--ease-out);
}

.rc-enter button:hover { background: #27272A; }

/* 参加者 */
.rc-members {
  font-size: var(--text-xs);
  color: var(--dark-text-mute);
  margin-bottom: var(--space-3);
}

.rc-members span { color: #22C55E; }

/* ログエリア */
.rc-log {
  padding: var(--space-3) 0;
  min-height: 120px;
  margin-bottom: var(--space-3);
}

.rc-line {
  font-size: var(--text-sm);
  line-height: 1.7;
  word-break: break-all;
  margin-bottom: var(--space-2);
}

.rc-name { font-weight: bold; }
.rc-name-ai { color: #f44; font-weight: bold; }
.rc-line-system { color: var(--dark-text-mute); }
.rc-line-system .rc-sysname { color: var(--dark-text-sub); font-weight: bold; }

.rc-time {
  color: var(--dark-text-mute);
  font-size: var(--text-xs);
  margin-left: var(--space-1);
}

.rc-msg { color: #ccc; }

.rc-typing { color: #f44; font-size: var(--text-sm); }
.rc-typing-dots::after {
  content: '';
  animation: typingDots 1.2s steps(4, end) infinite;
}

@keyframes typingDots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

.rc-empty {
  color: var(--dark-text-mute);
  font-size: var(--text-sm);
  text-align: center;
  padding: var(--space-8) 0;
}

/* 発言フォーム */
.rc-send {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.rc-send input[type="text"] {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-family: inherit;
  background: var(--dark-bg);
  border: 1px solid var(--dark-border);
  border-radius: 8px;
  color: var(--dark-text);
  height: 48px;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.rc-send input[type="text"]:focus {
  outline: none;
  border-color: #8B5CF6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.rc-send button {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-family: inherit;
  background: var(--dark-surface);
  border: 1px solid var(--dark-border);
  border-radius: 8px;
  color: var(--dark-text);
  cursor: pointer;
  white-space: nowrap;
  height: 48px;
  min-width: 80px;
  transition: background var(--duration-normal) var(--ease-out);
}

.rc-send button:hover { background: #27272A; }

.rc-send button:disabled {
  opacity: 0.4;
  cursor: default;
}

.rc-status {
  font-size: var(--text-xs);
  color: #EF4444;
  min-height: 1.5em;
  margin-top: var(--space-2);
}

/* hidden states */
.rc-send.hidden,
.rc-members.hidden,
.rc-enter.hidden { display: none; }

/* ============================================================
   Block: Tokyo 3D Music Visualizer
   ============================================================ */
.block--tokyo {
  min-height: auto;
  padding: 0;
  background: #f7f3e8;
}

#tokyo-section {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: #f7f3e8;
  transition: background 0.6s var(--ease-out);
}

#tokyo-section.dark-mode {
  background: #05040a;
}

#tokyo-canvas {
  display: block;
  width: 100%;
  height: 100%;
  /* SP は touches 無効化と合わせて、全タッチをブラウザに通す（スクロール優先） */
  touch-action: auto;
}

/* ── 中央の大型再生ボタン（再生前に表示） ── */
.tokyo-play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 92px;
  height: 92px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.92);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 25;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: opacity 0.6s ease, transform 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
  animation: tokyoPlayPulse 2.4s ease-in-out infinite;
}
.tokyo-play-overlay svg {
  margin-left: 4px; /* 三角形の視覚重心を中央に寄せる */
}
.tokyo-play-overlay:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(255, 255, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.tokyo-play-overlay:active {
  transform: translate(-50%, -50%) scale(0.96);
}
.tokyo-play-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.9);
}
@keyframes tokyoPlayPulse {
  0%, 100% { box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1), 0 0 0 0 rgba(255,255,255,0.10); }
  50%      { box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1), 0 0 0 16px rgba(255,255,255,0); }
}

/* ── Caption (Naru 関連語・回転表示) ── */
.tokyo-caption {
  position: absolute;
  top: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono, 'Inter', ui-monospace, monospace);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  text-shadow: 0 0 24px rgba(255, 255, 255, 0.12);
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  opacity: 0.85;
  transition: opacity 0.9s ease;
}

/* ── ボトム UI 配置（縦に積む：controls → stop → track） ──
   controls: bottom 24px
   stop    : bottom 88px（再生中のみ）
   track   : bottom 148px
*/

.tokyo-controls {
  position: absolute;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  z-index: 20;
}

.tokyo-controls button {
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 10px 16px;
  min-height: 36px;
  background: transparent;
  border: none;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.60);
  cursor: pointer;
  transition: color 0.28s ease, background 0.28s ease, transform 0.12s ease;
}

.tokyo-controls button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.tokyo-controls button:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.tokyo-controls button:active {
  transform: scale(0.96);
}

/* Stop（停止）フロートボタン — 再生中のみ下中央（controlsの上）に出現 */
.tokyo-stop-float {
  position: absolute;
  bottom: calc(var(--space-6) + 64px);
  left: 50%;
  transform: translateX(-50%) translateY(0);
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  color: rgba(255, 255, 255, 0.85);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 10px 30px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  z-index: 22;
  opacity: 1;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(.2,.8,.2,1),
              background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.tokyo-stop-float:hover {
  background: rgba(255, 80, 80, 0.18);
  color: #ffeaea;
  box-shadow: inset 0 0 0 1px rgba(255, 120, 120, 0.45),
              0 0 22px rgba(255, 60, 60, 0.22),
              0 10px 30px rgba(0, 0, 0, 0.45);
}

.tokyo-stop-float:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55),
              0 10px 30px rgba(0, 0, 0, 0.45);
}

.tokyo-stop-float:active {
  transform: translateX(-50%) scale(0.94);
}

.tokyo-stop-float.is-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
  pointer-events: none;
}

/* 非表示互換（旧 #tokyo-play 参照が残っても影響しないように） */
.tokyo-play-btn-hidden {
  position: absolute;
  width: 0;
  height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.tokyo-track {
  position: absolute;
  bottom: calc(var(--space-6) + 128px);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.55);
  padding: 5px 14px;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 9999px;
  z-index: 20;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100% - 48px);
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.9;
  transition: color 0.3s, background 0.3s;
}

/* =============================================================
   背景輝度に応じた UI 自動明暗（is-light-ui / is-dark-ui）
   — 墨絵や日中サイクルで背景色が変わるので、ボタン/テキストを常に見やすく
   ============================================================= */

/* 明るい背景（紙色・昼）用：濃い文字＆淡いグラスボタン */
#tokyo-section.is-light-ui .tokyo-caption,
#tokyo-section.is-light-ui .tokyo-track {
  color: rgba(28, 22, 16, 0.72);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.35);
  border-color: rgba(28, 22, 16, 0.10);
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
}

#tokyo-section.is-light-ui .tokyo-controls {
  background: rgba(40, 32, 24, 0.10);
  border-color: rgba(40, 32, 24, 0.12);
  box-shadow: 0 10px 32px rgba(60, 40, 20, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

#tokyo-section.is-light-ui .tokyo-controls button {
  color: rgba(28, 22, 16, 0.75);
  font-weight: 600;
}

#tokyo-section.is-light-ui .tokyo-controls button:hover {
  background: rgba(28, 22, 16, 0.08);
  color: rgba(20, 14, 8, 1);
}

#tokyo-section.is-light-ui .tokyo-controls button:focus-visible {
  background: rgba(28, 22, 16, 0.10);
  color: rgba(20, 14, 8, 1);
  box-shadow: inset 0 0 0 1px rgba(28, 22, 16, 0.35);
}

#tokyo-section.is-light-ui .tokyo-stop-float {
  background: rgba(255, 255, 255, 0.55);
  color: rgba(20, 14, 8, 0.82);
  box-shadow: inset 0 0 0 1px rgba(28, 22, 16, 0.14),
              0 10px 30px rgba(60, 40, 20, 0.22);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

#tokyo-section.is-light-ui .tokyo-stop-float:hover {
  background: rgba(255, 240, 240, 0.85);
  color: #a41e1e;
  box-shadow: inset 0 0 0 1px rgba(180, 40, 40, 0.45),
              0 0 22px rgba(180, 40, 40, 0.18),
              0 10px 30px rgba(60, 40, 20, 0.25);
}

/* 中央の大型再生ボタンも、明るい背景では濃いガラスに */
#tokyo-section.is-light-ui .tokyo-play-overlay {
  background: rgba(40, 32, 24, 0.18);
  border-color: rgba(40, 32, 24, 0.25);
  color: rgba(20, 14, 8, 0.88);
  box-shadow: 0 20px 60px rgba(60, 40, 20, 0.25),
              inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

#tokyo-section.is-light-ui .tokyo-play-overlay:hover {
  background: rgba(40, 32, 24, 0.28);
  border-color: rgba(40, 32, 24, 0.45);
  box-shadow: 0 20px 60px rgba(60, 40, 20, 0.3),
              0 0 40px rgba(255, 240, 220, 0.3),
              inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* Mobile tweaks */
@media (max-width: 639px) {
  /* SP：手動の視点操作を無効化したので、縦スワイプはすべてページスクロールに通る。
     そのため Tokyo はフル画面（100svh）でカッコよく見せる */
  #tokyo-section {
    height: 100svh;
    min-height: 520px;
  }

  /* SP では餌まき機構は非表示（鳥が自由に飛んでいる静かな画にする） */
  .about-actions,
  .about-feed-btn {
    display: none !important;
  }

  .tokyo-play-overlay {
    width: 76px;
    height: 76px;
  }
  .tokyo-play-overlay svg {
    width: 22px;
    height: 26px;
  }

  /* SP ではキャプション（NARU KUROKAWA / NARRATIVE）は非表示
     — トラック名ピルと位置が被るため、装飾要素をカット */
  .tokyo-caption {
    display: none;
  }
  .tokyo-track {
    /* SP では下からでなく上・右寄せにまわしてスクロール領域を確保 */
    bottom: auto;
    top: calc(56px + var(--space-3));
    left: auto;
    right: var(--space-3);
    transform: none;
    font-size: 9px;
    max-width: 58%;
  }

  /* 停止ボタンは左上（ヘッダー直下） — スクロール邪魔しない位置 */
  .tokyo-stop-float {
    top: calc(56px + var(--space-3));
    bottom: auto;
    left: var(--space-3);
    transform: none;
    width: 38px;
    height: 38px;
  }
  .tokyo-stop-float:active {
    transform: scale(0.94);
  }
  .tokyo-stop-float.is-hidden {
    transform: translateY(-8px);
  }

  /* コントロールピルは下中央のまま、タップしやすく */
  .tokyo-controls {
    bottom: var(--space-5);
    flex-wrap: wrap;
    justify-content: center;
    max-width: calc(100% - 24px);
    padding: 5px;
  }
  .tokyo-controls button {
    padding: 9px 13px;
    font-size: 9.5px;
    letter-spacing: 0.18em;
    min-height: 34px;
  }
}

/* ============================================================
   Footer — ウォームライト
   ============================================================ */
footer {
  padding: var(--space-12) var(--container-px);
  text-align: center;
  background: var(--warm-bg);
  border-top: 1px solid var(--warm-border);
}

footer p {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  color: var(--warm-text-mute);
}

/* ============================================================
   Responsive
   ============================================================ */

/* Tablet (640px+) */
@media (min-width: 640px) {
  .note-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
  }
}

/* Small Desktop (768px+) */
@media (min-width: 768px) {
  .note-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
  }
}

/* Mobile (max 639px) */
@media (max-width: 639px) {
  header {
    padding: var(--space-3) var(--space-4);
  }
  .header-nav { gap: var(--space-4); }

  /* SP：基本は auto、ただし About / Chat / Contact は 1画面フル */
  .block {
    min-height: auto;
  }
  .block--about,
  .block--chat,
  .block--contact {
    min-height: 100svh;
  }

  /* scroll-snap は iOS で挙動が粘っこく、少しのスワイプで戻されるので無効化。
     代わりに各セクションを 100svh にしてあるので、見た目はそのまま
     「1画面1コンテンツ」を保ちつつ、スクロール自体は自然に動く。 */

  /* Chat: SP では縦に余裕を持って中央寄せ */
  .block--chat {
    display: flex;
    align-items: center;
  }
  .block--chat .block-inner {
    width: 100%;
    padding: var(--space-16) var(--space-4);
  }

  .block-inner {
    padding: var(--space-16) var(--space-4);
  }

  .block--note .block-inner {
    padding: var(--space-16) var(--space-4);
  }

  .note-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .note-card {
    border-radius: 12px;
  }

  /* About: ツリーが1画面に収まるよう、コンテンツを上寄せ気味に縮める */
  .block--about {
    padding-top: clamp(72px, 10vh, 110px);
  }
  .block--about .block-inner {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .about-profile {
    gap: var(--space-4);
    margin-bottom: var(--space-6);
  }

  .block--about .about-label {
    margin-bottom: var(--space-6);
  }

  .about-avatar {
    width: 72px;
    height: 72px;
  }

  .about-links {
    gap: var(--space-4);
  }

  /* チャット：入室フォームが横幅を食うので縦積みに */
  .rc-enter {
    flex-wrap: wrap;
  }
  .rc-enter input[type="text"] {
    flex: 1;
    min-width: 0;
    width: auto;
  }

  .rc-send input[type="text"] {
    min-width: 0;
  }

  .block--contact {
    min-height: 40vh;
  }

  footer {
    padding: var(--space-8) var(--space-4);
    padding-bottom: calc(var(--space-8) + env(safe-area-inset-bottom, 0px));
  }
}

/* 横長モバイル（縦が短い）では visualizer/tokyo のフル高さを控えめに */
@media (max-width: 639px) and (max-height: 560px) {
  #visualizer-section,
  #tokyo-section {
    height: 100svh;
    min-height: 480px;
  }
}
