:root {
  --primary: #4a90e2;
  --primary-dark: #357abd;
  --bg: #f4f7f9;
  --card: #ffffff;
  --text: #333333;
  --border: #dce1e7;
  --danger: #e74c3c;
  --success: #2ecc71;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 16px;
  line-height: 1.5;
}

.container {
  max-width: 720px;
  margin: 0 auto;
}

h1 {
  font-size: 1.25rem;
  text-align: center;
  margin: 0 0 12px 0;
  color: #1a2530;
}

.site-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.site-nav a {
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: bold;
}

.site-nav a:hover {
  text-decoration: underline;
}

.tool-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tool-list a {
  display: block;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  color: inherit;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.15s;
}

.tool-list a:hover {
  border-color: var(--primary);
  background: #eef5fc;
}

.tool-list .tool-title {
  display: block;
  font-weight: bold;
  font-size: 1rem;
  margin-bottom: 4px;
  color: #1a2530;
}

.tool-list .tool-desc {
  display: block;
  font-size: 0.85rem;
  color: #667788;
}

/* Banner-style tool link (image is the whole button) */
.tool-list a.tool-banner {
  padding: 0;
  overflow: hidden;
  background: transparent;
  line-height: 0;
  /* Keep left text visible; right instruments may crop on narrow screens */
  aspect-ratio: 960 / 280;
}

.tool-list a.tool-banner:hover {
  background: transparent;
  border-color: var(--primary-dark);
  box-shadow: 0 4px 14px rgba(53, 122, 189, 0.22);
  transform: translateY(-1px);
}

.tool-list a.tool-banner:active {
  transform: translateY(0);
}

.tool-list a.tool-banner img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: left center;
}

@media (max-width: 480px) {
  /* Slightly taller frame → crops the right side first, text stays */
  .tool-list a.tool-banner {
    aspect-ratio: 2.15 / 1;
  }
}

.tool-list a.tool-banner .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hint {
  font-size: 0.82rem;
  color: #667788;
  margin: 0 0 10px 0;
  font-weight: normal;
}

.sub-label {
  font-size: 0.9rem;
  font-weight: bold;
  margin: 14px 0 6px 0;
}

.sub-label:first-of-type { margin-top: 0; }

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: bold;
  font-size: 0.95rem;
}

textarea {
  width: 100%;
  height: 120px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: monospace;
  font-size: 14px;
  resize: vertical;
}

.part-textarea { height: 80px; }
.overseas-part-textarea {
  height: 72px;
  margin-bottom: 8px;
}
.bulk-textarea { height: 160px; }

.btn-group {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

button {
  flex: 1;
  min-width: 110px;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: bold;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: opacity 0.2s;
  touch-action: manipulation;
}

button:active { opacity: 0.8; }
button.secondary { background: #6c7a89; }
button.success { background: var(--success); }
button.small-btn {
  flex: none;
  min-width: auto;
  padding: 6px 14px;
  font-size: 0.85rem;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.options {
  margin: 12px 0;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.options label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.field-row > span { font-weight: bold; }

.field-row select,
.field-row input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 28px 16px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  touch-action: manipulation;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: #eef5fc;
}

.dropzone-title {
  font-weight: bold;
  margin-bottom: 6px;
}

.dropzone-sub {
  font-size: 0.82rem;
  color: #667788;
}

.midi-file-info {
  margin-top: 10px;
  font-size: 0.85rem;
  color: #445566;
  word-break: break-all;
}

.char-count {
  font-size: 0.85rem;
  color: #666;
  font-weight: normal;
}

.char-count.over {
  color: var(--danger);
  font-weight: bold;
}

.part-box {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 12px;
}

.part-box:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.tip-footer {
  margin-top: 24px;
  padding: 16px;
  text-align: center;
  font-size: 0.9rem;
}

.tip-footer a {
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: bold;
}

.tip-footer a:hover {
  text-decoration: underline;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1000;
  max-width: 90%;
  text-align: center;
}

.toast.show { opacity: 1; }

.placeholder-note {
  font-size: 0.85rem;
  color: #667788;
  background: #f0f4f8;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}
