
/* —— v3 sang-opdager —— */

html, body {
  height: 100%;
  overflow: hidden;
}

.app-root {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.screen-host {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen-inner-v3 {
  max-width: 36rem;
  width: 100%;
}

.screen-sub {
  margin: -0.5rem 0 1.25rem;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.45;
}

.inline-status {
  margin-top: 0.75rem;
  font-size: 0.88rem;
  color: var(--muted);
  text-align: center;
}

.prefetch-hint {
  margin-top: 0.5rem;
}

.explore-resume-hint {
  margin: 0.75rem 0;
}

.explore-resume-btn {
  margin: 0.5rem 0 1rem;
}

.v3-directions {
  margin-bottom: 1rem;
}

.v3-directions__label {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.v3-directions__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
}

.v3-direction-btn {
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border-radius: 50%;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

.v3-direction-btn:hover,
.v3-direction-btn:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.05);
}

.v3-direction-btn--active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 0 0 2px rgba(201, 168, 124, 0.35);
}

.explore-textarea {
  min-height: 7rem;
  text-align: left;
  margin-bottom: 0;
  resize: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.explore-textarea::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.screen-host.is-explore-screen,
.screen-host.is-document-screen,
.screen-host.is-alignment-screen,
.screen-host.is-result-screen {
  align-items: stretch;
  justify-content: flex-start;
  min-height: 0;
  padding-top: var(--screen-chrome-top);
  padding-bottom: var(--screen-chrome-bottom);
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.screen-host.is-explore-screen,
.screen-host.is-document-screen,
.screen-host.is-alignment-screen,
.screen-host.is-result-screen {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.screen-inner-explore,
.screen-inner-document,
.screen-inner-alignment,
.screen-inner-result.screen-inner-result--clean {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  flex: 1 1 0%;
  align-self: stretch;
  max-height: 100%;
}

.explore-layout,
.v3-document-layout,
.alignment-layout,
.result-layout {
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  min-height: 0;
  width: 100%;
}

.explore-scroll,
.result-scroll {
  flex: 1 1 auto;
  min-height: min(28vh, 12rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.v3-document-scroll {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.alignment-main {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.alignment-reading-host {
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.alignment-scroll {
  flex: 1 1 0%;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.explore-footer,
.v3-document-footer,
.alignment-footer,
.result-footer {
  flex-shrink: 0;
  width: 100%;
  padding: 0.85rem 0 calc(0.35rem + env(safe-area-inset-bottom, 0));
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--bg-shift, #0d1a30);
}

.screen-inner-document {
  max-width: 42rem;
  width: 100%;
  margin-inline: auto;
  text-align: left;
}

.screen-render-error {
  margin: 1rem auto;
  max-width: 36rem;
  padding: 0.85rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.screen-inner-explore {
  max-width: min(42rem, calc(100vw - 2.5rem));
  width: 100%;
  margin-inline: auto;
}

.explore-header {
  flex-shrink: 0;
  padding-bottom: 0.75rem;
}

.explore-scroll {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  padding-bottom: 0.5rem;
  flex: 1 1 auto;
}

.explore-scroll > .explore-input-wrap {
  flex: 1 1 auto;
  min-height: 7rem;
  display: flex;
  flex-direction: column;
}

.explore-footer .btn-row-explore {
  margin-top: 0;
}

.screen-inner-explore .screen-title {
  flex-shrink: 0;
  margin-bottom: 1rem;
}

.screen-inner-explore .v3-directions {
  flex-shrink: 0;
  margin-bottom: 0.75rem;
}

.explore-input-wrap {
  flex: 1 1 auto;
  min-height: 7rem;
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  margin-bottom: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.explore-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.explore-input-wrap .explore-textarea {
  display: block;
  width: 100%;
  flex: 0 0 auto;
  min-height: 7rem;
  max-height: none;
  height: auto;
  box-sizing: border-box;
  padding: 0.85rem 3.25rem 0.85rem 1rem;
  margin-bottom: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  resize: none;
}

.explore-input-wrap .explore-textarea:focus {
  outline: none;
  border: none;
  box-shadow: none;
}

.btn-row-explore {
  flex-shrink: 0;
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
}

.btn-row-explore .btn-primary {
  width: auto;
  min-width: 10rem;
  max-width: min(100%, 16rem);
  padding-inline: 2.25rem;
}

@media (min-width: 768px) {
  .screen-inner-explore {
    max-width: min(56rem, calc(100vw - 2.5rem));
  }

  .screen-inner-alignment,
  .screen-inner-result.screen-inner-result--clean {
    max-width: min(52rem, calc(100vw - 2.5rem));
  }
}

@media (min-width: 1100px) {
  .screen-inner-explore {
    max-width: min(62rem, calc(100vw - 3rem));
  }

  .screen-inner-document {
    max-width: min(92rem, calc(100vw - 2.5rem));
  }

  .screen-inner-alignment,
  .screen-inner-result.screen-inner-result--clean {
    max-width: min(56rem, calc(100vw - 3rem));
  }
}

.v3-document-layout {
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  min-height: 0;
  gap: 0;
  width: 100%;
}

.v3-document {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex: 1 1 0%;
  min-height: 0;
}

.v3-doc-section {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.v3-doc-section__title {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 600;
  flex-shrink: 0;
}

.v3-doc-section__body {
  width: 100%;
  box-sizing: border-box;
  min-height: 7.5rem;
  padding: 0.85rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: none;
  overflow-y: hidden;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 168, 124, 0.55) rgba(0, 0, 0, 0.2);
  text-align: left;
}

.v3-document-scroll {
  flex: 1 1 0%;
  min-height: 0;
  padding-bottom: 0.5rem;
}

.v3-document-footer {
  margin-top: 0;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  border-top: none;
  background: transparent;
  padding: 0.75rem 0 0.65rem;
}

.v3-doc-section__body::-webkit-scrollbar {
  width: 8px;
}

.v3-doc-section__body::-webkit-scrollbar-thumb {
  background: rgba(201, 168, 124, 0.4);
  border-radius: 4px;
}

.v3-doc-section__body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

@media (min-width: 768px) and (min-height: 560px) {
  .screen-inner-document {
    max-width: min(88rem, calc(100vw - 2.5rem));
  }

  .v3-document-scroll {
    display: flex;
    flex-direction: column;
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: hidden;
  }

  .v3-document {
    display: grid;
    gap: 1.25rem 1.15rem;
    align-items: stretch;
    align-content: stretch;
    flex: 1 1 0%;
    min-height: 0;
    min-width: 0;
    width: 100%;
    height: 100%;
  }

  .v3-doc-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }

  .v3-doc-section__body {
    flex: 1 1 0%;
    min-height: 0;
    height: 100%;
    max-height: none;
  }
}

@media (min-width: 768px) and (min-height: 560px) and (max-width: 1099.98px) {
  .v3-document {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) and (min-height: 560px) {
  .v3-document {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: 1fr;
  }
}

@media (max-width: 767.98px), (max-height: 559.98px) {
  .v3-document {
    flex: 0 1 auto;
    min-height: 0;
  }

  .v3-doc-section {
    display: flex;
    flex-direction: column;
  }

  .v3-doc-section__body {
    min-height: 7.5rem;
    height: auto;
    max-height: none;
    overflow-y: hidden;
  }
}

.btn-row-document {
  margin-top: 0;
  padding: 0;
  background: none;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 2.75rem;
}

.v3-document-footer .btn-row-document {
  margin-top: 0;
}

.btn-document-continue {
  width: auto;
  align-self: center;
  padding: 0.65rem 1.1rem;
  font-size: 0.92rem;
  white-space: nowrap;
  min-width: 5.5rem;
}

@media (min-width: 768px) {
  body.is-document-screen .contact-fab {
    left: 1.25rem;
  }

  body.is-document-screen:has(.contact-fab) .team-chat-fab {
    left: calc(1.25rem + 3.25rem + 0.65rem);
  }

  body.is-document-screen:has(.team-chat-fab) .donate-fab {
    left: calc(1.25rem + (3.25rem + 0.65rem) * 2);
  }

  body.is-document-screen:has(.donate-fab) .links-panel-fab {
    left: calc(1.25rem + (3.25rem + 0.65rem) * 3);
  }
}

.output-sub {
  margin: -0.35rem 0 1.1rem;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.45;
  text-align: center;
}

.output-action-btn {
  padding: 0.65rem 1.15rem;
  font-size: 0.92rem;
  text-align: center;
}

.idea-textarea {
  resize: none;
  line-height: var(--idea-input-line-height);
  font-family: inherit;
  color: var(--text);
  box-sizing: border-box;
  overflow-y: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.idea-input-wrap .idea-textarea {
  min-height: var(--idea-input-min-height);
  padding: var(--idea-input-pad-block) 3.25rem var(--idea-input-pad-block) 1.25rem;
  font-size: var(--idea-input-font-size);
  text-align: left;
}

body.is-loading .donation-overlay {
  z-index: var(--z-chrome-panel);
}

body.is-loading .links-panel-overlay {
  z-index: var(--z-chrome-panel);
}

.app-screen-prompt {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(10, 22, 40, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: consent-fade-in 280ms ease;
}

.app-screen-prompt.is-closing {
  animation: consent-fade-out 300ms ease forwards;
}

.app-screen-prompt__actions .btn-ghost.output-action-btn {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.22);
}

.result-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem max(1.25rem, env(safe-area-inset-bottom));
  background: rgba(10, 22, 40, 0.85);
}

body.has-ui-preview-banner .result-overlay {
  padding-top: calc(2rem + 0.75rem);
}

.result-overlay__card {
  width: 100%;
  max-width: min(54rem, calc(100vw - 2rem));
  max-height: min(calc(100dvh - 3rem), 56rem);
  min-height: min(22rem, calc(100dvh - 8rem));
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem 1.1rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.result-overlay__ai-notice {
  margin: 0 0 0.65rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
  border-left: 3px solid var(--accent);
  background: rgba(201, 168, 124, 0.08);
  border-radius: 0 6px 6px 0;
}

.result-overlay__ai-notice--fallback {
  color: #f0d4b8;
  border-left-color: #e88;
  background: rgba(180, 60, 60, 0.12);
}

.result-overlay__editor {
  flex: 1 1 auto;
  min-height: 12rem;
  max-height: none;
  width: 100%;
  padding: 0.85rem 1rem;
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: none;
  margin-bottom: 0.65rem;
}

.result-overlay__actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.result-overlay__actions .btn-primary,
.result-overlay__actions .btn-ghost {
  width: auto;
  padding: 0.45rem 0.9rem;
  font-size: 0.8125rem;
  font-weight: 600;
}

.result-overlay__actions .btn-primary {
  box-shadow: 0 0 10px rgba(212, 132, 90, 0.32);
}

.loading-overlay {
  background: rgba(8, 14, 26, 0.62);
}

/* Song Identity overlay */
.identity-overlay-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(10, 22, 40, 0.88);
}

body.identity-overlay-open {
  overflow: hidden;
}

.identity-overlay-card {
  width: 100%;
  max-width: min(28rem, calc(100vw - 2rem));
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.identity-overlay__question {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text);
}

.identity-overlay__block + .identity-overlay__block {
  margin-top: 1.25rem;
}

.identity-overlay__options {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.identity-overlay__option {
  text-align: left;
  padding: 0.55rem 0.75rem;
  font: inherit;
  color: var(--text);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.identity-overlay__option::before {
  display: inline-block;
  width: 1.1rem;
  color: var(--muted);
  content: '○';
}

.identity-overlay__option.is-recommended::before {
  color: var(--accent);
  content: '●';
}

.identity-overlay__option.is-selected {
  border-color: var(--accent);
  background: rgba(201, 168, 124, 0.12);
}

.identity-overlay__option.is-recommended.is-selected {
  box-shadow: 0 0 0 1px rgba(201, 168, 124, 0.25);
}

.identity-overlay__ok {
  margin-top: 1.25rem;
  width: 100%;
}

/* Short viewports — tighter chrome so flow screens keep a usable scroll region */
@media (max-height: 520px) {
  .screen-host.is-explore-screen,
  .screen-host.is-document-screen,
  .screen-host.is-alignment-screen,
  .screen-host.is-result-screen {
    --screen-chrome-bottom: calc(
      5rem + var(--toolbar-h) + var(--fab-clearance) + env(safe-area-inset-bottom, 0px)
    );
    padding-bottom: var(--screen-chrome-bottom);
  }

  .explore-footer,
  .alignment-footer,
  .result-footer {
    padding-top: 0.45rem;
    padding-bottom: calc(0.15rem + env(safe-area-inset-bottom, 0px));
  }

  .v3-document-footer {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
  }

  .explore-header {
    padding-bottom: 0.35rem;
  }

  .screen-inner-explore .screen-title {
    margin-bottom: 0.5rem;
    font-size: clamp(1.15rem, 4vw, 1.35rem);
  }

  .screen-inner-explore .v3-directions {
    margin-bottom: 0.35rem;
  }

  .explore-scroll {
    gap: 0.55rem;
  }

  .explore-input-wrap {
    margin-bottom: 0;
  }

  .explore-scroll,
  .v3-document-scroll,
  .result-scroll {
    min-height: min(22vh, 8rem);
  }

  .alignment-main {
    min-height: 0;
    flex: 1 1 0%;
  }

  .alignment-reading-host {
    min-height: 0;
  }

  .alignment-scroll {
    max-height: none;
  }
}

@media (max-height: 520px) and (min-aspect-ratio: 401/300) {
  .explore-scroll,
  .v3-document-scroll,
  .result-scroll {
    min-height: 0;
    flex: 1 1 0%;
  }

  .alignment-main {
    min-height: 0;
    flex: 1 1 0%;
  }

  .alignment-reading-host {
    min-height: 0;
    flex: 0 1 auto;
  }

  .alignment-scroll {
    min-height: 0;
    max-height: none;
    flex: 1 1 0%;
  }

  .explore-header,
  .alignment-header {
    padding-bottom: 0.35rem;
  }

  .screen-inner-explore .screen-title,
  .screen-inner-alignment .screen-title {
    margin-bottom: 0.35rem;
    font-size: clamp(1.05rem, 3.5vw, 1.25rem);
  }

  .result-arrival__title {
    font-size: clamp(1.15rem, 4vw, 1.45rem);
    margin-bottom: 0.45rem;
  }

  .result-arrival__lead {
    font-size: 0.88rem;
    line-height: 1.45;
  }

  .result-footer {
    padding-top: 0.35rem;
    padding-bottom: calc(0.1rem + env(safe-area-inset-bottom, 0px));
  }

  .result-prompt-outputs .output-actions {
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .screen-inner-result .output-action-btn {
    width: auto;
    min-width: 0;
    flex: 1 1 6.5rem;
    font-size: 0.82rem;
    padding: 0.45rem 0.55rem;
  }
}

/* Short viewports — compact document fields on desktop */
@media (max-height: 500px) {
  @media (min-width: 768px) {
    .v3-doc-section__body {
      flex: 1 1 0%;
      min-height: 4.5rem;
      max-height: none;
      height: 100%;
    }
  }
}
