:root {
  --primary-color: #2f6f9e;
  --secondary-bg: #f3f2ef;
  --text-color: #2e2e2e;
  --page-bg: #ffffff;
  --border: #d8d5d0;
  --sidebar-width: 21rem;
  --warning-bg: #fff4e5;
  --warning-text: #8a5a00;
  --success-text: #1b6b3a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Source Sans Pro", "Segoe UI", sans-serif;
  color: var(--text-color);
  background: var(--page-bg);
}

body {
  accent-color: var(--primary-color);
}

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

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--secondary-bg);
  padding: 0.75rem 1rem 1.5rem;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.sidebar-heading {
  margin: 0.25rem 0 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.section-label {
  margin: 0 0 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
}

.control-label {
  display: block;
  margin: 0.5rem 0 0.25rem;
  font-size: 0.85rem;
  color: #555;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

select,
textarea,
input[type="text"] {
  width: 100%;
  font: inherit;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  background: #fff;
  padding: 0.45rem 0.55rem;
}

select:focus,
textarea:focus,
input[type="text"]:focus,
input[type="range"]:focus {
  outline: 2px solid rgba(47, 111, 158, 0.35);
  outline-offset: 1px;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

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

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-color);
  border-radius: 0.35rem;
  padding: 0.45rem 0.6rem;
  font: inherit;
  cursor: pointer;
}

.btn:hover {
  border-color: #b9b5ae;
  background: #fafafa;
}

.btn-primary {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  background: #275d86;
  border-color: #275d86;
  color: #fff;
}

.btn-block {
  width: 100%;
  margin-top: 0.35rem;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

input[type="range"] {
  flex: 1;
  width: 100%;
}

.slider-value {
  min-width: 1.75rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.55rem 0;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  width: 1.05rem;
  height: 1.05rem;
}

.caption {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: #666;
  line-height: 1.35;
}

.overwrite-prompt {
  margin-top: 0.75rem;
}

.overwrite-prompt.hidden,
.toast.hidden,
.about-popover.hidden,
.sections-panel.hidden,
.fullscreen-bar.hidden,
.sidebar.hidden {
  display: none;
}

.warning {
  margin: 0;
  padding: 0.55rem 0.65rem;
  background: var(--warning-bg);
  color: var(--warning-text);
  border-radius: 0.35rem;
  font-size: 0.85rem;
}

.toast {
  margin: 0.65rem 0 0;
  color: var(--success-text);
  font-size: 0.85rem;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 2.25rem 1.5rem 2rem;
}

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.title-row h1 {
  margin: 0;
  padding: 0;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}

.about-wrap {
  position: relative;
}

.btn-about {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 0.35rem;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.about-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  width: min(26rem, 80vw);
  max-height: 70vh;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 1rem 1.1rem;
  z-index: 20;
  font-size: 0.92rem;
  line-height: 1.45;
}

.about-popover p {
  margin: 0 0 0.75rem;
}

.about-popover ul {
  margin: 0 0 0.75rem;
  padding-left: 1.2rem;
}

.about-popover li {
  margin-bottom: 0.35rem;
}

#input-text {
  min-height: 200px;
  resize: vertical;
  margin-bottom: 0.65rem;
}

.song-name-input {
  margin-top: 1rem;
}

.sections-panel {
  margin-top: 0.85rem;
  border: none;
}

.sections-panel summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.section-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.4rem;
}

.section-row span {
  font-size: 0.92rem;
}

.song-output {
  margin-top: 1.25rem;
}

.fullscreen-bar {
  margin-bottom: 0.5rem;
}

body.is-fullscreen .sidebar {
  display: none;
}

body.is-fullscreen .main {
  padding: 0.5rem 1rem;
}

body.is-fullscreen #editor-panel {
  display: none;
}

body.is-fullscreen .song-output {
  margin-top: 0;
}

@media (max-width: 860px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .main {
    padding: 1.25rem 1rem 2rem;
  }

  .title-row h1 {
    font-size: 1.55rem;
  }
}
