:root {
  --green: #286849;
  --green-dark: #1f523b;
  --ink: #14211b;
  --muted: #68746f;
  --line: #dfe8e3;
  --card: #ffffff;
  --soft: #f5f8f6;
  --warn: #a15c00;
  --danger: #a33131;
  --ok: #236b3d;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--soft);
}

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

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

button,
.button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.primary {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.app-shell {
  max-width: 880px;
  margin: 0 auto;
}

.app-shell.is-login {
  max-width: none;
  width: 100%;
  margin: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(18px + env(safe-area-inset-top)) 18px 12px;
  position: relative;
}

.brand-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-line img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  flex: 0 0 auto;
}

.brand-wide-logo {
  display: none;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.topbar h1,
.login-card h1,
h2,
h3,
p {
  margin: 0;
}

.topbar h1 {
  font-size: 24px;
}

.eyebrow {
  color: var(--green);
  text-transform: uppercase;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .08em;
  margin-bottom: 4px;
}

.icon-btn {
  width: 44px;
  padding: 0;
  font-size: 22px;
}

.content {
  padding: 10px 14px calc(92px + env(safe-area-inset-bottom));
  display: grid;
  gap: 4px;
  align-content: start;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(880px, 100%);
  display: flex;
  overflow-x: auto;
  gap: 4px;
  background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  backdrop-filter: blur(12px);
  z-index: 20;
}

.side-brand {
  display: none;
}

.bottom-nav button {
  flex: 0 0 76px;
  min-height: 56px;
  border: 0;
  background: transparent;
  flex-direction: column;
  gap: 3px;
  font-size: 10px;
  color: var(--muted);
  padding: 6px 2px;
}

.bottom-nav span {
  font-size: 20px;
  line-height: 1;
}

.bottom-nav img,
.item-number img,
.icon-preview img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
}

.bottom-nav .active {
  color: var(--green);
  background: #e9f2ed;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 92px 20px 30px;
  background:
    radial-gradient(circle at 15% 10%, #e2eee6, transparent 35%),
    radial-gradient(circle at 85% 80%, #eee3cf, transparent 35%),
    var(--soft);
  position: relative;
}

.login-card {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, .94);
  border: 0;
  border-radius: 24px;
  padding: 44px;
  box-shadow: 0 14px 40px rgba(23, 53, 39, .08);
  display: grid;
  gap: 20px;
}

.login-brand {
  position: absolute;
  top: 28px;
  left: 32px;
  display: flex;
  align-items: center;
  gap: 11px;
}

.login-brand strong,
.login-brand small {
  display: block;
}

.login-brand small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.login-brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 0;
  background: transparent;
  color: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-weight: 800;
  position: relative;
}

.login-brand-mark::before {
  content: "";
}

.login-brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
  position: relative;
  z-index: 1;
}


.login-brand-mark.fallback::before {
  content: "✓";
}

.login-card h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  line-height: 1.1;
  margin: 8px 0 10px;
}

.asset-grid {
  display: grid;
  gap: 12px;
}

.asset-preview {
  min-height: 76px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #f8faf9;
  padding: 12px;
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  align-items: center;
}

.asset-preview span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.asset-preview img {
  max-width: 160px;
  max-height: 58px;
  object-fit: contain;
  justify-self: start;
}

.asset-preview.wide img {
  max-width: min(460px, 100%);
  max-height: 92px;
}

.asset-preview.missing {
  display: none;
}

.access-matrix-grid {
  display: grid;
  grid-template-columns: minmax(190px, 1.4fr) repeat(7, minmax(92px, 1fr));
  gap: 1px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--line);
}

.access-matrix-head,
.access-user,
.matrix-check {
  background: #fff;
  min-height: 58px;
  padding: 12px;
  display: grid;
  align-items: center;
}

.access-matrix-head {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.access-user strong,
.access-user span {
  display: block;
}

.access-user span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.matrix-check {
  justify-items: center;
}

.matrix-check input {
  width: 22px;
  height: 22px;
  accent-color: var(--green);
}

.login-copy {
  color: var(--muted);
  line-height: 1.5;
}

.stack {
  display: grid;
  gap: 12px;
}

.compact {
  gap: 8px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 9px;
}

.inline-check input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  padding: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.hero-card,
.panel,
.card,
.empty-state,
.search-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.hero-card {
  display: grid;
  gap: 14px;
  border-color: #c9ded2;
}

.hero-card h2 {
  font-size: 27px;
}

.hero-date {
  color: var(--muted);
  font-weight: 700;
}

.status-row,
.button-row,
.filter-row,
.tag-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hero-card .button-row,
.empty-state .button-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 4px;
  width: 100%;
}

.hero-card .button-row button,
.empty-state .button-row button {
  width: 100%;
  text-align: center;
}

.status-row span,
.tag-row span {
  background: #eef5f1;
  color: var(--green-dark);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 800;
}

.status-row .warn {
  color: var(--warn);
  background: #fff4df;
}

.status-row .ok {
  color: var(--ok);
}

.plan-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 4px;
  margin-top: 8px;
}

.plan-picker button {
  min-height: 64px;
  align-items: center;
  flex-direction: column;
  gap: 3px;
  text-align: center;
  background: #fff;
  width: 100%;
}

.plan-picker button.active {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.plan-picker span {
  color: inherit;
  opacity: .78;
  font-size: 13px;
}

.section-head,
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.detail-head {
  justify-content: flex-start;
  align-items: flex-start;
}

.detail-head > button {
  width: 44px;
  padding: 0;
}

.section-head h2,
.detail-head h2 {
  font-size: 26px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.stat-grid article {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 10px;
}

.stat-grid strong,
.stat-grid span {
  display: block;
  overflow-wrap: anywhere;
}

.stat-grid strong {
  font-size: 20px;
}

.stat-grid span,
.muted,
.card p,
.card span,
.service-item span {
  color: var(--muted);
}

.panel,
.card-list,
.search-panel,
.tag-row {
  margin-top: 12px;
}

.panel {
  display: grid;
  gap: 12px;
}

.card-list {
  display: grid;
  gap: 10px;
}

.song-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.song-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  cursor: pointer;
}

.song-row h3 {
  font-size: 16px;
  margin-bottom: 2px;
}

.song-row p,
.song-row span {
  display: block;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.song-row button {
  min-height: 36px;
  padding: 8px 10px;
}

.group-switch {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.group-switch button {
  background: #fff;
}

.group-switch .active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.song-row .missing-badges {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-left: 6px;
  vertical-align: middle;
}

.song-row .missing-badges b {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #fff4df;
  color: #8a4c00;
  border: 1px solid #efd4a0;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
}

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

.card h3 {
  font-size: 18px;
  margin-bottom: 3px;
}

.card div {
  min-width: 0;
}

.card-actions {
  display: grid;
  gap: 6px;
  flex: 0 0 auto;
}

.card-actions button {
  min-height: 38px;
  padding: 8px 10px;
}

.card p,
.card span {
  display: block;
  overflow-wrap: anywhere;
}

.song-card {
  cursor: pointer;
}

.service-list {
  display: grid;
  gap: 8px;
}

.service-item {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.service-item.is-song {
  border-color: #bcd8c8;
  background: #fbfefd;
  cursor: pointer;
}

.item-number {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e9f2ed;
  color: var(--green);
  font-weight: 900;
}

.icon-setting {
  align-items: end;
}

.icon-preview {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #fff;
}

.item-body {
  min-width: 0;
}

.item-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.preacher-chip {
  flex: 0 0 auto;
  min-height: 30px;
  max-width: 42%;
  padding: 5px 9px;
  border-color: #bad4c6;
  color: var(--green);
  background: #fff;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preacher-chip.readonly {
  border: 1px solid #bad4c6;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
}

.item-body strong,
.item-body span,
.item-body p,
.item-body em {
  display: block;
  overflow-wrap: anywhere;
}

.item-body em {
  color: var(--warn);
  margin-top: 4px;
}

.item-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 6px;
}

.item-actions button {
  min-height: 38px;
}

.search-panel {
  display: grid;
  gap: 8px;
}

.sticky {
  position: sticky;
  top: 0;
  z-index: 10;
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.filter-row input {
  grid-column: 1 / -1;
}

.settings-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(31, 82, 59, .06);
  margin-top: 6px;
}

.settings-box legend {
  color: var(--green);
  font-weight: 800;
  padding: 0 6px;
}

.settings-form {
  gap: 18px;
}

.settings-inline-save {
  width: 100%;
  margin-top: 10px;
}

.inline-picker {
  min-height: 34px;
  width: fit-content;
  margin-top: 6px;
  padding: 6px 10px;
  color: var(--green);
  background: #fff;
  border-color: #bad4c6;
  font-weight: 700;
}

.settings-box + label,
.settings-box + .settings-box {
  margin-top: 8px;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.check-line input {
  width: 18px;
  min-height: 18px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.lyrics {
  line-height: 1.55;
}

.lyrics pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  font: 15px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

audio {
  width: 100%;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20, 33, 27, .38);
  display: grid;
  align-items: end;
}

.modal {
  width: min(880px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--soft);
  border-radius: 8px 8px 0 0;
  margin: 0 auto;
  padding: 16px;
  box-shadow: 0 -14px 40px rgba(20, 33, 27, .2);
}

.modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal header button {
  width: 44px;
  padding: 0;
  font-size: 24px;
}

.mini-list {
  display: grid;
  gap: 8px;
}

.mini-list div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.mini-list strong,
.mini-list span {
  display: block;
}

.mini-list span {
  color: var(--muted);
  font-size: 13px;
}

.mini-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.mini-actions button {
  min-height: 34px;
  padding: 7px 10px;
}

.empty-state {
  display: grid;
  gap: 12px;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  width: min(360px, calc(100% - 28px));
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  opacity: 0;
  pointer-events: none;
  transition: .18s ease;
  z-index: 80;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.wrap {
  margin-bottom: 12px;
}

@media (min-width: 720px) {
  .content {
    padding-left: 22px;
    padding-right: 22px;
  }

  .card-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .service-item {
    grid-template-columns: 40px 1fr auto;
    align-items: center;
  }

  .item-actions {
    grid-column: auto;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  }
}

@media (min-width: 1100px) {
  .app-shell {
    max-width: none;
    width: 100%;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }

  .app-shell.is-login {
    display: block;
    grid-template-columns: none;
    grid-template-rows: none;
  }

  .topbar {
    grid-column: 2;
    width: auto;
    margin: 0;
    padding: 22px 32px 14px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 24px rgba(20, 33, 27, .04);
  }

  .brand-mark {
    width: 44px;
    height: 44px;
  }

  .brand-wide-logo {
    display: block;
    width: auto !important;
    max-width: min(520px, 42vw);
    height: 54px !important;
    object-fit: contain;
    border-radius: 0 !important;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }

  .brand-line:has(.brand-wide-logo:not([style*="display: none"])) .brand-mark,
  .brand-line:has(.brand-wide-logo:not([style*="display: none"])) .brand-copy {
    display: none;
  }

  .content {
    grid-column: 2;
    width: min(1480px, calc(100% - 64px));
    margin: 0 auto;
    padding: 28px 0 48px;
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: none;
    width: 264px;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    padding: 24px 18px 24px;
    background: #fff;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    overflow: auto;
    box-shadow: 8px 0 26px rgba(20, 33, 27, .05);
  }

  .side-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 28px;
    padding: 0 8px 12px;
  }

  .side-brand img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    flex: 0 0 auto;
  }

  .side-brand strong,
  .side-brand small {
    display: block;
  }

  .side-brand strong {
    font-size: 17px;
    line-height: 1.1;
  }

  .side-brand small {
    max-width: 170px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.25;
    text-transform: uppercase;
  }

  .bottom-nav button {
    flex: 0 0 auto;
    max-width: none;
    min-height: 48px;
    padding: 10px 12px;
    border-radius: 8px;
    flex-direction: row;
    justify-content: flex-start;
    font-size: 15px;
    gap: 12px;
  }

  .bottom-nav button[data-action="logout"] {
    margin-top: auto;
  }

  .hero-card,
  .panel,
  .empty-state {
    padding: 28px;
  }

  .hero-card h2,
  .section-head h2,
  .detail-head h2 {
    font-size: 38px;
  }

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

  .stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  }

  .settings-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 22px;
  }

  .settings-form > label,
  .settings-form > p,
  .settings-form > button {
    grid-column: 1 / -1;
  }

  .settings-box {
    margin-top: 0;
    padding: 22px;
  }

  .settings-box .two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .icon-setting {
    align-items: end;
  }

  .modal {
    border-radius: 12px;
    margin: auto;
    max-height: 86vh;
  }

  .login-screen {
    grid-template-rows: auto 1fr;
    place-items: center;
    padding: 34px 24px 80px;
    background:
      radial-gradient(circle at 16% 8%, #e2eee6, transparent 38%),
      radial-gradient(circle at 82% 86%, #eee3cf, transparent 35%),
      var(--soft);
  }

  .login-brand {
    position: static;
    align-self: start;
    justify-self: center;
    text-align: left;
  }

  .login-card {
    align-self: center;
    justify-self: center;
    width: min(390px, calc(100% - 40px));
    padding: 44px 42px;
    box-shadow: 0 20px 60px rgba(23, 53, 39, .09);
    border-radius: 22px;
    background: rgba(255, 255, 255, .93);
  }

  .login-screen::after {
    display: none;
  }

  .login-brand-mark {
    width: 54px;
    height: 54px;
    border-radius: 0;
    background: transparent;
  }

  .login-card > div,
  .login-card .eyebrow,
  .login-card h1 {
    text-align: center;
  }
}

@media (max-width: 640px) {
  .login-screen {
    padding: 86px 18px 24px;
  }

  .login-brand {
    left: 20px;
    right: 20px;
  }

  .login-card {
    padding: 30px 24px;
  }

  .login-card h1 {
    font-size: 30px;
  }
}

@media (max-width: 390px) {
  .bottom-nav button {
    font-size: 10px;
  }

  .hero-card h2,
  .section-head h2,
  .detail-head h2 {
    font-size: 23px;
  }

  .two-col {
    grid-template-columns: 1fr;
  }
}
