/* Crystyl — Chinese Blue & Gold */
:root {
  --blue-900: #0F2552;
  --blue-800: #16306A;
  --blue-700: #1F3D7A;   /* Chinese Blue */
  --blue-600: #2A4E96;
  --blue-500: #3A63B0;
  --gold-100: #FBEFC8;
  --gold-200: #F4D27A;
  --gold-300: #E8BE5E;
  --gold-400: #C9A24B;
  --gold-500: #A6822F;
  --ink:      #0B1A3A;
  --paper:    #FAF7EE;
  --paper-2:  #FFFDF6;
  --line:     rgba(31, 61, 122, 0.18);
  --shadow:   0 8px 28px rgba(15, 37, 82, 0.18);
  --radius:   18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08) 0 1px, transparent 1px 22px),
    radial-gradient(1200px 600px at 80% -10%, rgba(244, 210, 122, 0.30), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(31, 61, 122, 0.35), transparent 55%),
    linear-gradient(180deg, #0F2552 0%, #16306A 38%, #1F3D7A 100%);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(env(safe-area-inset-top), 16px) 16px max(env(safe-area-inset-bottom), 24px);
  overflow-x: hidden;
}

/* ---------- Sparkles ---------- */
.sparkles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(2px 2px at 12% 18%, #F4D27A 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 78% 12%, #FBEFC8 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 78%, #E8BE5E 50%, transparent 51%),
    radial-gradient(2px 2px at 88% 64%, #F4D27A 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 46% 38%, #FFFDF6 50%, transparent 51%),
    radial-gradient(1px 1px at 58% 88%, #E8BE5E 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 8% 52%, #F4D27A 50%, transparent 51%),
    radial-gradient(2px 2px at 94% 90%, #FBEFC8 50%, transparent 51%),
    radial-gradient(1px 1px at 36% 8%, #E8BE5E 50%, transparent 51%);
  animation: twinkle 4s ease-in-out infinite alternate;
  opacity: 0.85;
}
@keyframes twinkle {
  0%   { opacity: 0.35; transform: translateY(0) scale(1); }
  50%  { opacity: 0.9; }
  100% { opacity: 0.5; transform: translateY(-2px) scale(1.02); }
}

/* Decorative star sparkles */
.sparkle-star {
  position: absolute;
  width: 14px;
  height: 14px;
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(244, 210, 122, 0.7));
  animation: float 6s ease-in-out infinite;
}

/* ---------- Layout ---------- */
.app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.header { text-align: center; padding-top: 6px; color: #FFFDF6; }
.logo-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.logo { width: 40px; height: 40px; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35)); }
.brand {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 700;
  font-size: 34px;
  line-height: 1;
  margin: 0;
  letter-spacing: 0.5px;
  background: linear-gradient(180deg, #FBEFC8 0%, #E8BE5E 60%, #C9A24B 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 1px 0 rgba(0,0,0,0.06);
}
.tagline {
  margin: 6px 0 0;
  font-size: 13px;
  color: rgba(255,253,246,0.78);
  letter-spacing: 0.3px;
}

/* ---------- Quote ---------- */
.quote-card {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(220px 120px at 96% 0%, rgba(244, 210, 122, 0.34), transparent 65%),
    linear-gradient(180deg, rgba(255,253,246,0.98), rgba(251,239,200,0.94));
  border: 1px solid rgba(244, 210, 122, 0.78);
  border-radius: calc(var(--radius) + 6px);
  padding: 18px 18px 17px;
  box-shadow:
    0 16px 40px rgba(15, 37, 82, 0.20),
    inset 0 1px 0 rgba(255,255,255,0.78);
}
.quote-card::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(201, 162, 75, 0.24);
  border-radius: 18px;
  pointer-events: none;
}
.quote-card::after {
  content: "";
  position: absolute;
  width: 160px;
  height: 160px;
  right: -94px;
  bottom: -94px;
  border-radius: 999px;
  background: rgba(31, 61, 122, 0.08);
}
.quote-eyebrow {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 9px;
  color: var(--gold-500);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.3px;
  text-transform: uppercase;
}
.quote-mark {
  position: absolute;
  top: 44px;
  right: 18px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 40px;
  line-height: 1;
  color: rgba(201, 162, 75, 0.34);
  text-shadow: 0 1px 0 rgba(0,0,0,0.05);
}
.quote-text {
  position: relative;
  z-index: 1;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 21px;
  line-height: 1.35;
  color: var(--blue-800);
  margin: 0 0 10px;
  font-style: italic;
  text-align: center;
}
.quote-cite {
  position: relative;
  z-index: 1;
  font-size: 12px;
  line-height: 1.35;
  letter-spacing: 0.55px;
  color: var(--gold-500);
  text-transform: uppercase;
  margin: 0;
  font-weight: 800;
  text-align: center;
}

/* ---------- Cards ---------- */
.card {
  background: rgba(255,253,246,0.98);
  border: 1px solid rgba(255,255,255,0.55);
  border-radius: calc(var(--radius) + 2px);
  padding: 16px;
  box-shadow:
    0 16px 40px rgba(15, 37, 82, 0.18),
    inset 0 1px 0 rgba(255,255,255,0.76);
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--blue-700);
  margin: 2px 0 8px;
}
.output-label { margin-top: 14px; }

/* ---------- Input ---------- */
.input {
  width: 100%;
  resize: vertical;
  min-height: 110px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px; /* iOS no-zoom */
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
}
.input:focus {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(58, 99, 176, 0.18);
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.row-clear { justify-content: space-between; }
.row-actions { margin-top: 14px; }

.detected {
  font-size: 12px;
  color: var(--blue-600);
  letter-spacing: 0.3px;
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  flex: 1;
  background: linear-gradient(180deg, var(--blue-600) 0%, var(--blue-700) 100%);
  color: #FFFDF6;
  box-shadow: 0 4px 12px rgba(31, 61, 122, 0.32), inset 0 1px 0 rgba(255,255,255,0.18);
}
.btn-primary:hover { background: linear-gradient(180deg, #355CAA 0%, #244585 100%); }

.btn-gold {
  flex: 1;
  background: linear-gradient(180deg, var(--gold-200) 0%, var(--gold-400) 100%);
  color: var(--blue-900);
  box-shadow: 0 4px 12px rgba(201, 162, 75, 0.35), inset 0 1px 0 rgba(255,255,255,0.4);
}
.btn-gold:hover { filter: brightness(1.04); }

.btn-ghost {
  background: transparent;
  color: var(--blue-700);
  border: 1.5px solid var(--line);
  padding: 8px 14px;
  min-height: 36px;
  font-size: 13px;
}
.btn-ghost:hover { background: rgba(31, 61, 122, 0.06); }

/* loading state */
.spinner {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #FFFDF6;
  display: none;
  animation: spin 0.7s linear infinite;
}
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading .btn-label { opacity: 0.75; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Output ---------- */
.output {
  margin-top: 8px;
  background: linear-gradient(180deg, #fff 0%, var(--gold-100) 140%);
  border: 1.5px dashed var(--gold-300);
  border-radius: 12px;
  min-height: 90px;
  padding: 12px 14px;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.output:focus { outline: 2px solid var(--blue-500); outline-offset: 2px; }
.output .placeholder { color: rgba(11, 26, 58, 0.45); font-style: italic; }

.status {
  margin: 10px 2px 0;
  min-height: 18px;
  font-size: 13px;
  color: var(--blue-600);
}
.status.error { color: #B0341A; }
.status.success { color: #1f7a3f; }

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  color: rgba(255,253,246,0.7);
  font-size: 12px;
  padding: 8px 0 0;
}
.gold { color: var(--gold-200); }

/* ---------- Toast bump for Copy ---------- */
.copied-flash {
  animation: pop 0.4s ease;
}
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

/* ---------- Larger screens ---------- */
@media (min-width: 640px) {
  .app { max-width: 520px; gap: 22px; }
  .brand { font-size: 40px; }
  .quote-text { font-size: 21px; }
}
