:root {
  --bg: #f8f6fb;
  --paper: #ffffff;
  --ink: #15141c;
  --muted: #686575;
  --line: rgba(34, 31, 46, 0.1);
  --brand: #7655f6;
  --brand-strong: #5e3ee1;
  --rose: #e98cbd;
  --soft: #efebfb;
  --shadow: 0 24px 70px rgba(47, 39, 80, 0.12);
  font-family: "DM Sans", "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(248, 246, 251, 0.96) 42%),
    radial-gradient(circle at top right, rgba(233, 140, 189, 0.16), transparent 34%),
    var(--bg);
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.hair-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(20px, 5vw, 72px);
  background: rgba(248, 246, 251, 0.82);
  border-bottom: 1px solid rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(18px);
}

.hair-brand,
.hair-nav,
.language-button {
  display: flex;
  align-items: center;
}

.hair-brand {
  gap: 12px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0;
}

.hair-brand svg {
  width: 34px;
  height: 34px;
}

.hair-nav {
  gap: 14px;
}

.privacy-link {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: #393542;
  font-size: 14px;
}

.language-button {
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.language-button span {
  font-size: 13px;
  font-weight: 700;
}

.language-button span.active {
  color: var(--brand);
}

.language-button i {
  width: 1px;
  height: 16px;
  background: var(--line);
}

.hair-main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 62px 0 52px;
}

.hair-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
  align-items: end;
  margin-bottom: 28px;
}

.hair-kicker {
  margin: 0 0 18px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.hair-hero h1 {
  max-width: 780px;
  margin: 0;
  color: var(--ink);
  font-size: clamp(44px, 6vw, 86px);
  line-height: 0.98;
  letter-spacing: 0;
}

.hair-hero h1 em {
  color: var(--brand);
  font-style: normal;
}

.hair-lead {
  max-width: 660px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.8;
}

.research-notice {
  max-width: 720px;
  margin-top: 20px;
  padding: 16px 18px;
  border: 1px solid rgba(118, 85, 246, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 14px 38px rgba(47, 39, 80, 0.07);
}

.research-notice strong {
  display: block;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

.research-notice p {
  margin: 7px 0 0;
  color: #565268;
  font-size: 14px;
  line-height: 1.75;
}

.hair-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.hair-stats div {
  min-height: 112px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
}

.hair-stats span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.hair-stats strong {
  display: block;
  margin-top: 14px;
  font-size: 28px;
  line-height: 1;
}

.hair-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 18px;
  margin-bottom: 34px;
}

.upload-area,
.result-area,
.template-section {
  border: 1px solid rgba(34, 31, 46, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

#hair-upload {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.upload-area {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.upload-box {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 340px;
  padding: 28px;
  border: 1px dashed rgba(118, 85, 246, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(118, 85, 246, 0.1), rgba(233, 140, 189, 0.08)),
    #fbfaff;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
}

.upload-box b {
  margin-top: 14px;
  font-size: 22px;
}

.upload-box small {
  display: block;
  max-width: 360px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 8px;
  background: #fff;
  color: var(--brand);
  box-shadow: 0 12px 34px rgba(74, 56, 128, 0.13);
}

.upload-icon svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.upload-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

.upload-box.has-image {
  overflow: hidden;
  min-height: 420px;
  border-style: solid;
}

.upload-box.has-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 48%, rgba(0, 0, 0, 0.5));
}

.upload-box.has-image .upload-icon,
.upload-box.has-image b,
.upload-box.has-image small {
  position: relative;
  z-index: 2;
  color: #fff;
}

.upload-box.has-image .upload-icon {
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(12px);
}

.safety-box {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.safety-box p {
  margin: 0;
  color: #4f4b5c;
  font-size: 14px;
  line-height: 1.8;
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.7;
}

.consent-row input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  accent-color: var(--brand);
  flex: 0 0 auto;
}

.result-area {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 22px;
}

.selected-template {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(145deg, #fff, #f6f2ff);
}

.selected-template span {
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.selected-template strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
  line-height: 1.2;
}

.selected-template p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.generate-button,
.download-button {
  width: 100%;
  min-height: 54px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

.generate-button {
  margin-top: 18px;
  border: 0;
  background: var(--ink);
  color: #fff;
}

.generate-button:not(:disabled):hover {
  background: var(--brand-strong);
}

.generate-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.download-button {
  margin-top: 12px;
  border: 1px solid rgba(118, 85, 246, 0.24);
  background: #fff;
  color: var(--brand);
}

.download-button:hover {
  border-color: rgba(118, 85, 246, 0.48);
  background: #f7f3ff;
}

.status-line {
  min-height: 24px;
  margin: 16px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.status-line.error {
  color: #b42318;
}

.status-line.success {
  color: #157f3b;
}

.result-preview {
  margin: auto 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f6f3fb;
}

.result-preview canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 520px;
}

.result-preview figcaption {
  padding: 12px 14px;
  color: var(--muted);
  font-size: 13px;
}

.template-section {
  padding: 24px;
}

.template-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.template-head h2 {
  margin: 0;
  font-size: 34px;
  letter-spacing: 0;
}

.template-tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f1fb;
}

.template-tabs button {
  min-width: 92px;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.template-tabs button[aria-selected="true"] {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 8px 24px rgba(55, 41, 91, 0.09);
}

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

.template-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.template-card.active {
  border-color: rgba(118, 85, 246, 0.62);
  box-shadow: 0 0 0 3px rgba(118, 85, 246, 0.12);
}

.template-media {
  position: relative;
  aspect-ratio: 4 / 5;
  background: linear-gradient(135deg, #ede8fb, #f9e8f1);
}

.template-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.template-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--brand);
  font-size: 18px;
  font-weight: 700;
}

.template-copy {
  padding: 14px;
}

.template-copy strong {
  display: block;
  font-size: 16px;
  line-height: 1.35;
}

.template-copy p {
  display: -webkit-box;
  min-height: 44px;
  margin: 8px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.template-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 26px;
  margin-top: 12px;
}

.template-tags span {
  padding: 4px 7px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--brand);
  font-size: 11px;
}

.empty-state {
  margin: 20px 0 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  text-align: center;
}

.hair-footer {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 42px 0 52px;
  color: var(--muted);
  font-size: 14px;
}

.footer-panel {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(0, 1.4fr);
  gap: 28px;
  padding: 28px;
  border: 1px solid rgba(34, 31, 46, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 18px 52px rgba(47, 39, 80, 0.09);
}

.footer-intro .hair-kicker {
  margin-bottom: 12px;
}

.footer-intro h2 {
  margin: 0;
  color: var(--ink);
  font-size: 28px;
  line-height: 1.2;
}

.footer-intro p:not(.hair-kicker) {
  max-width: 360px;
  margin: 14px 0 0;
  line-height: 1.75;
}

.footer-info-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr) minmax(0, 0.9fr);
  gap: 12px;
}

.footer-info-item {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.footer-info-item span {
  display: block;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.footer-info-item p {
  margin: 10px 0 0;
  color: #3f3a4d;
  font-size: 14px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 2px 0;
}

.footer-bottom a,
.footer-info-item[href] {
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.footer-bottom a:hover {
  color: var(--brand);
}

.footer-info-item[href]:hover {
  border-color: rgba(118, 85, 246, 0.36);
  background: #fbf9ff;
}

.usage-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 22px;
}

.usage-modal[hidden] {
  display: none;
}

.usage-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(21, 20, 28, 0.36);
  backdrop-filter: blur(12px);
  cursor: pointer;
}

.usage-dialog {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(21, 20, 28, 0.24);
}

.usage-kicker {
  margin: 0 0 10px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.usage-dialog h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
}

.usage-dialog > p:not(.usage-kicker) {
  margin: 16px 0 0;
  color: #4f4b5c;
  font-size: 15px;
  line-height: 1.85;
}

.usage-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.usage-actions button {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

.usage-cancel {
  border: 1px solid var(--line);
  background: #fff;
  color: #4f4b5c;
}

.usage-confirm {
  border: 0;
  background: var(--ink);
  color: #fff;
}

.usage-confirm:hover {
  background: var(--brand-strong);
}

@media (max-width: 980px) {
  .hair-hero,
  .hair-workspace {
    grid-template-columns: 1fr;
  }

  .hair-stats {
    max-width: 420px;
  }

  .template-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .hair-header {
    padding: 16px 18px;
  }

  .hair-brand {
    font-size: 20px;
  }

  .privacy-link {
    display: none;
  }

  .hair-main {
    width: min(100% - 28px, 1180px);
    padding-top: 38px;
  }

  .hair-hero h1 {
    font-size: 42px;
  }

  .hair-lead {
    font-size: 16px;
  }

  .research-notice {
    padding: 14px;
  }

  .hair-stats {
    grid-template-columns: 1fr 1fr;
  }

  .upload-box {
    min-height: 270px;
    padding: 20px;
  }

  .upload-box.has-image {
    min-height: 330px;
  }

  .template-section {
    padding: 18px;
  }

  .template-head {
    display: grid;
    align-items: stretch;
  }

  .template-head h2 {
    font-size: 28px;
  }

  .template-tabs button {
    flex: 1;
    min-width: 0;
  }

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

  .hair-footer {
    width: min(100% - 28px, 1180px);
  }

  .footer-panel {
    grid-template-columns: 1fr;
    padding: 20px;
  }

  .footer-info-grid {
    grid-template-columns: 1fr;
  }

  .footer-bottom {
    display: grid;
  }

  .usage-dialog {
    padding: 22px;
  }

  .usage-actions {
    display: grid;
  }
}

@media (max-width: 430px) {
  .hair-stats,
  .template-grid {
    grid-template-columns: 1fr;
  }

  .hair-hero h1 {
    font-size: 36px;
  }
}
