/* ==========================================================================
   PRD Facile — Design System
   Inspired by Linear, Vercel, Raycast, Stripe
   ========================================================================== */

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

/* ===== Tokens ===== */
:root {
  /* Surface */
  --bg-base:    #09090b;
  --bg-subtle:  #0c0c0f;
  --bg-card:    rgba(255, 255, 255, 0.03);
  --bg-elevated: rgba(255, 255, 255, 0.06);
  --bg-input:   rgba(255, 255, 255, 0.04);
  --bg-input-focus: rgba(255, 255, 255, 0.06);

  /* Border */
  --border-subtle:  rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.08);
  --border-hover:   rgba(255, 255, 255, 0.12);
  --border-focus:   rgba(139, 92, 246, 0.5);

  /* Text */
  --text-primary:   rgba(255, 255, 255, 0.95);
  --text-secondary: rgba(255, 255, 255, 0.55);
  --text-tertiary:  rgba(255, 255, 255, 0.35);
  --text-ghost:     rgba(255, 255, 255, 0.2);

  /* Accent */
  --accent:       #8b5cf6;
  --accent-hover: #a78bfa;
  --accent-muted: rgba(139, 92, 246, 0.15);
  --accent-glow:  rgba(139, 92, 246, 0.25);
  --accent-2:     #06b6d4;

  /* Feedback */
  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.12);

  /* Shape */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Timing */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html { font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* ===== Ambient Background ===== */
.ambient {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.12;
}

.ambient-orb-1 {
  width: 600px; height: 600px;
  background: var(--accent);
  top: -200px; left: -100px;
  animation: float-1 20s ease-in-out infinite;
}

.ambient-orb-2 {
  width: 500px; height: 500px;
  background: var(--accent-2);
  bottom: -150px; right: -100px;
  animation: float-2 25s ease-in-out infinite;
}

.ambient-orb-3 {
  width: 400px; height: 400px;
  background: #ec4899;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation: float-3 22s ease-in-out infinite;
  opacity: 0.06;
}

@keyframes float-1 {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(60px, 40px); }
  66% { transform: translate(-30px, 60px); }
}

@keyframes float-2 {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(-50px, -30px); }
  66% { transform: translate(40px, -50px); }
}

@keyframes float-3 {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.15); }
}

/* Noise grain overlay */
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* ===== Header ===== */
header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(9, 9, 11, 0.72);
  backdrop-filter: blur(20px) saturate(1.2);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  max-width: 680px; margin: 0 auto;
  padding: 0 1.5rem;
  height: 56px;
  display: flex; justify-content: space-between; align-items: center;
}

.logo { display: flex; align-items: center; gap: 0.5rem; }

.logo-mark {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}

.logo-text {
  font-weight: 700; font-size: 0.95rem;
  letter-spacing: -0.03em; color: var(--text-primary);
}

.logo-badge {
  font-size: 0.6rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent); background: var(--accent-muted);
  padding: 0.15rem 0.45rem; border-radius: 6px;
}

.header-btn {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  background: var(--bg-card); border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-secondary); font-family: inherit;
  font-size: 0.8rem; font-weight: 500; cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.header-btn:hover {
  color: var(--text-primary); background: var(--bg-elevated);
  border-color: var(--border-hover);
}

/* ===== Hero ===== */
main {
  flex: 1; max-width: 680px; width: 100%;
  margin: 0 auto; padding: 0 1.5rem 3rem;
  position: relative; z-index: 2;
}

.hero { text-align: center; padding: 3rem 0 1rem; }

.hero-badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.3rem 0.75rem 0.3rem 0.6rem;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent); background: var(--accent-muted);
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 100px; margin-bottom: 1.25rem;
}

.hero h1 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 800; letter-spacing: -0.04em;
  line-height: 1.15;
  background: linear-gradient(to bottom, var(--text-primary) 40%, var(--text-secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.hero-sub {
  margin-top: 1rem; color: var(--text-secondary);
  font-size: 1.05rem; line-height: 1.6;
  max-width: 440px; margin-left: auto; margin-right: auto;
}

.hero-sub strong { color: var(--text-primary); font-weight: 600; }

/* ===== Cards (Questions) ===== */
.card {
  position: relative; margin-top: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out);
}

.card:hover {
  border-color: var(--border-hover);
}

.card:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow), 0 8px 40px -12px rgba(139, 92, 246, 0.15);
}

.card-accent {
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.card:focus-within .card-accent { opacity: 1; }

.card-inner { padding: 1.5rem; }

.card-head {
  display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.4rem;
}

.card-num {
  font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent); background: var(--accent-muted);
  padding: 0.25rem 0.55rem; border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

.card-title {
  font-size: 1.05rem; font-weight: 650;
  letter-spacing: -0.02em; color: var(--text-primary);
  cursor: pointer;
}

.card-hint {
  font-size: 0.85rem; color: var(--text-tertiary);
  margin-bottom: 0.85rem; padding-left: 3.3rem;
  line-height: 1.5;
}

@media (max-width: 600px) {
  .card-hint { padding-left: 0; }
}

textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit; font-size: 0.92rem;
  padding: 0.8rem 1rem;
  resize: vertical;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  line-height: 1.6;
}

textarea:focus {
  outline: none;
  background: var(--bg-input-focus);
  border-color: rgba(139, 92, 246, 0.3);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea::placeholder { color: var(--text-ghost); }

/* ===== CTA Button ===== */
.generate-zone {
  text-align: center; margin-top: 2.5rem; padding-bottom: 0.5rem;
}

.cta {
  position: relative; display: inline-flex;
  border: none; cursor: pointer; font-family: inherit;
  background: transparent; padding: 0;
  border-radius: var(--radius-md);
}

.cta-glow {
  position: absolute; inset: -1px;
  background: linear-gradient(135deg, var(--accent), #ec4899, var(--accent-2));
  border-radius: inherit;
  opacity: 0.6;
  filter: blur(12px);
  transition: opacity 0.3s, filter 0.3s;
  z-index: 0;
}

.cta:hover .cta-glow { opacity: 0.9; filter: blur(18px); }

.cta-content {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; gap: 0.6rem;
  padding: 0.85rem 2rem;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff; font-size: 1rem; font-weight: 650;
  letter-spacing: -0.01em;
  border-radius: inherit;
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s;
}

.cta:hover .cta-content {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px -4px rgba(139, 92, 246, 0.5);
}

.cta:active .cta-content { transform: translateY(0); }

.generate-hint {
  margin-top: 0.85rem; font-size: 0.8rem;
  color: var(--text-tertiary); letter-spacing: -0.01em;
}

/* ===== Shared: inputs, buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 1rem; border: none;
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.85rem; font-weight: 550;
  cursor: pointer; transition: all 0.2s var(--ease-out);
}

.btn-primary {
  background: var(--accent); color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-ghost-alt {
  background: var(--bg-elevated); color: var(--text-secondary);
  border: 1px solid var(--border-default);
}
.btn-ghost-alt:hover {
  color: var(--text-primary); border-color: var(--border-hover);
  background: rgba(255,255,255,0.08);
}

.full-width { width: 100%; justify-content: center; }
.hidden { display: none !important; }

input[type="text"], input[type="password"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit; font-size: 0.9rem;
  padding: 0.65rem 0.85rem;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus, input[type="password"]:focus {
  outline: none;
  background: var(--bg-input-focus);
  border-color: rgba(139, 92, 246, 0.3);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder { color: var(--text-ghost); }

.field-label {
  display: block; font-size: 0.78rem; font-weight: 550;
  color: var(--text-secondary); margin-bottom: 0.4rem;
  letter-spacing: -0.01em;
}

.input-wrapper { position: relative; }
.input-wrapper input { padding-right: 2.75rem; }

.input-action {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-tertiary);
  cursor: pointer; padding: 0.3rem; border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.input-action:hover { color: var(--text-secondary); background: var(--bg-elevated); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem;
}

.modal-overlay > .modal {
  animation: modal-in 0.25s var(--ease-out);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal {
  background: rgba(20, 20, 25, 0.95);
  backdrop-filter: blur(40px) saturate(1.4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 460px;
  box-shadow: 0 24px 80px -16px rgba(0, 0, 0, 0.6),
              0 0 1px 0 rgba(255,255,255,0.05) inset;
}

.modal-large { max-width: 700px; max-height: 88vh; display: flex; flex-direction: column; }

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header-left { display: flex; align-items: center; gap: 0.6rem; }

.modal-icon-badge {
  width: 32px; height: 32px;
  background: var(--accent-muted); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}

.modal-header h2 { font-size: 0.95rem; font-weight: 650; letter-spacing: -0.02em; }

.modal-close {
  width: 32px; height: 32px; border-radius: 8px;
  background: transparent; border: none;
  color: var(--text-tertiary); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--bg-elevated); color: var(--text-primary); }

.modal-body { padding: 1.25rem; overflow-y: auto; }

.modal-desc {
  color: var(--text-secondary); font-size: 0.85rem;
  margin-bottom: 1.25rem; line-height: 1.6;
}

/* ===== Settings: Model Selector ===== */
.model-selector { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1.25rem; }

.model-btn {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0.85rem;
  background: var(--bg-input); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary); font-family: inherit;
  cursor: pointer; transition: all 0.2s var(--ease-out);
}
.model-btn:hover { border-color: var(--border-hover); background: var(--bg-elevated); }

.model-btn.active {
  border-color: var(--border-focus);
  background: var(--accent-muted);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.model-icon {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.75rem; color: #fff;
  flex-shrink: 0;
}

.model-claude { background: linear-gradient(135deg, #d4a574, #b8734a); }
.model-gemini { background: linear-gradient(135deg, #4285f4, #34a853); }
.model-openai { background: linear-gradient(135deg, #10a37f, #0d8c6d); }

.model-info { display: flex; flex-direction: column; }
.model-name { font-size: 0.85rem; font-weight: 550; }
.model-by { font-size: 0.72rem; color: var(--text-tertiary); }

/* ===== PRD Output ===== */
.prd-banner {
  background: var(--accent-muted);
  border: 1px solid rgba(139, 92, 246, 0.12);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.prd-banner p { font-size: 0.85rem; color: var(--text-secondary); }
.prd-banner strong { color: var(--text-primary); }

.prd-actions { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }

.prd-output {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  font-size: 0.84rem; line-height: 1.8;
  white-space: pre-wrap; word-wrap: break-word;
  max-height: 50vh; overflow-y: auto;
  color: var(--text-secondary);
  font-variant-ligatures: none;
}

/* ===== Loading ===== */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
}

.loading-card { text-align: center; padding: 2rem; }

.loading-rings {
  position: relative;
  width: 56px; height: 56px;
  margin: 0 auto 1.5rem;
}

.ring {
  position: absolute; inset: 0;
  border: 2px solid transparent;
  border-radius: 50%;
}

.ring-1 {
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

.ring-2 {
  inset: 4px;
  border-right-color: var(--accent-2);
  animation: spin 1.5s linear infinite reverse;
}

.ring-3 {
  inset: 8px;
  border-bottom-color: #ec4899;
  animation: spin 2s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-card h3 {
  font-size: 1.05rem; font-weight: 650;
  letter-spacing: -0.02em; margin-bottom: 0.35rem;
}

.loading-sub { color: var(--text-tertiary); font-size: 0.85rem; }

/* ===== Footer ===== */
footer {
  position: relative; z-index: 2;
  border-top: 1px solid var(--border-subtle);
}

.footer-inner {
  max-width: 680px; margin: 0 auto;
  padding: 1.75rem 1.5rem;
  text-align: center;
}

footer p { color: var(--text-tertiary); font-size: 0.8rem; }
footer strong { color: var(--text-secondary); font-weight: 600; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.15);
  padding: 0.6rem 1.25rem;
  border-radius: 100px;
  font-size: 0.82rem; font-weight: 550;
  z-index: 999;
  transition: transform 0.35s var(--ease-spring);
  backdrop-filter: blur(12px);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .hero { padding: 2rem 0 0.5rem; }
  .hero h1 { font-size: 1.5rem; }
  .hero-sub { font-size: 0.95rem; }
  .card-inner { padding: 1.25rem; }
  .card-head { gap: 0.5rem; }
  .cta-content { padding: 0.8rem 1.5rem; font-size: 0.95rem; }
  .prd-actions { flex-direction: column; }
  .prd-actions .btn { width: 100%; justify-content: center; }
  .header-btn span { display: none; }
  .header-btn { padding: 0.4rem; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ===== Selection ===== */
::selection { background: var(--accent-muted); color: var(--text-primary); }
