:root {
  --red: #c8102e;
  --red-soft: #fdecee;
  --white-team: #9a6a2a;
  --white-soft: #f5ecdb;
  --ink: #222;
  --muted: #777;
  --line: #e4e4e4;
  --bg: #f6f4f1;
  --card: #fff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 15px;
}

button, input { font: inherit; }

.site-header {
  text-align: center;
  padding: 28px 16px 12px;
}
.site-header h1 {
  margin: 0;
  font-family: "Shippori Mincho", "Yu Mincho", serif;
  font-weight: 500;
  font-size: 32px;
  letter-spacing: .04em;
  background: linear-gradient(180deg, #d6bd84, #a8843f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.site-header p { margin: 6px 0 0; color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

.panel {
  background: var(--card);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.panel h2 { font-size: 17px; margin: 18px 0 10px; }
.panel h2:first-child { margin-top: 0; }

.preview-panel { position: sticky; top: 16px; align-self: start; }
@media (max-width: 860px) { .preview-panel { position: static; } }

input[type=text], input[type=number] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
}
input:focus { outline: 2px solid #f0a3ae; border-color: var(--red); }
input:disabled { background: #f2f2f2; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row-3 { grid-template-columns: 90px 1fr 1fr; }
.field-row label { font-size: 13px; color: var(--muted); display: grid; gap: 4px; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }

.adder { display: grid; gap: 8px; }
.adder-actions { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

.suggest-wrap { position: relative; }
.suggest {
  position: absolute;
  z-index: 10;
  left: 0; right: 0; top: calc(100% + 2px);
  margin: 0; padding: 4px 0;
  list-style: none;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,.12);
  max-height: 320px;
  overflow-y: auto;
  display: none;
}
.suggest.open { display: block; }
.suggest li {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.suggest li.active, .suggest li:hover { background: #fff2f4; }
.suggest .sub { color: var(--muted); font-size: 12px; white-space: nowrap; }
.suggest .tag-red { color: var(--red); }
.suggest .tag-white { color: var(--white-team); }

button {
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
button.ghost { border: none; color: var(--muted); padding: 8px 0; margin-top: 8px; }

.team-picker, .size-picker { display: inline-flex; border: 1px solid #ccc; border-radius: 8px; overflow: hidden; }
.team-picker button, .size-picker button { border: none; border-radius: 0; border-right: 1px solid #ccc; }
.team-picker button:last-child, .size-picker button:last-child { border-right: none; }
.team-picker button.on[data-team=red] { background: var(--red); color: #fff; }
.team-picker button.on[data-team=white] { background: var(--white-team); color: #fff; }
.team-picker button.on[data-team=special] { background: #555; color: #fff; }
.size-picker button.on { background: #333; color: #fff; }

.hint { margin: 0; min-height: 1.2em; font-size: 13px; color: var(--red); }

.list-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.list-actions .ghost { margin-top: 0; }
.counts-row { display: flex; justify-content: flex-end; }
.link-btn { border: none; background: none; padding: 2px 0; font-size: 13px; color: var(--red); text-decoration: underline; }
.link-btn[hidden] { display: none; }
.drag-hint { margin: 0 0 8px; font-size: 12px; color: #999; }

.lists { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .lists { grid-template-columns: 1fr; } }
h3 { font-size: 14px; margin: 6px 0; padding: 4px 8px; border-radius: 6px; }
h3.red { background: var(--red-soft); color: var(--red); }
h3.white { background: var(--white-soft); color: var(--white-team); }
h3.special { background: #eee; color: #444; margin-top: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
h3.special span { overflow-wrap: anywhere; white-space: pre-wrap; }
h3.special .link-btn { flex: none; font-weight: 400; font-size: 12px; }
#special-title { margin: 2px 0 6px; }
#special-title[hidden] { display: none; }

.entry-list { list-style: none; margin: 0; padding: 0; }
.entry-list { min-height: 40px; }
.entry-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 2px 6px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  background: #fff;
}
.entry-list li[hidden] { display: none; }
.entry-list .handle {
  grid-row: 1 / span 2; grid-column: 1;
  display: flex; align-items: center; justify-content: center;
  width: 22px; color: #bbb; font-size: 18px;
  cursor: grab; touch-action: none; user-select: none;
}
.entry-list .handle:hover { color: #666; }
.entry-list .name { grid-column: 2; font-weight: 700; overflow-wrap: anywhere; }
.entry-list .song { color: var(--muted); font-size: 13px; grid-column: 2; overflow-wrap: anywhere; cursor: pointer; }
.entry-list .song:hover { text-decoration: underline; }
.entry-list .ctrl { grid-row: 1 / span 2; grid-column: 3; display: flex; gap: 4px; align-items: center; }
.drag-ghost {
  position: fixed; z-index: 100; pointer-events: none; list-style: none;
  display: grid; grid-template-columns: auto 1fr auto; gap: 2px 6px; padding: 6px 4px;
  background: #fff; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.2); opacity: .92; font-size: 14px;
}
.drag-ghost .handle { grid-row: 1 / span 2; color: #666; font-size: 18px; width: 22px; display: flex; align-items: center; justify-content: center; }
.drag-ghost .name { font-weight: 700; }
.drag-ghost .song { grid-column: 2; color: var(--muted); font-size: 13px; }
.drag-ghost .ctrl { grid-row: 1 / span 2; grid-column: 3; display: flex; gap: 4px; align-items: center; }
.drag-ghost .ctrl button { padding: 3px 7px; font-size: 12px; }
.drag-ghost .count { width: 52px; padding: 3px 4px; font-size: 12px; }
.drag-placeholder { border: 2px dashed #e5b3bb !important; border-radius: 8px; background: #fff7f8 !important; list-style: none; }
body.dragging { user-select: none; cursor: grabbing; }
.entry-list .ctrl button { padding: 3px 7px; font-size: 12px; }
.entry-list .count { width: 52px; padding: 3px 4px; font-size: 12px; }
.entry-list .empty { color: #aaa; font-size: 13px; border: none; display: block; }
.entry-list .song-edit { grid-column: 1 / -1; }

.canvas-box { margin: 12px 0; background: #eee; border-radius: 8px; padding: 8px; text-align: center; }
.canvas-box img { display: block; margin: 0 auto; max-width: 100%; max-height: 70vh; height: auto; box-shadow: 0 1px 4px rgba(0,0,0,.15); background: #fff; -webkit-touch-callout: default; }
.preview-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }

.site-footer { text-align: center; font-size: 11px; color: #aaa; padding: 8px 16px 20px; }
.site-footer a { color: inherit; }

.doc { max-width: 720px; margin: 0 auto; padding: 24px 16px 48px; line-height: 1.8; }
.doc h1 { font-size: 24px; }
.doc h2 { font-size: 17px; margin-top: 28px; }
.doc-date { color: var(--muted); font-size: 13px; margin-top: 28px; }
.doc.shared { text-align: center; }
.doc.shared img { display: block; max-width: 100%; height: auto; margin: 0 auto 16px; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.make-own { display: inline-block; padding: 12px 32px; border-radius: 8px; background: var(--red); color: #fff; font-weight: 700; text-decoration: none; }

.import-box { margin-top: 4px; }
#import-result[hidden] { display: none; }
#import-msg { margin-top: 6px; }
.import-list { list-style: none; margin: 8px 0; padding: 0; max-height: 280px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.import-list label { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 14px; cursor: pointer; }
.import-list li:last-child label { border-bottom: none; }
.import-list .sub { color: var(--muted); font-size: 12px; }
.import-actions { display: flex; gap: 8px; align-items: center; }
.entry-list .buy { font-size: 11px; color: var(--muted); white-space: nowrap; }

.share-menu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.share-menu button { padding: 11px 6px; font-weight: 700; }
.share-menu [data-sns] { border: none; color: #fff; }
.sns-x { background: #000; }
.sns-instagram { background: linear-gradient(45deg, #f09433, #dc2743 50%, #bc1888); }
.sns-line { background: #06c755; }
.sns-threads { background: #333; }
.sns-facebook { background: #1877f2; }
.share-msg { margin: 8px 0 0; font-size: 13px; color: #333; min-height: 0; }
.share-msg:empty { display: none; }

.note {font-size: 12px; color: var(--muted); margin: 10px 0 0; }
