:root {
  --bg: #f6f2ea;
  --bg-soft: #fffdf8;
  --text: #18120b;
  --accent: #007a61;
  --accent-deep: #005f4a;
  --muted: #5f574e;
  --card: #fff;
  --border: #e0d7ca;
  --shadow: 0 14px 35px rgba(36, 20, 0, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 20%, #f1d9bd 0%, transparent 40%),
    radial-gradient(circle at 80% 0%, #bfdcd3 0%, transparent 35%),
    var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
}

.shell {
  width: min(1080px, 92vw);
  margin: 0 auto;
  padding: 3.5rem 0 4rem;
}

.hero {
  text-align: center;
  margin-bottom: 2.2rem;
  animation: riseIn 520ms ease both;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  margin: 0;
  color: var(--muted);
}

h1 {
  margin: 0.3rem 0 0.8rem;
  font-size: clamp(2rem, 4.3vw, 3.2rem);
  line-height: 1.05;
}

.byline-subtitle {
  margin-top: -0.3rem;
  margin-bottom: 0.45rem;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1.03rem;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
}

.tool-card {
  position: relative;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem 1rem 1.2rem;
  background: linear-gradient(160deg, var(--card) 0%, var(--bg-soft) 100%);
  box-shadow: var(--shadow);
  transition: transform 180ms ease, border-color 180ms ease;
  animation: riseIn 620ms ease both;
}

.tool-card h2 {
  margin: 0.2rem 0 0.45rem;
  font-size: 1.05rem;
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.tool-card-live:hover,
.tool-card-live:focus-visible {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.tool-card-soon {
  pointer-events: none;
  opacity: 0.75;
}

.dev-shell {
  width: min(1800px, 96vw);
  max-width: none;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1rem;
  align-items: start;
}

.mini-tool {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.mini-tool h2 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
}

.mini-tool p {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.mini-tool textarea,
.mini-tool input,
.mini-tool select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fdfcf8;
  color: #1f1f1f;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.88rem;
  padding: 0.55rem 0.6rem;
}

.mini-tool textarea {
  min-height: 140px;
  height: auto;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.55rem;
  margin-bottom: 0.55rem;
}

.mini-status {
  margin: 0.3rem 0 0;
  min-height: 1.2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.mini-status.success {
  color: #15643f;
}

.mini-status.error {
  color: #b7322c;
}

.mini-output {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fdfcf8;
  padding: 0.6rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.86rem;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 88px;
  max-height: 320px;
  overflow: auto;
}

.badge {
  display: inline-block;
  margin-top: 0.9rem;
  padding: 0.17rem 0.48rem;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
}

.tool-card-live .badge {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.site-footer {
  width: min(900px, 100%);
  margin: 2.2rem auto 0;
  padding: 1.15rem 1.25rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(160deg, #fff 0%, #fffdf8 100%);
  box-shadow: var(--shadow);
  text-align: left;
}

.site-footer h2 {
  margin: 0 0 0.7rem;
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #5b544a;
}

.site-footer p {
  margin: 0 0 0.72rem;
  color: var(--muted);
  font-size: 0.97rem;
  line-height: 1.5;
  max-width: 76ch;
}

.site-footer p:last-child {
  margin-bottom: 0;
}

.formatter-shell {
  width: min(1800px, 96vw);
  max-width: none;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.formatter-header {
  margin-bottom: 1rem;
}

.back-link {
  color: var(--accent-deep);
  text-decoration: none;
  font-size: 0.92rem;
}

.back-link:hover,
.back-link:focus-visible {
  text-decoration: underline;
}

.formatter-header p {
  margin-top: 0.25rem;
  color: var(--muted);
}

.formatter-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  flex: 1;
}

.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

label {
  display: block;
  margin-bottom: 0.45rem;
  font-weight: 600;
}

textarea {
  width: 100%;
  min-height: 300px;
  height: calc(100vh - 310px);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0.8rem;
  resize: vertical;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.92rem;
  line-height: 1.4;
  color: #1f1f1f;
  background: #fdfcf8;
}

textarea:focus {
  outline: 2px solid #4db8a3;
  outline-offset: 1px;
}

.preview-output {
  min-height: 300px;
  height: calc(100vh - 310px);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0.8rem;
  overflow: auto;
  background: #fdfcf8;
  font-family: "Space Grotesk", sans-serif;
  line-height: 1.45;
}

.preview-output h1,
.preview-output h2,
.preview-output h3,
.preview-output h4,
.preview-output h5,
.preview-output h6 {
  margin-top: 0.3rem;
  margin-bottom: 0.6rem;
}

.preview-output p,
.preview-output ul {
  margin-top: 0.4rem;
  margin-bottom: 0.7rem;
}

.preview-output code {
  font-family: "IBM Plex Mono", monospace;
  background: #ece6da;
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
}

.preview-output a {
  color: var(--accent-deep);
}

.controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  cursor: pointer;
  font-weight: 600;
  font-family: "Space Grotesk", sans-serif;
  background: var(--accent);
  color: #fff;
}

button:hover,
button:focus-visible {
  background: var(--accent-deep);
}

button.ghost {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
}

button.ghost:hover,
button.ghost:focus-visible {
  background: #f3ece2;
}

#status {
  margin: 0 0 0 auto;
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 1.3rem;
}

.single-tool-shell {
  width: min(1120px, 94vw);
}

.single-tool-shell .mini-tool textarea {
  min-height: 280px;
  height: auto;
}

.compare-shell {
  width: min(1800px, 96vw);
  max-width: none;
}

.compare-toolbar {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 0.8rem;
  margin-bottom: 1rem;
}

.compare-toolbar .btn-row {
  margin: 0;
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.compare-col {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 0.85rem;
}

.compare-col h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.compare-input {
  width: 100%;
  min-height: 56vh;
  resize: vertical;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.86rem;
}

.diff-view {
  margin-top: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fdfcf8;
  min-height: 240px;
  max-height: 34vh;
  overflow: auto;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
}

.diff-line {
  display: flex;
  gap: 0.6rem;
  padding: 0.2rem 0.45rem;
  border-bottom: 1px solid #efe7da;
}

.diff-line .ln {
  color: #786f64;
  min-width: 2.5rem;
  text-align: right;
}

.diff-line.diff {
  background: #fff2bf;
}

.diff-line.only {
  background: #ffdede;
}

.diff-line mark {
  background: #ffd24d;
  color: #2a1e00;
  border-radius: 3px;
  padding: 0 1px;
}

.compare-report {
  margin-top: 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 0.8rem;
}

.compare-report h2 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
}

.report-table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  max-height: 40vh;
  background: #fdfcf8;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
}

.report-table th,
.report-table td {
  border-bottom: 1px solid #eee4d4;
  text-align: left;
  padding: 0.35rem 0.45rem;
  vertical-align: top;
}

.report-table th {
  background: #f4ece0;
  color: #5d554b;
  position: sticky;
  top: 0;
  z-index: 1;
}

.change-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.08rem 0.44rem;
  border: 1px solid transparent;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
}

.change-added {
  background: #e4f9ea;
  color: #17663c;
  border-color: #9cd5ae;
}

.change-removed {
  background: #ffe5e5;
  color: #8e2020;
  border-color: #f0abab;
}

.change-updated {
  background: #fff4d0;
  color: #7a5200;
  border-color: #f0d37c;
}

.music-shell {
  width: min(1400px, 95vw);
}

.transposer-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.music-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
}

.shift-grid {
  margin-top: 0.7rem;
  grid-template-columns: 1fr 1fr;
}

.full-span {
  grid-column: 1 / -1;
}

.field-control {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fdfcf8;
  color: #1f1f1f;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9rem;
  padding: 0.55rem 0.6rem;
}

.music-summary {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.vocal-suggestions {
  margin-top: 0.35rem;
}

.suggestion-list {
  display: grid;
  gap: 0.45rem;
}

.suggestion-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fdfcf8;
  padding: 0.45rem 0.55rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
}

.apply-suggestion-btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
}

.shape-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.65rem;
}

.shape-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fdfcf8;
  padding: 0.65rem 0.7rem;
}

.shape-degree {
  margin: 0 0 0.45rem;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 700;
}

.shape-line {
  margin: 0.15rem 0;
  font-family: "IBM Plex Mono", monospace;
}

.shape-map {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.6rem;
}

.shape-chord {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: clamp(1.35rem, 4.6vw, 2.1rem);
  line-height: 1.05;
  color: #1f1f1f;
}

.shape-arrow {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: clamp(1.05rem, 3.6vw, 1.7rem);
  color: #0f8a6f;
  transform: translateY(-0.02em);
}

.shape-subline {
  margin: 0.38rem 0 0;
  color: #6a6258;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  text-align: center;
}

.music-textarea {
  min-height: 46vh;
  height: auto;
}

.mapping-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  background: #fdfcf8;
}

.mapping-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
}

.mapping-table th,
.mapping-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #eee4d4;
  text-align: left;
}

.mapping-table th {
  background: #f4ece0;
  color: #5d554b;
  position: sticky;
  top: 0;
}

#status.error {
  color: #b7322c;
}

#status.success {
  color: #15643f;
}

@media (min-width: 880px) {
  .formatter-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .shell {
    padding-top: 2.2rem;
  }

  .mini-grid {
    grid-template-columns: 1fr;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .transposer-grid {
    grid-template-columns: 1fr;
  }

  .shift-grid {
    grid-template-columns: 1fr;
  }

  .compare-grid {
    grid-template-columns: 1fr;
  }

  .compare-input {
    min-height: 42vh;
  }

  textarea {
    min-height: 230px;
    height: calc(100vh - 360px);
  }

  .preview-output {
    min-height: 230px;
    height: calc(100vh - 360px);
  }

  #status {
    width: 100%;
    margin-left: 0;
  }
}

@keyframes riseIn {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
