/* Complete record creation dialogs. */
.record-create-dialog {
  width: min(920px, calc(100vw - 28px));
}

.record-create-dialog .compact-dialog {
  display: grid;
  gap: 14px;
}

.record-create-dialog .field-group:not(.project-name-field) {
  margin-top: 0;
}

.record-create-dialog .field-group {
  min-width: 0;
}

.record-create-dialog .field-group textarea {
  width: 100%;
  min-height: 104px;
  resize: vertical;
}

.record-create-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.record-create-wide {
  grid-column: 1 / -1;
}

.qa-create-grid textarea {
  min-height: 112px;
}

.record-create-dialog .dialog-actions {
  position: sticky;
  bottom: calc(clamp(19px, 4vw, 30px) * -1);
  z-index: 5;
  margin: 2px calc(clamp(19px, 4vw, 30px) * -1) calc(clamp(19px, 4vw, 30px) * -1);
  padding: 14px clamp(19px, 4vw, 30px) clamp(19px, 4vw, 30px);
  background: linear-gradient(to bottom, transparent, var(--app-bg-soft) 20%);
}

/* Aurora Night: authentic northern-light curtains, scoped to Aurora only. */
[data-theme=aurora] body {
  background-color: #070b19;
  background-image:
    linear-gradient(rgba(7, 11, 25, .7), rgba(7, 11, 25, .88)),
    url("../aurora-panorama.webp");
  background-position: center, center top;
  background-repeat: no-repeat;
  background-size: auto, max(1220px, 100vw) auto;
  background-attachment: fixed;
}

[data-theme=aurora] :is(
  .project-card,
  .continue-card,
  .capture-card,
  .project-section,
  .piece-card,
  .qa-card,
  .record-list > article,
  .milestone-list > article,
  .settings-card,
  .privacy-note,
  .empty-state,
  .studio-dialog-card
) {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

[data-theme=aurora] :is(
  .project-card,
  .continue-card,
  .capture-card,
  .project-section,
  .piece-card,
  .qa-card,
  .record-list > article,
  .milestone-list > article,
  .settings-card,
  .privacy-note,
  .empty-state,
  .studio-dialog-card
)::before {
  content: "";
  position: absolute;
  z-index: 0;
  pointer-events: none;
  width: clamp(260px, 58%, 560px);
  aspect-ratio: 3 / 2;
  top: -105px;
  right: -115px;
  background: url("../aurora-card-ribbon.webp") right top / contain no-repeat;
  opacity: .17;
  mix-blend-mode: screen;
}

[data-theme=aurora] :is(
  .project-card,
  .continue-card,
  .capture-card,
  .project-section,
  .piece-card,
  .qa-card,
  .record-list > article,
  .milestone-list > article,
  .settings-card,
  .privacy-note,
  .empty-state,
  .studio-dialog-card
) > * {
  position: relative;
  z-index: 1;
}

[data-theme=aurora] .theme-preview-aurora .theme-swatch {
  background:
    linear-gradient(110deg, rgba(7, 16, 36, .48), rgba(54, 201, 186, .22), rgba(154, 114, 234, .24)),
    url("../aurora-panorama.webp") center top / cover no-repeat;
}

/* Sakura Dream: local SVG botanicals remain behind readable surfaces. */
[data-theme=sakura] body {
  background-color: #f8f1ee;
  background-image:
    linear-gradient(rgba(248, 241, 238, .86), rgba(248, 241, 238, .86)),
    url("../sakura-petals-illustrated.webp"),
    url("../sakura-branch-illustrated.webp");
  background-position: center, center 12%, right -155px bottom -145px;
  background-repeat: no-repeat, no-repeat, no-repeat;
  background-size: auto, min(1180px, 94vw) auto, min(820px, 66vw) auto;
  background-attachment: scroll, fixed, fixed;
}

[data-theme=sakura] :is(
  .project-card,
  .continue-card,
  .capture-card,
  .project-section,
  .piece-card,
  .qa-card,
  .record-list > article,
  .milestone-list > article,
  .settings-card,
  .privacy-note,
  .empty-state,
  .studio-dialog-card
) {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background-color: rgba(255, 253, 252, .92);
}

[data-theme=sakura] :is(
  .project-card,
  .continue-card,
  .capture-card,
  .project-section,
  .piece-card,
  .qa-card,
  .record-list > article,
  .milestone-list > article,
  .settings-card,
  .privacy-note,
  .empty-state,
  .studio-dialog-card
)::before {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
  width: clamp(150px, 33%, 290px);
  aspect-ratio: 1.2;
  right: -48px;
  bottom: -45px;
  background: url("../sakura-cluster-illustrated.webp") right bottom / contain no-repeat;
  opacity: .2;
}

[data-theme=sakura] :is(
  .project-card,
  .continue-card,
  .capture-card,
  .project-section,
  .piece-card,
  .qa-card,
  .record-list > article,
  .milestone-list > article,
  .settings-card,
  .privacy-note,
  .empty-state,
  .studio-dialog-card
) > * {
  position: relative;
  z-index: 1;
}

[data-theme=sakura] :is(.project-section, .studio-dialog-card, .continue-card)::after {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
  width: clamp(280px, 50%, 520px);
  aspect-ratio: 12 / 7;
  left: -95px;
  top: -70px;
  background: url("../sakura-branch-illustrated.webp") left top / contain no-repeat;
  opacity: .12;
  transform: scaleX(-1);
}

[data-theme=sakura] .theme-preview-sakura .theme-swatch {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(110deg, rgba(255, 248, 244, .84), rgba(225, 140, 171, .72), rgba(146, 112, 197, .76)),
    url("../sakura-cluster-illustrated.webp") right -10px bottom -20px / 130px auto no-repeat;
}

@media (max-width: 760px) {
  .record-create-dialog {
    width: calc(100vw - 20px);
  }

  .record-create-grid {
    grid-template-columns: 1fr;
  }

  .record-create-wide {
    grid-column: auto;
  }

  .record-create-dialog .dialog-actions {
    bottom: -19px;
    margin: 2px -19px -19px;
    padding: 13px 19px 19px;
  }

  [data-theme=sakura] body {
    background-position: center, center top, right -185px bottom -110px;
    background-size: auto, 680px auto, 560px auto;
    background-attachment: scroll;
  }

  [data-theme=aurora] body {
    background-position: center, 64% top;
    background-size: auto, 940px auto;
    background-attachment: scroll;
  }

  [data-theme=aurora] :is(
    .project-card,
    .project-section,
    .piece-card,
    .qa-card,
    .record-list > article,
    .milestone-list > article,
    .studio-dialog-card
  )::before {
    width: 330px;
    top: -75px;
    right: -125px;
    opacity: .14;
  }

  [data-theme=sakura] :is(
    .project-card,
    .project-section,
    .piece-card,
    .qa-card,
    .record-list > article,
    .milestone-list > article,
    .studio-dialog-card
  )::before {
    width: 170px;
    right: -65px;
    bottom: -48px;
    opacity: .15;
  }
}

/* Guided first-run walkthrough and Settings help. */
.tour-layer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  isolation: isolate;
  color: var(--text);
}

.tour-layer.tour-centered {
  background: rgba(3, 6, 15, .76);
  backdrop-filter: blur(5px);
}

.tour-spotlight {
  position: fixed;
  z-index: 1;
  box-sizing: border-box;
  pointer-events: none;
  border: 2px solid var(--coral);
  border-radius: 20px;
  box-shadow:
    0 0 0 6px rgba(99, 230, 213, .12),
    0 0 0 9999px rgba(3, 6, 15, .76),
    0 18px 70px rgba(0, 0, 0, .34);
  transition: inset .24s ease, width .24s ease, height .24s ease;
}

[data-theme=sakura] .tour-spotlight {
  border-color: var(--coral-deep);
  box-shadow:
    0 0 0 6px rgba(178, 94, 128, .14),
    0 0 0 9999px rgba(48, 25, 36, .68),
    0 18px 70px rgba(70, 35, 51, .24);
}

.tour-card {
  position: fixed;
  z-index: 2;
  width: min(430px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 24px 24px 24px 8px;
  background: linear-gradient(145deg, var(--panel-raised), var(--panel));
  box-shadow: 0 28px 90px rgba(0, 0, 0, .42);
  padding: 24px;
  outline: none;
}

.tour-mobile-handle {
  display: none;
}

.tour-body {
  min-width: 0;
}

.tour-centered .tour-card {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.tour-card:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 4px;
}

.tour-card-top {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.tour-symbol {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--border-strong);
  border-radius: 15px 15px 15px 5px;
  color: var(--aurora-teal);
  background: var(--soft-gradient);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
}

.tour-progress-copy {
  min-width: 0;
}

.tour-progress-copy > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: 9px;
  font-weight: 850;
}

.tour-progress-track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line-soft);
}

.tour-progress-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--aurora-teal), var(--aurora-violet));
  transition: width .24s ease;
}

.tour-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--muted);
  background: var(--field);
  font-size: 22px;
  line-height: 1;
}

.tour-close:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.tour-card h2 {
  margin: 4px 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(24px, 4vw, 31px);
  font-weight: 500;
  line-height: 1.08;
}

.tour-copy {
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.65;
}

.tour-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}

.tour-actions > div {
  display: flex;
  gap: 9px;
}

.tour-actions button {
  min-height: 42px;
}

.feedback-grid .settings-card {
  align-content: start;
}

.bug-report-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: fit-content;
  margin-top: 2px;
  text-decoration: none;
}

.feedback-privacy {
  margin: 12px 0 0;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--text-soft);
  background: var(--field);
  font-size: 10px;
  line-height: 1.55;
}

@media (max-width: 760px) {
  [data-tour] {
    scroll-margin-top: 84px;
  }

  .tour-layer {
    overflow: hidden;
    touch-action: none;
  }

  .tour-layer.tour-centered {
    background: rgba(3, 6, 15, .72);
    backdrop-filter: blur(4px);
  }

  .tour-spotlight {
    border-radius: 16px;
    box-shadow:
      0 0 0 4px rgba(99, 230, 213, .12),
      0 0 0 9999px rgba(3, 6, 15, .70),
      0 12px 42px rgba(0, 0, 0, .28);
  }

  [data-theme=sakura] .tour-spotlight {
    box-shadow:
      0 0 0 4px rgba(178, 94, 128, .13),
      0 0 0 9999px rgba(48, 25, 36, .64),
      0 12px 42px rgba(70, 35, 51, .22);
  }

  .tour-card,
  .tour-centered .tour-card,
  .tour-layer:not(.tour-centered) .tour-card {
    inset: auto 0 0 !important;
    width: 100%;
    max-height: min(68dvh, 520px);
    margin: 0;
    padding: 0 16px max(14px, env(safe-area-inset-bottom));
    overflow: hidden;
    transform: none;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 24px 24px 0 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    touch-action: pan-y;
    overscroll-behavior: contain;
    box-shadow: 0 -18px 54px rgba(0, 0, 0, .42);
  }

  .tour-mobile-handle {
    display: block;
    width: 44px;
    height: 4px;
    margin: 9px auto 8px;
    border-radius: 999px;
    background: var(--border-strong);
  }

  .tour-card-top {
    grid-template-columns: 38px minmax(0, 1fr) 34px;
    gap: 10px;
    margin-bottom: 11px;
  }

  .tour-symbol {
    width: 38px;
    height: 38px;
    border-radius: 13px 13px 13px 5px;
    font-size: 18px;
  }

  .tour-progress-copy > span {
    margin-bottom: 5px;
    font-size: 8px;
  }

  .tour-close {
    width: 34px;
    height: 34px;
  }

  .tour-body {
    min-height: 0;
    overflow: auto;
    padding: 0 2px 3px;
    overscroll-behavior: contain;
  }

  .tour-body .eyebrow {
    font-size: 9px;
  }

  .tour-card h2 {
    margin: 4px 0 8px;
    font-size: clamp(22px, 7vw, 27px);
    line-height: 1.08;
  }

  .tour-copy {
    font-size: 12.5px;
    line-height: 1.55;
  }

  .tour-actions {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line-soft);
  }

  .tour-actions > div {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .tour-actions > div > :only-child {
    grid-column: 1 / -1;
  }

  .tour-actions button {
    min-height: 40px;
    white-space: nowrap;
  }

  .tour-actions > .quiet-button {
    padding-inline: 8px;
  }
}

@media (max-width: 350px) {
  .tour-card {
    max-height: min(72dvh, 500px);
    padding-inline: 12px;
  }

  .tour-actions {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .tour-actions > .quiet-button {
    min-height: 34px;
  }

  .tour-actions button {
    width: 100%;
  }
}

@media (max-width: 760px) and (max-height: 640px) {
  .tour-card,
  .tour-centered .tour-card,
  .tour-layer:not(.tour-centered) .tour-card {
    max-height: 74dvh;
  }

  .tour-mobile-handle {
    margin-block: 7px 6px;
  }

  .tour-card-top {
    margin-bottom: 8px;
  }

  .tour-card h2 {
    font-size: 21px;
  }

  .tour-copy {
    font-size: 12px;
  }

  .tour-actions {
    margin-top: 9px;
    padding-top: 9px;
  }

  .tour-actions button {
    min-height: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tour-spotlight,
  .tour-progress-track i {
    transition: none;
  }
}
