@font-face { font-family: "Baloo Chettan 2"; src: url("../fonts/BalooChettan2-ExtraBold.ttf") format("truetype"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Anek Condensed"; src: url("../fonts/AnekMalayalam-CondensedExtraBold.ttf") format("truetype"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Manjari"; src: url("../fonts/Manjari-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Manjari"; src: url("../fonts/Manjari-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --maroon: #5e0a10;
  --maroon-d: #2a0407;
  --gold: #f2c14e;
  --gold-l: #fff4c2;
  --green: #1f6b3a;
  --ink: #2b1a12;
  --paper: #fffaf0;
  --line: #ead9b5;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Manjari", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(242,193,78,.18), transparent 40%),
    #f7efe0;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- Header ---------- */
.top {
  background: linear-gradient(135deg, #7d1018, var(--maroon-d));
  color: var(--gold-l);
  border-bottom: 4px solid var(--gold);
  padding: 14px 16px calc(14px);
  padding-top: calc(14px + env(safe-area-inset-top));
}
.top__inner { max-width: 1100px; margin: 0 auto; display: flex; gap: 12px; align-items: center; }
.top__lamp { font-size: 34px; }
.top__logo { width: 58px; height: 58px; flex: 0 0 auto; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
.top h1 { font-family: "Anek Condensed", "Baloo Chettan 2", sans-serif; font-weight: 800; font-size: clamp(22px, 5.6vw, 34px); margin: 0; line-height: 1.15; color: var(--gold); }
.top p { margin: 2px 0 0; font-size: 15px; opacity: .9; }

/* ---------- Layout ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 14px; display: grid; gap: 14px; }
@media (min-width: 900px) {
  .wrap { grid-template-columns: 1fr 1fr; align-items: start; padding: 24px; gap: 24px; }
  .preview { position: sticky; top: 16px; }
}
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 6px 20px rgba(94,10,16,.07);
}
.step + .step { margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--line); }
.step__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.step__head h2 { margin: 0; font-size: 19px; font-weight: 700; color: var(--maroon); }
.num {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-family: "Baloo Chettan 2", sans-serif;
  background: linear-gradient(180deg, #ffe08a, #c8901c); color: var(--maroon-d);
}

/* ---------- Inputs ---------- */
.input {
  width: 100%; font: inherit; font-size: 18px; color: var(--ink);
  padding: 13px 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--paper);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(242,193,78,.25); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--maroon) 50%), linear-gradient(135deg, var(--maroon) 50%, transparent 50%); background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
#itemOther { margin-top: 10px; }

.drop {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
  padding: 22px 14px; border: 2.5px dashed var(--gold); border-radius: 14px;
  background: linear-gradient(180deg, #fffaf0, #fff3d6); cursor: pointer;
  transition: transform .1s, background .2s;
}
.drop:active { transform: scale(.99); }
.drop.has-photo { border-style: solid; background: #f3fbef; border-color: #6cb56a; }
.drop__icon { font-size: 34px; }
.drop__title { font-size: 19px; font-weight: 700; color: var(--maroon); }
.drop__hint { font-size: 14px; color: #7a6a55; }

.status { min-height: 0; font-size: 15px; margin-top: 8px; }
.status.ok { color: #1f6b3a; }
.status.err { color: #b3121c; }
.status.busy { color: #8a5a00; }

.adjust { margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.adjust summary { padding: 12px 14px; cursor: pointer; font-weight: 700; color: var(--maroon); }
.adjust__body { padding: 0 14px 14px; }
.range { display: flex; align-items: center; gap: 12px; }
.range input { flex: 1; accent-color: var(--maroon); height: 28px; }
.hint { font-size: 14px; color: #7a6a55; margin: 8px 0; }


/* ---------- Preview ---------- */
.canvasBox { position: relative; border-radius: 12px; overflow: hidden; background: var(--maroon-d); box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: 540px; margin: 0 auto; }
#preview { display: block; width: 100%; height: auto; }
#preview.draggable { cursor: grab; touch-action: none; }
#preview.dragging { cursor: grabbing; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--gold-l); background: rgba(42,4,7,.6); font-size: 18px; }
.loading[hidden] { display: none; }

.error { color: #b3121c; min-height: 1.2em; margin: 10px 0 0; text-align: center; font-weight: 700; }
.actions { display: grid; gap: 10px; margin-top: 12px; }
.adjust { margin-top: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: 18px; text-decoration: none;
  padding: 15px 18px; border-radius: 14px; border: 0; cursor: pointer; min-height: 54px;
  transition: transform .1s, filter .15s, opacity .15s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn[disabled] { opacity: .55; cursor: progress; }
.btn--gold { background: linear-gradient(180deg, #ffe08a, #e0a823); color: var(--maroon-d); box-shadow: 0 4px 0 #a8740f; }
.btn--green { background: linear-gradient(180deg, #2f8f4f, #1b5e31); color: #fff; box-shadow: 0 4px 0 #0f3d20; }
.btn--ghost { background: transparent; color: var(--maroon); border: 2px solid var(--line); min-height: 48px; }
.btn--sm { font-size: 15px; padding: 9px 12px; min-height: 0; }


/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(20,2,4,.78); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal[hidden] { display: none; }
.modal__card { position: relative; width: min(480px, 100%); background: #fff; border-radius: var(--radius); padding: 18px; text-align: center; display: grid; gap: 10px; }
.modal__card h3 { margin: 0; font-family: "Manjari", sans-serif; font-size: 24px; color: var(--maroon); }
.modal__card img { width: 100%; border-radius: 10px; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.modal__close { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: #f3e7d1; font-size: 18px; cursor: pointer; }

.foot { text-align: center; color: #7a6a55; font-size: 14px; padding: 8px 16px 28px; }

/* ---------- v2: frames, fields, chips ---------- */
.frames { display: grid; grid-auto-flow: column; grid-auto-columns: 112px; gap: 10px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
@media (min-width: 900px) { .frames { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); overflow: visible; } }
.frame { position: relative; display: grid; gap: 6px; cursor: pointer; scroll-snap-align: start; text-align: center; }
.frame input { position: absolute; opacity: 0; pointer-events: none; }
.frame__img { display: block; aspect-ratio: 4 / 5; border-radius: 10px; overflow: hidden; border: 3px solid transparent; box-shadow: 0 3px 10px rgba(0,0,0,.15); transition: transform .15s, border-color .15s; }
.frame__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame__name { font-size: 15px; font-weight: 700; color: #6b5a44; }
.frame:has(input:checked) .frame__img { border-color: var(--maroon); transform: translateY(-2px); box-shadow: 0 0 0 3px rgba(242,193,78,.6), 0 6px 14px rgba(94,10,16,.25); }
.frame:has(input:checked) .frame__name { color: var(--maroon); }
.frame:has(input:focus-visible) .frame__img { outline: 3px solid var(--gold); }

.field { display: grid; gap: 6px; margin-top: 10px; }
.field:first-of-type { margin-top: 0; }
.field > span { font-weight: 700; font-size: 16px; color: #5b4a36; }
.field small { font-weight: 400; color: #8a7a65; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mt { margin-top: 10px; }
.sub { margin: 12px 0 8px; font-weight: 700; color: #5b4a36; }
.sub:first-of-type { margin-top: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-flex; align-items: center; min-height: 46px; padding: 8px 16px; border-radius: 999px; border: 2px solid var(--line); background: var(--paper); font-weight: 700; font-size: 16px; }
.chip:has(input:checked) span { background: var(--maroon); border-color: var(--maroon); color: var(--gold-l); }
.chip--grade:has(input:checked) span { background: linear-gradient(180deg, #ffe08a, #e0a823); border-color: #c8901c; color: var(--maroon-d); }
.chip:has(input:focus-visible) span { outline: 3px solid var(--gold); }
.wrap > * { min-width: 0; }
.frames { max-width: 100%; }
.row2 { align-items: end; }
