/* modal — dialog over a dimmed page; bottom sheet on phones */
.modal {
  position: fixed;
  z-index: 150;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gutter);
  background: rgb(20 24 17 / 0.6);
}

.modal__window {
  display: flex;
  flex-direction: column;
  width: min(100%, 520px);
  max-height: 100%;
}

.modal__window--wide {
  width: min(100%, 760px);
}

.modal__body {
  overflow: auto;
}

@media (max-width: 560px) {
  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal__window {
    width: 100%;
    max-height: 92dvh;
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* toast — transient notifications */
.toasts {
  position: fixed;
  z-index: 300;
  right: var(--gutter);
  bottom: max(var(--gutter), env(safe-area-inset-bottom));
  left: var(--gutter);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--sp-3);
  pointer-events: none;
}

.toast {
  max-width: min(100%, 420px);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid;
  border-color: var(--bevel-raised);
  background: var(--c-bg);
  box-shadow: 2px 2px 0 var(--c-shade);
  pointer-events: auto;
  animation: toast-in 0.15s ease-out;
}

.toast--error {
  color: var(--c-error);
}

.toast--success {
  color: var(--c-ok);
}

@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
}

/* notice — inline message box */
.notice {
  display: flex;
  gap: var(--sp-4);
  align-items: flex-start;
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid;
  border-color: var(--bevel-sunken);
  background: var(--c-bg-sunken);
}

.notice + .notice {
  margin-top: var(--sp-3);
}

.notice__mark {
  flex: none;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  font-weight: 700;
  font-size: var(--fs-s);
}

.notice__body {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.notice__title {
  font-weight: 700;
}

.notice__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

.notice--error .notice__mark { color: var(--c-error); }
.notice--warning .notice__mark { color: var(--c-warn); }
.notice--info .notice__mark { color: var(--c-info); }
.notice--success .notice__mark { color: var(--c-ok); }

/* badge — small label */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 var(--sp-3);
  border: 1px solid;
  border-color: var(--bevel-sunken);
  background: var(--c-bg-sunken);
  color: var(--c-text-dim);
  font-size: var(--fs-xs);
  line-height: 16px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge--accent { color: var(--c-accent); }
.badge--ok { color: var(--c-ok); }
.badge--warn { color: var(--c-warn); }
.badge--error { color: var(--c-error); }
.badge--info { color: var(--c-info); }

/* empty — placeholder for empty lists / errors */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-7) var(--sp-5);
  color: var(--c-text-dim);
  text-align: center;
}

.empty__icon {
  width: 64px;
  height: 64px;
  opacity: 0.8;
  filter: sepia(0.64) grayscale(0.32);
}

.empty__title {
  color: var(--c-text);
  font-size: var(--fs-l);
}

/* spinner — inline busy indicator */
.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--c-text-faint);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* skeleton blocks while loading */
.skeleton {
  min-height: 72px;
  border: 1px solid;
  border-color: var(--bevel-raised);
  background: linear-gradient(90deg, var(--c-bg) 0%, #56624c 50%, var(--c-bg) 100%) 0 0 / 200% 100%;
  animation: skeleton 1.4s ease-in-out infinite;
}

@keyframes skeleton {
  to { background-position: -200% 0; }
}
