.life-flower-modal {
  --lf-page: #f5f0e6;
  --lf-surface: #faf7f0;
  --lf-selected: #eef0e6;
  --lf-olive: #687257;
  --lf-olive-dark: #4f5942;
  --lf-text: #3d392f;
  --lf-muted: #978a78;
  --lf-border: #ddd3c3;
  --lf-divider: rgba(112, 96, 72, 0.14);
  position: fixed;
  inset: 0;
  z-index: 10080;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(34, 29, 23, 0.54);
  backdrop-filter: blur(10px);
}

.life-flower-modal.hidden { display: none; }

/* 360's legacy Chromium does not reliably resolve fixed dialogs from inset alone. */
html.browser-360 .life-flower-modal {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  min-height: 100vh !important;
}

.life-flower-dialog {
  width: min(1240px, 96vw);
  max-height: 94vh;
  overflow: hidden;
  border: 1px solid rgba(116, 91, 60, 0.2);
  border-radius: 26px;
  background: var(--lf-page);
  color: var(--lf-text);
  box-shadow: 0 32px 90px rgba(30, 22, 15, 0.28);
  display: flex;
  flex-direction: column;
}

.life-flower-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 24px 30px;
  border-bottom: 1px solid var(--lf-divider);
  background: linear-gradient(135deg, #f9f5ed, #eee4d4);
}

.life-flower-header span,
.life-flower-preview-heading span {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: #897050;
}

.life-flower-header h2 {
  margin: 5px 0 2px;
  font-family: "Noto Serif SC", serif;
  font-size: 28px;
  font-weight: 600;
}

.life-flower-header p { margin: 0; color: #7c6a55; }
.life-flower-header-actions { display: flex; align-items: center; gap: 8px; }

.life-flower-header-actions button {
  border: 1px solid rgba(105, 81, 55, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  padding: 9px 15px;
  color: #5d4b37;
}

.life-flower-header-actions .life-flower-close {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 24px;
}

.life-flower-body {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 0.75fr);
  min-height: 0;
  overflow: auto;
}

.life-flower-editor {
  position: relative;
  padding: 26px 28px 30px;
  background: var(--lf-surface);
}

.life-flower-section {
  position: relative;
  margin: 0 0 30px;
  padding: 0 0 0 52px;
  border: 0;
  background: transparent;
}

.life-flower-section:last-child { margin-bottom: 0; }

.life-flower-section:not(:last-child)::after {
  content: "";
  position: absolute;
  z-index: 0;
  top: 32px;
  bottom: -30px;
  left: 15.5px;
  width: 1px;
  background: var(--lf-divider);
}

.life-flower-step {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 32px;
  margin-bottom: 14px;
}

.life-flower-step i {
  position: absolute;
  z-index: 1;
  top: 0;
  left: -52px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  box-sizing: border-box;
  border: 1px solid var(--lf-border);
  border-radius: 50%;
  background: var(--lf-surface);
  color: var(--lf-muted);
  font-style: normal;
  font-size: 12px;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.life-flower-section.is-current .life-flower-step i {
  border-color: var(--lf-olive);
  background: var(--lf-olive);
  color: #faf7f0;
}

.life-flower-section.is-complete .life-flower-step i {
  border-color: rgba(104, 114, 87, 0.55);
  background: var(--lf-selected);
  color: var(--lf-olive-dark);
  font-size: 12px;
}

.life-flower-step > div { display: grid; gap: 4px; min-width: 0; }
.life-flower-step strong { color: var(--lf-text); font-size: 16px; font-weight: 600; line-height: 1.35; }
.life-flower-step small { color: var(--lf-muted); font-size: 12px; line-height: 1.45; }

.life-flower-step > button {
  flex: none;
  margin-left: auto;
  border: 1px solid var(--lf-border);
  border-radius: 999px;
  background: rgba(245, 240, 230, 0.8);
  padding: 7px 13px;
  color: #665541;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.life-flower-step > button:hover { border-color: rgba(104, 114, 87, 0.35); background: var(--lf-selected); }
.life-flower-step > button:disabled { cursor: not-allowed; opacity: 0.48; }
.life-flower-step > button.hidden { display: none; }

.life-flower-type-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  height: 68px;
  overflow: hidden;
  border: 1px solid var(--lf-border);
  border-radius: 14px;
  background: rgba(250, 247, 240, 0.34);
}

.life-flower-type-grid button {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 10px 16px;
  text-align: left;
  color: var(--lf-text);
  box-shadow: none;
  transition: background-color 150ms ease, color 150ms ease;
}

.life-flower-type-grid button + button { border-left: 1px solid var(--lf-divider); }
.life-flower-type-grid button:hover { background: rgba(238, 240, 230, 0.5); }
.life-flower-type-grid button.active { background: var(--lf-selected); color: var(--lf-olive-dark); box-shadow: none; }
.life-flower-type-grid strong { font-size: 16px; font-weight: 600; line-height: 1.2; white-space: nowrap; }
.life-flower-type-grid small { color: var(--lf-muted); font-size: 12px; line-height: 1.2; white-space: nowrap; }
.life-flower-type-grid button.active small { color: #737a65; }

.life-flower-choice-check {
  position: absolute;
  top: 8px;
  right: 10px;
  color: var(--lf-olive);
  font-size: 11px;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 150ms ease, transform 150ms ease;
}

.life-flower-type-grid button.active .life-flower-choice-check { opacity: 1; transform: scale(1); }

.life-flower-members { display: grid; gap: 12px; }

.life-flower-member-card {
  position: relative;
  display: block;
  padding: 42px 14px 14px;
  border: 1px solid rgba(221, 211, 195, 0.86);
  border-radius: 14px;
  background: rgba(245, 240, 230, 0.58);
  box-shadow: none;
}

.life-flower-member-card.matched { border-color: rgba(104, 114, 87, 0.26); background: rgba(238, 240, 230, 0.58); }

.life-flower-member-index {
  position: absolute;
  top: 15px;
  left: 15px;
  color: #80694e;
  font-family: Georgia, serif;
  font-size: 13px;
  letter-spacing: 0.1em;
  line-height: 1;
}

.life-flower-member-tools {
  position: absolute;
  top: 10px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.life-flower-member-details { position: relative; color: var(--lf-muted); font-size: 11px; }
.life-flower-member-details summary { cursor: pointer; list-style: none; padding: 4px; }
.life-flower-member-details summary::-webkit-details-marker { display: none; }

.life-flower-member-details code {
  position: absolute;
  z-index: 4;
  top: calc(100% + 5px);
  right: 0;
  display: block;
  width: max-content;
  max-width: min(320px, 70vw);
  overflow: hidden;
  border: 1px solid var(--lf-border);
  border-radius: 8px;
  background: #fffdf9;
  padding: 7px 9px;
  color: #756854;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(74, 62, 44, 0.08);
}

.life-flower-member-tools > button {
  border: 0;
  background: transparent;
  padding: 4px;
  color: #9b6b60;
  font-size: 11px;
}

.life-flower-member-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.life-flower-member-card label { display: grid; gap: 6px; color: #84725f; font-size: 12px; }

.life-flower-member-card input,
.life-flower-member-card select {
  width: 100%;
  min-width: 0;
  height: 44px;
  box-sizing: border-box;
  border: 1px solid rgba(151, 138, 120, 0.28);
  border-radius: 10px;
  outline: 0;
  background: rgba(255, 253, 249, 0.82);
  padding: 0 12px;
  color: var(--lf-text);
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.life-flower-member-card input:hover,
.life-flower-member-card select:hover { border-color: rgba(104, 114, 87, 0.38); }

#lifeFlowerModal .life-flower-member-card input:focus,
#lifeFlowerModal .life-flower-member-card select:focus {
  border-color: var(--lf-olive);
  background: #fffdf9;
  box-shadow: 0 0 0 3px rgba(104, 114, 87, 0.09);
}

.life-flower-match-result {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px 14px;
  margin-top: 12px;
  border: 1px solid rgba(221, 211, 195, 0.72);
  border-radius: 10px;
  background: rgba(250, 247, 240, 0.76);
  padding: 10px 12px;
}

.life-flower-member-card.matched .life-flower-match-result { background: rgba(238, 240, 230, 0.78); }
.life-flower-match-result span { color: var(--lf-olive-dark); font-family: "Noto Serif SC", serif; font-size: 14px; font-weight: 600; white-space: nowrap; }
.life-flower-match-result p { min-width: 0; margin: 0; color: #7b735f; font-size: 12px; line-height: 1.5; }

.life-flower-style-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.life-flower-style-grid button {
  position: relative;
  display: flex;
  min-width: 0;
  height: 104px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--lf-border);
  border-radius: 14px;
  background: rgba(250, 247, 240, 0.3);
  padding: 13px 15px;
  text-align: left;
  color: var(--lf-text);
  box-shadow: none;
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.life-flower-style-grid button:hover { background: rgba(238, 240, 230, 0.5); border-color: rgba(104, 114, 87, 0.35); }

.life-flower-style-grid button.active {
  border: 1.5px solid var(--lf-olive);
  background: linear-gradient(145deg, #f3f4ec, #e8ecdd);
  box-shadow: 0 8px 24px rgba(74, 62, 44, 0.05);
}

.life-flower-style-grid span { color: #98805f; font-size: 9px; letter-spacing: 0.12em; white-space: nowrap; }
.life-flower-style-grid strong { max-width: calc(100% - 22px); font-size: 16px; font-weight: 600; white-space: nowrap; }
.life-flower-style-grid small { max-width: 100%; overflow: hidden; color: var(--lf-muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.life-flower-style-check {
  position: absolute;
  top: 11px;
  right: 11px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  box-sizing: border-box;
  border: 1px solid var(--lf-border);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  font-style: normal;
  font-size: 10px;
}

.life-flower-style-grid button.active .life-flower-style-check { border-color: var(--lf-olive-dark); background: var(--lf-olive-dark); color: #faf7f0; }

.life-flower-orientation-heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 15px;
  color: var(--lf-text);
}

.life-flower-orientation-heading strong { font-size: 13px; font-weight: 600; }
.life-flower-orientation-heading small { color: var(--lf-muted); font-size: 11px; }

.life-flower-orientation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }

.life-flower-orientation-grid button {
  display: grid;
  min-height: 52px;
  gap: 3px;
  border: 1px solid var(--lf-border);
  border-radius: 12px;
  background: rgba(250, 247, 240, 0.34);
  padding: 9px 11px;
  color: #4c4034;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.life-flower-orientation-grid button:hover { background: rgba(238, 240, 230, 0.5); }
.life-flower-orientation-grid button.active { border-color: var(--lf-olive); background: var(--lf-selected); }
.life-flower-orientation-grid small { color: var(--lf-muted); font-size: 10px; }

.life-flower-type-grid button:focus-visible,
.life-flower-style-grid button:focus-visible,
.life-flower-orientation-grid button:focus-visible,
.life-flower-footer button:focus-visible,
.life-flower-step > button:focus-visible {
  outline: 2px solid rgba(104, 114, 87, 0.45);
  outline-offset: 2px;
}

.life-flower-type-grid button:disabled,
.life-flower-style-grid button:disabled,
.life-flower-orientation-grid button:disabled { cursor: not-allowed; opacity: 0.46; }

.life-flower-preview {
  padding: 30px;
  background: linear-gradient(160deg, #e8dfd0, #d9cbb8);
  border-left: 1px solid rgba(106, 83, 56, 0.14);
  overflow: auto;
}

.life-flower-preview-heading { padding-bottom: 18px; border-bottom: 1px solid rgba(86, 65, 42, 0.16); }
.life-flower-preview-heading h3 { margin: 7px 0 4px; font-family: "Noto Serif SC", serif; font-size: 29px; font-weight: 500; }
.life-flower-preview-heading p { margin: 0; color: #77634c; }
.life-flower-preview-members { display: grid; gap: 10px; margin-top: 20px; }
.life-flower-preview-members article { display: grid; grid-template-columns: 58px 1fr; gap: 13px; align-items: center; padding: 13px; border-radius: 16px; background: rgba(255, 252, 246, 0.65); border: 1px solid rgba(96, 74, 49, 0.12); }
.life-flower-preview-members article.waiting { opacity: 0.65; }
.life-flower-glyph { position: relative; display: grid; place-items: center; width: 56px; height: 56px; border: 1px solid rgba(102, 112, 80, 0.5); border-radius: 50%; }
.life-flower-glyph::before,
.life-flower-glyph::after,
.life-flower-glyph i::before,
.life-flower-glyph i::after { content: ""; position: absolute; inset: 8px 18px; border: 1px solid rgba(112, 120, 90, 0.45); border-radius: 50%; }
.life-flower-glyph::after { transform: rotate(90deg); }
.life-flower-glyph i::before { transform: rotate(45deg); }
.life-flower-glyph i::after { transform: rotate(-45deg); }
.life-flower-glyph span { position: relative; z-index: 1; font-family: Georgia, serif; font-size: 13px; color: #5d654d; }
.life-flower-preview-members article > div:last-child { display: grid; grid-template-columns: 1fr auto; gap: 1px 8px; }
.life-flower-preview-members small { color: #816d55; }
.life-flower-preview-members strong { grid-column: 1; font-family: "Noto Serif SC", serif; font-size: 20px; }
.life-flower-preview-members em { grid-column: 2; grid-row: 1/3; align-self: center; font-style: normal; font-size: 11px; color: #8d775b; }
.life-flower-preview-members p { grid-column: 1/-1; margin: 3px 0 0; color: #687055; font-size: 12px; }
.life-flower-preview-note { margin: 18px 2px 0; color: #786750; font-size: 11px; }
.life-flower-empty { padding: 40px 0; color: #897862; text-align: center; }
.life-flower-glyph img { position: relative; z-index: 2; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.life-flower-preview-members.hidden { display: none; }

.life-flower-footer {
  position: relative;
  z-index: 5;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  border-top: 1px solid var(--lf-divider);
  background: rgba(250, 247, 240, 0.97);
  box-shadow: 0 -8px 24px rgba(74, 62, 44, 0.035);
}

.life-flower-footer p { margin: 0; color: #786955; font-size: 12px; line-height: 1.5; }
.life-flower-footer p.error { color: #8e5f4f; }
.life-flower-footer-copy { display: grid; gap: 2px; min-width: 0; }
.life-flower-footer .life-flower-pricing { color: #596249; font-weight: 600; }
.life-flower-footer-copy a { width: max-content; color: #8b5d3d; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.life-flower-footer-copy a.hidden { display: none; }
.life-flower-footer-actions { display: flex; gap: 8px; }

.life-flower-footer button {
  height: 48px;
  border: 0;
  border-radius: 999px;
  background: var(--lf-olive);
  padding: 0 28px;
  color: #faf7f0;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 150ms ease, opacity 150ms ease;
}

.life-flower-footer button:hover:not(:disabled) { background: #747f62; }
.life-flower-footer button:disabled { cursor: not-allowed; background: #c8c4b8; color: #f4f0e8; opacity: 1; }
.life-flower-footer #lifeFlowerGenerate { background: var(--lf-olive-dark); }
.life-flower-footer #lifeFlowerGenerate:hover:not(:disabled) { background: #5d684e; }
.life-flower-footer #lifeFlowerSave { background: var(--lf-olive); }

.life-flower-generating { display: grid; place-items: center; gap: 10px; margin-top: 26px; padding: 35px 24px; border-radius: 18px; background: rgba(255, 252, 246, 0.62); text-align: center; }
.life-flower-generating i { width: 34px; height: 34px; border: 3px solid rgba(101, 109, 83, 0.22); border-top-color: #656d53; border-radius: 50%; animation: life-flower-spin 0.9s linear infinite; }
.life-flower-generating p { margin: 0; color: #786955; font-size: 12px; line-height: 1.6; }
@keyframes life-flower-spin { to { transform: rotate(360deg); } }

.life-flower-artwork-card { display: grid; gap: 12px; margin-top: 20px; }
.life-flower-artwork-card > img { display: block; width: 100%; max-height: 52vh; object-fit: contain; border-radius: 18px; background: #252721; box-shadow: 0 16px 32px rgba(65, 49, 31, 0.17); }
.life-flower-artwork-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.life-flower-artwork-meta span { padding: 5px 9px; border-radius: 999px; background: rgba(255, 252, 246, 0.66); font-size: 10px; color: #725f48; }
.life-flower-light-toggle,
.life-flower-artwork-actions { display: flex; gap: 8px; }
.life-flower-light-toggle button,
.life-flower-artwork-actions button { border: 1px solid rgba(91, 73, 49, 0.2); border-radius: 999px; background: rgba(255, 252, 246, 0.72); padding: 8px 12px; color: #5d4b37; }
.life-flower-light-toggle button.active { background: #4e5543; color: #fff; }
.life-flower-artwork-edit { display: grid; gap: 8px; padding: 12px; border-radius: 15px; background: rgba(255, 252, 246, 0.58); }
.life-flower-artwork-edit label { display: grid; gap: 4px; font-size: 11px; color: #77634c; }
.life-flower-artwork-edit input { border: 1px solid rgba(105, 81, 55, 0.17); border-radius: 9px; background: #fffdf9; padding: 9px; color: #3d342b; }
.life-flower-artwork-edit .life-flower-check { display: flex; align-items: center; gap: 7px; }
.life-flower-artwork-actions button:last-child { margin-left: auto; background: #656d53; color: #fff; }

@media (max-width: 900px) {
  .life-flower-modal { padding: 0; }
  .life-flower-dialog { width: 100vw; height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh; border-radius: 0; }
  .life-flower-header { padding: 16px 18px; }
  .life-flower-header h2 { font-size: 24px; }
  .life-flower-header-actions button:not(.life-flower-close) { display: none; }
  .life-flower-body { display: block; overflow: auto; }
  .life-flower-editor { padding: 22px 18px 28px; }
  .life-flower-preview { border-top: 1px solid var(--lf-divider); border-left: 0; }
  .life-flower-style-grid { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: minmax(210px, 70%); overflow-x: auto; padding: 1px 1px 8px; scroll-snap-type: x proximity; }
  .life-flower-style-grid button { scroll-snap-align: start; }
  .life-flower-footer { padding: 12px 18px; }
}

@media (max-width: 640px) {
  .life-flower-header span { font-size: 9px; }
  .life-flower-header p { font-size: 12px; }
  .life-flower-section { padding-left: 44px; }
  .life-flower-step i { left: -44px; }
  .life-flower-section:not(:last-child)::after { left: 15.5px; }
  .life-flower-step { gap: 8px; }
  .life-flower-step strong { font-size: 15px; }
  .life-flower-step small { font-size: 11px; }
  .life-flower-step > button { padding: 7px 9px; font-size: 11px; }
  .life-flower-type-grid { grid-template-columns: repeat(3, 140px); overflow-x: auto; }
  .life-flower-type-grid button { padding-inline: 14px; }
  .life-flower-member-fields { grid-template-columns: 1fr; gap: 10px; }
  .life-flower-match-result { grid-template-columns: 1fr; gap: 4px; }
  .life-flower-match-result span { white-space: normal; }
  .life-flower-orientation-grid { grid-template-columns: 1fr; }
  .life-flower-footer { align-items: stretch; flex-direction: column; gap: 8px; }
  .life-flower-footer-actions { width: 100%; }
  .life-flower-footer-actions button { flex: 1; min-width: 0; padding: 0 10px; font-size: 12px; }
  .life-flower-artwork-actions { flex-wrap: wrap; }
}
