/* Media queries e ajustes responsivos.
   Extraído de style.css na Fase 6 sem alterar regras visuais. */

@media (max-width: 1099px) {
  html,
  body {
    height: auto;
    min-height: 100%;
  }

  html {
    overflow-x: hidden;
  }

  body {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 0;
    padding: 0;
    background: var(--glass-header);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(112%);
    backdrop-filter: blur(var(--glass-blur)) saturate(112%);
  }

  .header-moon {
    display: none !important;
  }

  html[data-theme="night"] .daily-track {
    padding-right: 0;
  }

  .environment-overlay-layer .leaf-3,
  .environment-overlay-layer .leaf-4,
  .environment-overlay-layer .leaf-11,
  .environment-overlay-layer .leaf-12 {
    display: none;
  }

  .brand {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    min-height: 64px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: 10px;
  }

  .brand-title {
    font-size: 12px;
    letter-spacing: 0.06em;
    white-space: nowrap;
  }

  .live-info {
    grid-column: 2;
    grid-row: 1;
    flex: 0 0 auto;
    min-height: 64px;
    padding-left: 8px;
    padding-right: max(12px, env(safe-area-inset-right));
    gap: 8px;
  }

  .daily-strip {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 38px;
    padding: 8px max(14px, env(safe-area-inset-left));
    border: 0;
    border-top: 1px solid rgba(248, 240, 218, 0.16);
  }

  .daily-track {
    gap: 10px;
    font-size: 12px;
  }

  .daily-label {
    font-size: 8px;
  }

  .shell {
    width: 100%;
    min-width: 0;
    height: auto;
    grid-template-columns: minmax(0, 1fr);
  }

  .decor {
    max-width: 100%;
    height: auto;
  }

  .col-left,
  .col-center,
  .col-right {
    width: 100%;
    min-width: 0;
    overflow: visible;
    border: 0;
  }

  .col-left,
  .col-right {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .col-center {
    min-height: 0;
    padding: 12px max(16px, env(safe-area-inset-right)) 22px max(16px, env(safe-area-inset-left));
    border-top: 1px solid var(--stroke);
    border-bottom: 1px solid var(--stroke);
    scroll-margin-top: 68px;
  }

  .feelings-grid,
  .feeling {
    min-width: 0;
  }

  .feeling {
    min-height: 56px;
    padding-inline: 13px;
    overflow-wrap: normal;
  }

  .feelings-heading {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .feelings-heading-icon {
    width: 32px;
    height: 32px;
  }

  .feelings-grid {
    margin-top: 22px;
  }

  .primary-feeling-control {
    margin-top: 28px;
  }

  .radio {
    min-height: 44px;
    padding: 8px 4px;
  }

  .radio input {
    width: 18px;
    height: 18px;
  }

  .primary {
    min-height: 50px;
    font-size: 12.5px;
    letter-spacing: 0.04em;
    white-space: normal;
  }

  .tip-box {
    min-height: 96px;
  }

  .center-top {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .center-top .ghost {
    min-height: 44px;
    min-width: 0;
    padding-inline: 8px;
    white-space: normal;
  }

  .center-top #newBtn {
    grid-column: auto;
  }

  .center-card {
    overflow: visible;
    padding-inline: 12px;
    background-size: auto, 100% auto;
    background-position: center, center bottom;
  }

  .quote-stage {
    min-height: 0;
    width: 100%;
  }

  .quote-content {
    padding: 44px 34px 38px;
  }

  .quote {
    font-size: clamp(24px, 3.7vw, 29px);
  }

  .quote.long-quote {
    font-size: clamp(22px, 3.25vw, 26px);
  }

  .quote-action {
    width: 44px;
    height: 44px;
    line-height: 44px;
  }

  .block-text,
  .block-text.small,
  .philosophy-block .block-text,
  .book-rec {
    max-height: none;
  }

  .col-right {
    min-height: 0;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }

  .right-ambient-space {
    display: none;
  }

  .explore-card {
    min-height: 82px;
  }

  .full {
    min-height: 48px;
  }

  .favorites-dialog {
    width: calc(100% - 20px);
    max-width: calc(100% - 20px);
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    padding: 16px;
  }

  .tale-dialog {
    position: fixed;
    inset: 12px auto auto 12px;
    width: calc(100vw - 24px) !important;
    min-width: 0 !important;
    max-width: calc(100vw - 24px) !important;
    height: calc(100vh - 24px);
    height: calc(100dvh - 24px);
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    margin: 0;
    padding: 14px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: auto;
  }

  .tale-dialog[open] {
    display: block;
  }

  .tale-dialog .favorites-head {
    position: sticky;
    top: -14px;
    z-index: 3;
    flex-wrap: nowrap;
    gap: 10px;
    margin: -14px -14px 0;
    padding: 14px 14px 12px;
    background: var(--bg);
  }

  .tale-dialog .favorites-head > div {
    flex: 1 1 220px;
    min-width: 0;
  }

  .tale-title-row {
    display: flex;
    flex-wrap: wrap;
    min-width: 0;
  }

  #taleTitle,
  .tale-meta span,
  .tale-text,
  .tale-lesson {
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .tale-content {
    display: block;
    flex: none;
    min-height: 0;
    max-height: none;
    overflow: visible;
    padding-right: 2px;
    touch-action: auto;
  }

  .tale-meta {
    margin-bottom: 12px;
  }

  .tale-text {
    font-size: 16px;
    line-height: 1.68;
  }

  .tale-lesson {
    margin-top: 10px;
    padding: 12px;
  }

  .favorites-list {
    max-height: calc(100dvh - 170px);
  }
}

@media (max-width: 520px) {
  .brand-icon {
    width: 40px;
    height: 46px;
    flex-basis: 40px;
  }

  .environment-overlay-layer .leaf-2,
  .environment-overlay-layer .leaf-7,
  .environment-overlay-layer .leaf-13,
  .environment-overlay-layer .leaf-14 {
    display: none;
  }

  .environment-overlay-layer .leaf-1 {
    top: 88%;
    left: 3%;
    opacity: 0.26;
  }

  .daily-viewport {
    overflow: hidden;
    white-space: nowrap;
  }

  .brand {
    gap: 12px;
    padding-right: 6px;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .brand-raven {
    width: 64px;
    transform: translateX(-8px);
  }

  .brand-title {
    font-size: 12px;
  }

  .brand-subtitle {
    margin-top: 2px;
    font-size: 10px;
  }

  .live-info {
    gap: 5px;
    padding-left: 4px;
    padding-right: max(8px, env(safe-area-inset-right));
  }

  .online-counter {
    font-size: 9px;
  }

  .online-counter span {
    font-size: 18px;
  }

  .focus-feeling-btn {
    min-height: 44px;
    padding-inline: 12px;
  }

  .col-right {
    padding-top: 26px;
  }

  .side-section-title {
    margin-bottom: 14px;
    font-size: 16px;
  }

  .explore-cards {
    gap: 9px;
  }

  .explore-card {
    grid-template-columns: 34px minmax(0, 1fr) auto auto;
    min-height: 76px;
    padding: 12px 14px;
    gap: 10px;
  }

  .explore-card-icon svg {
    width: 30px;
    height: 30px;
  }

  .explore-card-title {
    font-size: 15.5px;
  }

  .explore-card-description {
    font-size: 12.5px;
  }

  .share-block {
    margin-top: 24px;
  }

  .emotional-synthesis-summary {
    padding-top: 12px;
  }

  .synthesis-human-summary {
    font-size: 13.5px;
    line-height: 1.6;
  }

  .section-title {
    font-size: 15px;
  }

  .section-subtitle {
    font-size: 12.5px;
  }

  .feeling {
    grid-template-columns: 21px minmax(0, 1fr);
    gap: 12px;
    padding-inline: 13px;
  }

  .feeling-icon {
    width: 21px;
    height: 21px;
  }

  .feelings-heading {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .feelings-heading-icon {
    width: 30px;
    height: 30px;
  }

  .tip-box {
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 14px;
  }

  .tip-icon {
    width: 24px;
    height: 24px;
  }

  .feeling-label {
    font-size: 12.5px;
  }

}

@media (min-width: 901px) and (max-width: 1400px) {
  .center-card {
    padding: 16px 20px 24px;
  }

  .quote-stage {
    width: 100%;
  }

  .quote-content {
    padding: 42px 42px 36px;
  }

  .quote {
    font-size: clamp(26px, 2.15vw, 31px);
  }

  .quote.long-quote {
    font-size: clamp(24px, 1.85vw, 26px);
  }

  .quote.quote-microtext {
    font-size: clamp(21px, 1.65vw, 24px);
  }
}

@media (max-width: 520px) {
  .center-card {
    padding: 16px 0 24px;
  }

  .quote-stage {
    width: 100%;
  }

  .quote-content,
  .quote-content:has(.quote.invitation) {
    padding: 22px 26px 34px;
  }

  .quote-ornament {
    position: static;
    width: 100%;
    height: 22px;
    margin: -2px 0 4px;
    justify-self: start;
    font-size: 32px;
    line-height: 0.86;
  }

  .firefly-7,
  .firefly-8,
  .firefly-9,
  .firefly-10 {
    display: none;
  }

  .quote,
  .quote.invitation {
    font-size: clamp(21px, 6.2vw, 25px);
  }

  .quote.long-quote {
    font-size: clamp(20px, 5.7vw, 23px);
  }

  .quote-author {
    margin-top: 20px;
    font-size: 15px;
  }

  .block,
  .book-rec {
    padding-inline: 4px;
  }

  .philosophy-block {
    padding-left: 22px;
  }

  .philosophy-block::before {
    left: 4px;
  }

  .block-title,
  .book-rec-label {
    font-size: 13px;
  }

  .block-text {
    font-size: 14px;
  }

  #adviceText {
    font-size: 16px;
  }

  .book-rec-title {
    font-size: 17px;
  }
}

@media (max-width: 380px) {
  .topbar {
    min-height: 98px;
  }

  .brand-icon {
    width: 36px;
    height: 42px;
    flex-basis: 36px;
  }

  .brand-title {
    font-size: 11px;
  }

  .live-info > span {
    display: none;
  }

  .col-center {
    scroll-margin-top: 60px;
  }

  .feelings-grid {
    gap: 7px;
  }

  .center-fixed {
    font-size: 16px;
  }

  .quote-stage {
    min-height: 0;
  }

  .quote-content {
    padding-inline: 26px;
  }
}

/* Densidade adaptativa da aplicação desktop. O breakpoint por largura mantém
   tablets e smartphones no fluxo normal do documento. */
@media (min-width: 1101px) {
  .col-center {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .col-center > .decor {
    bottom: 0;
    max-height: 100%;
  }

  .center-top .ghost {
    min-height: 44px;
  }
}

@media (min-width: 1101px) and (min-height: 760px) and (max-height: 959px) {
  .environment-tree {
    inset: 0;
    width: 100%;
    height: 100%;
  }

  .col-left {
    padding: 8px 18px;
  }

  .col-right {
    padding: 12px 18px;
  }

  .side-section-title {
    margin-bottom: 10px;
    font-size: 16px;
  }

  .explore-cards {
    gap: 8px;
  }

  .explore-card {
    grid-template-columns: 32px minmax(0, 1fr) auto auto;
    min-height: 80px;
    padding: 10px 14px;
    gap: 10px;
  }

  .explore-card-icon svg {
    width: 29px;
    height: 29px;
  }

  .explore-card-title {
    font-size: 15px;
  }

  .explore-card-description {
    font-size: 12px;
    line-height: 1.32;
  }

  .share-block {
    margin-top: 18px;
  }

  .share-guidance {
    font-size: 12.5px;
  }

  .share-actions,
  .share-style-picker {
    margin-top: 9px;
  }

  .share-style-option {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }

  .share-compatibility-note {
    margin-top: 6px;
  }

  .col-center {
    padding: 10px 20px 16px;
    gap: 8px;
  }

  .feelings-heading {
    grid-template-columns: 29px minmax(0, 1fr);
    gap: 9px;
  }

  .feelings-heading-icon {
    width: 29px;
    height: 29px;
  }

  .section-title {
    font-size: 14px;
  }

  .section-subtitle {
    margin-top: 3px;
    font-size: 11.5px;
    line-height: 1.3;
  }

  .feelings-grid {
    margin-top: 10px;
    gap: 7px;
  }

  .feeling {
    min-height: 48px;
    padding: 5px 10px;
    grid-template-columns: 20px minmax(0, 1fr);
    gap: 9px;
  }

  .feeling-icon {
    width: 20px;
    height: 20px;
  }

  .feeling-label {
    font-size: 12px;
  }

  .primary-feeling-control {
    margin-top: 10px;
    font-size: 11px;
  }

  .primary {
    min-height: 48px;
    margin-top: 10px;
    padding-block: 10px;
    font-size: 12px;
  }

  .content-load-status,
  .selection-hint {
    min-height: 14px;
    margin-top: 3px;
    font-size: 10px;
  }

  .tip {
    margin-top: 8px;
  }

  .tip-box {
    min-height: 62px;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 10px;
    padding: 9px 12px;
    font-size: 12px;
    line-height: 1.35;
  }

  .tip-icon {
    width: 22px;
    height: 22px;
  }

  .center-card {
    padding: 12px 16px 18px;
  }

  .quote-content {
    padding: 32px clamp(28px, 2.4vw, 36px) 30px;
  }

  .quote-ornament {
    top: 17px;
    left: clamp(28px, 2.4vw, 36px);
    font-size: 31px;
  }

  .quote {
    font-size: clamp(26px, 2.05vw, 31px);
    line-height: 1.38;
  }

  .quote.long-quote {
    font-size: clamp(22px, 1.75vw, 26px);
    line-height: 1.44;
  }

  .quote.quote-microtext {
    font-size: clamp(19px, 1.55vw, 23px);
    line-height: 1.48;
  }

  .quote-author {
    margin-top: 16px;
    font-size: 15px;
  }

  .quote-source {
    margin-top: 6px;
    font-size: 12.5px;
  }

  .quote-author:empty + .quote-source:not([hidden]) {
    margin-top: 16px;
  }

  .divider {
    margin: 18px 6% 0;
  }

  .block {
    padding: 14px 6% 16px;
  }

  .block-title,
  .book-rec-label {
    margin-bottom: 7px;
    font-size: 13px;
  }

  .block-text,
  .book-rec {
    font-size: 14px;
    line-height: 1.5;
  }

  .book-rec {
    padding: 14px 6% 16px;
  }

  .book-rec-title {
    margin-top: 7px;
    font-size: 17px;
  }

  .book-rec-why {
    margin-top: 7px;
    line-height: 1.52;
  }

  #adviceText {
    padding-left: 14px;
    font-size: 16px;
    line-height: 1.5;
  }
}

@media (min-width: 1101px) and (max-height: 759px) {
  .environment-tree {
    inset: 0;
    width: 100%;
    height: 100%;
  }

  .firefly {
    animation-duration: 8s;
  }
  .col-left,
  .col-right {
    padding: 8px 14px;
  }

  .col-center {
    padding: 7px 16px 10px;
    gap: 6px;
  }

  .side-section-title {
    margin-bottom: 8px;
    font-size: 15px;
  }

  .explore-cards {
    gap: 6px;
  }

  .explore-card {
    grid-template-columns: 30px minmax(0, 1fr) auto auto;
    min-height: 70px;
    padding: 8px 12px;
    gap: 9px;
  }

  .explore-card-icon svg {
    width: 27px;
    height: 27px;
  }

  .explore-card-title {
    font-size: 14.5px;
  }

  .explore-card-description {
    font-size: 11.5px;
    line-height: 1.25;
  }

  .share-block {
    margin-top: 12px;
  }

  .share-guidance {
    font-size: 12px;
  }

  .share-actions,
  .share-style-picker {
    margin-top: 7px;
  }

  .share-style-option {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
  }

  .share-compatibility-note,
  .share-status {
    margin-top: 4px;
    font-size: 10px;
    line-height: 1.25;
  }

  .feelings-heading {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 8px;
  }

  .feelings-heading-icon {
    width: 28px;
    height: 28px;
  }

  .section-title {
    font-size: 13px;
  }

  .section-subtitle {
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.25;
  }

  .feelings-grid {
    margin-top: 8px;
    gap: 7px;
  }

  .feeling {
    min-height: 48px;
    padding: 6px 10px;
    grid-template-columns: 20px minmax(0, 1fr);
    gap: 9px;
  }

  .feeling-icon {
    width: 20px;
    height: 20px;
  }

  .feeling-label {
    font-size: 12px;
  }

  .primary-feeling-control {
    margin-top: 8px;
    font-size: 10.5px;
  }

  .primary {
    min-height: 48px;
    margin-top: 8px;
    padding-block: 9px;
    font-size: 11.5px;
  }

  .content-load-status,
  .selection-hint {
    min-height: 12px;
    margin-top: 2px;
    font-size: 9.5px;
    line-height: 1.25;
  }

  .tip {
    margin-top: 6px;
  }

  .tip-box {
    min-height: 55px;
    grid-template-columns: 20px minmax(0, 1fr);
    gap: 8px;
    padding: 7px 10px;
    font-size: 11.5px;
    line-height: 1.3;
  }

  .tip-icon {
    width: 20px;
    height: 20px;
  }

  .center-top {
    padding-top: 1px;
    padding-bottom: 6px;
  }

  .center-card {
    padding: 9px 12px 14px;
  }

  .quote-content {
    padding: 28px 28px 26px;
  }

  .quote-ornament {
    top: 14px;
    left: 28px;
    font-size: 28px;
  }

  .quote {
    font-size: clamp(24px, 1.95vw, 28px);
    line-height: 1.38;
  }

  .quote.long-quote {
    font-size: clamp(21px, 1.68vw, 24px);
    line-height: 1.44;
  }

  .quote.quote-microtext {
    font-size: clamp(19px, 1.48vw, 22px);
    line-height: 1.48;
  }

  .quote-author {
    margin-top: 13px;
    font-size: 14px;
  }

  .quote-source {
    margin-top: 5px;
    font-size: 12px;
  }

  .divider {
    margin: 14px 6% 0;
  }

  .block,
  .book-rec {
    padding: 11px 6% 13px;
  }

  .block-title,
  .book-rec-label {
    margin-bottom: 6px;
    font-size: 12.5px;
  }

  .block-text,
  .book-rec {
    font-size: 13.5px;
    line-height: 1.48;
  }

  .book-rec-title {
    margin-top: 6px;
    font-size: 16px;
  }

  .book-rec-why {
    margin-top: 6px;
    line-height: 1.48;
  }

  #adviceText {
    padding-left: 12px;
    font-size: 15px;
    line-height: 1.48;
  }
}
