
:root {
  --bg-a: #05071a;
  --bg-b: #10174b;
  --bg-c: #1e1c65;
  --panel: rgba(18, 25, 78, 0.92);
  --panel-2: rgba(31, 42, 119, 0.94);
  --text: #eef7ff;
  --muted: #bdd6ff;
  --cyan: #56f2ff;
  --cyan-soft: rgba(86, 242, 255, 0.18);
  --violet: #a78bfa;
  --purple: #7c3aed;
  --magenta: #e879f9;
  --blue: #60a5fa;
  --green: #7dfad4;
  --yellow: #f7d96b;
  --danger: #fb7185;
  --dark: #07091f;
  --line: rgba(190, 225, 255, 0.18);
  --shadow: rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(86,242,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(167,139,250,.045) 1px, transparent 1px),
    radial-gradient(circle at 18% 0%, rgba(86,242,255,.24), transparent 28%),
    radial-gradient(circle at 82% 12%, rgba(232,121,249,.22), transparent 30%),
    linear-gradient(135deg, #06071d 0%, #10174b 40%, #22135c 76%, #08091f 100%);
  background-size: 28px 28px, 28px 28px, cover, cover, cover;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 0 40%, rgba(86,242,255,.08) 41%, transparent 42% 100%),
    linear-gradient(65deg, transparent 0 62%, rgba(232,121,249,.08) 63%, transparent 64% 100%);
  mix-blend-mode: screen;
}

.app-shell { display: grid; grid-template-columns: 310px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px 16px;

  display: flex;
  flex-direction: column;

  background: linear-gradient(180deg, rgba(7,9,31,.98), rgba(20,23,82,.96));
  border-right: 1px solid var(--line);
  box-shadow: 12px 0 28px rgba(0,0,0,.22);
}
.robot-border {
  border: 1px solid rgba(154, 226, 255, 0.42);
  box-shadow:
    0 0 0 1px rgba(167,139,250,.35),
    0 0 24px rgba(86,242,255,.13),
    10px 10px 0 rgba(0,0,0,.22);
}
.brand {
  border-radius: 18px;
  padding: 22px 18px;
  background:
    radial-gradient(circle at 80% 0%, rgba(86,242,255,.22), transparent 36%),
    linear-gradient(180deg, rgba(45,36,117,.96), rgba(13,20,69,.98));
  position: relative;
  overflow: hidden;
}
.brand::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: -40px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 18px solid rgba(86,242,255,.09);
}
.robot-mark {
  width: 78px;
  height: 62px;
  border-radius: 18px 18px 22px 22px;
  background: linear-gradient(180deg, #77f7ff, #4c7dff 50%, #6336d4);
  border: 2px solid rgba(255,255,255,.75);
  position: relative;
  box-shadow: 0 0 24px rgba(86,242,255,.35), inset 0 -10px rgba(0,0,0,.14);
}
.robot-mark::before {
  content: "";
  position: absolute;
  width: 36px;
  height: 8px;
  top: -14px;
  left: 19px;
  border-top: 2px solid var(--cyan);
  border-left: 2px solid var(--cyan);
  border-right: 2px solid var(--cyan);
  border-radius: 10px 10px 0 0;
}
.robot-eye {
  position: absolute;
  top: 19px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #08123c;
  box-shadow: 0 0 12px #fff;
}
.robot-eye.left { left: 18px; }
.robot-eye.right { right: 18px; }
.robot-mouth {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 15px;
  height: 5px;
  border-radius: 10px;
  background: #dffcff;
}
.brand h1 { margin: 14px 0 6px; font-size: 1.65rem; letter-spacing: .04em; }
.brand p { color: var(--muted); line-height: 1.65; margin: 0; overflow-wrap: anywhere; }

.nav {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.settings-menu {
  margin-top: auto;
}
.nav-btn, .pixel-btn {
  border: 1px solid rgba(167,139,250,.32);
  color: white;
  cursor: pointer;
  font-weight: 800;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(45,56,151,.95), rgba(28,34,92,.95));
  box-shadow: inset 0 -4px rgba(0,0,0,.2), 0 0 18px rgba(86,242,255,.08);
  transition: transform .15s, filter .15s, box-shadow .15s;
}
.nav-btn { padding: 14px 15px; text-align: left; font-size: .96rem; }
.nav-btn:hover, .pixel-btn:hover { transform: translateY(-2px); filter: brightness(1.12); box-shadow: inset 0 -4px rgba(0,0,0,.2), 0 0 24px rgba(86,242,255,.2); }
.nav-btn.active { background: linear-gradient(180deg, #2ce6ff, #5365f4 45%, #7c3aed); color: #07112f; border-color: rgba(255,255,255,.8); }
.main { padding: 28px; min-width: 0; }
.page { display: none; animation: enter .25s ease; }
.page.active { display: block; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero, .page-head, .panel, .card, .workflow-item {
  border-radius: 20px;
  background:
    radial-gradient(circle at 92% 8%, rgba(86,242,255,.11), transparent 30%),
    linear-gradient(180deg, rgba(33,42,124,.94), rgba(12,18,63,.98));
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.hero {
  padding: 28px;
  margin-bottom: 24px;
  background:
    radial-gradient(circle at 78% 22%, rgba(86,242,255,.24), transparent 24%),
    radial-gradient(circle at 10% 90%, rgba(232,121,249,.22), transparent 32%),
    linear-gradient(135deg, rgba(37,55,164,.96), rgba(98,58,206,.93) 60%, rgba(23,25,85,.98));
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 24px; align-items: center; }
.eyebrow { margin: 0 0 10px; color: var(--cyan); text-transform: uppercase; letter-spacing: .14em; font-size: .8rem; }
h2, h3 { margin-top: 0; }
.hero h2 { font-size: clamp(1.8rem, 3vw, 2.8rem); margin: 0 0 10px; line-height: 1.15; }
p { line-height: 1.72; color: var(--muted); overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.pixel-btn { padding: 12px 18px; white-space: nowrap; overflow-wrap: normal; word-break: keep-all; }
.pixel-btn.secondary { background: linear-gradient(180deg, rgba(33,42,119,.98), rgba(21,25,75,.98)); }
.pixel-btn.small { padding: 10px 14px; white-space: nowrap; min-width: max-content; }

.robot-guardian { width: 220px; height: 260px; margin: auto; position: relative; filter: drop-shadow(0 0 24px rgba(86,242,255,.25)); }
.robot-guardian .antenna { position: absolute; left: 101px; top: 0; width: 18px; height: 42px; border-left: 3px solid var(--cyan); border-right: 3px solid var(--cyan); }
.robot-guardian .antenna::before { content: ""; position: absolute; width: 24px; height: 24px; border-radius: 50%; background: var(--magenta); top: -16px; left: -6px; box-shadow: 0 0 22px var(--magenta); }
.robot-guardian .head { position: absolute; left: 36px; top: 44px; width: 148px; height: 100px; border-radius: 26px; background: linear-gradient(180deg, #72f4ff, #6378ff 55%, #773ee5); border: 3px solid rgba(255,255,255,.7); }
.robot-guardian .head span { position: absolute; top: 34px; width: 28px; height: 16px; border-radius: 20px; background: #06113a; box-shadow: 0 0 14px #fff; }
.robot-guardian .head span:first-child { left: 34px; }
.robot-guardian .head span:last-child { right: 34px; }
.robot-guardian .body-core { position: absolute; left: 54px; top: 152px; width: 112px; height: 88px; border-radius: 20px 20px 28px 28px; background: linear-gradient(180deg, #3220a6, #1c235f); border: 2px solid rgba(86,242,255,.5); }
.robot-guardian .body-core::after { content: ""; position: absolute; left: 39px; top: 24px; width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle, #fff 0 15%, var(--cyan) 16% 45%, transparent 46%); box-shadow: 0 0 24px var(--cyan); }
.robot-guardian .arm { position: absolute; width: 36px; height: 92px; top: 157px; background: linear-gradient(180deg, #53e9ff, #673dd7); border-radius: 18px; border: 2px solid rgba(255,255,255,.55); }
.robot-guardian .arm.left { left: 8px; transform: rotate(12deg); }
.robot-guardian .arm.right { right: 8px; transform: rotate(-12deg); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 22px; }
.stats div { padding: 15px; text-align: center; background: rgba(255,255,255,.08); border-radius: 14px; border: 1px solid rgba(86,242,255,.19); min-width: 0; }
.stats strong { display: block; font-size: 1.75rem; color: var(--cyan); text-shadow: 0 0 12px rgba(86,242,255,.48); }
.stats span { color: var(--muted); }
.grid.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid.one { display: grid; grid-template-columns: 1fr; gap: 18px; }
.panel, .page-head { padding: 20px; margin-bottom: 20px; }
.world-map { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.world-map div { min-height: 105px; display: grid; align-content: center; gap: 6px; text-align: center; background: linear-gradient(180deg, rgba(72,83,216,.8), rgba(31,42,119,.92)); border-radius: 14px; font-weight: 800; border: 1px solid rgba(86,242,255,.18); padding: 10px; min-width: 0; }
.world-map strong { color: white; }
.world-map span { color: var(--muted); font-size: .88rem; font-weight: 600; }
.search-box { display: flex; gap: 10px; align-items: stretch; }
.search-box input { flex: 1 1 auto; min-width: 0; }
.search-box .pixel-btn {
  flex: 0 0 auto;
  min-width: 92px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
  line-height: 1.1;
  text-align: center;
}
input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(86,242,255,.28); color: white; background: rgba(7,13,48,.88); outline: 0; min-width: 0; }
input:focus { box-shadow: 0 0 0 3px rgba(86,242,255,.16); }
.search-results { display: grid; gap: 8px; margin-top: 12px; }
.search-result { padding: 12px; background: rgba(255,255,255,.07); border-radius: 12px; color: var(--muted); border: 1px solid rgba(255,255,255,.08); min-width: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: stretch; }
.card, .workflow-item { padding: 18px; position: relative; min-width: 0; }
.card h3 { color: white; margin-bottom: 8px; line-height: 1.35; }
.tag { display: inline-block; padding: 5px 10px; border-radius: 999px; background: var(--cyan); color: #06113a; font-weight: 900; font-size: .8rem; margin-bottom: 9px; max-width: 100%; }
.tag.ai { background: var(--magenta); }
.tag.integration { background: var(--green); }
.tag.database { background: #c4b5fd; }
.tag.support { background: var(--yellow); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.filter-btn { border: 1px solid rgba(86,242,255,.22); background: rgba(255,255,255,.06); color: white; border-radius: 999px; padding: 9px 13px; cursor: pointer; font-weight: 800; }
.filter-btn.active { background: linear-gradient(180deg, #54ebff, #5368ff 60%, #7c3aed); color: #06113a; }
.pretty-list, .step-list { color: var(--muted); line-height: 1.9; padding-left: 20px; margin-bottom: 0; }
.pretty-list li, .step-list li { margin-bottom: 4px; overflow-wrap: anywhere; }
.workflow-list { display: grid; gap: 18px; }
.flow { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; align-items: center; }
.flow span { background: rgba(7,13,48,.82); border: 1px solid rgba(86,242,255,.16); padding: 8px 10px; border-radius: 10px; color: #dcefff; font-weight: 800; max-width: 100%; overflow-wrap: anywhere; }

.node-card { overflow: visible; }
.node-card::after {
  content: "แตะหรือเลื่อนเมาส์เพื่อดูรูป Node";
  display: inline-block;
  margin-top: 10px;
  color: var(--cyan);
  font-size: .82rem;
  letter-spacing: .02em;
}
.node-preview-pop {
  position: absolute;
  right: 18px;
  top: -112px;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(.96);
  transition: opacity .16s ease, transform .16s ease;
}
.node-card:hover .node-preview-pop,
.node-card:focus-within .node-preview-pop {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.preview-stage {
  width: 320px;
  min-height: 192px;
  padding: 12px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 80% 0%, rgba(86,242,255,.22), transparent 42%),
    linear-gradient(180deg, rgba(8,12,42,.98), rgba(20,24,74,.98));
  border: 1px solid rgba(86,242,255,.45);
  box-shadow: 0 18px 36px rgba(0,0,0,.38), 0 0 28px rgba(86,242,255,.16);
}
.node-real-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  background: #06113a;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 10px 22px rgba(0,0,0,.25);
}
.preview-caption { margin: 10px 0 0; text-align: center; font-size: .78rem; color: #dffcff; overflow-wrap: anywhere; line-height: 1.45; }
.n8n-node-preview { display: none; }
.preview-glyph, .preview-title, .preview-subtitle { overflow-wrap: anywhere; }

code {
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(7,13,48,.75);
  color: #e5f8ff;
  white-space: normal;
}

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two { grid-template-columns: 1fr; }
  .hero-grid { grid-template-columns: 1fr; }
  .robot-guardian { display: none; }
}
@media (max-width: 760px) {
  .main { padding: 16px; }
  .stats, .world-map { grid-template-columns: 1fr; }
  .search-box { flex-direction: column; }
  .search-box .pixel-btn { width: 100%; min-width: 0; }
  .card-grid { grid-template-columns: 1fr; }
  .node-preview-pop { display: none; }
}


.agent-guide-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
}
.agent-span-12 { grid-column: span 12; }
.agent-span-8 { grid-column: span 8; }
.agent-span-6 { grid-column: span 6; }
.agent-span-4 { grid-column: span 4; }
.agent-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 14px 0 4px;
}
.agent-flow span {
  max-width: 100%;
  overflow-wrap: anywhere;
  background: rgba(7,13,48,.82);
  border: 1px solid rgba(86,242,255,.2);
  color: #e8f7ff;
  padding: 9px 11px;
  border-radius: 12px;
  font-weight: 900;
  line-height: 1.45;
}
.agent-step {
  display: grid;
  grid-template-columns: 42px minmax(0,1fr);
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255,255,255,.055);
  border: 1px solid rgba(86,242,255,.16);
  margin-bottom: 12px;
  min-width: 0;
}
.agent-step strong:first-child {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(180deg, #56f2ff, #7c3aed);
  color: #06113a;
  box-shadow: 0 0 16px rgba(86,242,255,.25);
}
.agent-step h3, .agent-step h4 { margin: 0 0 6px; line-height: 1.35; }
.agent-step p { margin: 0; }
.code-panel {
  background: rgba(7,13,48,.9);
  border: 1px solid rgba(86,242,255,.18);
  border-radius: 16px;
  padding: 16px;
  color: #e7f7ff;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: Consolas, "Courier New", monospace;
  font-size: .92rem;
  overflow-x: auto;
}
.agent-mini-preview {
  min-height: 160px;
  display: grid;
  place-items: center;
  padding: 16px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 30% 20%, rgba(86,242,255,.24), transparent 35%),
    radial-gradient(circle at 78% 70%, rgba(232,121,249,.22), transparent 35%),
    rgba(7,13,48,.64);
  border: 1px solid rgba(86,242,255,.2);
}
.agent-card-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.agent-card-list .mini-card {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255,255,255,.055);
  border: 1px solid rgba(86,242,255,.14);
  min-width: 0;
}
.agent-card-list h4 { margin: 0 0 8px; line-height: 1.35; }
.agent-card-list p { margin: 0; }
.agent-note {
  border-left: 4px solid var(--cyan);
  background: rgba(86,242,255,.07);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--muted);
  line-height: 1.75;
  overflow-wrap: anywhere;
}
@media (max-width: 1120px) {
  .agent-span-8, .agent-span-6, .agent-span-4, .agent-span-12 { grid-column: span 12; }
}



/* Protected settings + image paste */
.settings-lock {
  max-width: 560px;
  margin: 8vh auto 0;
}
.settings-lock .lock-icon {
  width: 72px; height: 72px; margin: 0 auto 14px;
  border-radius: 20px; display: grid; place-items: center;
  font-size: 2rem; background: linear-gradient(180deg,#2ce6ff,#5365f4 45%,#7c3aed);
  color: #07112f; box-shadow: 0 0 28px rgba(86,242,255,.2);
}
.settings-login-form { display: grid; gap: 12px; }
.settings-login-form label { font-weight: 800; color: #eaf7ff; }
.settings-login-form input {
  width: 100%; padding: 13px 14px; border-radius: 12px;
  border: 1px solid rgba(86,242,255,.28); color: var(--text);
  background: rgba(7,13,48,.88); outline: none;
}
.settings-login-form input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(86,242,255,.1); }
.settings-login-error { min-height: 24px; color: var(--danger); font-weight: 800; }
.settings-authbar {
  display:flex; justify-content:space-between; align-items:center; gap:12px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.settings-user-badge {
  display:inline-flex; align-items:center; gap:8px; padding:8px 12px;
  border:1px solid rgba(125,250,212,.25); border-radius:999px;
  background:rgba(125,250,212,.07); color:var(--green); font-weight:800;
}
.node-paste-zone {
  min-height: 62px; padding: 12px 14px; border-radius: 13px;
  border: 1px dashed rgba(86,242,255,.38); background: rgba(7,13,48,.5);
  color: var(--muted); text-align:center; cursor:pointer;
  transition: .15s ease; display:grid; place-items:center;
}
.node-paste-zone:hover, .node-paste-zone:focus, .node-paste-zone.paste-ready {
  border-color: var(--cyan); background: rgba(86,242,255,.09);
  color: var(--text); outline:none;
}
.node-paste-zone strong { color: var(--cyan); }
@media (max-width: 760px) {
  .settings-lock { margin-top: 4vh; }
}

/* Node image settings page */
.settings-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}
.settings-note {
  border-left: 4px solid var(--cyan);
  background: rgba(86,242,255,.07);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--muted);
  line-height: 1.75;
  overflow-wrap: anywhere;
}
.node-setting-card {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.node-setting-card.no-preview {
  grid-template-columns: 1fr;
}
#nodeImageSettingsGrid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr));
}
.node-setting-preview {
  width: 100%;
  min-height: 118px;
  border-radius: 16px;
  background: rgba(7,13,48,.75);
  border: 1px dashed rgba(86,242,255,.35);
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 8px;
}
.node-setting-preview img {
  width: 100%;
  height: auto;
  max-height: 148px;
  object-fit: contain;
  border-radius: 12px;
  display: block;
}
.node-setting-preview.empty span {
  color: var(--muted);
  text-align: center;
  font-size: .9rem;
  line-height: 1.55;
}
.node-setting-actions {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.node-setting-actions label {
  color: #eaf7ff;
  font-weight: 800;
  font-size: .9rem;
}
.node-setting-actions input[type="text"] {
  font-size: .92rem;
}
.file-input-wrap {
  display: grid;
  gap: 8px;
}
.file-input-wrap input[type="file"] {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(86,242,255,.28);
  color: var(--muted);
  background: rgba(7,13,48,.88);
}
.settings-status {
  color: var(--green);
  font-weight: 800;
  min-height: 24px;
  overflow-wrap: anywhere;
}
.node-card.has-custom-image::after {
  content: "ใช้รูป Node ที่ตั้งค่าไว้แล้ว";
}
@media (max-width: 760px) {
  #nodeImageSettingsGrid { grid-template-columns: 1fr; }
  .node-setting-card { grid-template-columns: 1fr; }
}
