/* =====================================================
   Save Popup — ポップアップメニュー
   ===================================================== */

.save-popup {
  position: fixed;
  z-index: 9998;
  min-width: 180px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  padding: 0.35rem 0;
  font-family: 'Shippori Mincho', 'Noto Sans JP', serif;
  animation: savePopupIn 0.15s ease-out;
}

.save-popup.hidden {
  display: none;
}

@keyframes savePopupIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.save-popup__item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.6rem 1rem;
  background: none;
  border: none;
  text-align: left;
  font-family: inherit;
  font-size: 0.88rem;
  color: #333;
  cursor: pointer;
  transition: background 0.12s ease;
  white-space: nowrap;
}

.save-popup__item:hover {
  background: rgba(74, 109, 124, 0.08);
}

.save-popup__item:active {
  background: rgba(74, 109, 124, 0.14);
}

.save-popup__icon {
  flex-shrink: 0;
  font-size: 0.95rem;
  margin-right: 0.15rem;
}

.save-popup__badge {
  margin-left: auto;
  font-size: 0.72rem;
  color: #8c96a0;
  font-variant-numeric: tabular-nums;
  padding-left: 0.8rem;
}

/* =====================================================
   Save Modal — セーブコードモーダル
   ===================================================== */

.save-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
}

.save-modal.hidden {
  display: none;
}

/* 背景の暗幕 */
.save-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

/* 中央の箱 */
.save-modal__content {
  position: relative;
  max-width: 480px;
  max-height: 80vh;
  margin: 15vh auto;
  padding: 2rem;
  background: #ffffff;
  color: #333333;
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
  font-family: 'Shippori Mincho', 'Noto Sans JP', serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 閉じるボタン */
.save-modal__close {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  background: transparent;
  border: none;
  font-size: 1.8rem;
  color: #999;
  cursor: pointer;
  line-height: 1;
  z-index: 1;
}

.save-modal__close:hover {
  color: #333;
}

/* 見出し */
.save-modal__content h2 {
  margin: 0 0 1.2rem 0;
  font-size: 1.2rem;
  font-weight: 500;
  color: #333333;
  border-bottom: 1px solid #eee;
  padding-bottom: 0.5rem;
  flex-shrink: 0;
}

/* モーダルボディ */
.save-modal__body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* =====================================================
   プログレスバー（モーダル兼ページ一覧用）
   ===================================================== */

.save-modal__progress {
  margin-bottom: 1.2rem;
}

.save-modal__progress-text {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: #555;
}

.save-modal__progress-percent {
  font-size: 0.85rem;
  color: #888;
}

.save-modal__progress-bar {
  height: 6px;
  background: #e8ecef;
  border-radius: 3px;
  overflow: hidden;
}

.save-modal__progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4a6d7c, #6b9dae);
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 0;
}

/* =====================================================
   ページ一覧（page-list.html 用）
   ===================================================== */

.save-modal__page-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.save-modal__page-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.4rem;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s ease;
}

.save-modal__page-item:last-child {
  border-bottom: none;
}

.save-modal__page-item.is-visited {
  background: rgba(74, 109, 124, 0.03);
}

.save-modal__page-item:not(.is-visited) {
  opacity: 0.45;
}

.save-modal__page-no {
  flex-shrink: 0;
  width: 2.5em;
  font-size: 0.78rem;
  color: #8c96a0;
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding-top: 0.1em;
}

.save-modal__page-info {
  flex: 1;
  min-width: 0;
}

.save-modal__page-title {
  font-size: 0.88rem;
  color: #333;
  line-height: 1.4;
  word-break: break-all;
}

.save-modal__page-meta {
  font-size: 0.72rem;
  color: #aaa;
  margin-top: 0.15rem;
  line-height: 1.3;
  word-break: break-all;
}

.save-modal__page-check {
  flex-shrink: 0;
  width: 1.2em;
  text-align: center;
  font-size: 0.85rem;
  color: #4a6d7c;
  padding-top: 0.15em;
}

/* =====================================================
   記録コード セクション
   ===================================================== */

.save-modal__section-label {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.4rem;
}

.save-modal__code-display {
  font-family: 'Courier New', Consolas, monospace;
  font-size: 1rem;
  letter-spacing: 0.12em;
  color: #333;
  background: #f7f8fa;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 0.8rem 1rem;
  text-align: center;
  word-break: break-all;
  margin-bottom: 0.6rem;
  user-select: all;
  -webkit-user-select: all;
}

.save-modal__code-input {
  display: block;
  width: 100%;
  font-family: 'Courier New', Consolas, monospace;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  padding: 0.7rem 0.8rem;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  background: #fff;
  color: #333;
  text-align: center;
  margin-bottom: 0.6rem;
  box-sizing: border-box;
}

.save-modal__code-input:focus {
  outline: none;
  border-color: #4a6d7c;
  box-shadow: 0 0 0 2px rgba(74, 109, 124, 0.15);
}

.save-modal__btn {
  display: inline-block;
  padding: 0.5rem 1.4rem;
  font-size: 0.85rem;
  font-family: inherit;
  color: #4a6d7c;
  background: #fff;
  border: 1px solid #4a6d7c;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.05em;
}

.save-modal__btn:hover {
  background: #f4f8fa;
}

.save-modal__btn:active {
  background: #e8f0f4;
}

.save-modal__btn--copied {
  color: #2e7d32;
  border-color: #2e7d32;
}

.save-modal__message {
  font-size: 0.82rem;
  margin-top: 0.5rem;
  min-height: 1.2em;
}

.save-modal__message.success {
  color: #2e7d32;
}

.save-modal__message.error {
  color: #d32f2f;
}

.save-modal__section-divider {
  border: none;
  border-top: 1px solid #eee;
  margin: 1.2rem 0;
}

.save-modal__note {
  font-size: 0.75rem;
  color: #999;
  line-height: 1.6;
  margin-top: 1.2rem;
}

.save-modal__note p {
  margin: 0 0 0.2rem 0;
}

/* =====================================================
   スマホ対応
   ===================================================== */

@media (max-width: 600px) {
  .save-popup {
    min-width: 160px;
  }

  .save-modal__content {
    margin: 10vh 0.8rem;
    padding: 1.4rem;
    max-height: 85vh;
  }

  .save-modal__code-display {
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    padding: 0.6rem 0.5rem;
  }

  .save-modal__code-input {
    font-size: 0.85rem;
  }

  .save-modal__page-title {
    font-size: 0.82rem;
  }

  .save-modal__page-meta {
    font-size: 0.68rem;
  }
}
