@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&family=Noto+Sans+JP:wght@300;400;500&display=swap');

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg:       #f5f5f3;
  --color-surface:  #ffffff;
  --color-border:   #e0ddd6;
  --color-text:     #1a1a1a;
  --color-muted:    #6b6b6b;
  --color-hint:     #9a9a9a;
  --color-primary:  #1a1a2e;
  --color-accent: #ffffff;
  --color-blue:     #185FA5;
  --color-blue-bg:  #E6F1FB;
  --color-red:      #A32D2D;
  --color-red-bg:   #FCEBEB;
  --color-green:    #0F6E56;
  --color-green-bg: #E1F5EE;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--color-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Auth pages ===== */
.auth-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem 1rem; }

.auth-wrap { width: 100%; max-width: 400px; }

.auth-logo { text-align: center; margin-bottom: 2rem; }
.logo-icon  { font-size: 2.5rem; }
.logo-title { font-size: 1.25rem; font-weight: 600; margin-top: 0.5rem; }
.logo-sub   { font-size: 0.8125rem; color: var(--color-muted); margin-top: 0.25rem; }

.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 1.75rem; }
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 1.25rem; }

.auth-switch { text-align: center; margin-top: 1rem; font-size: 0.8125rem; color: var(--color-muted); }

/* ===== Forms ===== */
.form-group { margin-bottom: 1rem; }
.form-group label,
.form-label { display: block; font-size: 0.8125rem; color: var(--color-muted); margin-bottom: 0.3rem; }
.required { color: var(--color-red); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"] {
  width: 100%;
  padding: 0.5625rem 0.75rem;
  font-size: 0.9375rem;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus {
  border-color: var(--color-blue);
  box-shadow: 0 0 0 2px rgba(24,95,165,0.12);
}

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem; font-family: inherit; font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--color-bg); text-decoration: none; }

.btn-primary {
  background: var(--color-primary);
  color: var(--color-accent);
  border-color: var(--color-primary);
}
.btn-primary:hover { opacity: 0.87; background: var(--color-primary); }

.btn-outline { background: transparent; }
.btn-outline:hover { background: var(--color-bg); }

.btn-full { width: 100%; margin-top: 0.25rem; }
.btn-sm { padding: 0.3125rem 0.625rem; font-size: 0.75rem; }

/* ===== Alerts ===== */
.alert {
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.alert-error   { background: var(--color-red-bg);   color: var(--color-red);   border: 1px solid #f09595; }
.alert-success { background: var(--color-green-bg); color: var(--color-green); border: 1px solid #5dcaa5; }

/* ===== Admin layout ===== */
.admin-page { min-height: 100vh; }

.admin-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: nowrap; gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: 10;
}
.header-left { display: flex; align-items: center; gap: 0.625rem; min-width: 0; flex-shrink: 1; }
.logo-icon-sm { font-size: 1.5rem; }
.header-name { font-size: 0.9375rem; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-tag  { font-size: 0.6875rem; color: var(--color-hint); }
.header-right { display: flex; gap: 0.5rem; flex-shrink: 0; flex-wrap: nowrap; }

.admin-body { display: grid; grid-template-columns: 1fr 1fr; min-height: calc(100vh - 56px); }

.admin-panel {
  padding: 1.25rem 1.5rem;
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
}
.admin-panel:last-child { border-right: none; }

.section-title {
  font-size: 0.875rem; font-weight: 600;
  margin-bottom: 0.875rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.song-count-badge {
  font-size: 0.75rem; font-weight: 400; color: var(--color-hint);
}

/* URL section */
.url-section { margin-bottom: 1.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--color-border); }
.url-box { display: flex; align-items: center; gap: 0.5rem; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 0.625rem 0.75rem; }
.url-text { font-size: 0.75rem; color: var(--color-blue); font-family: monospace; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.url-hint { font-size: 0.75rem; color: var(--color-hint); margin-top: 0.4rem; }

/* Artist selector */
.artist-selector { margin-bottom: 1rem; }
.artist-pick-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.5625rem 0.75rem; font-size: 0.9375rem; font-family: inherit;
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface); color: var(--color-hint);
  cursor: pointer; text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.artist-pick-btn:hover { border-color: var(--color-blue); }
.artist-pick-btn.has-value { color: var(--color-text); }
.artist-count { font-size: 0.6875rem; color: var(--color-hint); }

/* Artist picker modal */
.artist-modal { width: min(560px, calc(100vw - 2rem)); }
.artist-modal-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--color-border); border-radius: var(--radius-md); margin-bottom: 1rem; }
.artist-modal-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 0.5625rem 0.875rem; font-family: inherit; font-size: 0.9375rem;
  border: none; border-bottom: 1px solid var(--color-border);
  background: transparent; cursor: pointer; text-align: left;
  transition: background 0.12s; color: var(--color-text);
}
.artist-modal-item:last-child { border-bottom: none; }
.artist-modal-item:hover { background: var(--color-bg); }
.artist-modal-item.active { background: var(--color-blue-bg); color: var(--color-blue); font-weight: 500; }
.artist-modal-divider {
  font-size: 0.75rem; font-weight: 600; color: var(--color-muted);
  display: flex; align-items: center; gap: 0.75rem; margin: 1rem 0 0.875rem;
}
.artist-modal-divider::before,
.artist-modal-divider::after { content: ''; flex: 1; height: 1px; background: var(--color-border); }

/* Song list in admin */
.song-group { margin-bottom: 1rem; }
.song-group-header { font-size: 0.75rem; font-weight: 600; color: var(--color-muted); padding: 0.25rem 0 0.375rem; border-bottom: 1px solid var(--color-border); margin-bottom: 0.375rem; }
.song-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.5rem 0.625rem; border: 1px solid var(--color-border); border-radius: var(--radius-md); margin-bottom: 0.375rem; }
.song-info { flex: 1; min-width: 0; }
.song-title { font-size: 0.9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chord-badge { display: inline-block; font-size: 0.6875rem; background: var(--color-blue-bg); color: var(--color-blue); padding: 0.125rem 0.4375rem; border-radius: 4px; margin-top: 0.2rem; margin-right: 0.25rem; }
.yt-badge { display: inline-block; font-size: 0.6875rem; background: var(--color-red-bg); color: var(--color-red); padding: 0.125rem 0.4375rem; border-radius: 4px; margin-top: 0.2rem; text-decoration: none; }
.btn-delete { width: 26px; height: 26px; border-radius: var(--radius-sm); background: var(--color-bg); border: 1px solid var(--color-border); cursor: pointer; color: var(--color-hint); font-size: 0.875rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.15s; }
.btn-delete:hover { background: var(--color-red-bg); color: var(--color-red); border-color: #f09595; }
.delete-form { display: contents; }

/* ===== Public page ===== */
.public-page { min-height: 100vh; }
.public-header {
  background: #ffffff;
  border-bottom: 1px solid #efefed;
  padding: 1.125rem 2.5rem;
  position: sticky; top: 0; z-index: 100;
}
.public-header-inner {
  max-width: 1000px; margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
}
.public-header-logo {
  font-family: 'Caveat', cursive;
  font-size: 1.625rem; font-weight: 700;
  color: #111111; text-decoration: none;
  justify-self: start;
}
.public-header-right {
  display: flex; align-items: baseline; gap: 0.375rem;
  justify-self: center;
}
.public-header-name {
  font-size: 0.9375rem; font-weight: 500;
  color: #111111;
  white-space: nowrap;
}
.public-header-label {
  font-size: 0.8125rem; color: #c8c8c4;
  white-space: nowrap;
}
.public-body  { max-width: 700px; margin: 0 auto; padding: 1.25rem 1.5rem; }

.stats-bar { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat-pill { font-size: 0.75rem; color: var(--color-muted); background: var(--color-surface); padding: 0.25rem 0.625rem; border-radius: 20px; border: 1px solid var(--color-border); }

.search-wrap { position: relative; margin-bottom: 1.25rem; }
.search-wrap input { width: 100%; padding: 0.5625rem 0.75rem 0.5625rem 2.25rem; background: var(--color-surface); }
.search-icon { position: absolute; left: 0.6875rem; top: 50%; transform: translateY(-50%); color: var(--color-hint); pointer-events: none; }

.artist-group { margin-bottom: 0.625rem; border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; }
.artist-header { padding: 0.625rem 0.875rem; background: var(--color-bg); display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; }
.artist-name { font-size: 0.9375rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.artist-count { font-size: 0.6875rem; color: var(--color-hint); font-weight: 400; }
.chevron { transition: transform 0.2s; flex-shrink: 0; }
.chevron.open { transform: rotate(180deg); }

.song-list-inner { border-top: 1px solid var(--color-border); }
.song-list-inner.collapsed { display: none; }

.song-row-pub { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.5625rem 0.875rem; border-bottom: 1px solid var(--color-border); }
.song-row-pub:last-child { border-bottom: none; }
.song-info-pub { flex: 1; min-width: 0; }
.song-title-pub { font-size: 0.9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.yt-btn { width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--color-red-bg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.empty-state { padding: 2.5rem; text-align: center; font-size: 0.9375rem; color: var(--color-hint); }
.empty-hint   { font-size: 0.8125rem; color: var(--color-hint); padding: 0.75rem 0; }
.hidden { display: none !important; }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .admin-body { grid-template-columns: 1fr; }
  .admin-panel { border-right: none; border-bottom: 1px solid var(--color-border); max-height: none; }
  .form-row-2 { grid-template-columns: 1fr; }
  .admin-header { padding: 0.625rem 1rem; }
  .admin-header .btn-outline { padding: 0.375rem 0.625rem; font-size: 0.6rem; }
  .header-name { font-size: 0.875rem; }
  .header-tag  { display: none; }
  .public-body { padding: 1rem; }
}

/* ===== 五十音インデックス ===== */
.gojuuon-nav {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 1.25rem;
}
.gojuuon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  font-size: 0.875rem; font-weight: 500;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-blue);
  text-decoration: none;
  transition: background 0.12s;
}
.gojuuon-btn:hover { background: var(--color-blue-bg); text-decoration: none; }
.gojuuon-btn.disabled { color: var(--color-hint); background: var(--color-bg); cursor: default; border-color: var(--color-border); }

.gojuuon-row-label {
  font-size: 0.75rem; font-weight: 700;
  color: var(--color-blue);
  background: var(--color-blue-bg);
  padding: 4px 10px;
  border-radius: 4px;
  margin: 1rem 0 0.5rem;
  display: inline-block;
  scroll-margin-top: 1rem;
}

/* ===== 背景画像アップロード ===== */
.bg-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}
.bg-preview {
  margin-bottom: 0.75rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
  max-height: 120px;
}
.bg-preview img {
  width: 100%; height: 120px;
  object-fit: cover; display: block;
}
.file-input {
  width: 100%;
  padding: 0.4rem 0;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--color-text);
}
.btn-danger {
  background: var(--color-red-bg);
  color: var(--color-red);
  border-color: #f09595;
}
.btn-danger:hover { background: #f7c1c1; }

/* ===== 曲行アクション（編集・削除） ===== */
.song-row-actions {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.btn-edit {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: var(--color-bg); border: 1px solid var(--color-border);
  cursor: pointer; font-size: 0.8125rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s;
}
.btn-edit:hover { background: #FFF8E6; border-color: #e8c97e; }

/* ===== 編集モーダル ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
}
.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius, var(--radius-lg));
  width: min(520px, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  z-index: 101;
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: var(--color-bg); border: 1px solid var(--color-border);
  cursor: pointer; font-size: 1rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--color-red-bg); color: var(--color-red); }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 0.5rem;
  margin-top: 1.25rem; padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

/* ===== 曲行ボタン群（コード譜・YouTube） ===== */
.song-btns {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.chord-btn {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: var(--color-blue-bg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; text-decoration: none;
  transition: background 0.12s;
}
.chord-btn:hover { background: #c8dff5; }

/* ===== サイト共通フッター ===== */
.site-footer {
  background: #ffffff;
  border-top: 1px solid #efefed;
  padding: 1.75rem 2.5rem;
  margin-top: auto;
  width: 100%;
}
.site-footer-inner {
  max-width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.75rem;
}
.site-footer-logo {
  font-family: 'Caveat', cursive;
  font-size: 1.375rem; font-weight: 700;
  color: #111111;
  text-decoration: none;
  letter-spacing: 0.01em;
}
.site-footer-links {
  display: flex; gap: 2rem; flex-wrap: wrap;
}
.site-footer-links a {
  font-size: 0.75rem; font-weight: 400;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: #c8c8c4;
  text-decoration: none;
  transition: color 0.15s;
}
.site-footer-links a:hover { color: #111111; }
.site-footer-copy {
  font-size: 0.6875rem;
  color: #c8c8c4;
  letter-spacing: 0.05em;
  width: 100%;
  text-align: center;
  margin-top: 0.25rem;
}

/* ページ全体をflexにしてフッターを最下部に固定 */
.auth-page, .admin-page, .public-page {
  display: flex; flex-direction: column; min-height: 100vh;
}
.auth-wrap   { flex: 1; }
.admin-body  { flex: 1; }
.public-body { flex: 1; }

@media (max-width: 480px) {
  .site-footer-inner { flex-direction: column; align-items: flex-start; }
  .site-footer-links { gap: 1rem; }
}

/* ===== Textarea ===== */
textarea {
  width: 100%;
  padding: 0.5625rem 0.75rem;
  font-size: 0.9375rem;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: vertical;
  line-height: 1.5;
}
textarea:focus {
  border-color: var(--color-blue);
  box-shadow: 0 0 0 2px rgba(24,95,165,0.12);
}

/* ===== プロフィール設定セクション（管理画面） ===== */
.profile-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

/* ===== 退会セクション（管理画面） ===== */
.danger-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

/* ===== CSV管理セクション（管理画面） ===== */
.csv-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}
.csv-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
@media (max-width: 640px) {
  .csv-row { grid-template-columns: 1fr; }
}

/* ===== 公開ページ SNSリンク ===== */
.profile-sns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.sns-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.3rem 0.875rem;
  border-radius: 20px;
  font-size: 0.75rem; font-weight: 500;
  text-decoration: none;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.sns-btn:hover { opacity: 0.78; text-decoration: none; }
.sns-x         { background: #000000; color: #ffffff; }
.sns-insta     { background: #E1306C; color: #ffffff; }
.sns-yt        { background: #FF0000; color: #ffffff; }
.sns-tiktok    { background: #010101; color: #ffffff; }
.sns-streaming { background: #5a4fcf; color: #ffffff; }

/* ===== トースト通知 ===== */
.toast {
  position: fixed; top: 4.5rem; left: 50%; transform: translateX(-50%) translateY(-0.5rem);
  background: var(--color-green-bg); color: var(--color-green);
  border: 1px solid #5dcaa5;
  padding: 0.625rem 1.25rem; border-radius: var(--radius-md);
  font-size: 0.875rem; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  opacity: 0; transition: opacity 0.22s, transform 0.22s;
  z-index: 200; pointer-events: none;
}
.toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }
