:root {
  --ink: #182026;
  --muted: #64727f;
  --line: #d8e0e7;
  --soft: #f5f7f3;
  --paper: #ffffff;
  --brand: #1f6f65;
  --brand-dark: #12463f;
  --accent: #d69b36;
  --danger: #b93838;
  --shadow: 0 18px 50px rgba(24, 32, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(31, 111, 101, 0.12), rgba(214, 155, 54, 0.11)),
    var(--soft);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  width: min(100%, 1120px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.login-view {
  min-height: calc(100vh - 48px);
  display: grid;
  align-content: center;
  gap: 24px;
}

.brand-block {
  display: grid;
  justify-items: center;
  text-align: center;
}

.brand-mark-button {
  width: 112px;
  height: 112px;
  padding: 0;
  margin: 0 0 18px;
  border: 0;
  background: transparent;
}

.brand-mark-button:focus-visible {
  outline: 4px solid rgba(31, 111, 101, 0.2);
  outline-offset: 4px;
  border-radius: 8px;
}

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

.kicker {
  margin: 0 0 8px;
  color: var(--brand-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.login-church-name {
  font-size: 30px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.25rem, 8vw, 4.25rem);
  line-height: 1.04;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 5vw, 2.1rem);
}

h3 {
  margin-bottom: 8px;
  font-size: 1.02rem;
}

.intro {
  max-width: 320px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.login-card,
.editor-panel,
.history-panel {
  background: var(--paper);
  border: 1px solid rgba(216, 224, 231, 0.82);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-card {
  width: min(100%, 420px);
  margin: 0 auto;
  padding: 18px;
}

.admin-login-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 70, 63, 0.3);
  backdrop-filter: blur(6px);
}

.admin-login-card {
  position: relative;
  width: min(100%, 380px);
  padding: 22px;
  background: var(--paper);
  border: 1px solid rgba(216, 224, 231, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.admin-login-card h2 {
  margin-bottom: 8px;
}

.admin-login-card .primary-action {
  margin-top: 12px;
}

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

.admin-login-close {
  position: absolute;
  top: 14px;
  right: 14px;
}

.site-footer {
  margin-top: 6px;
  color: #8a949e;
  font-size: 10px;
  text-align: center;
}

.member-view .site-footer,
.admin-view .site-footer {
  margin-top: 24px;
}

.field-label,
label {
  display: grid;
  gap: 8px;
  color: var(--brand-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input {
  min-height: 46px;
  padding: 0 13px;
}

textarea {
  resize: vertical;
  padding: 12px 13px;
  line-height: 1.5;
}

input:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(31, 111, 101, 0.12);
}

.pin-input {
  margin-top: 8px;
  font-size: 1.2rem;
  letter-spacing: 0.08em;
}

.form-error {
  min-height: 22px;
  margin: 8px 0 12px;
  color: var(--danger);
  font-size: 0.9rem;
}

.login-help {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.form-status {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--brand-dark);
  font-size: 0.92rem;
  font-weight: 800;
}

.primary-action,
.secondary-action,
.ghost-action,
.icon-action {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 850;
}

.primary-action {
  width: 100%;
  color: #fff;
  background: var(--brand);
}

.primary-action:hover {
  background: var(--brand-dark);
}

.secondary-action {
  padding: 0 14px;
  color: var(--brand-dark);
  background: #eaf3f0;
  border-color: #cce3dd;
}

.ghost-action {
  padding: 0 14px;
  color: var(--brand-dark);
  background: transparent;
  border-color: var(--line);
}

.icon-action {
  width: 42px;
  color: var(--danger);
  background: #fff5f5;
  border-color: #f0caca;
  font-size: 1.35rem;
}

.is-hidden {
  display: none !important;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 0 22px;
}

.member-top-bar {
  align-items: center;
  gap: 14px;
}

.member-heading-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.member-title-block {
  flex: 1;
  min-width: 0;
}

.member-admin-entry {
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
}

.member-admin-entry:focus-visible {
  outline: 3px solid rgba(31, 111, 101, 0.2);
  outline-offset: 3px;
  border-radius: 8px;
}

.member-kicker {
  margin-bottom: 6px;
  font-size: 1rem;
}

.member-header-mark {
  width: 74px;
  height: 74px;
  object-fit: contain;
  flex: 0 0 auto;
}

.admin-page-kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 20px;
}

.admin-church-name {
  color: var(--ink);
  font-weight: 800;
}

.admin-church-name span {
  color: var(--ink);
}

.summary-band {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  padding: 12px 14px;
  color: #fff;
  background: var(--brand-dark);
  border-radius: 8px;
}

.summary-band.has-search {
  gap: 9px;
}

.summary-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  align-items: start;
  gap: 12px;
}

.summary-band strong {
  font-size: 25px;
}

.summary-band span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.86rem;
}

.summary-copy {
  display: grid;
  gap: 2px;
}

.member-search {
  display: grid;
  gap: 6px;
}

.member-search-filter {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.member-search-filter label {
  display: grid;
  gap: 3px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.72rem;
  font-weight: 800;
}

.member-search-filter select {
  width: 100%;
  min-height: 34px;
  padding: 0 9px;
  color: var(--ink);
  background: #fff;
  border: 0;
  border-radius: 6px;
  font-size: 0.84rem;
  font-weight: 800;
}

.member-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.member-search input {
  min-height: 34px;
  padding: 0 10px;
  border-color: rgba(255, 255, 255, 0.32);
  font-size: 0.86rem;
}

.member-search button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--brand-dark);
  background: #fff;
  border: 0;
  border-radius: 6px;
  font-size: 0.86rem;
  font-weight: 800;
}

.member-search-result {
  min-height: 56px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.68rem;
}

.member-search-result ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 6px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.member-search-result li {
  display: grid;
  align-content: center;
  gap: 2px;
  min-height: 54px;
  padding: 7px 8px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  text-align: left;
}

.member-search-result li time {
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.64rem;
  font-weight: 700;
}

.member-search-result li span {
  overflow-wrap: anywhere;
  font-weight: 800;
  line-height: 1.15;
}

.member-search-result li small {
  overflow-wrap: anywhere;
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.64rem;
}

.purpose-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.purpose-card {
  min-height: 130px;
  padding: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.purpose-card h3 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--brand-dark);
}

.purpose-card h3 span {
  color: var(--accent);
  font-size: 0.86rem;
}

.name-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.name-list li {
  padding: 7px 10px;
  background: #f3f6f5;
  border: 1px solid #e0e8e5;
  border-radius: 999px;
  font-weight: 700;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.76);
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.editor-panel,
.history-panel {
  padding: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.55fr) minmax(220px, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.editor-head,
.panel-head,
.action-row,
.purpose-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.editor-head p,
.panel-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.purpose-editor {
  display: grid;
  gap: 12px;
  margin: 14px 0 18px;
}

.purpose-editor-item {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.purpose-title-row label {
  flex: 1;
}

.action-row {
  justify-content: flex-end;
}

.action-row .primary-action {
  width: auto;
  padding: 0 16px;
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.history-item {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.history-item.is-latest {
  border-color: rgba(31, 111, 101, 0.5);
  box-shadow: inset 4px 0 0 var(--brand);
}

.history-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 850;
}

.history-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

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

.history-actions button {
  flex: 1;
}

.has-open-viewer {
  overflow: hidden;
}

.admin-report-viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  padding: 0;
  background: rgba(18, 70, 63, 0.4);
}

.admin-report-viewer-shell {
  width: min(100%, 980px);
  height: 100%;
  margin: 0 auto;
  overflow: auto;
  background: var(--soft);
}

.viewer-top-bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.viewer-top-bar h2 {
  font-size: 1.35rem;
}

.viewer-tools {
  position: sticky;
  top: 73px;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(245, 247, 243, 0.96);
  border-bottom: 1px solid var(--line);
}

.viewer-tools input {
  min-height: 42px;
}

.viewer-result {
  margin: 14px 16px 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.viewer-purpose-list {
  display: grid;
  gap: 10px;
  padding: 0 16px 24px;
}

.viewer-purpose {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(24, 32, 38, 0.08);
}

.viewer-purpose summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  color: var(--brand-dark);
  font-weight: 850;
  cursor: pointer;
}

.viewer-purpose summary::marker {
  color: var(--accent);
}

.viewer-purpose summary small {
  color: var(--accent);
  font-size: 0.86rem;
}

.viewer-name-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 14px 14px;
  margin: 0;
  list-style: none;
}

.viewer-name-list li {
  padding: 7px 10px;
  background: #f3f6f5;
  border: 1px solid #e0e8e5;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 700;
}

@media (max-width: 820px) {
  .app-shell {
    padding: 16px;
  }

  .top-bar {
    align-items: flex-start;
  }

  .admin-layout,
  .summary-top,
  .form-row {
    grid-template-columns: 1fr;
  }

  .editor-head,
  .action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .action-row .primary-action,
  .secondary-action {
    width: 100%;
  }

  .viewer-tools {
    grid-template-columns: 1fr 1fr;
  }

  .viewer-tools input {
    grid-column: 1 / -1;
  }

}

@media (max-width: 480px) {
  .app-shell {
    padding: 12px;
  }

  .login-view {
    min-height: calc(100vh - 24px);
  }

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

  .brand-mark-button {
    width: 96px;
    height: 96px;
  }

  .top-bar {
    gap: 10px;
  }

  .member-top-bar {
    align-items: center;
  }

  .member-heading-group {
    gap: 8px;
  }

  .member-kicker {
    font-size: 0.92rem;
  }

  .member-header-mark {
    width: 58px;
    height: 58px;
  }

  .ghost-action {
    min-width: 74px;
  }

  .purpose-list {
    grid-template-columns: 1fr;
  }

  .viewer-top-bar {
    padding: 12px;
  }

  .viewer-top-bar h2 {
    font-size: 1.1rem;
  }

  .viewer-tools {
    top: 65px;
    padding: 10px 12px;
  }

  .viewer-result {
    margin-right: 12px;
    margin-left: 12px;
  }

  .viewer-purpose-list {
    padding: 0 12px 18px;
  }

  .member-search-result {
    font-size: 0.68rem;
  }

  .member-search-result ul {
    gap: 4px;
  }

  .member-search-result li {
    min-height: 46px;
    padding: 5px 2px;
  }
}
