* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Noto Sans Thai', 'Plus Jakarta Sans', system-ui, sans-serif;
  background: linear-gradient(150deg, #eef1f4 0%, #e2e6eb 40%, #ccd3db 100%);
  min-height: 100vh;
  color: #1c2320;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}
a { color: #0F3D2E; text-decoration: none; }
a:hover { opacity: .8; }

.page-wrap { width: 100%; display: flex; align-items: center; justify-content: center; }

.brand-row { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 22px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; background: #0F3D2E;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brand-name { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; font-size: 18px; color: #16201c; }

/* ===== Auth card (login) ===== */
.auth-card {
  background: #fff; border-radius: 22px; width: 420px; max-width: 100%;
  padding: 34px 32px 30px; box-shadow: 0 30px 60px -20px rgba(30,40,50,.28), 0 2px 8px rgba(30,40,50,.08);
}
.auth-title { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 21px; font-weight: 800; color: #16201c; margin: 0 0 4px; text-align: center; }
.auth-sub { font-size: 13px; color: #7d8983; margin: 0 0 22px; text-align: center; }

.quick-connect-label { font-size: 11.5px; font-weight: 700; color: #7d8983; text-align: center; margin-bottom: 10px; }
.quick-connect-row { display: flex; gap: 8px; margin-bottom: 20px; }
.quick-connect-chip {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 12px 6px; border-radius: 13px; border: 1.5px solid #e3e7e3; background: #fff;
  cursor: pointer; font-size: 11px; font-weight: 700; color: #3c463f;
}
.quick-connect-chip:hover { border-color: #0F3D2E; color: #0F3D2E; }
.quick-connect-chip.selected { border-color: #0F3D2E; background: #f2f8f4; color: #0F3D2E; box-shadow: 0 0 0 3px rgba(15,61,46,.08); }
.quick-connect-chip .badge-mono { width: 26px; height: 26px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 10px; font-weight: 800; }

.divider-row { display: flex; align-items: center; gap: 12px; margin: 4px 0 20px; }
.divider-row .line { flex: 1; height: 1px; background: #edf0ec; }
.divider-row span { font-size: 11.5px; color: #97a29b; font-weight: 600; }

.field-label { font-size: 12.5px; font-weight: 700; color: #4a544e; margin-bottom: 7px; display: block; }
.field-group { margin-bottom: 16px; }
input.text-input {
  width: 100%; font-family: inherit; font-size: 13.5px; padding: 11px 14px;
  border: 1.5px solid #e3e7e3; border-radius: 11px; background: #fff; color: #1c2320;
}
input.text-input:focus { outline: none; border-color: #0F3D2E; }

.btn { font-family: inherit; font-size: 13.5px; font-weight: 700; border-radius: 11px; padding: 12px 20px; border: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.btn-primary { background: #0F3D2E; color: #fff; }
.btn-primary:hover { filter: brightness(1.12); }
.btn-outline { background: #fff; color: #3c463f; border: 1.5px solid #dde3de; }
.btn-outline:hover { border-color: #0F3D2E; color: #0F3D2E; }

.form-error {
  background: #fdecec; border: 1px solid #f4c6c6; color: #a13030; font-size: 12.5px;
  font-weight: 600; padding: 10px 14px; border-radius: 10px; margin-bottom: 16px;
}
.form-note { font-size: 11.5px; color: #97a29b; text-align: center; margin-top: 18px; line-height: 1.6; }

/* ===== Onboarding ===== */
.onboard-card {
  background: #fff; border-radius: 24px; width: 760px; max-width: 100%;
  padding: 40px 40px 34px; box-shadow: 0 30px 60px -20px rgba(30,40,50,.28), 0 2px 8px rgba(30,40,50,.08);
}
.onboard-title { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 24px; font-weight: 800; color: #16201c; margin: 0 0 6px; text-align: center; }
.onboard-sub { font-size: 13.5px; color: #7d8983; margin: 0 0 28px; text-align: center; }
.connect-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 26px; }
.connect-card { border: 1.5px solid #e3e7e3; border-radius: 16px; padding: 20px 18px; text-align: center; }
.connect-card.done { border-color: #1f8a53; background: #f3faf5; }
.connect-icon { width: 46px; height: 46px; border-radius: 13px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 13px; margin: 0 auto 12px; font-family: 'Plus Jakarta Sans', sans-serif; }
.connect-name { font-size: 14px; font-weight: 700; color: #1c2320; margin-bottom: 4px; }
.connect-hint { font-size: 11.5px; color: #97a29b; margin-bottom: 14px; line-height: 1.5; }
.connect-done-pill { display: inline-flex; align-items: center; gap: 6px; background: #e6f4ea; color: #1f8a53; font-size: 11.5px; font-weight: 700; padding: 7px 14px; border-radius: 100px; }
.connect-form input.text-input { margin-bottom: 10px; font-size: 12.5px; padding: 9px 12px; }
.connect-form .btn { padding: 9px 14px; font-size: 12px; }
.onboard-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-top: 18px; border-top: 1px solid #edf0ec; }
.skip-link { font-size: 12.5px; color: #7d8983; font-weight: 600; }
.onboard-actions .btn-primary { width: auto; padding: 11px 26px; }

/* ===== Dashboard placeholder ===== */
.dash-shell {
  background: #fff; border-radius: 24px; width: 720px; max-width: 100%;
  padding: 36px 38px; box-shadow: 0 30px 60px -20px rgba(30,40,50,.28), 0 2px 8px rgba(30,40,50,.08);
}
.dash-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 14px; }
.dash-title { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 21px; font-weight: 800; color: #16201c; margin: 0 0 3px; }
.dash-sub { font-size: 13px; color: #7d8983; margin: 0; }
.dash-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.dash-row { display: flex; align-items: center; gap: 12px; border: 1px solid #edf0ec; border-radius: 13px; padding: 13px 16px; }
.dash-row .badge-mono { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 800; flex-shrink: 0; }
.dash-row-label { font-size: 13.5px; font-weight: 700; color: #1c2320; }
.dash-row-detail { font-size: 11.5px; color: #909b95; margin-top: 1px; }
.dash-row form { margin-left: auto; }
.dash-row .btn-outline { width: auto; padding: 7px 13px; font-size: 11.5px; }
.dash-empty { text-align: center; padding: 22px 0; color: #97a29b; font-size: 13px; }
.dash-footer { display: flex; gap: 10px; padding-top: 16px; border-top: 1px solid #edf0ec; }
.dash-footer form, .dash-footer a { flex: 1; }
.dash-footer .btn { width: 100%; }
.coming-soon-note { background: #f6f8f6; border-radius: 12px; padding: 14px 16px; font-size: 12px; color: #7d8983; line-height: 1.6; margin-bottom: 22px; }

/* ===== Settings ===== */
.settings-shell {
  background: #fff; border-radius: 24px; width: 640px; max-width: 100%;
  padding: 36px 38px; box-shadow: 0 30px 60px -20px rgba(30,40,50,.28), 0 2px 8px rgba(30,40,50,.08);
}

/* ===== App shell (post-login pages with sidebar) ===== */
body.app { display: block; padding: 0; align-items: initial; justify-content: initial; background: #f3f5f3; }
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }
.app-sidebar {
  width: 226px; flex-shrink: 0; background: #fff; border-right: 1px solid #e6e9e6;
  display: flex; flex-direction: column; padding: 22px 14px; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 2px 10px; margin-bottom: 24px; }
.brand-host { font-size: 10.5px; font-weight: 700; color: #97a29b; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  font-size: 13px; font-weight: 600; color: #5b665f; cursor: pointer; text-decoration: none;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: #f2f4f2; color: #16201c; }
.nav-item.active { background: #eaf3ee; color: #0F3D2E; font-weight: 700; }
.sidebar-user {
  border-top: 1px solid #edf0ec; padding-top: 14px; margin-top: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-left: 10px; padding-right: 4px;
}
.user-name { font-size: 12.5px; font-weight: 700; color: #3c463f; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badge { display: inline-block; background: #eaf3ee; color: #0F3D2E; font-size: 9.5px; font-weight: 800; padding: 2px 7px; border-radius: 100px; margin-left: 4px; vertical-align: middle; }
.logout-btn { background: none; border: none; cursor: pointer; color: #97a29b; padding: 4px; display: flex; }
.logout-btn:hover { color: #a13030; }

.app-main { flex: 1; padding: 32px 40px 60px; max-width: 1180px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 22px; font-weight: 800; color: #16201c; margin: 0 0 4px; }
.page-sub { font-size: 13px; color: #7d8983; margin: 0; }

.card {
  background: #fff; border-radius: 18px; padding: 24px 26px; margin-bottom: 20px;
  border: 1px solid #edf0ec; box-shadow: 0 2px 10px rgba(30,40,50,.05);
}
.card-title { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 15px; font-weight: 800; color: #16201c; margin: 0 0 6px; }
.card-hint { font-size: 12px; color: #97a29b; margin: 0 0 16px; line-height: 1.6; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-tile { background: #fff; border: 1px solid #edf0ec; border-radius: 16px; padding: 18px; }
.stat-label { font-size: 11.5px; color: #97a29b; font-weight: 700; margin-bottom: 8px; }
.stat-value { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 23px; font-weight: 800; color: #16201c; }
.stat-value.accent { color: #0F3D2E; }

.tab-row { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tab-btn {
  padding: 9px 16px; border-radius: 100px; border: 1.5px solid #e3e7e3; background: #fff;
  font-size: 12.5px; font-weight: 700; color: #5b665f; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.tab-btn:hover { border-color: #0F3D2E; color: #0F3D2E; }
.tab-btn.active { background: #0F3D2E; border-color: #0F3D2E; color: #fff; }

.status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; padding: 4px 10px; border-radius: 100px; flex-shrink: 0; }
.status-pending { background: #fdf3e3; color: #a3730f; }
.status-published { background: #e6f4ea; color: #1f8a53; }

.field-group { margin-bottom: 16px; }
textarea.text-input, textarea.contact-textarea {
  width: 100%; font-family: inherit; font-size: 13.5px; padding: 12px 14px; line-height: 1.6;
  border: 1.5px solid #e3e7e3; border-radius: 11px; background: #fff; color: #1c2320; resize: vertical;
}
textarea.text-input:focus, textarea.contact-textarea:focus { outline: none; border-color: #0F3D2E; }

.keyword-box {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; border: 1.5px solid #e3e7e3; border-radius: 12px;
}
.kw-chip, .color-chip {
  display: inline-flex; align-items: center; gap: 6px; background: #f2f4f2; color: #3c463f;
  font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 100px;
}
.kw-chip button, .color-chip button { background: none; border: none; cursor: pointer; color: #97a29b; display: flex; padding: 0; }
.kw-chip button:hover, .color-chip button:hover { color: #a13030; }
.color-swatch { width: 15px; height: 15px; border-radius: 50%; border: 1px solid rgba(0,0,0,.08); flex-shrink: 0; }
.kw-input { flex: 1; min-width: 140px; border: none; outline: none; font-family: inherit; font-size: 13px; padding: 6px 4px; background: transparent; }
.kw-add { width: 28px; height: 28px; border-radius: 8px; border: none; background: #0F3D2E; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kw-add:hover { filter: brightness(1.15); }

.drop-zone {
  position: relative; border: 1.5px dashed #d5dbd6; border-radius: 14px; padding: 22px; text-align: center; margin-bottom: 12px; cursor: pointer;
}
.drop-zone:hover { border-color: #0F3D2E; background: #fbfcfb; }
.drop-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.img-thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; margin-top: 6px; }
.img-thumb { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 1; background: #f2f4f2; border: 1px solid #edf0ec; }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-remove {
  position: absolute; top: 5px; right: 5px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(20,25,22,.55); border: none; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.thumb-remove:hover { background: rgba(161,48,48,.85); }
.thumb-source-tag {
  position: absolute; bottom: 5px; left: 5px; background: rgba(20,25,22,.6); color: #fff;
  font-size: 9.5px; font-weight: 700; padding: 2px 7px; border-radius: 100px;
}
.thumb-delete-form { position: absolute; top: 5px; right: 5px; }

.empty-row { text-align: center; padding: 16px 0; color: #97a29b; font-size: 12.5px; }
.library-count-badge { background: #eaf3ee; color: #0F3D2E; font-size: 11px; font-weight: 800; padding: 4px 11px; border-radius: 100px; }
.brain-section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }

.bottom-bar { display: flex; justify-content: flex-end; }
.bottom-bar .btn { width: auto; padding: 12px 22px; }

.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.guide-card { border: 1px solid #edf0ec; border-radius: 16px; padding: 18px; text-align: center; }
.guide-box { margin: 0 auto 14px; background: #eef1ee; border-radius: 8px; }
.guide-badge { display: inline-flex; width: 26px; height: 26px; border-radius: 7px; color: #fff; font-size: 10px; font-weight: 800; align-items: center; justify-content: center; margin-bottom: 8px; font-family: 'Plus Jakarta Sans', sans-serif; }
.guide-name { font-size: 13px; font-weight: 700; color: #1c2320; margin-bottom: 3px; }
.guide-purpose { font-size: 11.5px; color: #97a29b; margin-bottom: 8px; }
.guide-dims { font-size: 12.5px; font-weight: 700; color: #3c463f; margin-bottom: 4px; }
.guide-note { font-size: 11px; color: #97a29b; line-height: 1.5; }
.guide-type-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 100px; margin-bottom: 8px; }
.guide-type-image { background: #eaf1fb; color: #2a5ea8; }
.guide-type-video { background: #fdeee7; color: #b1502a; }

.gen-btn-row { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.seo-score-wrap { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.seo-score-num { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 26px; font-weight: 800; color: #0F3D2E; }
.seo-bar-track { flex: 1; height: 8px; border-radius: 100px; background: #edf0ec; overflow: hidden; }
.seo-bar-fill { height: 100%; background: #0F3D2E; border-radius: 100px; }

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .app-sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; overflow-x: auto; padding: 12px 14px; gap: 6px; }
  .sidebar-brand { margin-bottom: 0; margin-right: 8px; }
  .sidebar-nav { flex-direction: row; }
  .nav-item span, .nav-item { white-space: nowrap; }
  .sidebar-user { border-top: none; border-left: 1px solid #edf0ec; margin-top: 0; padding-top: 0; padding-left: 12px; margin-left: auto; }
  .app-main { padding: 20px 18px 40px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Content edit popup ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,25,22,.45); display: flex;
  align-items: center; justify-content: center; padding: 24px; z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: #fff; border-radius: 18px; width: 640px; max-width: 100%; max-height: 88vh;
  display: flex; flex-direction: column; box-shadow: 0 30px 60px -20px rgba(30,40,50,.35);
  overflow: hidden;
}
.modal-box > form {
  display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; padding: 20px 24px;
  border-bottom: 1px solid #edf0ec; flex-shrink: 0;
}
.modal-title { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 16px; font-weight: 800; color: #16201c; }
.modal-close {
  background: none; border: none; cursor: pointer; color: #97a29b; font-size: 20px; line-height: 1;
  padding: 4px; display: flex;
}
.modal-close:hover { color: #a13030; }
.modal-body { padding: 20px 24px; overflow-y: auto; min-height: 0; }
.modal-body textarea.text-input { min-height: 44px; }
.modal-body textarea#editArticle { min-height: 260px; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px;
  border-top: 1px solid #edf0ec; flex-shrink: 0;
}
.modal-actions .btn { width: auto; padding: 11px 20px; }

/* ===== Install wizard ===== */
.install-steps { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 30px; }
.install-step-dot {
  width: 30px; height: 30px; border-radius: 50%; background: #edf0ec; color: #97a29b;
  display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 800;
  font-family: 'Plus Jakarta Sans', sans-serif; flex-shrink: 0; transition: background .15s, color .15s;
}
.install-step-dot.active { background: #0F3D2E; color: #fff; }
.install-step-dot.done { background: #e6f4ea; color: #1f8a53; }
.install-step-line { width: 34px; height: 2px; background: #edf0ec; flex-shrink: 0; }
.install-panel { display: none; }
.install-panel.active { display: block; }
.install-intro-icon {
  width: 56px; height: 56px; border-radius: 16px; background: #0F3D2E; color: #fff;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 18px;
}
.install-intro-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.install-intro-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: #4a544e; line-height: 1.55; }
.install-intro-list li::before { content: '✓'; color: #1f8a53; font-weight: 800; flex-shrink: 0; }
.install-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-top: 22px; margin-top: 4px; border-top: 1px solid #edf0ec; }
.install-actions .btn { width: auto; padding: 11px 26px; }
.install-actions .btn-outline { padding: 11px 20px; }
.install-skip-note { font-size: 11.5px; color: #97a29b; font-weight: 600; }
.install-review-box { background: #f7f9f7; border: 1px solid #edf0ec; border-radius: 13px; padding: 16px 18px; margin-bottom: 6px; }
.install-review-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; padding: 6px 0; border-bottom: 1px solid #edf0ec; }
.install-review-row:last-child { border-bottom: none; }
.install-review-row span:first-child { color: #97a29b; font-weight: 600; }
.install-review-row span:last-child { color: #1c2320; font-weight: 700; text-align: right; word-break: break-all; }
