/* ===== MARKDOWN-STYLE RENDERING ===== */
.result-content h4, .rec-content h4, .cf-content h4 {
  color: var(--text-primary); font-size: 0.95rem; font-weight: 700;
  margin: 1rem 0 0.4rem; display: flex; align-items: center; gap: 0.4rem;
}
.result-content p, .rec-content p, .cf-content p { margin-bottom: 0.7rem; }
.result-content ul, .rec-content ul, .cf-content ul {
  padding-left: 1.4rem; margin-bottom: 0.7rem;
}
.result-content li, .rec-content li, .cf-content li { margin-bottom: 0.35rem; }
.result-content ol, .rec-content ol, .cf-content ol {
  padding-left: 1.4rem; margin-bottom: 0.7rem; counter-reset: item;
}
.result-content ol li, .rec-content ol li, .cf-content ol li { margin-bottom: 0.4rem; }

/* Tag chips inside analysis */
.tag-chip {
  display: inline-block; padding: 0.15rem 0.6rem;
  border-radius: 999px; font-size: 0.75rem; font-weight: 600;
  margin: 0.1rem; font-family: var(--font-en);
}
.tag-good { background: rgba(52,211,153,0.15); color: var(--accent3); border: 1px solid rgba(52,211,153,0.3); }
.tag-warn { background: rgba(251,191,36,0.15); color: var(--warning); border: 1px solid rgba(251,191,36,0.3); }
.tag-bad  { background: rgba(248,113,113,0.15); color: var(--danger); border: 1px solid rgba(248,113,113,0.3); }

/* Canvas feedback blocks */
.cf-block {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1rem 1.2rem;
  margin-bottom: 0.8rem;
}
.cf-block-title {
  font-size: 0.85rem; font-weight: 700; color: var(--text-primary);
  margin-bottom: 0.4rem; display: flex; align-items: center; gap: 0.4rem;
}
.cf-block-text { font-size: 0.87rem; color: var(--text-secondary); line-height: 1.7; }

/* ===== NAV GUIDE BUTTON ===== */
.nav-guide {
  background: rgba(167,139,250,0.1);
  border: 1px solid rgba(167,139,250,0.25);
  color: var(--accent2) !important;
  font-family: var(--font-thai);
  font-size: 0.9rem;
  cursor: pointer;
}
.nav-guide:hover {
  background: rgba(167,139,250,0.2);
  border-color: rgba(167,139,250,0.5);
  color: var(--accent2);
}

/* Model selector dropdown */
.settings-select {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.6rem 0.8rem;
  color: var(--text-primary); font-family: var(--font-thai); font-size: 0.85rem;
  outline: none; cursor: pointer; min-width: 180px;
  transition: border-color var(--transition);
}
.settings-select:focus { border-color: var(--accent); }
.settings-select option { background: var(--bg-card); }

/* ===== TEST CONNECTION BUTTON ===== */
.btn-test-api {
  background: rgba(139,92,246,0.15); border: 1px solid rgba(139,92,246,0.35);
  color: #a78bfa; font-size: 0.82rem; font-weight: 600;
  padding: 0.55rem 0.9rem; border-radius: 8px; cursor: pointer;
  transition: var(--transition); white-space: nowrap; font-family: var(--font-thai);
}
.btn-test-api:hover { background: rgba(139,92,246,0.28); border-color: #a78bfa; }
.btn-test-api:disabled { opacity: 0.5; cursor: not-allowed; }

/* Test result bar */
.api-test-result {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 1rem; border-radius: 8px; margin-top: 0.5rem;
  font-size: 0.82rem; font-weight: 500; font-family: var(--font-thai);
  animation: fadeIn 0.3s ease;
}
.api-test-result.success {
  background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.3);
  color: var(--accent3);
}
.api-test-result.error {
  background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3);
  color: var(--danger);
}
.api-test-result.testing {
  background: rgba(139,92,246,0.1); border: 1px solid rgba(139,92,246,0.3);
  color: #a78bfa;
}
.api-test-model {
  margin-left: auto; opacity: 0.65; font-size: 0.75rem;
  font-family: monospace; letter-spacing: 0.02em;
}

/* ===== AUTO-SAVE TOAST ===== */
.save-toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 8888;
  background: rgba(52,211,153,0.15); border: 1px solid rgba(52,211,153,0.35);
  color: var(--accent3); font-size: 0.82rem; font-weight: 600;
  padding: 0.5rem 1rem; border-radius: 999px;
  backdrop-filter: blur(8px);
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.save-toast.show { opacity: 1; transform: translateY(0); }

/* Autosave note bar */
.cta-autosave-note {
  display: flex; align-items: center; gap: 0.75rem;
  font-size: 0.82rem; color: var(--accent3);
  background: rgba(52,211,153,0.07); border: 1px solid rgba(52,211,153,0.2);
  padding: 0.45rem 1rem; border-radius: 999px;
}
.btn-clear-canvas {
  background: none; border: 1px solid rgba(248,113,113,0.3);
  color: var(--danger); font-size: 0.78rem; font-weight: 600;
  padding: 0.2rem 0.65rem; border-radius: 6px; cursor: pointer;
  transition: var(--transition); font-family: var(--font-thai);
}
.btn-clear-canvas:hover { background: rgba(248,113,113,0.12); border-color: var(--danger); }

/* ===== GUIDE MODAL OVERLAY ===== */
.guide-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(4, 8, 18, 0.85);
  backdrop-filter: blur(8px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 2rem 1rem;
  opacity: 0; visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  overflow-y: auto;
}
.guide-overlay.open {
  opacity: 1; visibility: visible;
}

.guide-modal {
  background: #0d1525;
  border: 1px solid rgba(99,179,237,0.2);
  border-radius: 20px;
  width: 100%; max-width: 820px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 60px rgba(79,156,249,0.08);
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
.guide-overlay.open .guide-modal {
  transform: translateY(0);
}

/* Modal Header */
.guide-modal-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  padding: 2rem 2.5rem 1.5rem;
  background: linear-gradient(135deg, rgba(79,156,249,0.08), rgba(167,139,250,0.06));
  border-bottom: 1px solid rgba(99,179,237,0.12);
}
.guide-modal-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0.3rem 0.8rem; border-radius: 999px;
  background: rgba(167,139,250,0.12); border: 1px solid rgba(167,139,250,0.3);
  color: var(--accent2); font-size: 0.78rem; font-weight: 600;
  margin-bottom: 0.6rem;
}
.guide-modal-title {
  font-size: clamp(1.3rem, 3vw, 1.75rem); font-weight: 800;
  color: var(--text-primary); margin-bottom: 0.4rem; line-height: 1.3;
}
.guide-modal-subtitle { font-size: 0.9rem; color: var(--text-secondary); }
.guide-close {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-secondary); border-radius: 8px;
  width: 36px; height: 36px; cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: var(--transition);
}
.guide-close:hover { background: rgba(248,113,113,0.15); border-color: var(--danger); color: var(--danger); }

/* Modal Body */
.guide-modal-body { padding: 2rem 2.5rem; display: flex; flex-direction: column; gap: 2rem; }

/* Intro */
.guide-intro {
  display: flex; gap: 1.2rem; align-items: flex-start;
  background: rgba(79,156,249,0.06); border: 1px solid rgba(79,156,249,0.15);
  border-radius: 14px; padding: 1.4rem;
}
.guide-intro-icon { font-size: 2.5rem; flex-shrink: 0; }
.guide-intro h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.4rem; }
.guide-intro p { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.8; }
.guide-intro strong { color: var(--accent); }

/* Section title */
.guide-section-title {
  font-size: 1.05rem; font-weight: 800; color: var(--text-primary);
  margin-bottom: 0.4rem;
}
.guide-section-desc { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 0; }

/* Why Grid */
.guide-why { display: flex; flex-direction: column; gap: 0.8rem; }
.guide-why-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem;
}
.guide-why-item {
  display: flex; gap: 0.75rem; align-items: flex-start;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 1rem;
}
.guide-why-icon { font-size: 1.4rem; flex-shrink: 0; }
.guide-why-item strong { display: block; font-size: 0.88rem; margin-bottom: 0.2rem; color: var(--text-primary); }
.guide-why-item p { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.6; margin: 0; }

/* Guide Blocks */
.guide-blocks { display: flex; flex-direction: column; gap: 1rem; }

.guide-block {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden;
  transition: border-color 0.2s ease;
}
.guide-block:hover { border-color: var(--border-glow); }
.guide-block-star {
  border-color: rgba(245,158,11,0.3);
  background: linear-gradient(135deg, var(--bg-card), rgba(245,158,11,0.04));
}

.guide-block-header {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 1rem 1.2rem;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
}
.guide-block-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 0.78rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-family: var(--font-en);
}
.guide-block-icon { font-size: 1.3rem; flex-shrink: 0; }
.guide-block-header h4 { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); margin: 0; }
.guide-block-tag {
  display: inline-block; padding: 0.15rem 0.55rem;
  border-radius: 999px; font-size: 0.7rem; font-weight: 600;
  background: rgba(99,179,237,0.12); color: var(--accent);
  border: 1px solid rgba(99,179,237,0.25); margin-top: 2px;
}
.guide-block-tag.tag-star {
  background: rgba(245,158,11,0.12); color: var(--gold);
  border-color: rgba(245,158,11,0.3);
}
.guide-block-tag.tag-money {
  background: rgba(52,211,153,0.12); color: var(--accent3);
  border-color: rgba(52,211,153,0.3);
}
.guide-block-tag.tag-cost {
  background: rgba(248,113,113,0.12); color: var(--danger);
  border-color: rgba(248,113,113,0.3);
}

.guide-block-body { padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: 0.8rem; }
.guide-block-body > p { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.7; margin: 0; }

/* Questions */
.guide-questions { display: flex; flex-direction: column; gap: 0.35rem; }
.guide-q {
  font-size: 0.82rem; color: var(--text-secondary);
  background: rgba(255,255,255,0.03); border-left: 2px solid rgba(79,156,249,0.4);
  padding: 0.35rem 0.7rem; border-radius: 0 6px 6px 0;
}

/* Example */
.guide-example {
  background: rgba(52,211,153,0.05); border: 1px solid rgba(52,211,153,0.15);
  border-radius: 8px; padding: 0.7rem 0.9rem;
}
.guide-example-label {
  font-size: 0.75rem; font-weight: 700; color: var(--accent3);
  display: block; margin-bottom: 0.25rem;
}
.guide-example p { font-size: 0.83rem; color: var(--text-secondary); margin: 0; line-height: 1.6; }
.guide-example em { color: var(--text-primary); font-style: normal; }

/* Resource Types */
.guide-resource-types { display: flex; flex-direction: column; gap: 0.4rem; }
.guide-rt {
  display: flex; gap: 0.6rem; align-items: flex-start;
  font-size: 0.83rem; color: var(--text-secondary);
}
.guide-rt span { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.guide-rt strong { color: var(--text-primary); }

/* Tips */
.guide-tips { display: flex; flex-direction: column; gap: 0.8rem; }
.guide-tips-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.guide-tip {
  display: flex; gap: 0.75rem; align-items: flex-start;
  background: rgba(167,139,250,0.06); border: 1px solid rgba(167,139,250,0.15);
  border-radius: 12px; padding: 1rem;
}
.guide-tip-num {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: #fff; font-size: 0.75rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.guide-tip strong { display: block; font-size: 0.85rem; margin-bottom: 0.2rem; color: var(--text-primary); }
.guide-tip p { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.6; margin: 0; }

/* Modal Footer */
.guide-modal-footer {
  display: flex; gap: 0.75rem; justify-content: flex-end;
  padding: 1.25rem 2.5rem;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}

/* Responsive guide modal */
@media (max-width: 600px) {
  .guide-modal-header, .guide-modal-body, .guide-modal-footer { padding-left: 1.2rem; padding-right: 1.2rem; }
  .guide-why-grid, .guide-tips-grid { grid-template-columns: 1fr; }
  .guide-overlay { padding: 0.5rem; }
  .guide-modal { border-radius: 14px; }
}
