@import url("https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&family=Fraunces:opsz,wght@9..144,600;9..144,700&display=swap");

:root {
  --ink: #1b1d21;
  --ink-soft: #61666d;
  --canvas: #efece4;
  --paper: #fffefa;
  --line: #d8d3c8;
  --accent: #c63a19;
  --accent-dark: #963116;
  --charcoal: #282a2e;
  --shadow: 0 20px 50px rgba(33, 29, 22, 0.12);
}

.export-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.export-controls select {
  max-width: 260px;
  border: 1px solid #b9b1a3;
  border-radius: 7px;
  padding: 8px 29px 8px 10px;
  color: var(--ink);
  background: #fffefa;
  font-size: 0.78rem;
  font-weight: 600;
}

.import-status {
  min-height: 1.3em;
  margin: 9px 0 0;
  color: #4d5158;
  font-size: 0.77rem;
  line-height: 1.45;
}

.import-status.is-error {
  color: #a5291b;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.38), transparent 42%),
    var(--canvas);
  font-family: "DM Sans", system-ui, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 2fr auto;
  align-items: center;
  gap: 24px;
  min-height: 74px;
  padding: 14px clamp(20px, 5vw, 72px) 14px clamp(22px, 3vw, 48px);
  color: #f8f4e9;
  background: var(--charcoal);
}

.wordmark {
  color: inherit;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.42rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.app-header p {
  margin: 0;
  color: #d1d0cc;
  font-size: 0.9rem;
}

.header-actions,
.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
}

.import-button {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.import-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.button {
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 10px 13px;
  color: var(--ink);
  background: #e9e6de;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.button:focus-visible,
.icon-button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(198, 58, 25, 0.42);
  outline-offset: 2px;
}

.button-primary {
  color: white;
  background: var(--accent);
}

.button-primary:hover {
  background: var(--accent-dark);
}

.button-quiet {
  color: inherit;
  border-color: currentColor;
  background: transparent;
}

.app-header .button-quiet {
  color: #f8f4e9;
  border-color: #74767b;
}

.button-small {
  padding: 8px 10px;
  color: var(--accent-dark);
  border-color: #d8a290;
  background: #fffbf5;
  font-size: 0.75rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 410px) minmax(0, 1fr);
  min-height: calc(100vh - 74px);
}

.editor-panel {
  padding: 36px clamp(22px, 3vw, 48px) 50px;
  border-right: 1px solid var(--line);
  background: #f8f6f0;
}

.panel-heading {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  letter-spacing: -0.035em;
}

h1 {
  font-size: 2.1rem;
}

h2 {
  font-size: 1.25rem;
}

.muted,
.optional {
  color: var(--ink-soft);
}

.muted {
  margin: 7px 0 0;
  font-size: 0.9rem;
}

.optional {
  font-size: 0.73rem;
  font-weight: 400;
}

.metadata-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

label {
  display: grid;
  gap: 6px;
  color: #34383f;
  font-size: 0.77rem;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid #cfc9bd;
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fffefa;
  font-size: 0.94rem;
  font-weight: 500;
}

textarea {
  resize: vertical;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
}

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

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 37px 0 15px;
}

.sections {
  display: grid;
  gap: 15px;
}

.section-editor {
  padding: 15px;
  border: 1px solid #d6d0c4;
  border-radius: 8px;
  background: #efede6;
}

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

.section-label-field {
  width: min(175px, 65%);
}

.section-controls {
  display: flex;
  gap: 5px;
}

.icon-button {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border: 1px solid #cdc6b9;
  border-radius: 5px;
  padding: 0;
  color: #4e5054;
  background: #fffefa;
  font-size: 1rem;
  font-weight: 700;
  transition: transform 150ms ease, background 150ms ease;
}

.delete-section:hover {
  color: white;
  border-color: #af2419;
  background: #af2419;
}

.syntax-help {
  margin-top: 32px;
  padding: 18px;
  border-left: 3px solid var(--accent);
  background: #ebe5d9;
}

.syntax-help h2 {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.84rem;
  letter-spacing: 0;
}

.syntax-help ul {
  margin: 10px 0 0;
  padding-left: 17px;
  color: #4d5158;
  font-size: 0.77rem;
  line-height: 1.55;
}

code {
  padding: 1px 3px;
  border-radius: 3px;
  color: #802814;
  background: rgba(198, 58, 25, 0.09);
  font-family: "DM Mono", monospace;
}

.preview-area {
  min-width: 0;
  padding: 28px clamp(20px, 5vw, 76px) 60px;
  background: #e8e3d9;
}

.preview-toolbar {
  justify-content: space-between;
  max-width: 900px;
  margin: 0 auto 13px;
}

.preview-toolbar .eyebrow {
  margin: 0;
}

.chart-page {
  width: min(100%, 900px);
  min-height: 1050px;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 58px);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.chart-header {
  padding-bottom: 12px;
  border-bottom: 2px solid var(--charcoal);
}

.chart-title-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
}

.chart-title {
  max-width: 76%;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(1.65rem, 4vw, 2.7rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.05;
  text-transform: uppercase;
}

.chart-composer {
  color: #4d5158;
  font-family: Georgia, serif;
  font-size: 1rem;
  font-style: italic;
  text-align: right;
}

.chart-metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 20px;
  margin-top: 14px;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.03em;
}
.chart-notes {
  margin-top: 21px;
  padding: 13px 16px;
  border-left: 3px solid var(--accent);
  color: #383c42;
  background: #f4f0e8;
  break-inside: avoid;
}

.chart-notes h2 {
  margin: 0 0 7px;
  color: var(--accent-dark);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.chart-notes p,
.chart-notes ul {
  margin: 0 0 8px;
  font-size: 0.88rem;
  line-height: 1.45;
}

.chart-notes p:last-child,
.chart-notes ul:last-child {
  margin-bottom: 0;
}

.chart-notes ul {
  padding-left: 19px;
}

.chart-notes h3,
.chart-notes h4,
.chart-notes h5 {
  margin: 12px 0 5px;
  font-family: Fraunces, Georgia, serif;
}

.chart-notes a {
  color: var(--accent-dark);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.chart-notes code {
  font-size: 0.84em;
}

.chart-sections {
  display: grid;
  gap: 27px;
  margin-top: 29px;
}

.chart-section {
  break-inside: avoid;
}

.chart-section-title {
  display: inline-block;
  margin: 0 0 8px;
  padding: 5px 11px 6px;
  color: var(--paper);
  background: var(--charcoal);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chord-grid {
  width: 100%;
  border-spacing: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

.chord-grid td {
  height: 62px;
  border: 2px solid var(--charcoal);
  padding: 6px;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: clamp(0.88rem, 2vw, 1.3rem);
  font-weight: 500;
  text-align: center;
  vertical-align: middle;
  white-space: pre-wrap;
}

.chord-grid td.empty-measure {
  border-color: transparent;
}

.chord-grid td.repeat-ending {
  width: 38px;
  border: 0;
  padding: 0 0 0 7px;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.16em;
}

.empty-state {
  display: grid;
  min-height: 800px;
  place-items: center;
  color: #686b70;
  font-family: Georgia, serif;
  font-style: italic;
  text-align: center;
}

@media (max-width: 860px) {
  .app-header {
    grid-template-columns: 1fr auto;
  }

  .app-header > p {
    display: none;
  }

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

  .editor-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 520px) {
  .app-header {
    grid-template-columns: 1fr;
    gap: 11px;
  }

  .header-actions {
    justify-content: space-between;
  }

  .header-actions .button {
    flex: 1;
  }

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

  .full-width {
    grid-column: auto;
  }

  .preview-area {
    padding: 19px 10px 30px;
  }

  .chart-page {
    min-height: 0;
    padding: 25px 17px;
  }

  .chart-title-line {
    align-items: start;
    flex-direction: column;
    gap: 8px;
  }

  .chart-title {
    max-width: none;
  }

  .chart-composer {
    text-align: left;
  }

  .chord-grid td {
    height: 52px;
    padding: 3px;
  }
}

@page {
  size: letter portrait;
  margin: 0.45in;
}

@media print {
  .no-print {
    display: none !important;
  }

  body,
  .preview-area {
    background: white;
  }

  .workspace {
    display: block;
    min-height: 0;
  }

  .chart-page {
    width: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }

  .chart-title {
    font-size: 25pt;
  }

  .chart-composer {
    font-size: 10pt;
  }

  .chart-metadata {
    font-size: 8.5pt;
  }

  .chart-sections {
    gap: 19px;
    margin-top: 20px;
  }

  .chart-notes {
    margin-top: 14px;
    padding: 9px 12px;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .chart-section-title {
    font-size: 9pt;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .chord-grid td {
    height: 43px;
    padding: 3px;
    font-size: 15pt;
  }

  .chord-grid td.repeat-ending {
    font-size: 16pt;
  }
}
