.portal-sidebar__home {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.portal-symbols {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.portal-sidebar-backdrop {
  position: fixed;
  z-index: 45;
  inset: 0;
  border: 0;
  background: rgba(24, 25, 24, 0.62);
  opacity: 0;
  transition: opacity 220ms ease;
}

.portal-sidebar-backdrop.is-visible {
  opacity: 1;
}

.portal-modal-root {
  position: relative;
  z-index: 100;
}

.portal-skeleton {
  display: block;
  width: min(100%, 680px);
  border-radius: 14px;
  background: linear-gradient(90deg, #eceae5 25%, #f8f7f4 45%, #eceae5 65%);
  background-size: 220% 100%;
  animation: portal-skeleton-shimmer 1.25s ease-in-out infinite;
}

.portal-skeleton--title {
  height: 48px;
}

.portal-skeleton--card {
  height: 280px;
  margin-top: 22px;
}

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

.portal-message-screen {
  display: grid;
  min-height: 100dvh;
  align-content: center;
  justify-items: center;
  gap: 36px;
  padding: 32px 16px;
  background: var(--canvas);
}

.portal-message-screen > .auth-brand {
  position: static;
}

.portal-message-screen__card {
  width: min(100%, 560px);
  padding: clamp(28px, 5vw, 52px);
  border: 1px solid var(--border);
  border-radius: 28px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: center;
}

.portal-message-screen__card h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 58px);
  font-weight: 400;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.portal-message-screen__card > p:not(.portal-kicker) {
  max-width: 460px;
  margin: 18px auto 28px;
  color: var(--muted);
}

.portal-message-screen__card .portal-button {
  width: 100%;
  margin-top: 8px;
}

.portal-record-list {
  display: grid;
  gap: 12px;
}

.portal-record-card {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
}

.portal-record-card__icon {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  place-items: center;
  border-radius: 13px;
  color: var(--ink);
  background: var(--accent);
}

.portal-record-card__copy {
  min-width: 0;
  flex: 1 1 auto;
}

.portal-record-card__title {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.portal-record-card__title h2,
.portal-record-card__title h4 {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 17px;
  font-weight: 600;
}

.portal-record-card__copy > p {
  margin: 6px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 13px;
}

.portal-record-card__amount {
  flex: 0 0 auto;
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
}

.portal-record-card--payment {
  border-left: 4px solid var(--accent-strong);
}

.portal-document-record__notice {
  color: var(--danger) !important;
}

.portal-document-form .portal-field--wide,
.portal-document-form__error {
  grid-column: 1 / -1;
}

.portal-document-form__file {
  padding: 18px;
  border: 1px dashed #aeaca6;
  border-radius: 16px;
  background: var(--canvas-soft);
}

.portal-document-form__file input[type="file"] {
  min-height: 52px;
  padding: 5px;
  cursor: pointer;
}

.portal-document-form__file input[type="file"]::file-selector-button {
  min-height: 40px;
  margin-right: 12px;
  padding: 0 16px;
  border: 0;
  border-radius: 20px;
  color: #fff;
  background: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.portal-document-form__file input[type="file"]:hover::file-selector-button {
  color: var(--ink);
  background: var(--accent);
}

.portal-document-form__file-summary,
.portal-document-form__error {
  overflow-wrap: anywhere;
}

.portal-document-form__error {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--danger-bg);
}

.portal-dialog--document {
  width: min(720px, calc(100vw - 32px));
}

.portal-stage-page,
.portal-project-record,
.portal-user-list,
.portal-route--chat {
  min-width: 0;
}

.portal-message__attachment--image {
  display: grid;
  grid-template-columns: minmax(0, 180px) minmax(0, 1fr);
}

.portal-message__image {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 240px;
  justify-self: start;
  border-radius: 9px;
  object-fit: contain;
}

.portal-chat__loading {
  display: grid;
  min-height: 160px;
  place-items: center;
  color: var(--muted);
}

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

.portal-notification-item {
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  text-decoration: none;
}

.portal-notification-item.is-unread {
  border-color: var(--accent-strong);
  background: #fffaf0;
}

.portal-notification-item p,
.portal-notification-item time {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.portal-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.portal-pager__status {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.portal-chat-list__pager {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--canvas);
}

.portal-chat-list__pager .portal-button {
  min-width: 0;
  min-height: 44px;
  padding-inline: 14px;
}

.portal-native-progress {
  width: 100%;
  height: 7px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  appearance: none;
  background: #e5e1d9;
}

.portal-native-progress::-webkit-progress-bar {
  border-radius: inherit;
  background: #e5e1d9;
}

.portal-native-progress::-webkit-progress-value {
  border-radius: inherit;
  background: var(--accent);
  transition: inline-size 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.portal-native-progress::-moz-progress-bar {
  border-radius: inherit;
  background: var(--accent);
}

.portal-native-progress--on-dark,
.portal-native-progress--on-dark::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.18);
}

.portal-record-card__actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.portal-dialog--wide {
  width: min(920px, calc(100vw - 32px));
}

.portal-content-editor {
  display: grid;
  gap: 28px;
}

.portal-content-editor__section {
  display: grid;
  gap: 12px;
}

.portal-content-editor__section + .portal-content-editor__section {
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.portal-record-list--compact {
  gap: 8px;
}

.portal-record-list--compact .portal-record-card {
  padding: 14px;
}

.portal-empty-note {
  margin: 0;
  padding: 20px;
  border-radius: 14px;
  color: var(--muted);
  background: var(--canvas-soft);
}

.portal-chat__composer textarea {
  field-sizing: content;
}

/* Keep secondary timestamps readable at WCAG AA contrast on white cards. */
.portal-activity__copy time {
  color: var(--muted);
  font-size: 11px;
}

.portal-toast--error .portal-toast__icon {
  color: #fff;
  background: var(--danger);
}

@media (max-width: 767px) {
  .is-mobile-thread-open .portal-mobile-nav {
    display: none;
  }

  .is-mobile-thread-open .portal-main {
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }

  body.is-mobile-thread-open .portal-route--chat {
    bottom: calc(
      var(--portal-keyboard-offset, 0px)
      + 12px
      + env(safe-area-inset-bottom)
    );
  }

  body.is-mobile-thread-open .portal-route--chat > .portal-chat-shell {
    height: 100%;
    max-height: 100%;
    min-height: 0;
  }

  .portal-record-card {
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 15px;
  }

  .portal-record-card__amount {
    width: 100%;
    padding-left: 64px;
  }

  .portal-message__attachment--image {
    grid-template-columns: 1fr;
  }

  .portal-message__image {
    max-height: 320px;
  }

  .portal-record-card__actions {
    width: 100%;
    justify-content: stretch;
  }

  .portal-user > .portal-row-actions {
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
    flex-wrap: wrap;
    justify-content: stretch;
  }

  .portal-user > .portal-row-actions .portal-button {
    min-width: 0;
    flex: 1 1 120px;
    padding-inline: 14px;
  }

  .portal-pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .portal-pager__status {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .portal-record-card__actions .portal-button {
    flex: 1 1 140px;
  }

  .portal-content-editor__section .portal-card__head {
    align-items: stretch;
  }

  .portal-content-editor__section .portal-card__head .portal-button {
    width: 100%;
  }

  .portal-document-form__file {
    padding: 14px;
  }

  .portal-dialog--document {
    width: 100%;
    max-width: 100vw;
  }

  .portal-document-form__file input[type="file"]::file-selector-button {
    display: block;
    width: 100%;
    margin: 0 0 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portal-skeleton,
  .portal-sidebar-backdrop {
    animation: none;
    transition: none;
  }

  .portal-native-progress::-webkit-progress-value {
    transition: none;
  }
}
