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

:root {
  color-scheme: light;
  --bg: rgb(237, 233, 230);
  --surface: rgb(244, 240, 237);
  --text: rgb(92, 79, 74);
  --muted: rgba(92, 79, 74, 0.7);
  --border: rgba(92, 79, 74, 0.18);
  --primary: rgb(201, 153, 107);
  --primary-hover: rgb(186, 139, 95);
  --secondary: rgb(92, 118, 109);
  --secondary-hover: rgb(80, 104, 96);
  --accent-text: rgb(237, 233, 230);
  --danger: rgb(176, 82, 73);
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, sans-serif;
  background:
    radial-gradient(circle at top, rgba(201, 153, 107, 0.12), transparent 32%),
    linear-gradient(180deg, rgb(241, 237, 234) 0%, var(--bg) 28%, var(--bg) 100%);
  color: var(--text);
  line-height: 1.5;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  max-width: 960px;
  margin: 0 auto;
  padding: 0.4rem 1rem;
}

.site-logo {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.25;
  color: inherit;
  text-decoration: none;
}

.site-logo:hover {
  text-decoration: underline;
}

.header-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.header-nav a {
  color: inherit;
  font-size: 0.95rem;
  text-decoration: none;
}

.header-nav a:hover {
  text-decoration: underline;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 0.65rem 1.25rem 1.25rem;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.1rem 0;
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(1.15rem, 1.7vw, 1.45rem);
  line-height: 1.2;
}

.hero-copy p {
  margin: 0;
  color: var(--muted);
}

.hero-cta {
  margin: 0.5rem 0 0;
}

.hero-cta a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.hero-cta a:hover {
  text-decoration: underline;
}

#url-section {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.5rem;
}

#url-section input {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

#url-section button,
#controls-section button,
.site-header #lang-toggle {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

#url-section button,
#controls-section button {
  padding: 0.55rem 1rem;
}

.site-header #lang-toggle {
  padding: 0.4rem 0.75rem;
  text-decoration: none;
  display: inline-block;
  box-sizing: border-box;
}

#load-btn {
  flex: 0 0 auto;
  align-self: stretch;
  white-space: nowrap;
  background: var(--primary);
  color: var(--accent-text);
  border-color: transparent;
}

#load-btn:hover {
  background: var(--primary-hover);
}

.site-header #lang-toggle:hover,
#controls-section button:not(.active):hover {
  background: var(--bg);
}

#error-message {
  flex: 1 1 100%;
  margin: 0;
  min-height: 1.5rem;
  color: var(--danger);
  font-size: 0.9rem;
}

#error-message.is-empty {
  min-height: 0;
  height: 0;
  overflow: hidden;
}

#player-section {
  width: 100%;
}

#player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 200px;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}

#player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

#controls-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

#ab-controls {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  align-self: center;
  width: auto;
  max-width: 100%;
  gap: 0.35rem 0.5rem;
  min-width: 0;
}

#ab-controls button {
  flex-shrink: 0;
}

#ab-controls .ab-sep {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.9rem;
  user-select: none;
}

#point-a-display,
#point-b-display {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.95rem;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* スマホ横持ち〜狭い画面まで（479px だと landscape で効かないことが多い） */
@media (max-width: 767px) {
  #ab-controls {
    gap: 0.12rem 0.22rem;
  }

  #ab-controls .ab-sep {
    font-size: 0.72rem;
    padding: 0 0.02rem;
  }

  /* #controls-section button より詳細度を上げてパディングを確実に上書き */
  #controls-section #ab-controls button {
    padding: 0.2rem 0.32rem;
    line-height: 1.15;
    border-radius: 6px;
    -webkit-appearance: none;
    appearance: none;
  }

  #point-a-display,
  #point-b-display {
    font-size: 0.74rem;
  }
}

#speed-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

#speed-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
}

.speed-btn-wrap {
  display: inline-flex;
}

.speed-btn-wrap button {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  min-width: 3rem;
}

.speed-btn-wrap button:hover {
  background: var(--bg);
}

button.active {
  background: var(--secondary);
  color: var(--accent-text);
  border-color: transparent;
}

button.active:hover {
  background: var(--secondary-hover);
}

.speed-btn-wrap[data-disabled='true'] button {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

#ad-placeholder {
  max-width: 960px;
  margin: 0 auto 2rem;
  padding: 0 1.25rem;
  height: 90px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-editorial {
  margin-top: 0.35rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
  width: 100%;
  align-self: stretch;
}

.home-editorial h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.2rem 0 0.45rem;
  color: var(--secondary);
}

.home-editorial h2:first-of-type {
  margin-top: 0;
}

.home-editorial p {
  margin: 0 0 0.65rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.home-editorial a {
  color: var(--primary);
  font-weight: 600;
}

.site-footer {
  margin-top: auto;
  padding: 1rem 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem 1.25rem;
  max-width: 960px;
  margin: 0 auto;
}

.footer-nav a {
  color: inherit;
  font-size: 0.9rem;
  text-decoration: none;
}

.footer-nav a:hover {
  text-decoration: underline;
}

.content-page {
  flex: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2.5rem;
  width: 100%;
}

.content-page h1 {
  margin: 0 0 0.75rem;
  font-size: 1.35rem;
  line-height: 1.3;
}

.content-page h2 {
  margin: 1.75rem 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.content-page p,
.content-page li {
  margin: 0 0 0.75rem;
}

.content-page .lead {
  font-size: 1.02rem;
  color: var(--text);
}

.content-page .meta-muted {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.content-page .article-meta {
  margin: -0.35rem 0 0.85rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.error-page {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.35rem;
  min-height: 52vh;
}

.error-code {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--primary);
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.error-actions a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.error-actions a:hover {
  text-decoration: underline;
}

.error-actions .primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  background: var(--primary);
  color: var(--accent-text);
}

.error-actions .primary-link:hover {
  background: var(--primary-hover);
  text-decoration: none;
}

.content-page ul,
.content-page ol.steps {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.content-page li {
  margin-bottom: 0.35rem;
}

.info-list {
  margin: 0 0 1rem;
}

.info-list dt {
  margin-top: 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
}

.info-list dt:first-child {
  margin-top: 0;
}

.info-list dd {
  margin: 0.25rem 0 0;
}

.faq-list {
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}

.faq-item {
  margin: 0 0 1.25rem;
  padding: 0 0 1rem;
  border-bottom: 1px solid var(--border);
}

.faq-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.faq-item h3 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}

.faq-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.faq-item p + p {
  margin-top: 0.5rem;
}

.content-page code {
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: color-mix(in srgb, var(--surface) 70%, var(--border));
}

.related-reading {
  margin: 2rem 0 0;
  padding: 1rem 1rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.related-reading h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.related-reading ul {
  margin: 0;
  padding-left: 1.1rem;
}

.related-reading li {
  margin-bottom: 0.35rem;
}

.back-to-home {
  margin: 2rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
}
