/* The shared visual language for every non-admin surface. */
:root {
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
}

html, body {
  min-height: 100%;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font-ui);
}

body { line-height: 1.5; }

::selection { color: var(--ink); background: color-mix(in srgb, var(--accent) 30%, var(--surface)); }

/* Static Rails exception documents load this sheet after their generated defaults. */
#error-description { fill: var(--danger); }
#error-id { fill: var(--hairline); }

/* Text links use the teal link/chord role; chrome and button selectors set their own ink. */
a { color: var(--accent); }

:where(button, a, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--focus-outline);
}

::placeholder { color: var(--muted); opacity: 1; }

:where(button, input, select, textarea):disabled,
[aria-disabled="true"] {
  color: var(--disabled-ink);
  background: var(--disabled-surface);
  opacity: 1;
}

input:-webkit-autofill,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  box-shadow: 0 0 0 1000px var(--surface) inset;
}

.public-header,
.chart-stage__chrome,
.chart-stage__header,
.performance-page,
.library-entry-dialog,
.performance-controls,
.member-nav__profile-menu,
.member-page-actions__menu,
.chart-stage__options-panel,
.list-selection-menu__panel,
.performance-control__overlay,
.song-links-control__panel,
.share-sheet__card,
.import-review__dropzone,
.import-review__item,
.library-sidebar,
.chart-list,
.group-card,
.setlist-card,
.collection-card,
.group-panel,
.setlist-panel,
.share-management-panel,
.share-management-note,
.quick-add__processing,
.quick-add__candidates,
.library__add-songs,
.dashboard-stat,
.public-hero__preview {
  border-color: var(--hairline);
  color: var(--ink);
  background: var(--surface);
  box-shadow: none;
}

.member-nav,
.public-footer,
.share-interface,
.share-interface__brand,
.share-sheet--stage,
.share-sheet--stage .share-sheet__card,
.set-follow {
  border-color: var(--hairline);
  color: var(--ink);
  background: var(--surface);
}

.public-header__brand,
.member-nav__brand,
.share-interface__brand {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.public-header__nav a,
.member-nav__links > a,
.member-nav__profile summary,
.member-nav__sign-out,
.member-nav__profile-menu a,
.public-footer,
.public-footer a,
.share-interface__brand span { color: var(--ink); }

.member-nav__links > a:hover,
.member-nav__profile summary:hover,
.member-nav__sign-out:hover,
.member-nav__profile-menu a:hover { color: var(--ink); background: var(--tint); }

/* Quick add is navigation, not the page's primary action: a quiet outline button (mustard is for the page's one primary action). */
.member-nav__quick-add,
.member-nav__quick-add:hover { border: 1px solid var(--hairline); border-radius: var(--radius-control); color: var(--ink) !important; background: transparent; }
.member-nav__quick-add:hover { background: var(--tint); }

/* Portrait tablets keep the only sticky header to one row: brand, Add, account menu. */
@media (min-width: 48rem) and (max-width: 64rem) {
  .member-nav__rail { min-width: 0; gap: 0.5rem; padding-inline: 0.75rem; }
  .member-nav__brand { min-width: 0; }
  .member-nav__links { min-width: 0; gap: 0.5rem; }
  .member-nav__collections { display: none; }
  .member-nav__quick-add { flex: 0 0 auto; }
  .member-nav__profile summary { max-width: 9rem; }
}

/* The wordmark and text-link widths depend on the loaded UI font, so collapse them
   before tablet portrait widths rather than risking a clipped single-row header. */
@media (max-width: 56rem) {
  .member-nav__links > a:not(.member-nav__quick-add) { display: none !important; }
  .member-nav__profile-menu .member-nav__mobile-link { display: block !important; }
}

.preview-notice {
  min-height: 0;
  border-color: var(--hairline);
  color: var(--ink);
  background: var(--tint);
}
.preview-notice__rail { min-height: 2.75rem; padding: var(--space-2) 0; }
.preview-notice__dismiss { border-color: var(--ink); border-radius: var(--radius-control); }

.eyebrow,
.public-hero__summary,
.public-page > p:not(.eyebrow),
.library__count,
.chart-card__artist,
.chart-card__meta,
.group-card__identity span,
.group-card__meta,
.setlist-card__identity span,
.setlist-card__meta,
.collection-card__identity span,
.collection-card__meta,
.dashboard-recent-item small,
.dashboard-recent-item time,
.field-hint,
.song-links__title,
.share-sheet__receiver,
.share-sheet__status,
.share-sheet__manage,
.import-review__item p,
.library-empty-import__heading p,
.song-import-form__hint,
.set-join-preferences label,
.shared-save-invitation,
.shared-set .shared-save-invitation { color: var(--muted); }

.eyebrow { color: var(--muted); }

.button,
.confirmation-dialog__button {
  min-height: 44px;
  border-color: var(--ink);
  border-radius: var(--radius-control);
  box-shadow: none;
}
.button.button--primary { border-color: var(--selected-line); color: var(--selected-ink); background: var(--selected-fill); }
.button.button--secondary,
.confirmation-dialog__button--cancel { color: var(--ink); background: var(--surface); }
.button.button--danger { border-color: var(--danger); color: var(--danger); background: var(--surface); }
.confirmation-dialog__button--confirm { border-color: var(--danger); color: var(--on-danger); background: var(--danger); }
.button:hover { background: var(--tint); }
.button.button--primary:hover { border-color: var(--selected-line); background: var(--selected-fill); }
/* Public and shared calls to action use the same teal outline and pastel fill as other primary actions.
   One solid mustard button per screen: Quick add in personal Songs controls, Print on the Print page, Get started in the public header. */
/* The public header and the sheet bar are always charcoal, so their teal outline uses the dark (fixed) teal pair. */
:is(.public-header, .sheet-bar) .button.button--primary,
:is(.public-header, .sheet-bar) .button.button--primary:hover {
  border-color: var(--stage-fixed-selected-line);
  color: var(--stage-fixed-selected-ink);
  background: var(--stage-fixed-selected-fill);
}
/* Get started: the public header's one solid mustard button (public pages have no Quick add), dark text like Quick add. */
.public-header__nav a.button.button--primary[href$="/sign_up"],
.public-header__nav a.button.button--primary[href$="/sign_up"]:hover {
  border-color: var(--on-primary);
  color: var(--on-primary);
  background: var(--primary);
}
/* Stage on the set pages (member and shared): an outline with a pastel teal fill, never the one solid mustard button. */
.button.button--stage,
.button.button--stage:hover { border-color: var(--selected-line); color: var(--selected-ink); background: var(--selected-fill); }

.flash { margin: 0 0 var(--space-4); border: 1px solid var(--hairline); border-radius: var(--radius-control); }
.flash--notice { color: var(--ink); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.flash--alert { border-color: var(--danger); color: var(--danger); background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }

:where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  min-height: 44px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-control);
  color: var(--ink);
  background: var(--surface);
  font: inherit;
}
:where(input:not([type="checkbox"]):not([type="radio"]), select, textarea):hover { border-color: var(--accent); }
:where(input[type="checkbox"], input[type="radio"]) { accent-color: var(--accent); }

.auth-page,
.settings-page,
.groups-page,
.setlists-page,
.collections-page,
.editor-page,
.quick-add,
.import-review { gap: var(--space-6); }

.auth-card,
.settings-card,
.dashboard-panel,
.public-feature-grid article,
.empty-state,
.editor-danger-zone,
.list-selection-rail { border-color: var(--hairline); border-radius: var(--radius-card); color: var(--ink); background: var(--surface); box-shadow: none; }
.empty-state { border-style: dashed; color: var(--muted); }
.editor-danger-zone { border-color: var(--danger); }
.editor-danger-zone__content { border-color: var(--hairline); }
.editor-danger-zone__content p { color: var(--muted); }

.member-page-heading h1,
.editor-page__header h1,
.library-sidebar h1,
.chart-stage__identity h1,
.public-hero h1,
.public-features h2,
.public-page h1,
.auth-card h1 { font-family: var(--font-display); font-variation-settings: "opsz" 72; }

.group-card:hover,
.setlist-card:hover,
.collection-card:hover,
.chart-selection-row:hover,
.chart-selection-row.is-selected,
.dashboard-stat:hover { border-color: var(--accent); color: var(--ink); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); box-shadow: none; transform: none; }

.chart-selection-row,
.dashboard-recent-item,
.group-roster li,
.share-link-list li { border-color: var(--hairline); }
.library-filters .kor-search-filter-pill-link { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.library-filters .kor-search-filter-pill-link:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }

.chart-key-chip,
.chart-navigation__indicator,
.chart-navigation__tab-toggle,
.chart-section-jump,
.chart-stage__back,
.chart-stage__options > summary,
.list-selection-menu summary,
.performance-control__trigger,
.performance-option,
.performance-stepper__button,
.key-option,
.member-page-actions summary {
  border-color: var(--hairline);
  color: var(--ink);
  background: var(--surface);
}
.chart-key-chip:hover,
.chart-navigation__tab-toggle:hover,
.chart-section-jump:hover,
.chart-stage__back:hover,
.performance-control__trigger:hover,
.performance-control__trigger[aria-expanded="true"],
.key-option:hover { border-color: var(--selected-line); color: var(--ink); background: var(--row-hover); }
.chart-key-chip--selected,
.chart-section-jump--current,
.performance-option[aria-pressed="true"],
.key-option--selected { border-color: var(--selected-line); color: var(--selected-ink); background: var(--selected-fill); }
.chart-stage__identity p,
.key-option__shift,
.performance-controls__status { color: var(--muted); }
.performance-controls__status { border-color: var(--hairline); background: var(--surface); box-shadow: var(--shadow-floating); }

.performance-controls,
.performance-control:not(:last-child),
.performance-control__overlay,
.key-option { border-color: var(--hairline); }
.performance-page .chart-sheet { color: var(--ink); background: var(--surface); }
.library-entry-dialog::backdrop,
.share-sheet::backdrop,
.confirmation-dialog::backdrop { background: color-mix(in srgb, var(--ink) 65%, transparent); }

.song-import-form textarea,
.chart-editor__field input,
.chart-editor__field textarea,
.share-link-copy__controls input,
.share-sheet__url-label input,
.set-join-preferences select,
.song-links-control__form input { border-color: var(--hairline); color: var(--ink); background: var(--surface); }
.chart-editor__source,
.song-import-form textarea,
.chart-line--tab { font-family: var(--font-editor) !important; }
.song-import-form__drop-zone { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.song-import-form__drop-zone--active { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.import-review__dropzone { border-color: var(--accent); }
.import-review__item--problem { border-color: var(--danger); }
.import-review__item pre { color: var(--ink); font-family: var(--font-editor); }
.import-review__warning { color: var(--ink) !important; font-weight: 700; }

.share-sheet { color: var(--ink); }
.stage-share-trigger { border-color: var(--hairline); border-radius: var(--radius-control); color: var(--ink); background: var(--surface); }
.share-sheet--stage .share-sheet__url-label input { color: var(--ink); }
.set-follow__button[aria-pressed="true"] { border-color: var(--selected-line); color: var(--selected-ink); background: var(--selected-fill); }
.set-follow__status { color: var(--muted); }

table { width: 100%; border-collapse: collapse; color: var(--ink); background: var(--surface); }
th, td { padding: var(--space-3); border-bottom: 1px solid var(--hairline); text-align: left; }
th { color: var(--muted); font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }

@media (max-width: 42rem) {
  /* One row on a phone: the mark, then Sign in and Get started. (The rail used to stack, which pushed Get started onto a row of
     its own and the stripe below it, and the only way to sign in was hidden.) The other links live in the footer. */
  .public-header__rail { width: min(100% - 1.5rem, 76rem); min-height: 4rem; align-items: center; flex-direction: row; padding: 0; }
  .public-header__nav { width: auto; flex-wrap: nowrap; gap: var(--space-3); font-size: 0.82rem; }
  .public-header__nav a:not(.button):not([href$="/sign_in"]):not([href$="/tools"]) { display: none; }
  .public-header__nav a { white-space: nowrap; }
  .public-header__brand-label { font-size: 1.05rem; }
  .public-header__brand { padding-right: 10px; gap: 0.4rem; }
  .public-header__nav { padding-left: 10px; }
  .public-main, .member-main { width: min(100% - 1.5rem, 90rem); padding: var(--space-5) 0; }
  .member-nav__rail { padding: 0 var(--space-3); }
  .member-nav__links { gap: var(--space-3); }
  .member-nav__collections, .member-nav__quick-add { display: none !important; }
  .member-nav__profile-menu .member-nav__mobile-link { display: block !important; }
  .member-page-heading { align-items: flex-start; flex-direction: column; gap: var(--space-4); }
  .member-page-heading__actions { width: 100%; }
  .member-page-heading__actions .button { flex: 1 1 auto; justify-content: center; }
  .settings-grid, .settings-form__row, .group-list, .setlist-list, .collection-list, .group-detail-grid, .setlist-detail-grid, .share-management-grid, .dashboard-stats, .chart-editor__grid { grid-template-columns: 1fr; }
  .group-card, .setlist-card, .collection-card { min-height: 0; padding: var(--space-4); }
  .public-hero { grid-template-columns: 1fr; gap: var(--space-5); }
  .public-feature-grid { grid-template-columns: 1fr; }
  .public-footer__rail { width: min(100% - 1.5rem, 76rem); flex-direction: column; align-items: flex-start; gap: var(--space-3); padding: var(--space-5) 0; }
  .preview-notice__rail { width: min(100% - 1.5rem, 90rem); }
  .share-link-list li { align-items: flex-start; flex-direction: column; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (min-width: 43rem) and (max-width: 70rem) {
  .group-list, .setlist-list, .collection-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Chart chips match the library chips: 36px tall, 0 14px padding, pill, 15px 600, 8px apart. */
.chart-key-chip,
.chart-section-jump { min-height: 36px; padding: 0 14px; border-width: 1.5px; border-radius: 999px; font-size: 15px; font-weight: 600; }
.chart-key-chips,
.chart-section-jumps { gap: 8px; }

/* Drop-downs: the native arrow sits hard against the right edge, so every single-line select draws its own chevron
   with room around it. The mid grey reads on light and dark fields. The declarations are !important because many
   component rules set the background shorthand, which would otherwise erase the chevron. */
select:not([multiple]):not([size]) {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.5rem !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238F8A80' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.9rem center !important;
  background-size: 0.875rem !important;
}

/* A checkbox whose label wraps stays level with the first line of the label, never centred against the block. */
.library-filters__scopes .kor-search-field-checkbox-wrapper,
.library-filters__tags label,
.settings-form > div:has(input[type="checkbox"]),
.group-form__field:has(input[type="checkbox"]),
.library-filters__collection:has(input[type="checkbox"]) {
  align-items: flex-start;
}
.library-filters__scopes .kor-search-field-checkbox-wrapper input[type="checkbox"],
.library-filters__tags label input[type="checkbox"],
.settings-form > div:has(input[type="checkbox"]) input[type="checkbox"],
.group-form__field:has(input[type="checkbox"]) input[type="checkbox"],
.library-filters__collection:has(input[type="checkbox"]) input[type="checkbox"] {
  flex: none;
  margin-top: 0.2em;
}

/* The preview notice is one quiet line (two on a phone) with a text-only Dismiss. The button keeps a 44px hit area; only the
   word is drawn. */
.preview-notice .preview-notice__rail { min-height: 0; gap: 0.75rem; padding: 0; }
.preview-notice .preview-notice__rail p { font-size: 0.85rem; line-height: 1.3; }
.preview-notice .preview-notice__dismiss {
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0 0.25rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
@media (max-width: 30rem) {
  .preview-notice .preview-notice__dismiss { min-width: 2.75rem; padding: 0 0.25rem; }
}

/* On the narrowest phones the mark stands alone (the member bar does the same below 45rem), so Sign in and Get started always fit. */
@media (max-width: 26rem) {
  .public-header__brand-label { display: none; }
}
