:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-strong: #eef2ed;
  --ink: #17201b;
  --muted: #65726b;
  --line: #d9dfd8;
  --accent: #23615b;
  --accent-strong: #174641;
  --accent-soft: #dfecea;
  --warn: #8a5b16;
  --shadow: 0 18px 50px rgba(31, 45, 38, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 76px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
}

.topbar h1,
.dialog-heading h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  font-weight: 720;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.topbar-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-status {
  min-width: 110px;
  text-align: right;
  color: var(--muted);
  font-size: 13px;
}

.primary-button,
.ghost-button {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 14px;
  border: 1px solid transparent;
  font-weight: 700;
}

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

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--accent-strong);
}

.ghost-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.ghost-button:hover,
.ghost-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(248px, 300px) minmax(0, 1fr) minmax(220px, 280px);
  gap: 0;
}

.control-panel,
.variant-panel {
  min-height: 0;
  overflow: auto;
  padding: 18px;
  background: var(--surface);
}

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

.variant-panel {
  border-left: 1px solid var(--line);
}

.field-label,
.section-heading {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.text-input,
.upload-form input,
.upload-form select,
.upload-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

.text-input {
  height: 42px;
  margin-top: 8px;
  padding: 0 12px;
}

.text-input:focus,
.upload-form input:focus,
.upload-form select:focus,
.upload-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.panel-section {
  margin-top: 22px;
}

.category-list,
.song-list,
.variant-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.category-button,
.song-button,
.variant-button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.category-button {
  min-height: 36px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.song-button {
  min-height: 74px;
  padding: 10px;
}

.variant-button {
  min-height: 58px;
  padding: 10px;
}

.category-button:hover,
.song-button:hover,
.variant-button:hover,
.category-button.active,
.song-button.active,
.variant-button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.song-title,
.variant-title {
  display: block;
  font-weight: 750;
  line-height: 1.25;
}

.song-subtitle,
.variant-detail,
.meta-line {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.count-badge {
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.transpose-control {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  gap: 8px;
  align-items: center;
}

.transpose-control button {
  height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}

.transpose-control output {
  height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  background: var(--surface-strong);
  font-weight: 800;
}

.range-input {
  width: 100%;
  margin-top: 12px;
  accent-color: var(--accent);
}

.score-stage {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 18px 22px;
}

.song-header {
  min-height: 82px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.song-header h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.18;
  letter-spacing: 0;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chart-preview {
  min-height: calc(100vh - 198px);
  display: grid;
  place-items: stretch;
}

.preview-frame {
  width: 100%;
  min-height: calc(100vh - 220px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.preview-image {
  width: 100%;
  max-height: calc(100vh - 220px);
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.text-chart {
  margin: 0;
  min-height: calc(100vh - 220px);
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: #fffef8;
  box-shadow: var(--shadow);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 16px;
  line-height: 1.7;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  min-height: 240px;
  display: grid;
  place-items: center;
  padding: 28px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.55);
}

.chart-meta {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.upload-dialog {
  width: min(780px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.upload-dialog::backdrop {
  background: rgba(22, 31, 27, 0.38);
}

.upload-form {
  padding: 22px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

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

.form-grid label {
  display: grid;
  gap: 7px;
}

.form-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.wide-field {
  grid-column: 1 / -1;
}

.upload-form input,
.upload-form select {
  height: 40px;
  padding: 0 10px;
}

.upload-form textarea {
  resize: vertical;
  min-height: 120px;
  padding: 10px;
}

.form-message {
  min-height: 22px;
  margin: 14px 0;
  color: var(--warn);
  font-size: 13px;
}

@media (max-width: 1040px) {
  .workspace {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .variant-panel {
    grid-column: 1 / -1;
    border-left: none;
    border-top: 1px solid var(--line);
  }

  .variant-list {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .workspace {
    display: block;
  }

  .control-panel,
  .variant-panel {
    border-right: none;
    border-left: none;
    border-bottom: 1px solid var(--line);
  }

  .song-header {
    display: block;
  }

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

