:root {
  --bg: var(--theme-bg, #f6f2ea);
  --bg-soft: var(--theme-soft, #fffdf8);
  --text: var(--theme-text, #18120b);
  --accent: var(--theme-accent, #007a61);
  --accent-deep: var(--theme-button, #005f4a);
  --link: var(--theme-link, #005f4a);
  --danger: var(--theme-error, #8e3123);
  --muted: var(--theme-muted, #5f574e);
  --card: var(--theme-surface, #fff);
  --border: var(--theme-border, #e0d7ca);
  --shadow: var(--theme-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%, var(--theme-glow-peach, #f1d9bd) 0%, transparent 40%),
    radial-gradient(circle at 80% 0%, var(--theme-glow-teal, #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;
}

.hero-logo {
  display: block;
  width: min(340px, 46vw);
  margin: -0.35rem 0 0.2rem;
  height: auto;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
}

.brand-byline {
  white-space: nowrap;
}

.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;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.module-utility-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0.95rem;
  margin: -0.2rem 0 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(160deg, var(--card) 0%, var(--bg-soft) 100%);
  box-shadow: var(--shadow);
}

.module-utility-copy h2 {
  margin: 0 0 0.2rem;
  font-size: 1rem;
}

.module-utility-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.module-utility-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 0.42rem 0.9rem;
  transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.module-utility-link:hover,
.module-utility-link:focus-visible {
  transform: translateY(-1px);
  background: var(--accent-deep);
  border-color: var(--accent-deep);
}

.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.has-favorite-toggle {
  padding-right: 2.8rem;
  padding-bottom: 1.2rem;
}

button.favorite-toggle {
  position: absolute;
  right: 0.78rem;
  bottom: 0.95rem;
  width: auto;
  height: auto;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  appearance: none;
  color: #7e745f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

button.favorite-toggle:hover,
button.favorite-toggle:focus-visible {
  background: transparent;
  color: var(--theme-warning, #745100);
}

.tool-card.is-favorited {
  border-color: #d5c187;
}

.tool-card.is-favorited button.favorite-toggle {
  color: var(--theme-warning, #9f7200);
}

.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: var(--theme-surface, #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: var(--theme-soft, #fdfcf8);
  color: var(--theme-text, #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: var(--theme-success, #15643f);
}

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

.mini-output {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--theme-soft, #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;
}

.palette-output {
  display: grid;
  gap: 0.35rem;
}

.palette-output-row {
  display: grid;
  grid-template-columns: minmax(110px, auto) minmax(90px, 1fr);
  align-items: center;
  gap: 0.75rem;
}

.palette-output-code {
  font-family: "IBM Plex Mono", monospace;
}

.palette-output-swatch {
  display: block;
  height: 1.35rem;
  border-radius: 0.35rem;
  border: 1px solid rgba(0, 0, 0, 0.18);
}

.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);
}

.favorites-empty {
  margin: 0 0 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--theme-soft, #fffdf8);
  padding: 0.9rem 1rem;
  color: var(--muted);
}

.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, var(--theme-surface, #fff) 0%, var(--theme-soft, #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(--link);
  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: var(--theme-surface, #fff);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.formatter-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
}

.formatter-panel-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.formatter-panel-head label {
  margin-bottom: 0;
}

.stacktrace-rich-output {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--theme-soft, #fdfcf8);
  padding: 0.75rem;
  min-height: 220px;
  max-height: 46vh;
  overflow: auto;
  margin-bottom: 0.6rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.45;
}

.stacktrace-rich-output h3 {
  margin: 0 0 0.45rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.95rem;
}

.stacktrace-summary {
  margin-bottom: 0.75rem;
}

.stacktrace-row {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 0.5rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid #eee4d4;
}

.stacktrace-row:last-child {
  border-bottom: 0;
}

.stacktrace-key {
  color: var(--theme-muted, #5d554b);
  font-weight: 600;
}

.stacktrace-root {
  color: var(--theme-error, #8e2020);
  font-weight: 700;
}

.stacktrace-source {
  color: var(--theme-muted, #5d554b);
  font-size: 0.78rem;
}

.stacktrace-frame {
  border: 1px solid #e8decd;
  border-radius: 10px;
  padding: 0.4rem 0.5rem;
  margin-bottom: 0.38rem;
}

.stacktrace-frame-custom {
  background: var(--theme-warning-bg, #fff2bf);
  border-color: #e0be66;
}

.stacktrace-frame-platform {
  background: var(--theme-soft, #f6f1e7);
}

.stacktrace-method {
  font-weight: 600;
}

.stacktrace-location {
  margin-top: 0.12rem;
  color: var(--theme-muted, #5d554b);
  font-size: 0.78rem;
}

.stacktrace-code {
  margin-top: 0.2rem;
  border-radius: 6px;
  background: var(--theme-surface, #fff);
  border: 1px solid #e8decd;
  padding: 0.2rem 0.35rem;
  color: var(--theme-text, #3f372f);
  font-size: 0.77rem;
}

.stacktrace-repeat {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.03rem 0.35rem;
  border-radius: 999px;
  font-size: 0.7rem;
  background: var(--theme-inset, #efe4cf);
  color: var(--theme-muted, #6b604f);
  border: 1px solid #dcc9a7;
}

.stacktrace-marker {
  background: var(--theme-info-bg, #eef7ff);
  border-color: #bdd8f5;
  color: var(--theme-info, #1d4f79);
  font-style: italic;
}

.stacktrace-note {
  background: var(--theme-surface, #fff);
  color: var(--theme-muted, #5d554b);
}

.stacktrace-raw-output {
  min-height: 180px;
}

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: var(--theme-text, #1f1f1f);
  background: var(--theme-soft, #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: var(--theme-soft, #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: var(--theme-inset, #ece6da);
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
}

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

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

.trace-profile-label {
  margin: 0;
  font-weight: 600;
}

.trace-profile-select {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--theme-surface, #fff);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
}

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.favorite-toggle,
button.favorite-toggle:hover,
button.favorite-toggle:focus-visible {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent !important;
  box-shadow: none !important;
}

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

button.ghost:hover,
button.ghost:focus-visible {
  background: var(--theme-inset, #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: var(--theme-surface, #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: var(--theme-surface, #fff);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 0.85rem;
}

.compare-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  margin-bottom: 0.5rem;
}

.compare-col-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

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

.compare-copy-btn {
  white-space: nowrap;
}

.compare-input {
  width: 100%;
  min-height: 4.2rem;
  height: auto;
  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: var(--theme-soft, #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: var(--theme-muted, #786f64);
  min-width: 2.5rem;
  text-align: right;
}

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

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

.diff-line.diff-line-active {
  box-shadow: inset 0 0 0 1px #b07800;
  background: #ffd24d;
}

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

.compare-report {
  margin-top: 1rem;
  background: var(--theme-surface, #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: var(--theme-soft, #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: var(--theme-inset, #f4ece0);
  color: var(--theme-muted, #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: var(--theme-success-bg, #e4f9ea);
  color: var(--theme-success, #17663c);
  border-color: #9cd5ae;
}

.change-removed {
  background: var(--theme-error-bg, #ffe5e5);
  color: var(--theme-error, #8e2020);
  border-color: #f0abab;
}

.change-updated {
  background: var(--theme-warning-bg, #fff4d0);
  color: var(--theme-warning, #7a5200);
  border-color: #f0d37c;
}

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

.compare-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.compare-results-head h2 {
  margin: 0;
  font-size: 1rem;
}

.compare-results-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.compare-results-actions .mini-status {
  margin: 0;
  min-height: 1.2rem;
}

.hidden {
  display: none !important;
}

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

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

.compare-highlight-nav {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.55rem;
}

.compare-highlight h3 {
  margin: 0 0 0.45rem;
  font-size: 0.92rem;
  color: var(--theme-muted, #5d554b);
}

.json-highlight-view {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--theme-soft, #fdfcf8);
  min-height: 240px;
  max-height: 40vh;
  overflow: auto;
  padding: 0.65rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre;
}

.json-key {
  color: var(--theme-success, #17663c);
}

.json-string {
  color: var(--theme-error, #8e2020);
}

.json-number {
  color: #005fa3;
}

.json-boolean {
  color: var(--theme-warning, #7a5200);
}

.json-null {
  color: var(--theme-muted, #786f64);
}

.json-diff-line {
  display: block;
  margin: 0 -0.2rem;
  padding: 0 0.2rem;
  border-radius: 4px;
  background: #fff2bf;
}

.json-diff-line-active {
  background: #ffd24d;
  box-shadow: inset 0 0 0 1px #d39f00;
}

.xml-highlight-view {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--theme-soft, #fdfcf8);
  min-height: 240px;
  max-height: 40vh;
  overflow: auto;
  padding: 0.65rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre;
}

.xml-line {
  display: block;
  margin: 0 -0.2rem;
  padding: 0 0.2rem;
  border-radius: 4px;
}

.xml-ln {
  display: inline-block;
  min-width: 2.8rem;
  text-align: right;
  margin-right: 0.55rem;
  color: var(--theme-muted, #786f64);
}

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

.xml-diff-line-active {
  background: #ffd24d;
  box-shadow: inset 0 0 0 1px #d39f00;
}

.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: var(--theme-soft, #fdfcf8);
  color: var(--theme-text, #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: var(--theme-soft, #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: var(--theme-soft, #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: var(--theme-text, #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: var(--theme-muted, #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: var(--theme-soft, #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: var(--theme-inset, #f4ece0);
  color: var(--theme-muted, #5d554b);
  position: sticky;
  top: 0;
}

.tuner-head {
  margin-bottom: 0.85rem;
}

.tuner-head h2 {
  margin: 0 0 0.35rem;
}

.tuner-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.tuner-main-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 1rem;
}

.tuner-display-card,
.tuner-controls-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--theme-soft, #fdfcf8);
  padding: 0.85rem;
}

.tuner-label {
  margin: 0 0 0.28rem;
  color: var(--theme-muted, #6a6258);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.76rem;
}

.tuner-note-row {
  display: flex;
  align-items: baseline;
  gap: 0.24rem;
}

.tuner-note {
  font-family: "IBM Plex Mono", monospace;
  font-size: clamp(2.2rem, 8vw, 3.8rem);
  font-weight: 700;
  line-height: 1;
}

.tuner-octave {
  font-family: "IBM Plex Mono", monospace;
  color: #665d52;
  font-size: clamp(1rem, 2.8vw, 1.4rem);
}

.tuner-freq {
  margin: 0.3rem 0 0.7rem;
  color: var(--theme-muted, #5d554b);
  font-family: "IBM Plex Mono", monospace;
}

.tuner-gauge-wrap {
  margin-top: 0.35rem;
}

.tuner-gauge-track {
  position: relative;
  height: 22px;
  border-radius: 999px;
  border: 1px solid #d8cebe;
  background: linear-gradient(90deg, #f8dede 0%, #fff5d3 32%, #dcf4e5 50%, #fff5d3 68%, #f8dede 100%);
  overflow: hidden;
}

.tuner-gauge-center {
  position: absolute;
  left: 50%;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: #0f8a6f;
}

.tuner-needle {
  position: absolute;
  top: 2px;
  left: 50%;
  width: 10px;
  height: 16px;
  border-radius: 6px;
  background: #1c1711;
  transform: translateX(-50%);
  transition: left 90ms linear;
}

.tuner-gauge-labels {
  margin-top: 0.35rem;
  display: flex;
  justify-content: space-between;
  color: var(--theme-muted, #6a6258);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
}

.tuner-hint {
  margin: 0.62rem 0 0;
  color: var(--theme-muted, #5f574e);
  min-height: 1.2rem;
}

.tuner-hint.in-tune {
  color: var(--theme-success, #15643f);
  font-weight: 700;
}

.tuner-controls-card h3 {
  margin: 0;
}

.tuner-copy {
  margin: 0.34rem 0 0.6rem;
  color: var(--theme-muted, #5f574e);
  font-size: 0.92rem;
}

.tuner-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
  font-size: 0.9rem;
}

.tuner-string-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}

.tuner-string-btn {
  width: 100%;
  text-align: center;
}

.warmup-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.45rem;
}

.warmup-meta {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  background: var(--theme-soft, #fdfcf8);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  color: var(--theme-muted, #5f574e);
  white-space: nowrap;
}

.warmup-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 1rem;
}

.music-match-panel .warmup-grid {
  grid-template-columns: 1fr;
}

.warmup-settings-summary {
  margin: 0;
  font-size: 0.82rem;
  color: var(--theme-muted, #5f574e);
  font-family: "IBM Plex Mono", monospace;
}

.warmup-settings-icon-btn {
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
}

.warmup-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 20, 28, 0.45);
  display: grid;
  place-items: center;
  z-index: 2100;
  padding: 1rem;
}

.warmup-modal-backdrop[hidden] {
  display: none !important;
}

.warmup-modal-panel {
  width: min(520px, 94vw);
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--theme-surface, #fff);
  box-shadow: 0 22px 45px rgba(0, 0, 0, 0.2);
  padding: 0.9rem;
}

.warmup-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.warmup-modal-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.warmup-settings-grid {
  display: grid;
  gap: 0.75rem;
}

.warmup-countdown {
  margin: 0.45rem 0 0.1rem;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  color: #0f8a6f;
}

.warmup-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}

.warmup-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3rem;
  border-radius: 999px;
  border: 1px solid #d8cebe;
  background: var(--theme-surface, #fff);
  padding: 0.28rem 0.55rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  cursor: pointer;
}

.warmup-chip.ghost {
  background: var(--theme-soft, #f7f4ee);
  color: var(--theme-muted, #6d655b);
}

.warmup-chip:disabled {
  cursor: not-allowed;
  opacity: 0.75;
}

.warmup-chip.ok {
  background: var(--theme-success-bg, #e4f9ea);
  border-color: #9cd5ae;
  color: var(--theme-success, #17663c);
}

.warmup-chip.target-active {
  background: #d7ecff;
  border-color: #86b8e6;
  color: #124f82;
}

.warmup-chip.bad {
  background: var(--theme-error-bg, #ffe5e5);
  border-color: #f0abab;
  color: var(--theme-error, #8e2020);
}

.warmup-results {
  margin-top: 0.8rem;
  padding: 0.8rem;
}

.warmup-results h3,
.warmup-results p {
  margin: 0;
}

.warmup-results p {
  margin-top: 0.4rem;
  color: var(--theme-muted, #5d554b);
  font-family: "IBM Plex Mono", monospace;
}

.warmup-score-history {
  margin-top: 0.5rem;
}

.warmup-score-line {
  margin: 0.25rem 0 0;
  color: var(--theme-muted, #5d554b);
  font-family: "IBM Plex Mono", monospace;
}

.warmup-score-total {
  margin-top: 0.45rem;
  font-weight: 700;
  color: var(--theme-success, #17663c);
}

.metronome-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.metronome-bpm-readout {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.78rem;
  background: var(--theme-soft, #fdfcf8);
  font-family: "IBM Plex Mono", monospace;
  color: var(--theme-muted, #5f574e);
  font-size: 0.9rem;
  white-space: nowrap;
}

.metronome-case {
  margin: 0.3rem auto 1rem;
  width: min(420px, 92%);
  border-radius: 18px 18px 24px 24px;
  border: 1px solid #cabda8;
  background: linear-gradient(180deg, #eee5d7 0%, #dbc9b0 100%);
  padding: 1rem 1rem 1.25rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.metronome-window {
  position: relative;
  height: 250px;
  border-radius: 14px;
  border: 1px solid #bbab94;
  background: linear-gradient(180deg, #f8f2e8 0%, #f1e6d7 100%);
  overflow: hidden;
}

.metronome-needle {
  position: absolute;
  bottom: 27px;
  left: 50%;
  width: 4px;
  height: 178px;
  border-radius: 4px;
  background: #15100a;
  transform-origin: bottom center;
  transform: translateX(-50%) rotate(0deg);
  transition: transform 80ms linear;
}

.metronome-pivot {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #9d896e;
  background: #dfd0bb;
  transform: translateX(-50%);
}

.metronome-scale-left,
.metronome-scale-right {
  position: absolute;
  bottom: 40px;
  width: 80px;
  height: 2px;
  background: #99876f;
  opacity: 0.7;
}

.metronome-scale-left {
  left: 18%;
  transform: rotate(-26deg);
}

.metronome-scale-right {
  right: 18%;
  transform: rotate(26deg);
}

.metronome-controls {
  max-width: 560px;
  margin: 0 auto;
}

.metronome-controls input[type="range"] {
  width: 100%;
}

.simon-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.45rem;
}

.simon-top-controls {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.simon-top-controls button {
  margin: 0;
}

.simon-bottom-card {
  padding: 0.85rem;
}

.simon-bottom-grid {
  display: grid;
  grid-template-columns: minmax(240px, 380px) 1fr;
  gap: 1rem;
}

.simon-bottom-pane {
  min-width: 0;
}

.simon-bottom-pane + .simon-bottom-pane {
  border-left: 1px solid var(--border);
  padding-left: 1rem;
}

.simon-score-card {
  margin: 0;
}

.simon-score-card h3 {
  margin-bottom: 0.5rem;
}

.simon-score-card #simonSummary {
  margin: 0;
  line-height: 1.35;
  font-size: 0.98rem;
}

.warmup-modal-panel .tuner-label {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: #766a5b;
}

.warmup-modal-panel .field-control {
  font-size: 0.92rem;
  color: #4f463c;
}

.setting-disabled {
  opacity: 0.42;
}

.music-match-miss-overlay {
  position: fixed;
  inset: 0;
  z-index: 2700;
  display: grid;
  place-items: center;
  background: rgba(24, 8, 8, 0.28);
}

.music-match-miss-overlay[hidden] {
  display: none !important;
}

.music-match-miss-x {
  font-family: "IBM Plex Mono", monospace;
  font-size: clamp(5.5rem, 22vw, 12rem);
  font-weight: 700;
  color: #ca3e36;
  text-shadow: 0 0 0.5rem rgba(255, 255, 255, 0.28), 0 0 1.4rem rgba(202, 62, 54, 0.45);
  animation: musicMatchMissIn 980ms cubic-bezier(0.18, 0.78, 0.18, 1) forwards;
  will-change: transform, opacity;
}

.simon-response-cue {
  margin-top: 0.25rem;
}

.simon-response-track {
  position: relative;
  height: 14px;
  border-radius: 999px;
  border: 1px solid #d9ccb8;
  background: linear-gradient(90deg, #f5eee4 0%, #e3f2e8 50%, #f5eee4 100%);
  overflow: hidden;
}

.simon-response-needle {
  position: absolute;
  top: -3px;
  left: 0;
  width: 6px;
  height: 20px;
  border-radius: 5px;
  background: #0f8a6f;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
  transform: translateX(-50%);
}

.simon-expected-note {
  margin: 0.35rem 0 0;
  color: var(--theme-muted, #5f574e);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
}

.simon-count-overlay {
  position: fixed;
  inset: 0;
  z-index: 2600;
  background: rgba(10, 12, 16, 0.55);
  display: grid;
  place-items: center;
}

.simon-count-overlay[hidden] {
  display: none !important;
}

.simon-count-value {
  min-width: 140px;
  text-align: center;
  border-radius: 20px;
  border: 1px solid #d9ccb8;
  background: #fffaf1;
  color: #1f1710;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  font-size: clamp(2rem, 11vw, 3.2rem);
  padding: 1rem 1.2rem;
  box-shadow: 0 20px 42px rgba(0, 0, 0, 0.28);
}

.simon-device-panel h3 {
  margin-bottom: 0.9rem;
}

.simon-pad {
  position: relative;
  width: min(84vw, 620px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: 50%;
  border: 2px solid #cdbca4;
  background: radial-gradient(circle at 50% 50%, #f7eddc 0%, #ead9c4 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.72);
  overflow: hidden;
}

@media (min-width: 900px) {
  .simon-pad {
    width: min(74vw, 700px);
  }
}

.simon-pad::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(
    from -90deg,
    rgba(125, 102, 76, 0.55) 0deg 1deg,
    transparent 1deg 45deg
  );
  pointer-events: none;
  z-index: 2;
}

.simon-pad-btn {
  position: absolute;
  inset: 0;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: default;
  color: #2f2519;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  transition: color 120ms ease;
  -webkit-tap-highlight-color: transparent;
  z-index: 1;
}

.simon-pad-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #f8efe3;
  transition: background-color 120ms ease, filter 120ms ease;
}

.simon-pad-btn:hover,
.simon-pad-btn:focus,
.simon-pad-btn:focus-visible,
.simon-pad-btn:active {
  background: transparent;
  border: 0;
  box-shadow: none;
  outline: none;
  transform: none;
}

.simon-pad-btn.flash {
  color: #062e54;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}

.simon-pad-btn.flash::before {
  background: #88ccff !important;
  filter: saturate(1.28) brightness(1.1);
  box-shadow: inset 0 0 0 2px rgba(22, 93, 156, 0.55), inset 0 0 22px rgba(255, 255, 255, 0.38);
}

.simon-pad-label {
  position: absolute;
  left: var(--lx);
  top: var(--ly);
  transform: translate(-50%, -50%);
  font-size: 0.94rem;
  pointer-events: none;
  z-index: 4;
}

.simon-pad-btn.d0::before { background: #efddd0; clip-path: polygon(50% 50%, 50% 2%, 84% 16%); }
.simon-pad-btn.d1::before { background: #eae5cb; clip-path: polygon(50% 50%, 84% 16%, 98% 50%); }
.simon-pad-btn.d2::before { background: #dceacc; clip-path: polygon(50% 50%, 98% 50%, 84% 84%); }
.simon-pad-btn.d3::before { background: #d4e8dd; clip-path: polygon(50% 50%, 84% 84%, 50% 98%); }
.simon-pad-btn.d4::before { background: #d2e2ec; clip-path: polygon(50% 50%, 50% 98%, 16% 84%); }
.simon-pad-btn.d5::before { background: #dcdcf0; clip-path: polygon(50% 50%, 16% 84%, 2% 50%); }
.simon-pad-btn.d6::before { background: #e6d8ec; clip-path: polygon(50% 50%, 2% 50%, 16% 16%); }
.simon-pad-btn.d7::before { background: #edd6e0; clip-path: polygon(50% 50%, 16% 16%, 50% 2%); }

.simon-pad-btn.d0 { --lx: 62%; --ly: 18%; }
.simon-pad-btn.d1 { --lx: 81%; --ly: 35%; }
.simon-pad-btn.d2 { --lx: 81%; --ly: 64%; }
.simon-pad-btn.d3 { --lx: 62%; --ly: 82%; }
.simon-pad-btn.d4 { --lx: 38%; --ly: 82%; }
.simon-pad-btn.d5 { --lx: 19%; --ly: 64%; }
.simon-pad-btn.d6 { --lx: 19%; --ly: 35%; }
.simon-pad-btn.d7 { --lx: 38%; --ly: 18%; }

.simon-pad::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid #cdbca4;
  background: radial-gradient(circle at 50% 40%, #fff8ea 0%, #efe1ce 100%);
  z-index: 3;
}

#status.error {
  color: #b7322c;
}

#status.success {
  color: var(--theme-success, #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;
  }

  .tuner-main-grid {
    grid-template-columns: 1fr;
  }

  .tuner-string-grid {
    grid-template-columns: 1fr;
  }

  .warmup-top {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

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

  .simon-bottom-grid {
    grid-template-columns: 1fr;
  }

  .simon-bottom-pane + .simon-bottom-pane {
    border-left: 0;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 0.9rem;
  }

  .warmup-strip {
    display: grid;
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 0.32rem;
  }

  .warmup-chip {
    min-width: 0;
    width: 100%;
    padding: 0.22rem 0.18rem;
    font-size: 0.72rem;
  }

  .metronome-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .metronome-window {
    height: 220px;
  }

  .metronome-needle {
    height: 156px;
  }

  .module-utility-strip {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .brand-row {
    flex-direction: column;
    gap: 0.25rem;
  }

  .hero-logo {
    width: min(340px, 86vw);
    margin-top: -0.2rem;
  }

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

  .compare-input {
    min-height: 4.2rem;
    height: auto;
  }

  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;
  }
}

@keyframes musicMatchMissIn {
  0% {
    opacity: 0;
    transform: scale(0.55) rotate(-14deg);
  }
  22% {
    opacity: 1;
    transform: scale(1.28) rotate(2deg);
  }
  58% {
    opacity: 1;
    transform: scale(2.4) rotate(-1deg);
  }
  100% {
    opacity: 0;
    transform: scale(4.4) rotate(0deg);
  }
}
