.formulary-body {
  min-height: 100dvh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.85rem 0.75rem calc(6.8rem + env(safe-area-inset-bottom));
  background-color: var(--bg);
  /* background: linear-gradient(180deg, #ffffff 0%, #f4fbfa 100%); */
  color: var(--fg);
}

.formulary-header {
  width: min(760px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.slogan-bottom,
.slogan-top {
  width: 102px;
  text-align: center;
  padding: 0.4rem 0;
  font-size: 1.08rem;
  font-weight: bold;
}

.slogan-top {
  background-color: var(--blue);
  color: var(--fg);
  border-radius: 10px 10px 0 10px;
  transform: translateX(0%);
  animation: 2s anime-slogan-top ease;
}

.slogan-bottom {
  background-color: var(--yellow);
  color: var(--fg);
  transform: translateX(30%);
  border-radius: 0 10px 10px 10px;
  animation: 2s anime-slogan-bottom ease;
}

.slogan-legend {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.slogan-legend span {
  font-size: 0.92rem;
  font-weight: bold;
  color: var(--fg);
}

.formulary-main {
  width: min(760px, 100%);
  flex: 1;
}

.formulary-form {
  width: 100%;
  display: grid;
  gap: 0.75rem;
}

.box {
  border: solid 1px var(--blue);
  border-radius: 14px;
  padding: 0.85rem;
  display: grid;
  gap: 0.5rem;
  width: 100%;
  background-color: var(--bg);
  box-shadow: 0 8px 24px #002f340f;
}

.box legend {
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg);
  padding: 0 0.45rem;
}

.box input,
.box textarea {
  background-color: #ffffff;
  width: 100%;
  min-height: 2.75rem;
  font-size: 0.98rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg);
  outline: none;
  padding: 0 0.75rem;
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease;
}

.box textarea {
  min-height: 120px;
  padding: 0.7rem 0.75rem;
  resize: vertical;
}

.box input::placeholder,
.box textarea::placeholder {
  color: #6e7f82;
}

.box input:focus-visible,
.box textarea:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px #97d8ce59;
}

.box label {
  color: var(--fg);
  font-size: 0.9rem;
  font-weight: 500;
}

.media-box {
  gap: 0.75rem;
}

.media-help {
  font-size: 0.82rem;
  color: #4f6366;
  line-height: 1.35;
}

.media-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

.media-trigger {
  min-height: 48px;
  border: 1px dashed #7fb3aa;
  background: #f2fbf9;
  color: var(--fg);
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0 0.75rem;
  cursor: pointer;
  transition:
    transform 120ms ease,
    filter 120ms ease,
    border-color 120ms ease;
}

.media-trigger:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.media-trigger:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
  border-color: var(--fg);
}

.media-trigger i {
  font-size: 1rem;
}

.media-preview-group {
  display: grid;
  gap: 0.4rem;
}

.media-label {
  display: flex;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--fg);
}

.media-counts {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  font-weight: 700;
}

.media-counts span {
  color: #587276;
  background-color: #eef6f5;
  border: 1px solid #d7e8e7;
  border-radius: 999px;
  padding: 0.14rem 0.48rem;
}

.media-preview {
  min-height: 76px;
  border: 1px dashed #b8c8ca;
  border-radius: 12px;
  background: #fbfefe;
  padding: 0.45rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.media-empty {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 0.78rem;
  color: #6f8184;
  align-self: center;
}

.media-thumb {
  margin: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #dde8e8;
  background: #ffffff;
}

.media-thumb img {
  width: 100%;
  aspect-ratio: 1.45 / 1;
  object-fit: cover;
  display: block;
}

.media-thumb figcaption {
  font-size: 0.7rem;
  padding: 0.3rem 0.35rem;
  color: #4e6366;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-source {
  font-size: 0.68rem;
  padding: 0.18rem 0.34rem 0;
  color: #446568;
  font-weight: 700;
  text-transform: uppercase;
}

.location-actions {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.2rem;
}

.location-trigger {
  min-height: 44px;
}

.location-status {
  font-size: 0.8rem;
  color: #587276;
  line-height: 1.35;
}

.location-status.is-success {
  color: #2d6b46;
}

.location-status.is-error {
  color: #b8434d;
}

.formulary-footer {
  /* bottom: calc(0.65rem + env(safe-area-inset-bottom)); */
  width: calc(100% - 1rem);
  /* width: min(370px, calc(100% - 1rem)); */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  border-radius: 16px;
  border: 1px solid #ffffffcc;
  /* background: linear-gradient(180deg, #ffffffed 0%, #f4fbfadb 100%); */
  background-color: transparent;
  box-shadow: 0 14px 36px #002f3433;
}

.action-btn {
  border: 1px solid transparent;
  width: calc(100% - 3rem);
  min-height: 52px;
  padding: 0.4rem 0.25rem;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--fg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  cursor: pointer;
  box-shadow: 0 8px 16px #002f3421;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    filter 140ms ease;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 24px #002f3430;
  filter: saturate(1.05);
}

.action-btn:active {
  transform: translateY(0);
  box-shadow: 0 8px 14px #002f341e;
}

.action-btn:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.action-btn i {
  font-size: 1.05rem;
  line-height: 1;
}

.action-btn span {
  line-height: 1.05;
}

.action-download {
  background: linear-gradient(180deg, #dbe2ff 0%, #c8d3ff 100%);
  border-color: #a4b3ee;
}

.action-send {
  /* background: linear-gradient(180deg, #e3f8cf 0%, #d0efb1 100%); */
  background-color: var(--blue);
}

.action-send i {
  font-size: 2rem;
}

.action-clear {
  background: linear-gradient(180deg, #ffdfe2 0%, #f8c3c8 100%);
  border-color: #e69ea7;
}

@media (min-width: 560px) {
  .formulary-body {
    padding-right: 1rem;
    padding-left: 1rem;
    gap: 1rem;
  }

  .formulary-header {
    gap: 1rem;
  }

  .slogan-legend span {
    font-size: 0.98rem;
  }

  .media-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .media-preview-group {
    gap: 0.5rem;
  }

  .formulary-footer {
    width: min(500px, calc(100% - 2rem));
    gap: 0.45rem;
  }

  .action-btn {
    min-height: 56px;
    font-size: 0.76rem;
  }
}

@media (min-width: 900px) {
  .formulary-body {
    padding-bottom: calc(7.2rem + env(safe-area-inset-bottom));
  }

  .formulary-footer {
    width: min(620px, calc(100% - 3rem));
  }

  .action-btn {
    flex-direction: row;
    gap: 0.35rem;
    font-size: 0.84rem;
  }
}

.pdf-status {
  position: fixed;
  left: 50%;
  bottom: calc(5.4rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(560px, calc(100% - 1.5rem));
  text-align: center;
  font-size: 0.78rem;
  color: #436064;
  background-color: #ffffffd9;
  border: 1px solid #d8e5e6;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  box-shadow: 0 6px 18px #002f3417;
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.pdf-status.is-visible {
  opacity: 1;
}

.pdf-status.is-error {
  color: #a33e47;
}

@keyframes anime-slogan-top {
  0% {
    transform: translateX(30%);
  }

  100% {
    transform: translateX(0%);
  }
}

@keyframes anime-slogan-bottom {
  0% {
    transform: translateX(0%);
  }

  100% {
    transform: translateX(30%);
  }
}
