:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-raised: #ffffff;
  --border: #e2e8f0;
  --fg: #334155;
  --heading: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --accent: #0a422f;
  --accent-deep: #062e21;
  --accent-bright: #b19460;
  --link: #1a56db;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: clip;
}

body {
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--fg);
  font-family: "Hiragino Sans", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.8;
  transition: background-color 0.3s, color 0.3s;
}

body.dark-mode {
  --bg: #0f172a;
  --bg-raised: #1e293b;
  --border: #334155;
  --fg: #e2e8f0;
  --heading: #f8fafc;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --accent: #2f7a57;
  --accent-deep: #4fae82;
  --accent-bright: #c9a876;
  --link: #6ea8fe;
}

body.dark-mode header {
  background-color: rgba(15, 23, 42, 0.9);
  border-bottom-color: rgba(51, 65, 85, 0.8);
}

body.dark-mode .home-hero,
body.dark-mode .home-section.alt-bg {
  background-color: #1e293b;
  background-image:
    conic-gradient(#263449 90deg, #1a2437 90deg 180deg, #263449 180deg 270deg, #1a2437 270deg);
}

body.dark-mode .home-hero .hero-title {
  color: #eaf7ef;
}

body.dark-mode .home-hero .hero-title::before {
  background: radial-gradient(ellipse at 50% 55%, rgba(148, 163, 184, 0.35) 0%, rgba(148, 163, 184, 0.18) 45%, rgba(148, 163, 184, 0) 75%);
}

body.dark-mode .article-body pre {
  background: #0b1220;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.82rem;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.icon-btn:hover {
  color: var(--accent);
  background-color: rgba(10, 66, 47, 0.06);
}

body.dark-mode .icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.lang-toggle {
  margin-left: 0.25rem;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

header .site-title a {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-img {
  height: 28px;
  width: auto;
  display: block;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

header nav {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 2rem);
}

header nav a {
  margin-left: 0;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  transition: color 0.2s ease;
}

header nav a:hover {
  color: var(--accent);
}

.header-toggles {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.nav-toggle-btn {
  display: none;
  background: transparent;
  border: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--fg);
  cursor: pointer;
  flex-shrink: 0;
}

.nav-toggle-btn:hover {
  background-color: rgba(10, 66, 47, 0.06);
}

body.dark-mode .nav-toggle-btn:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

@media (max-width: 640px) {
  .logo-img {
    height: 24px;
  }
  .header-right {
    gap: 0.25rem;
  }
  header nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background-color: var(--bg-raised);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
    padding: 0.5rem 0;
  }
  header.nav-open nav {
    display: flex;
  }
  header nav a {
    padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
    font-size: 1rem;
  }
  .nav-toggle-btn {
    display: inline-flex;
  }
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 3rem) 1.5rem;
}

.site-tagline {
  color: var(--accent-deep);
  font-size: clamp(0.95rem, 2vw, 1.05rem);
  font-weight: 600;
  margin: 0 0 2rem;
  max-width: 32rem;
  animation: fade-up 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.terminal-box {
  background: #0f172a;
  border-radius: 12px;
  padding: 1.75rem 2.25rem;
  color: var(--accent-bright);
  font-size: 1.15rem;
  margin-bottom: 2.5rem;
  width: 100%;
  max-width: 34rem;
  box-sizing: border-box;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  animation: fade-up 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 0.1s;
}

@media (max-width: 480px) {
  .terminal-box {
    font-size: 0.95rem;
    padding: 1.5rem 1.25rem;
  }
}

.terminal-dots {
  display: flex;
  gap: 8px;
  margin-bottom: 1.1rem;
}

.terminal-dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.terminal-dots .dot-red { background: #ef4444; }
.terminal-dots .dot-yellow { background: #eab308; }
.terminal-dots .dot-green { background: #22c55e; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.article-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.03);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.article-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px rgba(2, 132, 199, 0.12);
  border-color: #7dd3fc;
}

.article-card h2 {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
}

.article-card h2 a {
  color: var(--heading);
  text-decoration: none;
}

.article-card h2 a:hover {
  color: var(--accent);
}

.article-card time {
  color: var(--muted-2);
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  color: var(--muted-2);
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.article-meta .reading-time::before {
  content: "·";
  margin-right: 0.75rem;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}

.tag-chip {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.article-card .article-tags {
  margin-top: 0.75rem;
  margin-bottom: 0;
}

.toc {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
}

.toc-title {
  margin: 0 0 0.5rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--heading);
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.toc li a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
}

.toc li a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.toc li.toc-sub {
  margin-left: 1.25rem;
}

.article-body img {
  max-width: 100%;
  border-radius: 8px;
}

.article-body pre {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  margin-top: 2rem;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--fg);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

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

.related-articles {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.related-articles h2 {
  font-size: 1.1rem;
  margin: 0 0 1rem;
  color: var(--heading);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.related-card {
  display: block;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-raised);
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.related-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
}

.related-card h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
  color: var(--heading);
}

.related-card p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--accent);
  z-index: 300;
  transition: width 0.1s linear;
}

#back-to-top {
  position: fixed;
  left: 1.5rem;
  bottom: 1.5rem;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--fg);
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
  z-index: 90;
}

#back-to-top[hidden] {
  display: none;
}

#back-to-top:hover {
  color: var(--accent);
  border-color: var(--accent);
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 480px;
}

form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 600;
}

form input,
form textarea {
  font: inherit;
  padding: 0.65rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: var(--bg-raised);
  color: var(--fg);
}

form button {
  font: inherit;
  font-weight: 700;
  padding: 0.7rem 1.4rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  width: fit-content;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
  transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

form button:hover {
  background: var(--accent-deep);
  box-shadow: 0 8px 20px rgba(2, 132, 199, 0.35);
  transform: translateY(-2px);
}

/* ボット対策のハニーポット。人間の利用者からは見えない位置に配置する。 */
.honeypot-field {
  position: absolute;
  left: -9999px;
}

#chat-toggle {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.4);
}

#chat-toggle:hover {
  background: var(--accent-deep);
}

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

#chat-panel {
  position: fixed;
  right: 1.5rem;
  bottom: 5.5rem;
  width: 320px;
  max-width: calc(100vw - 3rem);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#chat-log {
  height: 320px;
  overflow-y: auto;
  padding: 0.75rem;
}

.chat-message {
  margin: 0 0 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.875rem;
  max-width: 85%;
}

.chat-user {
  background: var(--accent);
  color: white;
  margin-left: auto;
}

.chat-ai {
  background: var(--border);
  color: var(--fg);
}

#chat-form {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  max-width: none;
}

#chat-form input {
  flex: 1;
}

.reveal-init {
  opacity: 0;
  transform: translateY(56px) scale(0.94);
  transition: opacity 0.85s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.85s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-init.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.reveal-right-init {
  opacity: 0;
  transform: translateX(-60px);
  transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

.reveal-left-init {
  opacity: 0;
  transform: translateX(60px);
  transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

.reveal-right-init.is-visible,
.reveal-left-init.is-visible {
  opacity: 1;
  transform: translateX(0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal-init,
  .reveal-right-init,
  .reveal-left-init {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

footer {
  text-align: center;
  color: var(--muted-2);
  font-size: 0.8rem;
  padding: 2rem 1.5rem;
}

.footer-mark {
  display: block;
  width: 40px;
  height: 40px;
  margin: 0 auto 0.75rem;
  border-radius: 8px;
  opacity: 0.9;
}
