:root {
  --bg-top: #eef4e6;
  --bg-bottom: #cfe0bb;
  --card-bg: #fbfaf3;
  --text: #24301f;
  --muted: #5b6b57;
  --border: #c9d6bd;
  --accent: #2f5233;
  --accent-text: #ffffff;
  --highlight: #c98a3b;
  --highlight-text: #ffffff;
}

* {
  box-sizing: border-box;
}

/* hidden属性は、display:flex等を持つクラスより必ず優先させる */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Sawarabi Gothic", -apple-system, "Hiragino Kaku Gothic ProN",
    "Yu Gothic", "PingFang SC", "Noto Sans KR", sans-serif;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  color: var(--text);
  line-height: 1.6;
}

button,
.watch-link {
  font-family: "Kiwi Maru", "Sawarabi Gothic", sans-serif;
}

#current-title {
  font-family: "BIZ UDPGothic", "Sawarabi Gothic", sans-serif;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* ==== ページ全体のセクション配置（Grid） ====
   S11: あいさつ〜言語設定 / S12: タイトル画像 / SR: サムネ表示
   S21: Q1 タグ / S22: Q2 再生数 / S31: Q3 キーワード / S32: Q4 ジャンル
   S41: Q5 投稿日 / SS: 検索ボタン / SH: 記録

   スマホ幅では全セクションが縦一列（1カラム）。
   ブラウザ幅（769px〜）では、S11+S12, S21+S22, S31+S32, S41+SSをそれぞれ2カラムで並べ、
   SR（サムネ表示）とSH（記録）は常に1カラム全幅で表示する。 */
.page-grid {
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 20px;
}

.page-grid > form {
  display: contents;
}

/* 追加の検索ボタン：スマホ幅では非表示、PC幅（2カラム）の空きマスにだけ表示 */
.search-button-extra {
  display: none;
}

@media (min-width: 769px) {
  main.page-grid {
    max-width: 960px;
  }

  .page-grid {
    grid-template-columns: 1fr 1fr;
    column-gap: 24px;
  }

  /* Q1〜SSをまとめて含むform内も、同じ2カラムGridの並びに乗せる */
  .page-grid > form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-column: 1 / -1;
    column-gap: 24px;
    row-gap: 20px;
  }

  .section-s11 {
    grid-column: 1 / 2;
    align-self: center;
    display: flex;
    justify-content: center;
  }

  .section-s11-inner {
    text-align: left;
  }

  .section-s12 {
    grid-column: 2 / 3;
    align-self: center;
  }

  .section-s21 {
    grid-column: 1 / 2;
  }

  .section-s22 {
    grid-column: 2 / 3;
  }

  .section-s31 {
    grid-column: 1 / -1;
  }

  .section-s32 {
    grid-column: 1 / -1;
  }

  .section-s41 {
    grid-column: 1 / 2;
  }

  .section-ss {
    grid-column: 2 / 3;
    align-self: stretch;
    height: 100%;
  }

  /* 追加の検索ボタン（スクロールしなくても検索できるように、空きマスに配置） */
  .search-button-extra {
    display: block;
    align-self: stretch;
    height: 100%;
  }

  .search-button-extra-b {
    grid-column: 1 / 2;
  }

  .section-sr,
  .section-sh,
  #status {
    grid-column: 1 / -1;
  }

  .section-share {
    grid-column: 1 / 2;
  }

  .section-tagmap {
    grid-column: 2 / 3;
  }

  .section-kiite {
    grid-column: 1 / 2;
  }

  .section-info {
    grid-column: 2 / 3;
  }
}

.top-bar {
  margin-bottom: 16px;
}

h1 {
  font-family: "Hina Mincho", serif;
  font-size: 1.5rem;
  margin: 0 0 4px;
  color: var(--accent);
  white-space: nowrap;
}

.lead {
  color: var(--muted);
  margin: 0 0 2px;
  white-space: nowrap;
}

.lead-sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 6px 0 0;
}

.disclaimer {
  color: var(--muted);
  font-size: 0.72rem;
  margin: 6px 0 0;
  white-space: pre-line;
}

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

.lang-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.lang-field select {
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--card-bg);
  color: var(--text);
}

.title-viewer-link {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 12px;
  overflow-wrap: anywhere;
}

.title-viewer-link a {
  color: var(--accent);
}

.privacy-field {
  margin-bottom: 22px;
}

.privacy-field .disclaimer {
  margin-top: 6px;
}

.field {
  margin-bottom: 18px;
}

.forest-box {
  position: relative;
  border: 8px solid transparent;
  border-radius: 16px 22px 14px 24px / 22px 14px 26px 16px;
  background:
    linear-gradient(var(--card-bg), var(--card-bg)) padding-box,
    repeating-linear-gradient(
        98deg,
        #b9895a 0px,
        #b9895a 5px,
        #a87a4d 5px,
        #a87a4d 9px,
        #c49a6c 9px,
        #c49a6c 14px
      )
      border-box;
  padding: 18px 20px;
  box-shadow: 0 5px 10px rgba(47, 82, 51, 0.28), inset 0 0 0 1px rgba(90, 58, 30, 0.15);
  margin-bottom: 0;
  transform: rotate(-0.4deg);
}

.forest-box:nth-of-type(2n) {
  transform: rotate(0.4deg);
}

.forest-box::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1.5px dashed rgba(122, 79, 44, 0.3);
  border-radius: 12px 18px 10px 20px / 18px 10px 20px 12px;
  pointer-events: none;
}

.field label,
.field-label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.section-question {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  font-family: "Hina Mincho", serif;
}

.label-with-info {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.label-with-info .field-label {
  margin-bottom: 0;
  flex-shrink: 0;
  white-space: nowrap;
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--muted);
  color: var(--muted);
  font-size: 0.75rem;
  cursor: help;
}

.toggle-row {
  display: flex;
  gap: 10px;
}

.toggle-btn {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--card-bg);
  color: var(--accent);
  font-size: 0.9rem;
}

.toggle-btn:hover {
  background: #eef1e6;
}

.toggle-btn.active {
  background: var(--accent);
  color: var(--accent-text);
}

.field input[type="text"],
.field input[type="number"],
.field input[type="date"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  background: var(--card-bg);
  color: var(--text);
}

.field input[type="number"] {
  padding-right: 8px;
}

/* 数値入力のスピンボタンを、常時・大きめに表示する（Chrome/Edge/Safari） */
.field input[type="number"]::-webkit-inner-spin-button,
.field input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
  transform: scale(1.8);
  transform-origin: right center;
  margin-left: 6px;
  cursor: pointer;
}

.field-row {
  display: flex;
  gap: 16px;
}

.field-row > div {
  flex: 1;
}

.views-row {
  align-items: flex-end;
}

.tilde {
  color: var(--muted);
  padding-bottom: 10px;
  font-size: 1.1rem;
}

.keyword-suggest {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.keyword-suggest .note {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
}

.pill-button {
  align-self: flex-start;
  padding: 8px 14px;
  background: var(--card-bg);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 999px;
  font-size: 0.85rem;
}

.pill-button:hover {
  background: var(--accent);
  color: var(--accent-text);
}

.copy-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.copy-toast {
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 700;
}

.note-toggle {
  display: inline-block;
  margin-top: 8px;
  padding: 0;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.note-toggle:hover {
  opacity: 0.75;
}

#fine-tune-panel {
  margin-top: 8px;
}

.radio-group {
  display: flex;
  gap: 16px;
  font-size: 0.95rem;
  flex-wrap: wrap;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}

#filter-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 14px;
  margin-bottom: 18px;
  background: var(--card-bg);
}

#filter-panel summary {
  cursor: pointer;
  padding: 10px 0;
  font-weight: 600;
  font-size: 0.95rem;
  list-style: none;
  color: var(--accent);
}

#filter-panel summary::-webkit-details-marker {
  display: none;
}

#filter-panel summary::before {
  content: "▸ ";
}

#filter-panel[open] summary::before {
  content: "▾ ";
}

.filter-body {
  padding: 4px 0 14px;
}

button {
  cursor: pointer;
  font-size: 1rem;
  border-radius: 6px;
  border: none;
}

#search-button,
.search-button-extra {
  width: 100%;
  padding: 18px;
  white-space: pre-line;
  line-height: 1.3;
  background: var(--highlight);
  color: var(--highlight-text);
  margin-top: 8px;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  box-shadow: 0 4px 14px rgba(201, 138, 59, 0.55);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  animation: searchButtonPulse 10s ease-in-out infinite;
}

@keyframes searchButtonPulse {
  0%,
  100% {
    box-shadow: 0 4px 14px rgba(201, 138, 59, 0.55);
    transform: scale(1);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  }
  50% {
    box-shadow: 0 8px 36px rgba(201, 138, 59, 0.9);
    transform: scale(1.05);
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  }
}

#search-button:hover,
.search-button-extra:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(201, 138, 59, 0.7);
  filter: brightness(1.05);
}

#search-button:disabled,
.search-button-extra:disabled {
  opacity: 0.6;
  cursor: default;
}

#status {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 1.4em;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  text-align: right;
}

#status-fairy-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}

#status.status-error {
  color: #7a2021;
}

#result {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.video-meeting-spot-wrapper {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  height: 100vh;
  background: #1c2826;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-meeting-spot {
  position: relative;
  width: 100%;
  max-width: 520px;
  padding: 24px 20px;
  border-radius: 20px;
  background: #1c2826;
  overflow: hidden;
}

@media (min-width: 769px) {
  .video-meeting-spot {
    max-width: 920px;
  }
}

.video-meeting-spot #current-title {
  font-family: "Hina Mincho", serif;
  font-size: 1.1rem;
}

#current-title {
  font-weight: 600;
  margin-top: 0;
  margin-bottom: 2px;
  color: #ffffff;
}

#current-uploader {
  color: #dcedd8;
  font-size: 0.9rem;
  margin-top: 0;
  margin-bottom: 12px;
}

#player {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #10160f;
  margin-bottom: 16px;
  border-radius: 6px;
  overflow: hidden;
  perspective: 600px;
}

.player-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.player-thumb.thumb-hidden {
  opacity: 0;
}

#player-embed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 1;
  transition: opacity 0.8s ease;
}

#player-embed.embed-hidden {
  opacity: 0;
}

.player-fairy {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28%;
  max-width: 100px;
  transform: translate(-50%, -50%) rotateY(0deg);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.player-fairy.fairy-visible {
  opacity: 1;
}

.player-fairy.spin-active {
  animation: playerFairySpin 0.8s linear;
}

@keyframes playerFairySpin {
  from {
    transform: translate(-50%, -50%) rotateY(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotateY(360deg);
  }
}

.player-fairy.wave-rtl {
  animation: playerFairyWaveRTL 1.2s ease-in-out;
}

@keyframes playerFairyWaveRTL {
  0% {
    transform: translate(100%, -50%) translateY(0);
  }
  12.5% {
    transform: translate(62.5%, -50%) translateY(-14px);
  }
  25% {
    transform: translate(25%, -50%) translateY(0);
  }
  37.5% {
    transform: translate(-12.5%, -50%) translateY(14px);
  }
  50% {
    transform: translate(-50%, -50%) translateY(0);
  }
  62.5% {
    transform: translate(-87.5%, -50%) translateY(-14px);
  }
  75% {
    transform: translate(-125%, -50%) translateY(0);
  }
  87.5% {
    transform: translate(-162.5%, -50%) translateY(14px);
  }
  100% {
    transform: translate(-200%, -50%) translateY(0);
  }
}

.player-fairy.wave-ltr {
  animation: playerFairyWaveLTR 1.2s ease-in-out;
}

/* Cの動きは img_fairy.png を左右反転（scaleX(-1)）させながら移動させる */
@keyframes playerFairyWaveLTR {
  0% {
    transform: translate(-200%, -50%) translateY(0) scaleX(-1);
  }
  12.5% {
    transform: translate(-162.5%, -50%) translateY(-14px) scaleX(-1);
  }
  25% {
    transform: translate(-125%, -50%) translateY(0) scaleX(-1);
  }
  37.5% {
    transform: translate(-87.5%, -50%) translateY(14px) scaleX(-1);
  }
  50% {
    transform: translate(-50%, -50%) translateY(0) scaleX(-1);
  }
  62.5% {
    transform: translate(-12.5%, -50%) translateY(-14px) scaleX(-1);
  }
  75% {
    transform: translate(25%, -50%) translateY(0) scaleX(-1);
  }
  87.5% {
    transform: translate(62.5%, -50%) translateY(14px) scaleX(-1);
  }
  100% {
    transform: translate(100%, -50%) translateY(0) scaleX(-1);
  }
}

.hero-image-wrap {
  margin: 20px 0;
}

.hero-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  box-shadow: 0 4px 10px rgba(47, 82, 51, 0.25);
}

.title-image-wrap {
  margin: 0;
}

.title-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  box-shadow: 0 4px 10px rgba(47, 82, 51, 0.25);
}

.result-actions {
  display: flex;
  gap: 10px;
}

.share-buttons {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  margin-bottom: 10px;
}

.share-buttons .pill-button {
  flex: 1;
  text-align: center;
  background: #d4a017;
  color: #ffffff;
  border-color: #d4a017;
}

.share-buttons .pill-button:hover {
  background: #b8890f;
  border-color: #b8890f;
  color: #ffffff;
}

#next-button {
  flex: 2;
  padding: 12px;
  background: var(--accent);
  color: var(--accent-text);
}

.watch-link {
  flex: 1;
  padding: 12px;
  background: var(--card-bg);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  text-align: center;
  text-decoration: none;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

#history {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

#history h2 {
  font-family: "Hina Mincho", serif;
  font-size: 1.2rem;
  color: var(--accent);
  margin: 0 0 12px;
}

.section-share {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.section-share h2 {
  font-family: "Hina Mincho", serif;
  font-size: 1.2rem;
  color: var(--accent);
  margin: 0 0 12px;
}

.section-share .disclaimer {
  margin-bottom: 12px;
}

.reply-text-section {
  margin: 0 0 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.03);
}

.reply-text-section h3 {
  font-family: "Hina Mincho", serif;
  font-size: 1rem;
  color: var(--accent);
  margin: 0 0 10px;
}

.hashtag-section {
  margin: 0 0 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.03);
}

.hashtag-section h3 {
  font-family: "Hina Mincho", serif;
  font-size: 1rem;
  color: var(--accent);
  margin: 0 0 10px;
}

.thumbnail-section {
  margin: 0 0 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.03);
}

.thumbnail-section h3 {
  font-family: "Hina Mincho", serif;
  font-size: 1rem;
  color: var(--accent);
  margin: 0 0 10px;
}

.share-button-section {
  margin: 0 0 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.03);
}

.share-button-section h3 {
  font-family: "Hina Mincho", serif;
  font-size: 1rem;
  color: var(--accent);
  margin: 0 0 10px;
}

.reply-text-preview {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.7;
  margin: 0 0 12px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

#hashtag-panel {
  margin: 12px 0 16px;
}

#hashtag-panel .toggle-row {
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.hashtag-list {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--card-bg);
}

.hashtag-group {
  margin-bottom: 12px;
}

.hashtag-group:last-child {
  margin-bottom: 0;
}

.hashtag-group-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 6px;
}

.hashtag-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 2px;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}

.hashtag-checkbox {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.section-tagmap {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.section-tagmap h2 {
  font-family: "Hina Mincho", serif;
  font-size: 1.2rem;
  color: var(--accent);
  margin: 0 0 12px;
}

.section-tagmap .disclaimer {
  margin-bottom: 12px;
}

.section-kiite {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.section-kiite h2 {
  font-family: "Hina Mincho", serif;
  font-size: 1.2rem;
  color: var(--accent);
  margin: 0 0 12px;
}

.section-kiite .disclaimer {
  margin-bottom: 12px;
}

.section-info {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.section-info .disclaimer {
  margin-bottom: 12px;
}

#history-list,
.history-group-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  padding: 8px 10px;
}

.history-thumb {
  width: 64px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: #10160f;
}

.history-text {
  min-width: 0;
}

.history-title {
  margin: 0;
  font-size: 0.85rem;
  font-family: "BIZ UDPGothic", "Sawarabi Gothic", sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-uploader {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.history-title-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

#history .history-title-row h2 {
  margin: 0;
}

#history-more-button {
  margin-top: 0;
}

/* 記録の全履歴ウィンドウ：検索語ごとのグループとトグルボタン */
.history-group {
  margin-bottom: 18px;
}

.history-group-toggle {
  width: 100%;
  text-align: left;
  font-size: 0.9rem;
}

.history-group-list {
  margin-top: 10px;
}

.history-group-body {
  margin-top: 10px;
}

.history-group-expired {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

#tag-map-section {
  margin-top: 32px;
}

.tag-map-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  box-shadow: 0 4px 10px rgba(47, 82, 51, 0.25);
  cursor: pointer;
}

#scroll-to-q1-button {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-family: "Kiwi Maru", "Sawarabi Gothic", sans-serif;
  font-size: 0.9rem;
  box-shadow: 0 4px 10px rgba(47, 82, 51, 0.35);
}

#scroll-to-q1-button:hover {
  filter: brightness(1.08);
}

@media (max-width: 480px) {
  .lead,
  h1 {
    white-space: normal;
  }
}
