:root {
  --pagination-visible-height: 40px;
  --pagination-safe-padding: calc(var(--pagination-visible-height) + 100px);
}

/* ===== ベーススタイル ===== */
body {
  font-family: "Hiragino Sans", "Noto Sans JP", sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
  overflow-y: auto;
}

main.container {
  max-width: 800px;
  margin: 0 auto;
  padding-top: 64px;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== 固定ヘッダー領域 ===== */
.fixed-header {
  flex: 0 0 auto;
  padding: 16px;
  background-color: #fff;
}

.song-title-text-wrapper {
  position: relative;
}

.song-title-text {
  font-size: 1.8em;
  text-align: center;
  margin-bottom: 0.3em;
  word-break: break-word;
}

.kana-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 600px;
  margin: 0 auto 1em;
  padding: 0 12px;
}

.kana {
  font-size: 0.9em;
  color: var(--text-light);
  text-align: center;
  margin-right: 12px;
  flex: 1;
}

/* ===== コピー操作ボタン ===== */
.copy-button-group {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.copy-button {
  background: rgba(255, 255, 255, 0.8);
  border: none;
  padding: 4px;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  opacity: 0.6;
  transition: opacity 0.2s ease;
  font-size: 0.8em;
  cursor: pointer;
  white-space: nowrap;
}

.copy-button:hover {
  opacity: 1;
}

/* ===== 楽曲情報グリッド ===== */
.info-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  row-gap: 12px;
  column-gap: 16px;
  margin-bottom: 16px;
  align-items: start;
}

.label,
.stream-label {
  color: var(--text);
  font-weight: bold;
}

.value,
.value a {
  font-size: 15px;
  color: var(--main-dark);
  word-break: break-word;
  text-decoration: none;
  font-weight: bold;
}

.value a:hover {
  text-decoration: underline;
}

.info-grid .value .stream-edit-block {
  margin-top: -8px;
}

/* ===== 配信者メモトグル ===== */
.stream-memo-toggle {
  cursor: pointer;
  font-weight: bold;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--main-dark);
}

.toggle-icon {
  transition: transform 0.3s ease;
}

.stream-memo-toggle.open .toggle-icon {
  transform: rotate(90deg);
}

/* ===== 編集ブロック開閉 ===== */
.stream-edit-block {
  margin-top: 8px;
  width: 100%;
  display: block;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  max-height: 1000px;
  opacity: 1;
}

.stream-edit-block.collapsed {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
}

/* ===== 編集行（歌唱キー・リンク） ===== */
.stream-edit-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  width: 100%;
  margin-bottom: 8px;
  min-width: 0;
}

.stream-edit-row input[type="text"] {
  flex: 1;
  min-width: 160px;         /* 最小幅（狭めの初期表示） */
  width: 100%;              /* 親の幅に応じて広がる */
  max-width: 558px;         /* 最大幅（広がりすぎ防止） */
  box-sizing: border-box;
  padding: 6px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.stream-label {
  min-width: 90px;
  flex-shrink: 0;
}

.key-options-inline {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  flex: 1;
  min-width: 0;
}

.key-option {
  white-space: nowrap;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.key-option input[type="radio"] {
  accent-color: var(--main-dark);
  cursor: pointer;
}

.save-button,
.open-button {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
  cursor: pointer;
}

.save-button:hover,
.open-button:hover {
  background-color: #e0f2f1;
}

.save-icon,
.open-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.open-button.disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

.open-button.disabled .open-icon {
  opacity: 0.4;
}
.save-message {
  background: #e0ffe0;
  color: #006600;
  padding: 8px 12px;
  margin: 8px 0;
  border-radius: 4px;
  font-weight: bold;
  animation: fadeOut 2s ease-in-out forwards;
}

@keyframes fadeOut {
  0% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; display: none; }
}


/* ===== 配信履歴テーブル ===== */
.song-stream-list {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: visible;
  min-height: 0;
}

#scroll-padding-cell {
  width: 100%;
  min-width: 100%;
  display: table-cell;
  box-sizing: border-box;
  line-height: 1px;
}

.stream-table-wrapper {
  flex-grow: 1;
  overflow-y: auto;
  width: 100%;
  max-width: none;
  min-height: 360px;
  box-sizing: border-box;
  max-height: none; /*calc(100vh - var(--pagination-visible-height) +60);*/
  padding-bottom: var(--pagination-visible-height);
}

.stream-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.stream-table th {
  position: sticky;
  border: none; /* ✅ 縦線を消す */
  top: 0;
  color: var(--text);
  background-color: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  font-weight: bold;
  padding: 8px;
  text-align: left;
  z-index: 2;
}

.stream-table td {
  border: none; /* ✅ 縦線を消す */
  padding: 12px;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.stream-table thead th {
  font-weight: bold;
  background-color: var(--bg-alt);
  border-bottom: 2px solid var(--border); /* ✅ ヘッダーは少し濃く */
}

.stream-table tbody tr:last-child td {
  border-bottom: none;
}

.stream-table tfoot tr:hover td {
  background-color: transparent !important;
  cursor: default !important;
}

.stream-table tbody tr:hover td {
  background-color: var(--bg-hover);
  cursor: pointer;
}
.stream-title-area a {
  color: var(--main-dark); /* ← ここが現在の色指定 */
  text-decoration: none;
  font-weight: bold;
}

.stream-table .scroll-padding-row td {
  border: none;
  background: transparent;
}

.date-col {
  width: 120px;
  white-space: nowrap;
}

.title-col,
.col-title {
  max-width: 100%;
  overflow: hidden;
}

.stream-title-cell {
  position: relative;
  padding-right: 80px;
  overflow: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

.stream-title-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.stream-title-area {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.stream-title-text {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.inline-actions {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  display: flex;
  gap: 6px;
}

/* ===== その他 ===== */

.register-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: bold;
  text-decoration: none;
  color: var(--main-dark);
  padding: 6px 12px;
  border: 1px solid var(--main-mid);
  border-radius: 4px;
  background-color: transparent;
  transition: background-color 0.2s ease;
  flex: none;
}

.register-button:hover {
  background-color: var(--bg-hover);
}

.register-button .icon {
  width: 24px;
  height: 24px;
  display: inline-block;
  object-fit: contain;
}

/* モーダル共有関連 */
#x-share-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 480px;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 4px 12px var(--shadow);
  z-index: 9999;
  box-sizing: border-box;

  /* ✅ 高さを内容に合わせて自動調整 */
  height: auto;
  max-height: none;
  overflow: visible;
}

#x-share-modal.show {
  display: block;
  opacity: 1;
}

#x-share-text {
  width: 100%;
  padding: 8px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  resize: vertical;
  box-sizing: border-box;
  margin-bottom: 12px;
}

/* ✅ ボタンを横並びに整えるラッパー */
.modal-actions {
  display: flex;
  justify-content: flex-end; /* 右寄せ。中央にしたい場合は center */
  gap: 8px;                  /* ボタン間の余白 */
  margin-top: 8px;
}

#x-share-confirm {
  background-color: var(--main-mid);
  color: var(--main-dark);
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#x-share-confirm:hover {
  background-color: var(--main-light);
  color: var(--main-dark);
}

#x-share-cancel {
  background-color: var(--main-mid);
  color: var(--main-dark);
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#x-share-cancel:hover {
  background-color: var(--main-light);
  color: var(--main-dark);
}

/* アイコンボタン共通 */
.icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
}

.open-icon {
  transition: opacity 0.2s ease;
}

.open-button.disabled .open-icon {
  opacity: 0.4;
}

.open-button.disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

/* アクションボタン（共有・お気に入り） */
.action-button,
.save-button,
.open-button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  cursor: pointer;
}

.action-button:hover,
.save-button:hover,
.open-button:hover {
  background-color: #e0f2f1;
}

/* ツールチップ */
.custom-tooltip {
  position: absolute;
  background-color: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 4px;
  white-space: normal;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  z-index: 9999;
  max-width: 400px;
  display: none;
}

/* スクロール領域 */
.scroll-area {
  flex-direction: column;
  display: flex;
  flex: 1 1 auto;
  overflow-y: hidden;
  position: relative;
  min-height: 0;
}

.scrollable-results {
  flex: 1;
  overflow: hidden !important;
  max-height: none !important;
  padding-bottom: 80px;
}

.stream-edit-row[data-type="key-save"] {
  justify-content: flex-end;
}

.stream-title-cell {
  position: relative;
  padding-right: 80px; /* ボタン領域分の余白を確保 */
  overflow: hidden;
  box-sizing: border-box;
}

.stream-title-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  overflow: hidden;
}

.stream-title-area {
  flex: none;
  width: calc(100% - 50px); /* ボタン領域を除いた幅に制限 */
  min-width: 0;
  overflow: hidden;
}

.stream-title-text {
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.stream-table-wrapper.full-height {
  max-height: 100vh;
  padding-bottom: 0;
}

.scrollable-results {
  flex: 1 1 auto;
  overflow-y: auto;
  max-height: 100%;
  min-height: 0;
}

