/* ONGEN DB の土台（色・文字・骨組み・部品）。見た目は Listagram（sales-database-mvp/public/styles.css）と同じ作りで、差し色だけ紫。
   各画面の細かい見た目は css/sidebar.css・list.css・panels.css に足す（この表は土台の担当だけが直す）。 */
[hidden] { display: none !important; }
:root {
  color-scheme: light;
  --nav: #fafafa;
  --nav-active: #ece9f4;
  --canvas: #ffffff;
  --panel: #ffffff;
  --ink: #303841;
  --muted: #7b858e;
  --subtle: #a7afb6;
  --line: #e2e5e8;
  --line-dark: #d2d7dc;
  --head: #f4f5f6;
  --brand: #6a45c9;
  --brand-dark: #5434a8;
  --brand-soft: #f3effc;
  --brand-line: #d9cdf3;
  --accent: #ffdf72;
  --danger: #e5484d;
  --danger-soft: #fdeeee;
  --success: #2ca962;
  --success-soft: #e9f7ef;
  --warning-soft: #fff6dd;
  /* 点数の色（90+ / 80+ / 70+ / 69 以下 / 未評価） */
  --score-top: #4b2aa3;
  --score-high: #6a45c9;
  --score-mid-bg: #ece5fb;
  --score-mid-ink: #5434a8;
  --score-low-bg: #f6eded;
  --score-low-ink: #a2484b;
  --radius: 5px;
  --shadow: 0 8px 28px rgba(28, 23, 48, .12);
  --sidebar-w: 264px;
  --panel-w: min(460px, 94vw);
}

html, body { margin: 0; min-height: 100%; }
body { color: var(--ink); background: var(--canvas); font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif; font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* 骨組み */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
#sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 8px 16px; border-right: 1px solid var(--line); color: #5e6871; background: var(--nav); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; box-sizing: border-box; }
#main { min-width: 0; display: flex; flex-direction: column; }
body.panel-open #main { padding-right: var(--panel-w); }

/* 見出し（Listagram の topbar を少し低く） */
#topbar { min-height: 104px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 28px 32px 18px; box-sizing: border-box; }
#topbar h1 { margin: 0 0 6px; color: #303841; font-size: 25px; font-weight: 750; letter-spacing: -.03em; }
#topbar p { margin: 0; color: var(--muted); font-size: 12px; }
#topbar .topbar-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#toolbar { padding: 0 32px 14px; }
#view { flex: 1; min-width: 0; padding: 0 32px 48px; }

/* 右の詳しく */
#detail-panel { position: fixed; top: 0; right: 0; bottom: 0; width: var(--panel-w); background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow); overflow-y: auto; z-index: 30; box-sizing: border-box; }

/* ボタン（Listagram と同じ） */
.button { box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 8px 16px; border: 1px solid transparent; border-radius: var(--radius); font-size: 13px; font-weight: 700; white-space: nowrap; background: none; text-decoration: none; }
.button.primary { color: #fff; border-color: var(--brand); background: var(--brand); box-shadow: 0 2px 4px rgba(84, 52, 168, .12); }
.button.primary:hover { background: var(--brand-dark); }
.button.secondary { color: #64717a; border-color: var(--line-dark); background: #fff; }
.button.secondary:hover { color: var(--ink); border-color: #aeb7bd; }
.button.danger { color: #fff; border-color: var(--danger); background: var(--danger); }
.button.ghost { color: var(--muted); }
.button.ghost:hover { color: var(--ink); background: #f0f1f2; }
.button.small { min-height: 30px; padding: 5px 11px; font-size: 12px; }
.button:disabled { opacity: .5; cursor: default; }
.text-button { padding: 0; border: 0; background: none; color: var(--brand); font-size: 12px; font-weight: 700; }
.text-button:hover { text-decoration: underline; }
.icon-button { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: var(--radius); background: none; color: var(--muted); }
.icon-button:hover { background: #f0f1f2; color: var(--ink); }
.icon-button svg, .nav-icon svg { width: 18px; height: 18px; display: block; }

/* 入力 */
.input, .select, .textarea { box-sizing: border-box; min-height: 36px; padding: 7px 10px; border: 1px solid var(--line-dark); border-radius: var(--radius); background: #fff; font-size: 13px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.textarea { min-height: 72px; resize: vertical; line-height: 1.6; }
.field { display: grid; gap: 6px; font-size: 12px; color: #58636c; font-weight: 650; }
.field > small { color: var(--subtle); font-weight: 500; }

/* 札 */
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 22px; padding: 1px 9px; border: 1px solid var(--line-dark); border-radius: 999px; color: #5e6871; background: #fff; font-size: 11px; font-weight: 650; white-space: nowrap; }
.chip.brand { color: var(--brand-dark); border-color: var(--brand-line); background: var(--brand-soft); }
.chip.success { color: #1f7a47; border-color: #bfe6cf; background: var(--success-soft); }
.chip.danger { color: #a2484b; border-color: #efcfd0; background: var(--danger-soft); }
.chip.muted { color: var(--muted); border-style: dashed; }

/* 点数の札（ui.scoreClass が class を決める） */
.score { display: inline-grid; place-items: center; min-width: 40px; height: 26px; padding: 0 7px; border-radius: 6px; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; box-sizing: border-box; border: 1px solid transparent; }
.score.s-top { color: #fff; background: var(--score-top); }
.score.s-high { color: #fff; background: var(--score-high); }
.score.s-mid { color: var(--score-mid-ink); background: var(--score-mid-bg); }
.score.s-low { color: var(--score-low-ink); background: var(--score-low-bg); }
.score.s-none { color: var(--subtle); border: 1px dashed var(--line-dark); background: #fff; font-weight: 600; }
button.score { cursor: pointer; }
button.score:hover { box-shadow: 0 0 0 3px var(--brand-soft); }

/* 表（Listagram の data-table） */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { height: 46px; padding: 0 14px; border-bottom: 1px solid var(--line); color: #58636c; background: var(--head); font-size: 12px; font-weight: 750; text-align: left; white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.data-table td { height: 58px; padding: 8px 14px; border-bottom: 1px solid var(--line); color: #68737c; font-size: 12px; vertical-align: middle; }
.data-table tbody tr:hover { background: #fbfafe; }
.data-table tbody tr.is-selected { background: var(--brand-soft); }
.data-table small { display: block; margin-top: 3px; color: #a0a9b0; font-size: 10.5px; }

/* 空・読み込み中 */
.empty { padding: 48px 24px; text-align: center; color: var(--muted); border: 1px dashed var(--line-dark); border-radius: 10px; }
.loading { padding: 10px 14px; border: 1px solid var(--brand-line); border-radius: 6px; background: var(--brand-soft); color: var(--brand-dark); font-size: 12px; font-weight: 600; }

/* 知らせ */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; }
.toast { display: flex; align-items: center; gap: 14px; min-width: 260px; max-width: min(560px, 92vw); padding: 11px 16px; border-radius: 8px; color: #fff; background: #2d2840; box-shadow: var(--shadow); font-size: 13px; }
.toast.error { background: #8f2f33; }
.toast .text-button { color: #d9cdf3; }

/* 小窓 */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(32, 26, 48, .32); }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; border-radius: 12px; background: #fff; box-shadow: var(--shadow); box-sizing: border-box; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 10px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { display: grid; gap: 14px; padding: 8px 22px 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 18px; border-top: 1px solid var(--line); }

/* スマホ幅：左メニューは上の帯に畳む（細かいところは sidebar.css） */
@media (max-width: 860px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  #sidebar { position: static; height: auto; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 8px; }
  /* 読み込み中（左メニューがまだ空）に大きな空き地を出さない */
  #sidebar:empty { min-height: 56px; height: 56px; }
  #topbar { min-height: 0; padding: 18px 16px 12px; flex-wrap: wrap; }
  #topbar h1 { font-size: 21px; }
  #toolbar { padding: 0 16px 10px; }
  #view { padding: 0 16px 40px; }
  body.panel-open #main { padding-right: 0; }
  #detail-panel { width: 100vw; }
}

/* 起動の骨組み（index.html に直に書いたもの）。各画面が描くと中身ごと置きかわる。
   棒は表・左メニューと同じ寸法にして、本物に替わったときに形が跳ねないようにする。 */
.boot-skel { pointer-events: none; user-select: none; }
.bs-bar { display: block; flex-shrink: 0; height: 12px; border-radius: 4px; background: linear-gradient(90deg, #eef0f2 0%, #f6f7f8 40%, #eef0f2 80%); background-size: 240% 100%; animation: bs-shine 1.4s ease-in-out infinite; }
@keyframes bs-shine { from { background-position: 100% 0; } to { background-position: -140% 0; } }
@media (prefers-reduced-motion: reduce) { .bs-bar { animation: none; } }
.boot-failed .bs-bar { animation: none; } /* 読めなかったときは「まだ読んでいる」に見せない */
.bs-nav { display: flex; flex-direction: column; gap: 14px; padding: 22px 16px 0; }
.bs-nav .bs-section { width: 34px; height: 9px; margin-top: 10px; }
.bs-nav .bs-item { width: 72%; height: 14px; }
.bs-nav .bs-item.is-on { width: 100%; height: 30px; margin: -8px 0; background: var(--nav-active); animation: none; }
.bs-nav .bs-sub { width: 56%; margin-left: 30px; }
.boot-skel-top { display: grid; gap: 10px; padding-bottom: 6px; }
.bs-title { width: 168px; height: 24px; }
.bs-line { width: 260px; max-width: 70vw; height: 10px; }
.bs-tools { display: flex; align-items: center; gap: 10px; padding: 12px 0 2px; border-top: 1px solid var(--line); }
.bs-tools .bs-search { flex: 1 1 auto; max-width: 420px; height: 36px; }
.bs-tools .bs-seg { width: 120px; height: 36px; }
.bs-table { margin-top: 10px; border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
.bs-head { height: 46px; border-bottom: 1px solid var(--line); background: var(--head); }
.bs-row { display: flex; align-items: center; gap: 18px; height: 54px; padding: 0 14px; border-bottom: 1px solid var(--line); box-sizing: border-box; }
.bs-row:last-child { border-bottom: 0; }
.bs-row .bs-score { width: 40px; height: 26px; border-radius: 6px; }
.bs-two { display: grid; gap: 7px; flex: 1 1 auto; min-width: 0; }
.bs-name { width: 46%; height: 13px; }
.bs-artist { width: 28%; height: 10px; }
.bs-name.w2 { width: 34%; }
.bs-name.w3 { width: 58%; }
.bs-artist.w2 { width: 20%; }
.bs-row .bs-chip { width: 84px; height: 22px; border-radius: 999px; }

/* 起動のあいだの小さな知らせ（前回の一覧を表示中・最新を読めなかった）。知らせ（#toast）と同じ下の真ん中 */
#boot-note { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 55; display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(100vw - 32px); padding: 8px 14px; box-sizing: border-box; border: 1px solid var(--brand-line); border-radius: 999px; color: var(--brand-dark); background: #fff; box-shadow: 0 6px 20px rgba(28, 23, 48, .10); font-size: 12px; font-weight: 650; line-height: 1.5; }
#boot-note.is-error { padding-right: 8px; border-color: #efcfd0; border-radius: 10px; color: #8f2f33; background: var(--danger-soft); }
#boot-note svg { width: 16px; height: 16px; display: block; flex: 0 0 auto; }
.boot-note-spin { animation: boot-spin .9s linear infinite; }
@keyframes boot-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .boot-note-spin { animation: none; } }
.boot-note-reload { display: grid; place-items: center; flex: 0 0 auto; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 6px; color: inherit; background: transparent; }
.boot-note-reload:hover { background: rgba(0, 0, 0, .06); }

@media (max-width: 860px) {
  /* 本文が画面より短いとき（骨組み・0件）に、上の帯が引き伸ばされて太くならないように */
  .app-shell { align-content: start; }
  /* スマホ幅の左メニューは上の帯（ブランドだけ）。骨組みも帯の高さにそろえる */
  .boot-skel-side .bs-nav { display: none; }
  .boot-skel-side .brand { min-height: 36px; padding: 0 4px 0 8px; border-bottom: 0; }
  .boot-skel-side .brand-copy span { display: none; }
  .bs-tools .bs-seg, .bs-row .bs-chip { display: none; }
  .bs-name { width: 70%; }
  .bs-name.w2 { width: 56%; }
  .bs-name.w3 { width: 82%; }
  .bs-artist { width: 40%; }
  #boot-note { bottom: 16px; }
}
