/* ==========================================================
   Submit Your Poem — Dr Pathik
   Sab classes "sp-" se start hoti hain taaki aapke existing
   CSS se clash na ho.
   ========================================================== */

.sp-page {
  --sp-brown: #7a4b2a;
  --sp-brown-d: #5a3419;
  --sp-dark: #2f1e11;
  --sp-cream: #fffdf9;
  --sp-sand: #f3e6d3;
  --sp-border: #e6d6bf;
  --sp-text: #3a2616;
  --sp-muted: #8a7664;
  --sp-red: #b3382c;
  --sp-green: #2f7a4b;
  --sp-radius: 14px;
  --sp-font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --sp-font-head: "Playfair Display", "Noto Serif Devanagari", Georgia, serif;

  background: var(--sp-cream);
  color: var(--sp-text);
  font-family: var(--sp-font-ui);
  padding: 24px 16px 64px;
  line-height: 1.5;
}
.sp-page *, .sp-page *::before, .sp-page *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

/* ---------- Hero ---------- */
.sp-hero {
  max-width: 984px;
  margin: 0 auto 28px;
  padding: 52px 24px;
  text-align: center;
  color: #fff;
  border-radius: 20px;
  background: radial-gradient(circle at 15% 10%, #6b4a2d 0%, #3a2616 55%, #2b1a0e 100%);
}
.sp-eyebrow {
  display: inline-block;
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-weight: 600;
  color: #e9a867;
}
.sp-eyebrow-dark { color: var(--sp-brown); }
.sp-hero h1 {
  margin: 10px 0 12px;
  font-family: var(--sp-font-head);
  font-size: clamp(28px, 5vw, 46px);
  line-height: 1.15;
}
.sp-hero p {
  max-width: 560px;
  margin: 0 auto;
  font-size: clamp(13px, 2vw, 15px);
  color: #f1dfc6;
}

/* ---------- Layout ---------- */
.sp-wrap { max-width: 984px; margin: 0 auto; }
.sp-form { display: flex; flex-direction: column; gap: 20px; }

.sp-card {
  background: #fff;
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  padding: clamp(16px, 3vw, 28px);
  box-shadow: 0 6px 24px rgba(90, 52, 25, .06);
}
.sp-card-title {
  margin: 0 0 18px;
  font-family: var(--sp-font-head);
  font-size: 20px;
  color: var(--sp-dark);
}
.sp-req { color: var(--sp-red); font-family: var(--sp-font-ui); }

.sp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.sp-full { grid-column: 1 / -1; }

/* ---------- Fields ---------- */
.sp-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sp-field label { font-size: 13px; font-weight: 600; color: var(--sp-dark); }
.sp-field label b { color: var(--sp-red); }
.sp-opt { font-weight: 400; color: var(--sp-muted); font-size: 12px; }

.sp-page input[type="text"],
.sp-page input[type="email"],
.sp-page select,
.sp-page textarea {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--sp-text);
  background: var(--sp-cream);
  border: 1px solid var(--sp-border);
  border-radius: 10px;
  padding: 11px 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.sp-page textarea { resize: vertical; min-height: 84px; }
.sp-page input:focus, .sp-page select:focus, .sp-page textarea:focus {
  border-color: var(--sp-brown);
  box-shadow: 0 0 0 3px rgba(122, 75, 42, .14);
}
.sp-field.sp-invalid input,
.sp-field.sp-invalid select { border-color: var(--sp-red); }

.sp-error { display: block; min-height: 0; color: var(--sp-red); font-size: 12px; margin-top: 4px; }
.sp-error:empty { display: none; }

/* ---------- Banner / links ---------- */
.sp-banner {
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between;
  background: var(--sp-sand);
  border: 1px solid var(--sp-border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}
.sp-link-btn {
  background: none; border: 0; padding: 4px 2px; cursor: pointer;
  color: var(--sp-brown); font: inherit; font-size: 13px; font-weight: 600;
}
.sp-link-btn:hover { text-decoration: underline; }

/* ---------- Editor card ---------- */
.sp-editor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sp-editor-head .sp-card-title { margin: 0; }

.sp-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 10px;
  background: var(--sp-sand);
  border: 1px solid var(--sp-border);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  position: sticky; top: 0; z-index: 5;
}
.sp-tgroup {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  padding-right: 8px;
  border-right: 1px solid var(--sp-border);
}
.sp-tgroup:last-child { border-right: 0; padding-right: 0; }

.sp-tb {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 8px;
  background: #fff;
  color: var(--sp-text);
  border: 1px solid var(--sp-border);
  border-radius: 8px;
  font: inherit; font-size: 15px; line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: background .12s, border-color .12s, color .12s;
}
.sp-tb:hover { border-color: var(--sp-brown); }
.sp-tb.is-active { background: var(--sp-brown); color: #fff; border-color: var(--sp-brown); }
.sp-tb-text { font-size: 12.5px; font-weight: 600; }
.sp-tb:focus-visible, .sp-ts:focus-visible { outline: 2px solid var(--sp-brown); outline-offset: 1px; }

.sp-page .sp-ts {
  width: auto; height: 36px; padding: 0 26px 0 10px;
  font-size: 13px; border-radius: 8px; background-color: #fff;
}

.sp-color { flex-direction: column; gap: 2px; padding-top: 4px; }
.sp-color span { font-weight: 700; font-size: 15px; line-height: 1; }
.sp-color i { display: block; width: 18px; height: 4px; border-radius: 2px; background: #7a4b2a; }
.sp-color input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; padding: 0; border: 0; }

.sp-editor-wrap {
  border: 1px solid var(--sp-border);
  border-radius: 0 0 12px 12px;
  background: var(--sp-cream);
}
.sp-editor-wrap:focus-within { border-color: var(--sp-brown); box-shadow: 0 0 0 3px rgba(122, 75, 42, .12); }

/* ---------- Editable surface ---------- */
.sp-editor {
  --sp-fs: 19px;
  --sp-lh: 1.9;
  position: relative;
  min-height: 340px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 22px clamp(14px, 3vw, 28px);
  outline: none;
  font-size: var(--sp-fs);
  line-height: var(--sp-lh);
  font-family: Georgia, "Noto Serif Devanagari", serif;
  color: var(--sp-text);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.sp-editor.is-empty::before {
  content: attr(data-placeholder);
  white-space: pre-line;
  position: absolute; left: clamp(14px, 3vw, 28px); right: 14px; top: 22px;
  color: #b8a794; pointer-events: none;
  font-size: calc(var(--sp-fs) * .85); line-height: 1.6;
}
.sp-editor[dir="rtl"].is-empty::before { left: 14px; right: clamp(14px, 3vw, 28px); text-align: right; }

.sp-editor p, .sp-editor div { margin: 0; min-height: calc(var(--sp-fs) * var(--sp-lh)); }
.sp-editor h2 { font-family: var(--sp-font-head); font-size: 1.45em; line-height: 1.3; margin: .3em 0; }
.sp-editor h3 { font-family: var(--sp-font-head); font-size: 1.2em; line-height: 1.3; margin: .3em 0; }
.sp-editor blockquote {
  margin: .4em 0; padding: 2px 0 2px 16px;
  border-left: 3px solid var(--sp-brown); color: var(--sp-brown-d); font-style: italic;
}
.sp-editor[dir="rtl"] blockquote { border-left: 0; border-right: 3px solid var(--sp-brown); padding: 2px 16px 2px 0; }
.sp-editor ul, .sp-editor ol { margin: .3em 0; padding-inline-start: 1.6em; }
.sp-editor hr {
  border: 0; text-align: center; margin: .8em 0; height: auto; overflow: visible;
}
.sp-editor hr::after { content: "❖  ❖  ❖"; color: var(--sp-brown); letter-spacing: .4em; font-size: .8em; }
.sp-editor ::selection { background: rgba(122, 75, 42, .25); }

/* language fonts */
.sp-lang-hi, .sp-lang-hinglish { font-family: "Noto Serif Devanagari", Georgia, serif; }
.sp-lang-hinglish, .sp-lang-en { font-family: Georgia, "Times New Roman", serif; }
.sp-lang-ur { font-family: "Noto Nastaliq Urdu", "Noto Serif", serif; --sp-lh: 2.4; }
.sp-lang-pa { font-family: "Noto Serif Gurmukhi", Georgia, serif; }
.sp-lang-bn { font-family: "Noto Serif Bengali", Georgia, serif; }

/* ---------- Stat bar ---------- */
.sp-statbar {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px;
  margin-top: 10px; font-size: 12.5px; color: var(--sp-muted);
}
.sp-stats { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.sp-stats b { color: var(--sp-dark); }
.sp-saved { color: var(--sp-green); }

/* ---------- Checkbox ---------- */
.sp-check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; cursor: pointer; }
.sp-check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--sp-brown); flex: none; }

/* ---------- Buttons ---------- */
.sp-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; margin-top: 22px; }
.sp-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 24px;
  font: inherit; font-size: 14.5px; font-weight: 600;
  border-radius: 999px; cursor: pointer;
  border: 1px solid transparent;
  transition: transform .1s, background .15s, box-shadow .15s;
}
.sp-btn:active { transform: translateY(1px); }
.sp-btn-primary { background: var(--sp-brown); color: #fff; box-shadow: 0 6px 16px rgba(122, 75, 42, .3); }
.sp-btn-primary:hover { background: var(--sp-brown-d); }
.sp-btn-ghost { background: #fff; color: var(--sp-brown); border-color: var(--sp-border); }
.sp-btn-ghost:hover { border-color: var(--sp-brown); }
.sp-btn[disabled] { opacity: .7; cursor: not-allowed; }
.sp-spin {
  display: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff;
  animation: sp-rot .7s linear infinite;
}
.sp-btn.is-loading .sp-spin { display: inline-block; }
@keyframes sp-rot { to { transform: rotate(360deg); } }

/* ---------- Success ---------- */
.sp-success { text-align: center; padding: 48px 20px; }
.sp-success h2 { font-family: var(--sp-font-head); margin: 12px 0 8px; }
.sp-success p { max-width: 420px; margin: 0 auto 20px; color: var(--sp-muted); }
.sp-tick {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 50%;
  display: grid; place-items: center; font-size: 30px;
  background: #e5f3ea; color: var(--sp-green);
}

/* ---------- Modal ---------- */
.sp-modal { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; padding: 16px; }
.sp-modal-bg { position: absolute; inset: 0; background: rgba(30, 18, 8, .6); }
.sp-modal-box {
  position: relative; width: min(680px, 100%); max-height: 88vh; overflow-y: auto;
  background: #fff; border-radius: 16px; padding: 28px clamp(18px, 4vw, 36px);
}
.sp-modal-x {
  position: absolute; top: 10px; right: 12px; width: 36px; height: 36px;
  border: 0; border-radius: 50%; background: var(--sp-sand); font-size: 22px; cursor: pointer; color: var(--sp-dark);
}
.sp-pv-title { font-family: var(--sp-font-head); font-size: clamp(22px, 4vw, 30px); margin: 6px 0 2px; }
.sp-pv-by { margin: 0 0 14px; color: var(--sp-muted); font-size: 13.5px; }
.sp-pv-body { min-height: 0; max-height: none; overflow: visible; padding: 14px 0 0; border-top: 1px dashed var(--sp-border); }

/* ---------- Toast ---------- */
.sp-toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 10000;
  transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px);
  background: var(--sp-dark); color: #fff; padding: 11px 20px; border-radius: 999px; font-size: 13.5px;
  transition: opacity .25s, transform .25s;
}
.sp-toast.show { opacity: 1; transform: translate(-50%, 0); }
.sp-toast.is-error { background: var(--sp-red); }

/* ---------- Focus mode ---------- */
.sp-editor-card.is-focus {
  position: fixed; inset: 0; z-index: 9990; border-radius: 0; overflow-y: auto;
  display: flex; flex-direction: column; padding: 16px;
}
.sp-editor-card.is-focus .sp-editor-wrap { flex: 1; display: flex; flex-direction: column; }
.sp-editor-card.is-focus .sp-editor { flex: 1; max-height: none; }
body.sp-lock { overflow: hidden; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .sp-page { padding: 14px 12px 48px; }
  .sp-hero { padding: 36px 16px; border-radius: 16px; margin-bottom: 18px; }
  .sp-grid { grid-template-columns: 1fr; gap: 14px; }
  .sp-toolbar { gap: 6px; padding: 8px; }
  .sp-tgroup { padding-right: 6px; }
  .sp-actions { flex-direction: column-reverse; }
  .sp-btn { width: 100%; }
  .sp-editor { min-height: 280px; max-height: 60vh; }
}
@media (max-width: 420px) {
  .sp-tb { min-width: 34px; height: 34px; font-size: 14px; }
  .sp-page .sp-ts { height: 34px; font-size: 12.5px; }
  .sp-editor-head { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  .sp-page * { transition: none !important; animation: none !important; }
}
