*, *:before, *:after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Arial, sans-serif;
  min-height: 100vh;
}

/* ==============================
   JD INPUT SCREEN — Dark Theme
============================== */

.jd-screen {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 30px 15px 50px;
  background: radial-gradient(circle at top, #111827, #05070f);
}

.jd-card {
  background: rgba(18, 26, 43, 0.95);
  border-radius: 22px;
  padding: 40px 35px;
  max-width: 620px;
  width: 100%;
  box-shadow: 0 15px 50px rgba(0,0,0,0.4);
  text-align: center;
  border: 1px solid #1e293b;
}

.jd-card img {
  margin-bottom: 18px;
}

.jd-card h1 {
  font-size: 26px;
  color: white;
  margin-bottom: 12px;
  font-weight: 700;
}

.jd-sub {
  color: #94a3b8;
  font-size: 15px;
  line-height: 1.65;
  margin-bottom: 22px;
}

.jd-badges {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.jd-badges span {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid #059669;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.jd-card textarea {
  width: 100%;
  height: 190px;
  padding: 14px;
  border: 1.5px solid #374151;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  color: #f1f5f9;
  outline: none;
  font-family: Arial, sans-serif;
  background: #0f172a;
  -webkit-overflow-scrolling: touch;
}

.jd-card textarea:focus {
  border-color: #3b82f6;
  background: #0f172a;
}

.jd-card textarea::placeholder {
  color: #64748b;
}

/* Language label */
.lang-label-wrap {
  text-align: left;
  margin-top: 14px;
  margin-bottom: 4px;
  padding: 0 2px;
}

.lang-label-text {
  font-size: 14px;
  font-weight: 700;
  color: #f1f5f9;
}

.lang-label-note {
  display: block;
  font-size: 12px;
  color: #64748b;
  margin-top: 3px;
  line-height: 1.5;
}

.jd-select {
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid #374151;
  font-size: 14px;
  color: #f1f5f9;
  background: #0f172a;
  outline: none;
  cursor: pointer;
}

.jd-btn {
  width: 100%;
  margin-top: 18px;
  padding: 16px;
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  color: white;
  font-size: 17px;
  font-weight: bold;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: 0.2s;
  letter-spacing: 0.3px;
}

.jd-btn:hover  { opacity: 0.9; transform: translateY(-2px); }
.jd-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.jd-pricing {
  margin-top: 16px;
  font-size: 15px;
  color: #60a5fa;
  font-weight: 700;
}

.jd-note {
  font-size: 12px;
  color: #f87171;
  margin-top: 8px;
}

/* ==============================
   CHAT SCREEN — Dark Space Theme
============================== */

.jd-chat-wrapper {
  display: flex;
  flex-direction: column;
  height: 100svh;
  max-width: 500px;
  margin: auto;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(circle at top, #111827, #05070f);
  color: white;
  overflow: hidden;
}

.jd-chat-wrapper::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, white, transparent),
    radial-gradient(1px 1px at 30% 80%, white, transparent),
    radial-gradient(1px 1px at 50% 40%, white, transparent),
    radial-gradient(1px 1px at 70% 10%, white, transparent),
    radial-gradient(1px 1px at 90% 60%, white, transparent),
    radial-gradient(2px 2px at 20% 50%, white, transparent),
    radial-gradient(2px 2px at 60% 15%, white, transparent),
    radial-gradient(2px 2px at 80% 70%, white, transparent);
  background-size: 250px 250px;
  opacity: 0.3;
  z-index: 0;
  pointer-events: none;
  animation: twinkle 4s infinite alternate;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.2; }
  50%       { opacity: 0.5; }
}

/* Header */
.jd-chat-header {
  background: rgba(18, 26, 43, 0.95);
  padding: 12px 14px;
  border-bottom: 1px solid #1e293b;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 10;
  backdrop-filter: blur(8px);
  gap: 8px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.header-title {
  font-weight: bold;
  font-size: 14px;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step-badge {
  background: #1e40af;
  color: #93c5fd;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Template button — header me */
.template-header-btn {
  padding: 7px 13px;
  background: #1e3a5f;
  color: #93c5fd;
  border: 1px solid #2563eb;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: 0.2s;
}

.template-header-btn:hover {
  background: #1e40af;
  color: white;
}

.new-btn {
  padding: 7px 12px;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* Progress Bar */
.progress-bar-wrap {
  height: 3px;
  background: #1e293b;
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #06b6d4);
  transition: width 0.5s ease;
}

/* Chat Box */
.jd-chat-box {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 110px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  z-index: 5;
  -webkit-overflow-scrolling: touch;
}

/* Messages */
.jd-msg {
  padding: 12px 15px;
  border-radius: 18px;
  max-width: 84%;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.jd-msg.ai {
  background: rgba(31, 41, 55, 0.95);
  color: #f1f5f9;
  align-self: flex-start;
  border: 1px solid #374151;
  border-bottom-left-radius: 4px;
}

.jd-msg.user {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* Quick Reply Chips */
.chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  padding: 7px 16px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid #3b82f6;
  border-radius: 20px;
  color: #93c5fd;
  font-size: 13px;
  cursor: pointer;
  transition: 0.2s;
  white-space: nowrap;
}

.chip:hover,
.chip:active {
  background: rgba(59, 130, 246, 0.4);
  color: white;
}

/* Example hint */
.example-hint {
  font-size: 12px;
  color: #64748b;
  margin-top: 7px;
  font-style: italic;
  line-height: 1.5;
}

/* Chat Input */
.jd-chat-input {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 500px;
  margin: auto;
  display: flex;
  padding: 12px 14px;
  background: rgba(18, 26, 43, 0.97);
  border-top: 1px solid #1e293b;
  backdrop-filter: blur(8px);
  z-index: 20;
}

.jd-chat-input input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #374151;
  background: #1e293b;
  color: white;
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
}

.jd-chat-input input::placeholder { color: #64748b; }
.jd-chat-input input:focus { border-color: #3b82f6; }

.jd-chat-input button {
  margin-left: 10px;
  padding: 12px 18px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: bold;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.jd-chat-input button:hover { background: #2563eb; }

/* Generating animation */
.generating-msg {
  background: rgba(31, 41, 55, 0.95) !important;
  border: 1px solid #1e40af !important;
}

.gen-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 5px 0;
  font-size: 13px;
  color: #94a3b8;
  transition: color 0.4s;
}

.gen-line.done { color: #4ade80; }

@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50%       { opacity: 1;   }
}

.dot-anim {
  display: inline-block;
  animation: pulse 1.2s infinite;
  font-size: 10px;
}
.dot-anim:nth-child(2) { animation-delay: 0.2s; }
.dot-anim:nth-child(3) { animation-delay: 0.4s; }

/* ==============================
   TEMPLATE POPUP
============================== */

.jd-template-popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 999;
  padding: 20px 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.jd-popup-box {
  background: #0f172a;
  border: 1px solid #1e293b;
  padding: 25px 20px;
  border-radius: 18px;
  width: 95%;
  max-width: 860px;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  text-align: center;
  color: white;
}

.jd-popup-box h3 {
  font-size: 18px;
  margin-bottom: 20px;
}

.jd-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 20px;
}

.jd-template-card {
  background: #1e293b;
  border: 1.5px solid #334155;
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  transition: 0.25s;
}

.jd-template-card img {
  width: 100%;
  height: auto;
  max-height: 460px;
  object-fit: contain;
  border-radius: 8px;
}

.jd-template-card p {
  margin: 10px 0 6px;
  font-weight: bold;
  color: white;
  font-size: 14px;
}

.jd-template-card:hover  { border-color: #3b82f6; transform: scale(1.02); }
.jd-template-card.selected { border: 2px solid #3b82f6; background: #1e3a5f; }

.price-tag {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: bold;
}

.price-tag.green { background: #dcfce7; color: #166534; }
.price-tag.blue  { background: #dbeafe; color: #1d4ed8; }

.jd-generate-btn {
  width: 100%;
  margin-top: 12px;
  padding: 11px;
  background: #22c55e;
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: bold;
  cursor: pointer;
  font-size: 14px;
}

.jd-generate-btn:hover { background: #16a34a; }

.jd-close-btn {
  padding: 10px 24px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}

/* ==============================
   MOBILE RESPONSIVE
============================== */

@media (max-width: 480px) {

  .jd-card { padding: 22px 16px; border-radius: 16px; }
  .jd-card h1 { font-size: 20px; }
  .jd-sub { font-size: 14px; }
  .jd-card textarea { height: 140px; font-size: 16px; }
  .jd-btn { font-size: 15px; padding: 14px; }

  .jd-chat-wrapper { max-width: 100%; }
  .jd-chat-input   { max-width: 100%; padding: 10px 12px; }

  .jd-chat-input input  { font-size: 16px; padding: 11px 12px; }
  .jd-chat-input button { padding: 11px 14px; font-size: 13px; }

  .header-title { font-size: 13px; }
  .template-header-btn { font-size: 12px; padding: 6px 10px; }
  .new-btn { font-size: 12px; padding: 6px 10px; }
  .step-badge { font-size: 10px; padding: 2px 8px; }

  .jd-msg { max-width: 90%; font-size: 13px; }
  .jd-chat-box { padding: 14px 12px 110px; }

  .chips-wrap {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .chips-wrap::-webkit-scrollbar { display: none; }

  .jd-popup-box { padding: 20px 14px; max-height: 92vh; }
  .jd-template-grid { grid-template-columns: 1fr; }
}