body {
  background: #f7f7f5;
}

.navbar {
  border-bottom: 1px solid #e6e2dc;
}

.page-shell {
  max-width: 1120px;
}

.app-version {
  color: #6c757d;
  font-size: 0.75rem;
  font-weight: 400;
  margin-left: 0.25rem;
}

.nav-shell {
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.nav-topline {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  justify-content: space-between;
}

.nav-actions {
  flex: 1 1 36rem;
  flex-wrap: wrap;
  gap: 0.5rem !important;
  justify-content: flex-end;
}

.nav-actions .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.nav-link-button.active {
  background: #343a40;
  border-color: #343a40;
  color: #fff;
  font-weight: 700;
}

.nav-actions form {
  flex: 0 0 auto;
}

.admin-menu {
  flex: 0 0 auto;
  position: relative;
}

.admin-menu summary {
  align-items: center;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  list-style: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.admin-menu summary::-webkit-details-marker {
  display: none;
}

.admin-menu summary::after {
  content: "▾";
  display: inline-block;
  font-size: 0.75rem;
  margin-left: 0.35rem;
}

.admin-menu[open] summary::after {
  transform: rotate(180deg);
}

.admin-menu-panel {
  display: grid;
  gap: 0.4rem;
  min-width: 12rem;
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: 10;
}

.admin-menu-panel .btn {
  justify-content: flex-start;
  text-align: left;
}

.admin-menu-close {
  justify-content: center !important;
  text-align: center !important;
}

.nav-toggle,
.nav-toggle-label {
  display: none;
}

.portal-card {
  color: #212529;
}

.portal-card[href]:hover {
  border-color: #b8c5d6 !important;
  box-shadow: 0 0.35rem 1rem rgba(33, 37, 41, 0.08);
}

.portal-card-title {
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.portal-card-body {
  color: #495057;
  min-height: 3rem;
}

.portal-card-meta {
  color: #6c757d;
  font-size: 0.875rem;
  margin-top: 1rem;
}

.portal-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.portal-card-actions .btn {
  flex: 1 1 7rem;
}

.admin-task-summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  list-style: none;
}

.admin-task-summary::-webkit-details-marker {
  display: none;
}

.admin-task-summary::after {
  color: #6c757d;
  content: "▾";
  font-size: 0.85rem;
  margin-left: auto;
}

.admin-task-details[open] .admin-task-summary::after {
  transform: rotate(180deg);
}

.table td,
.table th {
  vertical-align: middle;
}

.status-pill {
  display: inline-block;
  min-width: 3.75rem;
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
}

.status-yes {
  background: #d7f0df;
  color: #11602c;
}

.status-no {
  background: #f7d9d9;
  color: #8a1f1f;
}

.status-maybe {
  background: #fff1c7;
  color: #765400;
}

.status-unanswered {
  background: #e9ecef;
  color: #495057;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0;
}

.markdown-body p:last-child,
.markdown-body ul:last-child,
.markdown-body ol:last-child {
  margin-bottom: 0;
}

.notice-preview-panel {
  position: sticky;
  top: 1rem;
}

.notice-preview-body {
  min-height: 10rem;
}

.template-token {
  background: #f1f3f5;
  border: 1px solid #dee2e6;
  border-radius: 0.25rem;
  color: #343a40;
  padding: 0.15rem 0.4rem;
}

.email-preview {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  min-height: 12rem;
  padding: 0.75rem;
  white-space: pre-wrap;
}

.login-page {
  align-items: flex-start;
}

.recipient-list {
  max-height: 16rem;
  overflow: auto;
}

.contact-summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
}

.contact-summary::marker {
  color: #6c757d;
}

.message-timeline {
  display: grid;
  gap: 0.75rem;
}

.message-row {
  display: flex;
}

.message-row-own {
  justify-content: flex-end;
}

.message-bubble {
  max-width: min(42rem, 100%);
}

.message-row-own .message-bubble {
  background: #eef6f2 !important;
  border-color: #c9dfd5 !important;
}

.message-body {
  white-space: pre-wrap;
}

.attendance-target {
  display: none;
}

.attendance-mobile-details {
  display: none;
}

.rehearsal-mobile-hint {
  display: none;
  margin: 0;
}

.attendance-status-options {
  display: flex;
  gap: 0.35rem;
}

.attendance-choice {
  border: 1px solid #ced4da;
  color: #343a40;
  min-width: 4rem;
  position: relative;
}

.attendance-radio {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.attendance-choice-yes:hover,
.attendance-choice-yes:has(.attendance-radio:checked) {
  background: #d7f0df;
  border-color: #91c9a1;
  color: #11602c;
}

.attendance-choice-no:hover,
.attendance-choice-no:has(.attendance-radio:checked) {
  background: #f7d9d9;
  border-color: #dfa2a2;
  color: #8a1f1f;
}

.attendance-choice-maybe:hover,
.attendance-choice-maybe:has(.attendance-radio:checked) {
  background: #fff1c7;
  border-color: #dfc56f;
  color: #765400;
}

@media (max-width: 992px) {
  .nav-shell {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.5rem;
  }

  .nav-topline {
    width: 100%;
  }

  .nav-toggle {
    display: none;
  }

  .nav-toggle-label {
    display: inline-block;
    flex: 0 0 auto;
  }

  .nav-actions {
    align-items: stretch !important;
    display: none !important;
    flex-direction: column;
    gap: 0.45rem !important;
    max-height: none;
    overflow: visible;
    padding: 0.25rem 0 0.5rem;
    width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .nav-shell:has(.nav-toggle:checked) .nav-actions {
    display: flex !important;
  }

  .nav-shell.nav-open .nav-actions {
    display: flex !important;
  }

  .nav-actions .btn,
  .nav-actions form,
  .nav-actions form .btn {
    width: 100%;
  }

  .nav-actions .small {
    padding: 0.15rem 0;
  }

  .login-page {
    padding-bottom: 40vh;
  }
}

@media (max-width: 576px) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  .btn {
    min-height: 2.5rem;
  }

  .nav-shell {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.5rem;
  }

  .nav-topline {
    width: 100%;
  }

  .nav-toggle {
    display: none;
  }

  .nav-toggle-label {
    display: inline-block;
    flex: 0 0 auto;
  }

  .nav-actions {
    align-items: stretch !important;
    display: none !important;
    flex-direction: column;
    gap: 0.45rem !important;
    max-height: none;
    overflow: visible;
    padding: 0.25rem 0 0.5rem;
    width: 100%;
  }

  .nav-shell:has(.nav-toggle:checked) .nav-actions {
    display: flex !important;
  }

  .nav-shell.nav-open .nav-actions {
    display: flex !important;
  }

  .nav-actions .btn,
  .nav-actions form,
  .nav-actions form .btn {
    width: 100%;
  }

  .nav-actions {
    -webkit-overflow-scrolling: touch;
  }

  .row.g-4,
  .row.g-3,
  .row.g-2,
  .row {
    --bs-gutter-x: 0;
  }

  .bg-white.border.rounded-2.p-4 {
    padding: 1rem !important;
  }

  .d-flex.flex-wrap.gap-2 .btn,
  .col-md-2.d-flex.gap-2 .btn {
    flex: 1 1 9rem;
  }

  .nav-actions .small {
    padding: 0.15rem 0;
  }

  .page-heading,
  main > .d-flex.justify-content-between {
    flex-direction: column;
    gap: 0.75rem;
  }

  .page-shell {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .portal-card-body {
    min-height: auto;
  }

  .notice-preview-panel {
    position: static;
  }

  .table {
    font-size: 0.875rem;
  }

  .table td,
  .table th {
    white-space: nowrap;
  }

  .table form.row {
    min-width: 18rem;
  }

  .rehearsal-list {
    background: transparent !important;
    border: 0 !important;
  }

  .rehearsal-mobile-hint {
    display: block !important;
    margin-bottom: 0.75rem;
  }

  .rehearsal-table-wrap {
    overflow: visible;
  }

  .rehearsal-table {
    border-collapse: separate;
    border-spacing: 0;
  }

  .rehearsal-table thead {
    display: none;
  }

  .rehearsal-table tbody,
  .rehearsal-table td {
    display: block;
    width: 100%;
  }

  .rehearsal-table tbody {
    display: grid;
    gap: 0.6rem;
  }

  .rehearsal-table tr {
    align-items: center;
    background: #fff;
    border: 1px solid #d9d3ca;
    border-radius: 0.45rem;
    box-shadow: 0 0.18rem 0.55rem rgba(33, 37, 41, 0.05);
    cursor: pointer;
    display: grid;
    grid-template-columns: 6.35rem minmax(0, 1fr) 4.75rem;
    grid-template-rows: auto auto;
    overflow: hidden;
  }

  .rehearsal-table td {
    border-bottom: 0;
    padding: 0.55rem 0.65rem;
    white-space: normal;
  }

  .rehearsal-table td:first-child {
    align-self: stretch;
    background: #f4f1ec;
    border-right: 1px solid #e1d9cf;
    font-size: 0.82rem;
    grid-column: 1;
    grid-row: 1 / 3;
    font-weight: 700;
    line-height: 1.25;
    padding-left: 0.5rem;
    padding-right: 0.4rem;
  }

  .rehearsal-table td:first-child .small {
    display: block;
    font-size: 0.74rem;
    margin-top: 0.15rem;
  }

  .rehearsal-table td[data-label="練習"] {
    grid-column: 2;
    grid-row: 1 / 3;
    min-width: 0;
  }

  .rehearsal-table td[data-label="練習"] .fw-semibold {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .rehearsal-table td[data-label="練習"] .small,
  .rehearsal-table td[data-label="会場"] {
    display: none;
  }

  .rehearsal-table td[data-label="現在"] {
    grid-column: 3;
    grid-row: 1;
    padding: 0.5rem 0.5rem 0.2rem 0.25rem;
    text-align: right;
  }

  .rehearsal-table td[data-label="現在"] .small {
    display: none;
  }

  .rehearsal-table td[data-label="登録・変更"] {
    grid-column: 3;
    grid-row: 2;
    padding: 0;
  }

  .rehearsal-table td[data-label="登録・変更"]:has(.attendance-mobile-details[open]) {
    background: #f8f6f2;
    border-top: 1px solid #e6e2dc;
    cursor: auto;
    grid-column: 1 / -1;
    grid-row: 3;
    padding: 0.65rem;
  }

  .rehearsal-table td::before {
    color: #6c757d;
    content: attr(data-label);
    display: none;
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
  }

  .rehearsal-table .attendance-form {
    margin: 0;
    min-width: 0;
  }

  .rehearsal-table .attendance-form-desktop {
    display: none;
  }

  .rehearsal-table .attendance-mobile-details {
    display: block;
  }

  .rehearsal-table .attendance-mobile-details > summary {
    display: none;
    list-style: none;
  }

  .rehearsal-table .attendance-mobile-details > summary::-webkit-details-marker {
    display: none;
  }

  .rehearsal-table .attendance-target {
    background: #fff;
    border: 1px solid #e6e2dc;
    border-radius: 0.375rem;
    display: block;
    padding: 0.6rem 0.75rem;
  }

  .rehearsal-table .status-pill {
    box-sizing: border-box;
    font-size: 0.78rem;
    min-width: 0;
    padding: 0.15rem 0.35rem;
    width: 100%;
  }

  .rehearsal-table .attendance-status-field,
  .rehearsal-table .attendance-comment-field,
  .rehearsal-table .attendance-submit-field {
    flex: 0 0 100%;
    max-width: 100%;
    width: 100%;
  }

  .rehearsal-table .attendance-status-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .rehearsal-table .attendance-choice {
    font-size: 0.86rem;
    min-width: 0;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
    white-space: nowrap;
    width: 100%;
  }

  .rehearsal-table .attendance-form .form-control,
  .rehearsal-table .attendance-form .btn {
    width: 100%;
  }
}

@media (max-width: 992px) {
  .admin-menu {
    width: 100%;
  }

  .admin-menu summary {
    width: 100%;
  }

  .admin-menu-panel {
    margin-top: 0.5rem;
    position: static;
    width: 100%;
  }
}

@media (max-width: 360px) {
  .rehearsal-table tr {
    grid-template-columns: 5.8rem minmax(0, 1fr) 4.25rem;
  }

  .rehearsal-table td {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .rehearsal-table td:first-child {
    font-size: 0.76rem;
    padding-left: 0.4rem;
    padding-right: 0.35rem;
  }

  .rehearsal-table td:first-child .small,
  .rehearsal-table td[data-label="練習"] {
    font-size: 0.72rem;
  }

  .rehearsal-table .status-pill {
    font-size: 0.72rem;
  }
}
