:root {
  --bg: #ffffff;
  --bg-alt: #f6f7f9;
  --surface: #ffffff;
  --text: #1c1f24;
  --text-muted: #5b6370;
  --border: #e3e6eb;
  --accent: #2563eb;
  --accent-contrast: #ffffff;
  --accent-soft: #e8efff;
  --bubble-user: #2563eb;
  --bubble-user-text: #ffffff;
  --bubble-ai: #f0f2f5;
  --danger: #c62828;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
  --header-h: 96px;
  --font: "Hiragino Sans", "Noto Sans JP", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --bg-alt: #171b21;
    --surface: #1d222a;
    --text: #e7eaee;
    --text-muted: #9aa3af;
    --border: #2c333d;
    --accent: #6c9cff;
    --accent-contrast: #0b1020;
    --accent-soft: #1f2a44;
    --bubble-user: #3b6fe0;
    --bubble-user-text: #ffffff;
    --bubble-ai: #252b34;
    --danger: #ff7b7b;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 8px);
}

body {
  margin: 0;
  font-family: var(--font);
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--accent);
}

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

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

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  /* border-bottom: 1px solid transparent; */
  transition: background-color 0.2s, border-color 0.2s;
}

/* ページ最上部では透明にして背景動画を見せ、スクロールしたら背景色を付ける（js/main.js で切り替え） */
.site-header.is-scrolled {
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom-color: var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
}

.nav-brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 20px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.nav-links a:hover {
  color: var(--text);
}

.nav-links {
  margin-left: auto;
}

.lang-switch {
  display: inline-flex;
  flex-shrink: 0;
  margin-left: 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.lang-switch button {
  padding: 2px 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.lang-switch button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-contrast);
}

/* Buttons */
.btn {
  display: inline-block;
  border: none;
  border-radius: 999px;
  padding: 10px 24px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 4px 14px;
  font-size: 0.85rem;
}

/* Hero */
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  /* header の裏まで動画を広げ、header と hero を一続きに見せる */
  margin-top: calc(-1 * var(--header-h));
  padding: calc(96px + var(--header-h)) 0 120px;
}

/* 背景動画。上に重ねた半透明の背景色で文字を読みやすくする */
.hero-video {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
}

.hero > .container {
  position: relative;
}

.hero-eyebrow {
  margin: 0;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.hero-name {
  margin: 8px 0 16px;
  font-size: clamp(2.2rem, 7vw, 3.4rem);
  line-height: 1.2;
}

.hero-lead {
  max-width: 36em;
  margin: 0 0 32px;
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* Sections */
.section {
  padding: 72px 0;
}

.section-alt {
  background: var(--bg-alt);
}

.section-title {
  margin: 0 0 28px;
  font-size: 1.6rem;
}

.section-lead {
  margin: -12px 0 24px;
  color: var(--text-muted);
}

/* Skills */
.skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.skill-item {
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.skill-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.skill-name {
  font-weight: 700;
}

.skill-years {
  flex-shrink: 0;
  white-space: nowrap;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
}

.skills-extra {
  margin: 24px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.skill-note {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Works */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

/* 制作物の横スクロール（js/scroll-fx.js が有効にしたときだけ横一列に並べる） */
#works {
  overflow: hidden;
}

/* 画面上端で固定している間も見出しが header に隠れないよう、上の余白を header の分だけ取る。
   固定中に画面へ収まるよう、下の余白は減らす */
#works:has(.card-grid.is-horizontal) {
  padding: calc(var(--header-h) + 24px) 0 32px;
}

.card-grid.is-horizontal {
  display: flex;
  will-change: transform;
}

.card-grid.is-horizontal > .card {
  flex: 0 0 min(300px, 80vw);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
}

/* カード内のリンクのクリック範囲をカード全体に広げる */
.card-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.card:has(.card-link:hover) {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.card-link:focus-visible {
  outline: none;
}

.card:has(.card-link:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-title {
  margin: 0 0 8px;
  font-size: 1.1rem;
  overflow-wrap: anywhere;
}

.card-summary {
  flex: 1;
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.tag {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
}

.card-link {
  font-weight: 600;
  text-decoration: none;
}

/* Blog */
.blog-card {
  padding: 0;
  overflow: hidden;
}

.blog-card-img {
  display: block;
  width: 100%;
  aspect-ratio: 309 / 160;
  object-fit: cover;
  background: var(--bg-alt);
}

.blog-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 16px 20px 20px;
}

.blog-card .card-title {
  flex: 1;
}

.blog-card-date {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.blog-status {
  margin: 0;
  color: var(--text-muted);
}

.skills-more,
.works-more,
.blog-more {
  margin: 24px 0 0;
  text-align: center;
}

/* Architecture */
.arch {
  margin: 0 0 24px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.arch svg {
  display: block;
  width: 100%;
  height: auto;
}

.arch-box {
  fill: var(--bg-alt);
  stroke: var(--border);
  stroke-width: 1.5;
}

.arch-accent {
  fill: var(--accent-soft);
  stroke: var(--accent);
}

.arch-group {
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1;
  stroke-dasharray: 5 4;
}

.arch-label {
  fill: var(--text);
  font-size: 15px;
  font-weight: 700;
  text-anchor: middle;
}

.arch-sub {
  fill: var(--text-muted);
  font-size: 12.5px;
  text-anchor: middle;
}

.arch-line {
  stroke: var(--text-muted);
  stroke-width: 1.6;
}

.arch-arrowhead {
  fill: var(--text-muted);
}

.design-notes {
  margin: 0;
  padding-left: 1.2em;
}

.design-notes li {
  margin-bottom: 8px;
}

/* Contact */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 640px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-weight: 600;
  font-size: 0.95rem;
}

.field input,
.field textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.field textarea {
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field [aria-invalid="true"] {
  border-color: var(--danger);
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.85rem;
}

.field-error:empty {
  display: none;
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}

.contact-status {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.contact-status.is-success {
  color: var(--accent);
  font-weight: 600;
}

.contact-status.is-error {
  color: var(--danger);
}

.recaptcha-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* reCAPTCHA のバッジは右下のチャットボタンと重なるため隠す（代わりにフォームの下に規定の文言を表示している） */
.grecaptcha-badge {
  visibility: hidden;
}

/* Chat（画面右下の開閉式ウィジェット） */
.chat-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.chat-launcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 20px 0 16px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font: inherit;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.chat-launcher:hover {
  filter: brightness(1.08);
}

.chat-launcher .icon-close,
.chat-launcher[aria-expanded="true"] .icon-open,
.chat-launcher[aria-expanded="true"] .chat-launcher-label {
  display: none;
}

.chat-launcher[aria-expanded="true"] {
  width: 52px;
  padding: 0;
  justify-content: center;
}

.chat-launcher[aria-expanded="true"] .icon-close {
  display: block;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(400px, calc(100vw - 40px));
  height: min(640px, calc(100vh - 120px));
  padding: 14px 16px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  animation: chat-pop 0.18s ease-out;
}

.chat-panel[hidden] {
  display: none;
}

@keyframes chat-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.chat-title {
  margin: 0;
  font-size: 1.05rem;
}

.chat-lead {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.chat-close {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.chat-close:hover {
  background: var(--bg-alt);
  color: var(--text);
}

.chat-log {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 4px;
}

.msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.msg-user {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-ai {
  align-self: flex-start;
  align-items: flex-start;
}

.bubble {
  padding: 10px 14px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-user .bubble {
  background: var(--bubble-user);
  color: var(--bubble-user-text);
  border-bottom-right-radius: 4px;
}

.msg-ai .bubble {
  background: var(--bubble-ai);
  border-bottom-left-radius: 4px;
}

.msg-error .bubble {
  color: var(--danger);
  border: 1px solid var(--danger);
  background: transparent;
}

.msg-actions {
  margin-top: 6px;
}

.msg-note {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.tool-badges:empty {
  display: none;
}

.tool-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}

.tool-badge {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
}

.loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.dots {
  display: inline-flex;
  gap: 4px;
}

.dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: blink 1.2s infinite ease-in-out;
}

.dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

/* 会話欄を広く取れるよう、質問例は横 1 行に並べて横スクロールさせる */
.chat-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chat-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-form textarea {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.chat-form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.chat-meta {
  text-align: right;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.chat-notice {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Footer */
.site-footer {
  /* 下側は右下のチャットボタンと重ならないよう広めに取る */
  padding: 32px 0 96px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer-inner p {
  margin: 4px 0;
}

.footer-copy {
  margin-top: 12px !important;
  font-size: 0.8rem;
}

@media (max-width: 600px) {
  .nav-links {
    gap: 12px;
    font-size: 0.8rem;
  }

  .nav-brand {
    font-size: 0.9rem;
  }

  .hero {
    padding: calc(64px + var(--header-h)) 0 56px;
  }

  .section {
    padding: 56px 0;
  }

  .msg {
    max-width: 92%;
  }

  /* スマホではパネルを画面いっぱいに広げ、閉じるボタンはパネル上部のものを使う */
  .chat-widget {
    right: 16px;
    bottom: 16px;
  }

  .chat-open .chat-widget {
    inset: 8px;
  }

  .chat-panel {
    width: 100%;
    height: 100%;
  }

  .chat-launcher[aria-expanded="true"] {
    display: none;
  }
}

@media (max-width: 720px) {
  .nav-links li:nth-child(4) {
    display: none;
  }
}

@media (max-width: 480px) {
  .nav-links li:nth-child(2) {
    display: none;
  }

  .lang-switch {
    margin-left: 10px;
  }
}

@media (max-width: 380px) {
  .nav-links li:nth-child(1) {
    display: none;
  }
}

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

  .dots span,
  .chat-panel {
    animation: none;
  }

  .hero-video {
    display: none;
  }
}
