:root {
  color-scheme: light;
  --ivory: #fffbf7;
  --paper: #ffffff;
  --lavender: #f6eefc;
  --lavender-strong: #eadcf5;
  --purple: #6f2699;
  --purple-dark: #4c166d;
  --purple-soft: #8a4cac;
  --saffron: #d28b20;
  --ink: #251b2b;
  --muted: #756b7b;
  --line: #e9dff0;
  --success: #257a57;
  --danger: #b23b4b;
  --warning: #9a661a;
  --shadow-sm: 0 4px 16px rgb(76 22 109 / 7%);
  --shadow-lg: 0 24px 70px rgb(76 22 109 / 14%);
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 6% 4%, rgb(210 139 32 / 8%), transparent 27rem),
    radial-gradient(circle at 92% 10%, rgb(111 38 153 / 10%), transparent 31rem),
    var(--ivory);
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--saffron);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px 18px;
}

.login-card {
  width: min(100%, 460px);
  padding: 38px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgb(111 38 153 / 12%);
  border-radius: 30px;
  background: rgb(255 255 255 / 92%);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
}

.login-card::before {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  top: -92px;
  right: -70px;
  border-radius: 50%;
  background: var(--lavender);
  z-index: -1;
}

.brand-mark {
  display: grid;
  width: 72px;
  height: 72px;
  margin-bottom: 26px;
  place-items: center;
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.brand-mark img {
  width: 50px;
  height: 50px;
  object-fit: contain;
}

.login-card h1 {
  max-width: 330px;
  margin: 0;
  color: var(--purple-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 7vw, 3rem);
  line-height: 1.04;
  letter-spacing: -0.035em;
}

.login-copy {
  margin: 16px 0 28px;
  color: var(--muted);
  line-height: 1.55;
}

.login-form {
  display: grid;
  gap: 17px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--purple-dark);
  font-size: 0.84rem;
  font-weight: 750;
}

.login-form input {
  width: 100%;
  min-height: 50px;
  padding: 0 15px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: var(--ivory);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.login-form input:focus {
  border-color: var(--purple-soft);
  box-shadow: 0 0 0 4px rgb(111 38 153 / 10%);
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 52px;
}

.icon-button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 11px;
  color: var(--purple);
  background: transparent;
}

.icon-button:hover {
  background: var(--lavender);
}

.form-error {
  margin: -4px 0 0;
  color: var(--danger);
  font-size: 0.86rem;
}

.primary-button,
.secondary-button,
.quiet-button,
.danger-button {
  min-height: 42px;
  padding: 0 17px;
  border-radius: 12px;
  font-weight: 760;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.primary-button {
  color: white;
  border: 1px solid var(--purple);
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  box-shadow: 0 8px 20px rgb(111 38 153 / 20%);
}

.secondary-button {
  color: var(--purple);
  border: 1px solid var(--line);
  background: var(--paper);
}

.quiet-button {
  color: var(--purple);
  border: 1px solid rgb(111 38 153 / 14%);
  background: rgb(255 255 255 / 70%);
}

.danger-button {
  color: var(--danger);
  border: 1px solid rgb(178 59 75 / 18%);
  background: rgb(178 59 75 / 5%);
}

.primary-button:hover,
.secondary-button:hover,
.quiet-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none !important;
  box-shadow: none !important;
}

.full-width {
  width: 100%;
  min-height: 52px;
  margin-top: 4px;
}

.privacy-note {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.45;
  text-align: center;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 74px;
  padding: 10px clamp(18px, 4vw, 48px);
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgb(111 38 153 / 9%);
  background: rgb(255 251 247 / 88%);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  color: var(--purple-dark);
  text-decoration: none;
}

.brand img {
  width: 42px;
  height: 42px;
  padding: 5px;
  object-fit: contain;
  border-radius: 13px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.brand span {
  display: grid;
  gap: 1px;
}

.brand strong {
  font-size: 1rem;
}

.brand small {
  color: var(--muted);
  font-size: 0.72rem;
}

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

.secure-pill {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 8px 12px;
  color: var(--success);
  border-radius: 999px;
  background: rgb(37 122 87 / 8%);
  font-size: 0.76rem;
  font-weight: 750;
}

.secure-pill span {
  font-size: 0.58rem;
}

.workspace {
  display: grid;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 38px clamp(18px, 4vw, 48px) 70px;
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
  gap: clamp(26px, 4vw, 54px);
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 108px;
  display: grid;
  gap: 18px;
}

.intro-card {
  position: relative;
  padding: 26px;
  overflow: hidden;
  color: white;
  border-radius: 26px;
  background: linear-gradient(145deg, var(--purple), var(--purple-dark));
  box-shadow: var(--shadow-lg);
}

.intro-card::after {
  content: "❋";
  position: absolute;
  top: -27px;
  right: -6px;
  color: rgb(255 255 255 / 8%);
  font-size: 9rem;
  line-height: 1;
}

.intro-card .eyebrow {
  color: #f0bd68;
}

.intro-card h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.75rem, 3vw, 2.35rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.intro-card > p:last-child {
  position: relative;
  z-index: 1;
  margin: 16px 0 0;
  color: rgb(255 255 255 / 76%);
  font-size: 0.88rem;
  line-height: 1.55;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-card {
  display: grid;
  min-height: 134px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgb(255 255 255 / 78%);
  box-shadow: var(--shadow-sm);
}

.stat-card span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.stat-card strong {
  align-self: end;
  color: var(--purple);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.15rem;
  line-height: 1;
}

.stat-card small {
  color: var(--muted);
  font-size: 0.68rem;
}

.stat-mapped strong {
  color: var(--success);
}

.help-card {
  display: flex;
  gap: 13px;
  padding: 18px;
  border: 1px solid rgb(210 139 32 / 18%);
  border-radius: 20px;
  background: rgb(255 250 239 / 82%);
}

.help-icon {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  color: var(--saffron);
  border-radius: 12px;
  background: rgb(210 139 32 / 11%);
}

.help-card h2 {
  margin: 1px 0 5px;
  color: var(--purple-dark);
  font-size: 0.88rem;
}

.help-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.help-card code,
.example-key {
  color: var(--purple) !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.example-key {
  margin-top: 8px !important;
  word-break: break-all;
}

.catalog {
  min-width: 0;
}

.catalog-heading {
  display: flex;
  gap: 20px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 22px;
}

.catalog-heading h2 {
  margin: 0;
  color: var(--purple-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.result-summary {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.catalog-tools {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

.search-field {
  position: relative;
  display: flex;
  flex: 1 1 420px;
  min-width: 220px;
  align-items: center;
}

.search-field input {
  width: 100%;
  height: 54px;
  padding: 0 48px 0 48px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  outline: none;
  background: rgb(255 255 255 / 90%);
  box-shadow: var(--shadow-sm);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search-field input:focus {
  border-color: var(--purple-soft);
  box-shadow: 0 0 0 4px rgb(111 38 153 / 9%), var(--shadow-sm);
}

.search-icon {
  position: absolute;
  z-index: 1;
  left: 17px;
  color: var(--purple);
  font-size: 1.55rem;
  transform: rotate(-15deg);
}

.clear-search {
  position: absolute;
  right: 9px;
  width: 36px;
  height: 36px;
  color: var(--muted);
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 1.4rem;
}

.clear-search:hover {
  color: var(--purple);
  background: var(--lavender);
}

.segmented-control {
  display: flex;
  flex: 0 0 auto;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgb(255 255 255 / 84%);
}

.segmented-control button {
  min-height: 42px;
  padding: 0 14px;
  color: var(--muted);
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 0.8rem;
  font-weight: 760;
}

.segmented-control button[aria-pressed="true"] {
  color: var(--purple);
  background: var(--lavender);
  box-shadow: inset 0 0 0 1px rgb(111 38 153 / 8%);
}

.notice {
  margin-bottom: 16px;
  padding: 13px 15px;
  color: var(--warning);
  border: 1px solid rgb(210 139 32 / 18%);
  border-radius: 14px;
  background: rgb(210 139 32 / 7%);
  font-size: 0.84rem;
  line-height: 1.5;
}

.notice.error {
  color: var(--danger);
  border-color: rgb(178 59 75 / 16%);
  background: rgb(178 59 75 / 5%);
}

.kirtan-list {
  display: grid;
  gap: 14px;
}

.kirtan-card {
  padding: 20px;
  border: 1px solid rgb(111 38 153 / 10%);
  border-radius: 22px;
  background: rgb(255 255 255 / 88%);
  box-shadow: var(--shadow-sm);
  animation: card-in 260ms both ease-out;
}

.kirtan-card.entrance-1 {
  animation-delay: 35ms;
}

.kirtan-card.entrance-2 {
  animation-delay: 70ms;
}

.kirtan-card.entrance-3 {
  animation-delay: 105ms;
}

.kirtan-card.entrance-4 {
  animation-delay: 140ms;
}

.kirtan-card.entrance-5 {
  animation-delay: 175ms;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.kirtan-card.is-saving {
  opacity: 0.72;
  pointer-events: none;
}

.kirtan-card-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
}

.kirtan-identity {
  display: flex;
  min-width: 0;
  gap: 13px;
  align-items: flex-start;
}

.audio-state-icon {
  display: grid;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  place-items: center;
  color: var(--purple);
  border-radius: 15px;
  background: var(--lavender);
  font-size: 1.15rem;
}

.kirtan-card.mapped .audio-state-icon {
  color: var(--success);
  background: rgb(37 122 87 / 8%);
}

.kirtan-title-wrap {
  min-width: 0;
}

.original-title {
  margin: 0 0 4px;
  overflow: hidden;
  color: var(--purple-dark);
  font-size: 1.05rem;
  font-weight: 780;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.secondary-title {
  margin: 0;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.4;
}

.status-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  color: var(--warning);
  border-radius: 999px;
  background: rgb(210 139 32 / 9%);
  font-size: 0.7rem;
  font-weight: 800;
}

.mapped .status-badge {
  color: var(--success);
  background: rgb(37 122 87 / 8%);
}

.metadata-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 14px 0 16px 59px;
}

.metadata-chip {
  padding: 6px 9px;
  color: var(--purple-soft);
  border-radius: 999px;
  background: var(--lavender);
  font-size: 0.72rem;
  font-weight: 680;
}

.mapping-box {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--ivory);
}

.mapping-label-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.mapping-label-row label {
  color: var(--purple-dark);
  font-size: 0.76rem;
  font-weight: 800;
}

.mapping-feedback {
  min-height: 1em;
  color: var(--muted);
  font-size: 0.7rem;
  text-align: right;
}

.mapping-feedback.valid {
  color: var(--success);
}

.mapping-feedback.invalid {
  color: var(--danger);
}

.mapping-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
}

.mapping-input {
  min-width: 0;
  height: 44px;
  padding: 0 13px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  background: var(--paper);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
}

.mapping-input:focus {
  border-color: var(--purple-soft);
  box-shadow: 0 0 0 3px rgb(111 38 153 / 8%);
}

.mapping-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.mapping-actions button,
.mapping-actions a {
  display: inline-flex;
  min-height: 36px;
  padding: 0 12px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 760;
  text-decoration: none;
}

.mapping-actions .check-button,
.mapping-actions .preview-link {
  color: var(--purple);
  border: 1px solid var(--line);
  background: var(--paper);
}

.mapping-actions .save-button {
  color: white;
  border: 1px solid var(--purple);
  background: var(--purple);
}

.mapping-actions .clear-button {
  color: var(--danger);
  border: 1px solid rgb(178 59 75 / 15%);
  background: transparent;
}

.load-more-row {
  display: flex;
  padding-top: 22px;
  justify-content: center;
}

.empty-state,
.error-state {
  padding: 54px 24px;
  border: 1px dashed var(--line);
  border-radius: 24px;
  background: rgb(255 255 255 / 55%);
  text-align: center;
}

.empty-state-icon {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 0 auto 15px;
  place-items: center;
  color: var(--purple);
  border-radius: 18px;
  background: var(--lavender);
  font-size: 1.45rem;
}

.empty-state h3,
.error-state h3 {
  margin: 0 0 7px;
  color: var(--purple-dark);
}

.empty-state p,
.error-state p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.skeleton-card {
  height: 210px;
  border: 1px solid rgb(111 38 153 / 7%);
  border-radius: 22px;
  background:
    linear-gradient(90deg, transparent, rgb(255 255 255 / 80%), transparent),
    var(--lavender);
  background-size: 220% 100%;
  animation: shimmer 1.25s infinite linear;
}

@keyframes shimmer {
  to {
    background-position: -220% 0;
  }
}

.toast-region {
  position: fixed;
  z-index: 50;
  right: 22px;
  bottom: 22px;
  display: grid;
  max-width: min(390px, calc(100vw - 36px));
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 13px 16px;
  color: white;
  border-radius: 14px;
  background: var(--purple-dark);
  box-shadow: var(--shadow-lg);
  font-size: 0.84rem;
  line-height: 1.45;
  animation: toast-in 180ms ease-out;
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    grid-template-columns: minmax(0, 1.4fr) minmax(230px, 0.8fr);
  }

  .intro-card {
    grid-row: span 2;
  }

  .stats-grid,
  .help-card {
    align-self: stretch;
  }
}

@media (max-width: 720px) {
  .topbar {
    min-height: 66px;
  }

  .secure-pill {
    display: none;
  }

  .workspace {
    padding-top: 24px;
  }

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

  .intro-card {
    grid-row: auto;
  }

  .catalog-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .search-field {
    flex-basis: auto;
  }

  .segmented-control {
    width: 100%;
  }

  .segmented-control button {
    flex: 1;
  }

  .catalog-heading {
    align-items: flex-start;
  }

  .metadata-row {
    margin-left: 0;
  }

  .mapping-input-row {
    grid-template-columns: 1fr;
  }

  .mapping-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 480px) {
  .login-card {
    padding: 28px 22px;
    border-radius: 24px;
  }

  .brand span small {
    display: none;
  }

  .topbar .quiet-button {
    min-height: 38px;
    padding-inline: 12px;
  }

  .workspace {
    padding-inline: 14px;
  }

  .kirtan-card {
    padding: 16px;
  }

  .status-badge {
    display: none;
  }

  .original-title {
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
