:root {
  --cream: #fff8f1; --paper: #ffffff; --ink: #2b1d2a; --muted: #7a6873; --line: #eedfd6;
  --coral: #ff5a7a; --coral-d: #e23d60; --lagoon: #0fb5ae; --sun: #ffc93c;
  --radius: 18px; --shadow: 0 18px 40px rgba(60, 25, 40, .12);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--cream); color: var(--ink); font-family: var(--dv-body), 'Plus Jakarta Sans', system-ui, sans-serif; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--dv-head), 'Fraunces', Georgia, serif; line-height: 1.1; margin: 0; letter-spacing: -.015em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }

.nav { display: flex; align-items: center; justify-content: space-between; padding: 18px clamp(16px, 4vw, 48px); max-width: 1200px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--dv-head), 'Fraunces', serif; font-weight: 700; font-size: 24px; }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 18px;
  background: linear-gradient(135deg, var(--coral), var(--sun)); color: #fff; transform: rotate(-6deg); box-shadow: 0 6px 14px rgba(255, 90, 122, .35); }
.brand small { display: block; font-family: var(--dv-body), 'Plus Jakarta Sans', sans-serif; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .06em; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 700; font-size: 15px;
  padding: 12px 22px; border-radius: 999px; border: 2px solid transparent; cursor: pointer; text-decoration: none; transition: transform .15s, background .2s, box-shadow .2s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--coral); color: #fff; box-shadow: 0 10px 22px rgba(255, 90, 122, .3); }
.btn-primary:hover { background: var(--coral-d); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-sm { padding: 8px 16px; font-size: 14px; }
.btn-block { width: 100%; }

/* Phone frame for previews */
.phone { width: min(330px, 84vw); aspect-ratio: 9 / 18.5; border-radius: 40px; padding: 10px; background: #1d1420;
  box-shadow: 0 30px 60px rgba(40, 15, 30, .3), inset 0 0 0 2px #3a2d38; position: relative; }
.phone::before { content: ''; position: absolute; top: 18px; left: 50%; width: 70px; height: 7px; border-radius: 9px; background: #000; transform: translateX(-50%); z-index: 10; }
.phone .stage { border-radius: 30px; }

/* Home */
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; max-width: 1200px; margin: 0 auto; padding: 24px clamp(16px, 4vw, 48px) 60px; }
.kicker { display: inline-block; font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--coral-d);
  background: #ffe6ec; padding: 6px 12px; border-radius: 999px; margin: 0 0 18px; }
.hero h1 { font-size: clamp(38px, 6vw, 68px); }
.hero h1 em { color: var(--coral); }
.lead { font-size: clamp(16px, 1.6vw, 19px); color: var(--muted); max-width: 34em; margin: 20px 0 28px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-demo { display: flex; justify-content: center; position: relative; }
.hero-demo::before { content: ''; position: absolute; inset: 8% 4%; border-radius: 50%; background: radial-gradient(circle, rgba(255, 201, 60, .4), transparent 65%); filter: blur(10px); }
.trust { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 26px; font-size: 14px; color: var(--muted); }

.section { max-width: 1200px; margin: 0 auto; padding: 50px clamp(16px, 4vw, 48px); }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }
.section h2 { font-size: clamp(30px, 4vw, 44px); }
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.how-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.how-card b { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: #e3f7f6; color: #0b7c77; font-family: var(--dv-head), 'Fraunces', serif; font-size: 20px; margin-bottom: 14px; }
.how-card h3 { font-size: 20px; margin-bottom: 6px; }
.how-card p { margin: 0; color: var(--muted); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 14px; font-weight: 600; padding: 8px 15px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.tile { background: var(--paper); border-radius: 22px; overflow: hidden; border: 1px solid var(--line); display: flex; flex-direction: column; transition: transform .2s, box-shadow .2s; }
.tile:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.tile-art { aspect-ratio: 16 / 10; background: var(--bg); display: grid; place-items: center; cursor: pointer; position: relative; }
.tile-art span { font-size: 64px; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .2)); transition: transform .3s; }
.tile:hover .tile-art span { transform: scale(1.12) rotate(-6deg); }
.tile-art .play { font-style: normal; position: absolute; right: 12px; bottom: 12px; font-size: 12px; font-weight: 700; background: rgba(255, 255, 255, .9); color: var(--ink); padding: 5px 10px; border-radius: 999px; }
.tile-body { padding: 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.tag { font-size: 12px; font-weight: 700; color: var(--lagoon); text-transform: uppercase; letter-spacing: .08em; }
.tile h3 { font-size: 22px; }
.tile p { margin: 0 0 10px; color: var(--muted); font-size: 14.5px; flex: 1; }
.tile-actions { display: flex; gap: 8px; }

footer { text-align: center; color: var(--muted); font-size: 14px; padding: 40px 16px 60px; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(30, 15, 25, .6); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; animation: fade .2s; }
.modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.modal-box { position: relative; display: flex; flex-direction: column; align-items: center; gap: 16px; max-height: 100%; }
.modal-x { position: absolute; top: -6px; right: -6px; z-index: 20; width: 40px; height: 40px; border-radius: 50%; border: 0; background: #fff; font-size: 20px; cursor: pointer; box-shadow: var(--shadow); }
.modal-actions { display: flex; gap: 10px; }
.modal .phone { height: min(76vh, 640px); width: auto; }

/* Builder */
.builder { max-width: 1200px; margin: 0 auto; padding: 8px clamp(16px, 4vw, 48px) 60px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 48px; align-items: start; }
.back { display: inline-block; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; margin-bottom: 14px; }
.back:hover { color: var(--ink); }
.b-form h1 { font-size: clamp(30px, 4vw, 44px); }
.b-form .sub { color: var(--muted); margin: 8px 0 26px; }
.form-card { background: var(--paper); border: 1px solid var(--line); border-radius: 22px; padding: clamp(18px, 3vw, 28px); display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-weight: 700; font-size: 14px; }
.req { color: var(--coral); }
.field input[type=text], .field input[type=number], .field input[type=date], .field textarea, .field select {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--cream); border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; width: 100%; }
.field textarea { resize: vertical; min-height: 120px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--coral); background: #fff; box-shadow: 0 0 0 4px rgba(255, 90, 122, .15); }
.field.bad input { border-color: var(--coral); }
.count { font-size: 12px; color: var(--muted); text-align: right; }
.help { font-size: 13px; color: var(--muted); margin: 0; }
.err { color: var(--coral-d); font-weight: 600; margin: 0; min-height: 1em; }
.ph-list { display: flex; flex-direction: column; gap: 8px; }
.ph-item { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; background: var(--cream); border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
.ph-item img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.ph-item input { font: inherit; font-size: 15px; border: 0; background: transparent; padding: 8px; min-width: 0; }
.ph-item input:focus { outline: 2px solid rgba(255, 90, 122, .4); border-radius: 8px; background: #fff; }
.ph-tools { display: flex; gap: 4px; }
.ph-tools button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 14px; }
.ph-tools button:hover { border-color: var(--ink); }
.b-preview { position: sticky; top: 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.b-preview .phone { height: min(80vh, 680px); width: auto; }
.tabs { display: none; }

.share-box { background: var(--paper); border-radius: 26px; padding: 30px; width: min(460px, 100%); align-items: stretch; text-align: center; }
.share-box h2 { font-size: 30px; }
.share-box p { color: var(--muted); margin: 0; }
.linkrow { display: flex; gap: 8px; }
.linkrow input { flex: 1; min-width: 0; font: inherit; font-size: 15px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--cream); }
.share-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.wa { background: #25d366; color: #fff; }
.vb { background: #7360f2; color: #fff; }

/* Viewer */
.viewer { height: 100vh; height: 100dvh; background: #000; }
.viewer .stage { height: 100%; }
.make-own { position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 30; text-decoration: none; font-size: 13px; font-weight: 700;
  background: rgba(255, 255, 255, .92); color: var(--ink); padding: 8px 14px; border-radius: 999px; box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
  opacity: 0; transform: translateY(10px); transition: opacity .6s, transform .6s; pointer-events: none; }
.make-own.show { opacity: 1; transform: none; pointer-events: auto; }
.missing { display: grid; place-items: center; height: 100%; text-align: center; color: #fff; padding: 24px; background: linear-gradient(160deg, #2b1d2a, #5a2a45); }
.missing h1 { font-size: 34px; margin: 14px 0 8px; }
.missing p { color: #e9d6df; margin: 0 0 22px; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; text-align: center; }
  .lead { margin-inline: auto; }
  .hero-actions, .trust { justify-content: center; }
  .how-grid { grid-template-columns: 1fr; }
  .builder { grid-template-columns: 1fr; gap: 16px; }
  .tabs { display: flex; position: sticky; top: 0; z-index: 20; background: var(--cream); padding: 10px 0; gap: 8px; }
  .tabs button { flex: 1; font: inherit; font-weight: 700; padding: 11px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; }
  .tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
  body[data-tab=edit] .b-preview { display: none; }
  body[data-tab=preview] .b-form { display: none; }
  .b-preview { position: static; }
  .b-preview .phone { height: min(72vh, 620px); }
}

/* ── Language switch & Dhivehi pages ── */
.nav-right { display: flex; gap: 8px; align-items: center; }
.lang-btn { min-width: 84px; }
.lang-btn:lang(dv) { font-size: 15px; }
html[lang=dv] body { font-size: 16.5px; line-height: 1.8; }
html[lang=dv] h1, html[lang=dv] h2, html[lang=dv] h3 { letter-spacing: 0; line-height: 1.45; }
html[lang=dv] .hero h1 em { font-style: normal; }
html[lang=dv] .kicker, html[lang=dv] .tag { letter-spacing: 0; text-transform: none; }
html[lang=dv] .tile-art .play { right: auto; left: 12px; }
html[lang=dv] .ph-item { grid-template-columns: 56px 1fr auto; }
.field-lang select { font-weight: 700; }
.kb-toggle { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: var(--muted);
  background: var(--cream); border: 1px dashed var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.kb-toggle input { width: 18px; height: 18px; accent-color: var(--coral); }
.kb-toggle kbd { margin-inline-start: auto; font-family: inherit; font-size: 13px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; direction: ltr; }
/* Phones and tablets have their own Dhivehi keyboards. */
@media (hover: none) and (pointer: coarse) { .kb-toggle { display: none; } }

/* ── Builder sections, ދިވެހި fill and font pickers ── */
.form-stack { display: flex; flex-direction: column; gap: 18px; }
.card-title { font-size: 22px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--cream); border: 1.5px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { font: inherit; font-weight: 700; font-size: 14px; border: 0; background: none; padding: 7px 16px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.seg button[lang=dv] { font-family: var(--dv-body), sans-serif; font-size: 16px; }
.seg button.on { background: var(--ink); color: #fff; }
.form-card code { background: var(--cream); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; font-size: 13px; }
.field-text label { font-weight: 600; color: var(--muted); font-size: 13px; }
.field textarea.lines { min-height: 0; resize: vertical; }
.field-label { font-weight: 700; font-size: 14px; }
.font-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.font-chip { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px 8px; border-radius: 12px; cursor: pointer;
  background: var(--cream); border: 1.5px solid var(--line); font: inherit; color: var(--ink); transition: border-color .15s, background .15s; }
.font-chip:hover { border-color: var(--ink); }
.font-chip.on { border-color: var(--coral); background: #fff0f3; box-shadow: 0 0 0 3px rgba(255, 90, 122, .15); }
.font-sample { font-size: 26px; line-height: 1.6; }
.font-chip small { font-size: 11px; color: var(--muted); font-weight: 600; }
.field input[dir=auto]:dir(rtl), .field textarea:dir(rtl) { font-family: var(--dv-body), 'Plus Jakarta Sans', sans-serif; font-size: 17px; }

/* ── QR card in the share sheet ── */
.modal-box { overflow-y: auto; }
.share-box { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); }
.qr-wrap { display: flex; justify-content: center; }
.qr-wrap canvas { width: min(260px, 70vw); height: auto; aspect-ratio: 1080 / 1350; border-radius: 18px; box-shadow: 0 10px 30px rgba(60, 25, 40, .18); }
.qr-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* Dhivehi greeting quick-pick (ލޯބިވާ / އެކުވެރި) */
.greet-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.greet-pick .chip { display: inline-flex; align-items: baseline; gap: 6px; padding: 5px 13px; }
.greet-pick b { font-family: var(--dv-body), sans-serif; font-size: 16px; font-weight: 400; }
.greet-pick small { font-size: 11px; opacity: .75; }

.link-btn { align-self: flex-start; background: none; border: 0; padding: 0; font: inherit; font-size: 14px; font-weight: 700; color: var(--coral-d); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.field input::placeholder, .field textarea::placeholder { color: #b9a7ae; }

/* ── Print options in the share sheet ── */
.print-opts { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.print-opts[hidden] { display: none; }
.print-opt { display: flex; gap: 12px; align-items: flex-start; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--cream); border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px; transition: border-color .15s; }
.print-opt:hover { border-color: var(--coral); }
.print-opt:disabled { opacity: .6; cursor: progress; }
.print-opt b { display: block; font-size: 15px; }
.print-opt small { display: block; color: var(--muted); font-size: 13px; line-height: 1.4; margin-top: 2px; }
.po-icon { font-size: 26px; line-height: 1; }
#print-status a { color: var(--coral-d); font-weight: 700; }

/* ── Vedhun logo (leaf letter) ── */
.brand-logo { height: 40px; width: auto; flex: none; filter: drop-shadow(0 4px 6px rgba(120, 70, 20, .2)); transform: rotate(-2deg); transition: transform .3s; }
.brand:hover .brand-logo { transform: rotate(-6deg) scale(1.05); }
footer [lang=dv] { font-family: var(--dv-head), sans-serif; font-size: 1.1em; }
