.dreams-page {
  color: var(--white-warm);
  background: #080c16;
}

.dreams-shell {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
  padding: clamp(1rem, 4vw, 3rem) clamp(1rem, 4vw, 3rem) 11rem;
}

.starfield {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.ambient-star {
  position: absolute;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: rgba(245, 240, 235, 0.78);
  opacity: var(--opacity);
  animation: twinkle var(--duration) ease-in-out infinite alternate;
}

.dreams-header,
.dream-sky {
  position: relative;
  z-index: 1;
  width: min(100%, 1120px);
  margin-inline: auto;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  margin-bottom: clamp(1rem, 3vw, 1.75rem);
  color: rgba(245, 240, 235, 0.72);
  text-decoration: none;
}

.dreams-header__main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  align-items: end;
}

.dreams-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 8vw, 4.8rem);
  font-weight: 600;
  line-height: 1.14;
  text-wrap: balance;
}

.dreams-status {
  min-height: 1.7rem;
  margin: 0.85rem 0 0;
  color: rgba(245, 240, 235, 0.62);
  font-family: var(--font-mono);
  font-size: 0.84rem;
}

.dreams-toggle,
.dream-primary,
.dream-secondary,
.dream-danger,
.dream-icon-button {
  min-height: 2.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition:
    opacity 160ms ease-out,
    transform 160ms ease-out,
    background 160ms ease-out;
}

.dreams-toggle,
.dream-secondary,
.dream-icon-button {
  border: 1px solid rgba(245, 240, 235, 0.16);
  color: var(--white-warm);
  background: rgba(245, 240, 235, 0.07);
}

.dream-primary {
  border: 1px solid rgba(204, 168, 91, 0.78);
  padding: 0 1rem;
  color: #14120d;
  background: #d9b66f;
}

.dream-danger {
  border: 1px solid rgba(192, 57, 43, 0.62);
  padding: 0 1rem;
  color: var(--white-warm);
  background: rgba(192, 57, 43, 0.22);
}

.dreams-toggle {
  padding: 0 1rem;
}

.dream-secondary {
  padding: 0 1rem;
}

.dreams-toggle:hover,
.dream-primary:hover,
.dream-secondary:hover,
.dream-danger:hover,
.dream-icon-button:hover {
  transform: translateY(-1px);
}

.dream-sky {
  min-height: min(58vh, 38rem);
  margin-top: clamp(1.5rem, 5vw, 3rem);
}

.dream-stars {
  position: relative;
  min-height: min(58vh, 38rem);
}

.dream-star {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--star-size);
  height: var(--star-size);
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: #fff8dd;
  box-shadow: 0 0 0.7rem rgba(255, 248, 221, 0.72);
  cursor: pointer;
  transform: translate(-50%, -50%);
  animation: starArrive 700ms ease-out both;
}

.dream-star.is-faded {
  opacity: 0.32;
  width: calc(var(--star-size) * 0.78);
  height: calc(var(--star-size) * 0.78);
}

.dream-star.is-her {
  background: #d8e7ff;
  box-shadow: 0 0 0.75rem rgba(216, 231, 255, 0.68);
}

.dream-detail,
.dream-list-panel {
  position: fixed;
  z-index: var(--z-toast);
  inset-block-start: max(1rem, env(safe-area-inset-top));
  inset-inline-end: max(1rem, env(safe-area-inset-right));
  width: min(calc(100% - 2rem), 25rem);
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  padding: 1rem;
  border: 1px solid rgba(245, 240, 235, 0.16);
  border-radius: 8px;
  background: rgba(12, 16, 27, 0.96);
}

.dream-detail__top,
.dream-list-panel__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.dream-detail h2,
.dream-list-panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
}

.dream-icon-button {
  width: 2.75rem;
  flex: 0 0 auto;
  font-size: 1.35rem;
  line-height: 1;
}

.dream-detail__meta,
.dream-detail__faded,
.dream-list__meta {
  margin: 0.7rem 0 0;
  color: rgba(245, 240, 235, 0.58);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.dream-detail__content {
  margin: 1rem 0 0;
  color: rgba(245, 240, 235, 0.86);
  text-wrap: pretty;
  overflow-wrap: anywhere;
}

.dream-detail__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.dream-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.dream-list article {
  padding: 0.85rem;
  border: 1px solid rgba(245, 240, 235, 0.12);
  border-radius: 8px;
  background: rgba(245, 240, 235, 0.05);
}

.dream-list p {
  margin: 0.5rem 0 0;
  color: rgba(245, 240, 235, 0.82);
  overflow-wrap: anywhere;
}

.dream-list__actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.7rem;
}

.dream-composer {
  position: fixed;
  z-index: var(--z-floating);
  inset-inline: max(1rem, env(safe-area-inset-left)) max(1rem, env(safe-area-inset-right));
  inset-block-end: max(1rem, env(safe-area-inset-bottom));
  width: min(calc(100% - 2rem), 58rem);
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.65rem;
  padding: 0.75rem;
  border: 1px solid rgba(245, 240, 235, 0.16);
  border-radius: 8px;
  background: rgba(12, 16, 27, 0.96);
}

.author-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
}

.author-switch label {
  display: grid;
  place-items: center;
  min-height: 2.4rem;
  border: 1px solid rgba(245, 240, 235, 0.14);
  border-radius: 8px;
  color: rgba(245, 240, 235, 0.68);
  cursor: pointer;
}

.author-switch input {
  position: absolute;
  opacity: 0;
}

.author-switch label:has(input:checked) {
  color: #14120d;
  background: var(--white-warm);
}

.dream-input-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.dream-composer textarea {
  width: 100%;
  min-height: 4.5rem;
  max-height: 10rem;
  border: 1px solid rgba(245, 240, 235, 0.16);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  color: var(--white-warm);
  background: rgba(15, 15, 35, 0.52);
  resize: vertical;
}

.dream-composer textarea[aria-invalid="true"] {
  border-color: rgba(192, 57, 43, 0.78);
}

.dream-composer__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
}

.dream-form-error {
  flex: 1;
  min-height: 1.4rem;
  margin: 0;
  color: #e6b0a6;
  font-size: 0.84rem;
}

.dream-toast {
  position: fixed;
  z-index: var(--z-toast);
  inset-inline: 1rem;
  inset-block-end: calc(max(1rem, env(safe-area-inset-bottom)) + 9rem);
  max-width: 26rem;
  margin-inline: auto;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(245, 240, 235, 0.16);
  border-radius: 8px;
  color: var(--white-warm);
  background: rgba(12, 16, 27, 0.96);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity 180ms ease-out,
    transform 180ms ease-out;
}

.dream-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes twinkle {
  from {
    opacity: calc(var(--opacity) * 0.45);
  }

  to {
    opacity: var(--opacity);
  }
}

@keyframes starArrive {
  from {
    opacity: 0;
    transform: translate(-50%, 8rem) scale(0.6);
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@media (min-width: 760px) {
  .dreams-header__main {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .dream-composer {
    grid-template-columns: 8rem minmax(0, 1fr) auto;
    align-items: end;
  }

  .dream-composer__actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ambient-star,
  .dream-star,
  .dream-toast,
  .dreams-toggle,
  .dream-primary,
  .dream-secondary,
  .dream-danger,
  .dream-icon-button {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
