:root{
  --paper: #FAF7F1;
  --paper-warm: #F3ECDF;
  --surface: #FFFFFF;
  --ink: #1E2A32;
  --ink-soft: #4B5B63;
  --teal: #167D7F;
  --teal-deep: #0E5C5E;
  --amber: #F2A93B;
  --amber-deep: #D98A1E;
  --coral: #E4572E;
  --line: #E4DCC9;
  --radius-lg: 22px;
  --radius-md: 14px;
  --shadow: 0 12px 32px -12px rgba(30, 42, 50, 0.18);
}

*{ box-sizing: border-box; }

body{
  margin: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(242,169,59,0.10), transparent 45%),
    radial-gradient(circle at 88% 92%, rgba(22,125,127,0.10), transparent 45%),
    var(--paper);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 48px 20px 64px;
}

.app{ width: 100%; max-width: 560px; position: relative; }

.lang-switcher-wrap{
  position: absolute;
  top: 2px;
  right: 0;
}
.lang-switcher{
  appearance: none;
  -webkit-appearance: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--teal-deep);
  background-color: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 6px 30px 6px 14px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%234B5B63' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.lang-switcher:hover{ border-color: var(--teal); }
.lang-switcher:focus{
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(22,125,127,0.12);
}

header.hero{ text-align: center; margin-bottom: 32px; padding-top: 6px; }

.mark{ width: 56px; height: 56px; margin: 0 auto 18px; display: flex; align-items: center; justify-content: center; }

h1{
  font-family: 'Fraunces', serif;
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 2.35rem;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
  color: var(--ink);
}

.sub{
  color: var(--ink-soft);
  font-size: 0.98rem;
  line-height: 1.5;
  max-width: 400px;
  margin: 0 auto;
}

nav.tabs{
  display: flex;
  background: var(--paper-warm);
  border-radius: 999px;
  padding: 5px;
  margin: 28px 0 22px;
  border: 1px solid var(--line);
}
nav.tabs button{
  flex: 1;
  border: none;
  background: transparent;
  padding: 11px 14px;
  border-radius: 999px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .25s ease;
}
nav.tabs button.active{
  background: var(--surface);
  color: var(--teal-deep);
  box-shadow: 0 4px 12px -4px rgba(30,42,50,0.15);
}

.card{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}

.panel{ display: none; }
.panel.active{ display: block; }

label{
  display: block;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin: 0 0 8px;
}

textarea, input[type=text], input[type=password], select{
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 0.96rem;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  resize: vertical;
  transition: border-color .2s ease, box-shadow .2s ease;
}
textarea:focus, input:focus, select:focus{
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(22,125,127,0.12);
}

textarea{ min-height: 130px; line-height: 1.5; }

.field{ margin-bottom: 18px; }

.row{ display: flex; gap: 14px; }
.row .field{ flex: 1; }

.check-row{
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
  cursor: pointer;
  user-select: none;
}
.check-row input{ width: 18px; height: 18px; accent-color: var(--teal); cursor: pointer; }
.check-row span{ font-size: 0.88rem; color: var(--ink-soft); font-weight: 500; }

.btn{
  width: 100%;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 0.98rem;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn:active{ transform: scale(0.98); }
.btn:disabled{ opacity: 0.55; cursor: not-allowed; }

.btn-primary{
  background: linear-gradient(180deg, var(--teal) 0%, var(--teal-deep) 100%);
  color: #fff;
  box-shadow: 0 10px 24px -10px rgba(14,92,94,0.55);
}
.btn-primary:hover:not(:disabled){ box-shadow: 0 12px 28px -8px rgba(14,92,94,0.65); }

.btn-ghost{
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--ink);
  margin-top: 12px;
}
.btn-ghost:hover{ border-color: var(--teal); color: var(--teal-deep); }

.hint{
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 8px;
  line-height: 1.5;
}

/* --- Envelope signature element --- */
.envelope-stage{ display: flex; justify-content: center; margin: 4px 0 22px; perspective: 900px; }
.envelope{ width: 128px; height: 84px; position: relative; }
.envelope .body{
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #FDFBF6, #F3ECDF);
  border: 1.5px solid var(--line);
  border-radius: 8px;
}
.envelope .flap{
  position: absolute;
  top: -1px; left: -1px; right: -1px;
  height: 46px;
  background: linear-gradient(160deg, #F7F1E4, #EAE0C8);
  border: 1.5px solid var(--line);
  clip-path: polygon(0 0, 100% 0, 50% 92%);
  transform-origin: top center;
  transform: rotateX(0deg);
  transition: transform .7s cubic-bezier(.6,.1,.25,1);
  border-radius: 8px 8px 0 0;
}
.envelope.sealed .flap{ transform: rotateX(180deg); }
.envelope .seal{
  position: absolute;
  left: 50%; top: 40px;
  width: 34px; height: 34px;
  background: radial-gradient(circle at 35% 30%, var(--amber), var(--amber-deep));
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  box-shadow: 0 4px 10px -3px rgba(217,138,30,0.6);
  transition: transform .35s cubic-bezier(.34,1.56,.64,1) .55s;
  display: flex; align-items: center; justify-content: center;
}
.envelope.sealed .seal{ transform: translate(-50%, -50%) scale(1); }
.envelope .seal svg{ width: 16px; height: 16px; }

/* --- Result --- */
.result{ display: none; }
.result.active{ display: block; }

.link-box{
  display: flex; align-items: center; gap: 8px;
  background: var(--paper);
  border: 1.5px dashed var(--teal);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin: 4px 0 14px;
}
.link-box code{
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--teal-deep);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
}
.icon-btn{
  border: none; background: var(--teal); color: #fff;
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background .2s ease;
}
.icon-btn:hover{ background: var(--teal-deep); }
.icon-btn svg{ width: 16px; height: 16px; }

.warn{
  display: flex; gap: 10px;
  background: #FFF5EC;
  border: 1px solid #F3D9B8;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 0.82rem;
  color: #8A5A1E;
  line-height: 1.5;
  margin-bottom: 8px;
}
.warn svg{ width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; color: var(--amber-deep); }

/* --- Redeem panel --- */
.message-box{
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ink);
  margin-bottom: 14px;
}

.status{ text-align: center; padding: 8px 4px 4px; color: var(--ink-soft); font-size: 0.9rem; }
.status.error{ color: var(--coral); font-weight: 600; }
.status.success{ color: var(--teal-deep); font-weight: 600; }

footer{
  text-align: center;
  margin-top: 26px;
  font-size: 0.74rem;
  color: var(--ink-soft);
  opacity: 0.8;
  line-height: 1.6;
}

@media (prefers-reduced-motion: reduce){
  .envelope .flap, .envelope .seal{ transition: none; }
}
