:root {
  --fg: #1f2328;
  --muted: #57606a;
  --bg: #ffffff;
  --bg-alt: #f6f8fa;
  --border: #d0d7de;
  --accent: #0969da;
  --warn: #cf222e;
  --ok: #1a7f37;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.5;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 64px;
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 24px;
}

h2 {
  font-size: 1.1rem;
  margin: 0;
}

section {
  margin-bottom: 32px;
  padding: 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.course-select {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.course-select label {
  font-weight: 600;
}

.course-select select {
  flex: 1;
  min-width: 240px;
  padding: 6px 8px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
}

.course-select a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.course-select a:hover {
  text-decoration: underline;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

th, td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.95rem;
  vertical-align: middle;
}

th {
  background: var(--bg-alt);
  font-weight: 600;
}

tbody tr:last-child td {
  border-bottom: none;
}

input[type='number'] {
  width: 100%;
  max-width: 140px;
  padding: 4px 6px;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
}

input[type='number']:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

button {
  padding: 6px 12px;
  font-size: 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  background: #eaeef2;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.result {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.result.warn {
  color: var(--warn);
}

.result.below-threshold {
  color: var(--warn);
}

.result.at-or-above-threshold {
  color: var(--accent);
}

.result.placeholder {
  color: var(--muted);
  font-weight: normal;
}

.hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* X 投稿ボタン (個別 Acc 行直下に配置) */
.combined-table tr.share-row > td.share-cell {
  padding: 8px 12px;
  text-align: right;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

#tweetBtn {
  background: #0f1419;
  color: #fff;
  border: none;
  padding: 6px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.15s;
}

#tweetBtn:hover:not(:disabled) {
  background: #272c30;
}

#tweetBtn:disabled {
  background: #aab8c2;
  color: #f4f6f8;
  cursor: not-allowed;
}

.song-name {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.4;
}

.song-empty {
  color: var(--muted);
  font-style: italic;
}

/* 行列入れ替えテーブル: 行ラベルを左端の th として表示 */
table.transposed th.row-header,
table.transposed th.row-header-cell {
  background: var(--bg-alt);
  white-space: nowrap;
  font-weight: 600;
  text-align: left;
}

table.transposed th[scope="row"] {
  width: 1%;            /* 自然な最小幅 */
}

table.transposed thead th {
  text-align: center;
}

table.transposed td {
  text-align: center;
}

table.transposed td input[type="number"] {
  max-width: 120px;
  text-align: right;
}

.input-pct {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.input-pct .unit {
  color: var(--muted);
  font-size: 0.95rem;
}

table.transposed td.song-name {
  text-align: center;
  vertical-align: middle;
  min-width: 180px;
}

/* 統合テーブルのセクション見出し / ヒント / 列ヘッダ */
.combined-table tr.section-header > th {
  background: #dde5ee;
  color: var(--fg);
  text-align: left;
  padding: 10px 12px;
  font-size: 1.05rem;
  border-top: 2px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.combined-table tr.section-header:first-child > th {
  border-top: none;
}

.combined-table tr.section-hint > td {
  background: var(--bg-alt);
  color: var(--muted);
  font-size: 0.9rem;
  padding: 6px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.combined-table tr.column-header > th {
  background: var(--bg-alt);
  text-align: center;
  font-weight: 600;
}

.combined-table tr.column-header > th:first-child {
  background: var(--bg-alt);
}

/* コピー行: 行ラベルは他行と同じ見た目を維持しつつ、行の高さとボタンを小さく */
.combined-table tr.copy-row > th,
.combined-table tr.copy-row > td {
  padding-top: 2px;
  padding-bottom: 2px;
}

.combined-table tr.copy-row > th.row-header {
  font-size: 0.8rem;
}

.combined-table tr.copy-row > td {
  font-size: 0.8rem;
  background: var(--bg);
}

.combined-table tr.copy-row .copy-btn {
  padding: 1px 10px;
  font-size: 0.95rem;
  line-height: 1.2;
  min-width: 36px;
}
