/* 풀문 트리거 스튜디오 — deep-night glass over a moonlit gradient.
   Palette mirrors the bot's card renderer: ink navy, gold moon, lavender. */

:root {
  --ink-0: #0b0e1a;
  --ink-1: #111527;
  --ink-2: #181d33;
  --ink-3: #222848;
  --line: rgba(167, 176, 222, 0.14);
  --text: #e8eaf6;
  --text-dim: #9aa3c7;
  --gold: #f2c94c;
  --gold-soft: #ffe9a8;
  --lav: #b39ddb;
  --teal: #4dd0c4;
  --rose: #ef7d93;
  --danger: #e5484d;
  --dc-bg: #313338;
  --dc-text: #dbdee1;
  --radius: 14px;
  font-size: 15px;
}

* { box-sizing: border-box; }

/* CSS display rules would otherwise override the hidden attribute the app
   toggles (e.g. .playground's display:flex). */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(242, 201, 76, 0.10), transparent 60%),
    radial-gradient(700px 600px at -10% 30%, rgba(179, 157, 219, 0.12), transparent 55%),
    linear-gradient(180deg, var(--ink-0), #0d1020 55%, #0a0c18);
  background-attachment: fixed;
}

button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: var(--text); }

/* ---- brand ---------------------------------------------------------- */

.brand { display: flex; align-items: center; gap: 12px; }

.brand-moon {
  width: 38px; height: 38px; border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, var(--gold-soft), var(--gold) 55%, #8a6a1e);
  box-shadow: 0 0 18px rgba(242, 201, 76, 0.45), inset -4px -5px 10px rgba(80, 55, 5, 0.45);
  position: relative;
}
.brand-moon::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background:
    radial-gradient(5px 5px at 62% 38%, rgba(120, 88, 18, 0.5), transparent 70%),
    radial-gradient(4px 4px at 40% 62%, rgba(120, 88, 18, 0.4), transparent 70%);
}
.brand-moon.big { width: 72px; height: 72px; margin: 0 auto 18px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 1.05rem; letter-spacing: -0.01em; }
.brand-text span { font-size: 0.78rem; color: var(--text-dim); }

/* ---- top bar --------------------------------------------------------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 16, 32, 0.72);
  backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }

.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 12px 5px 6px;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(24, 29, 51, 0.7);
  font-size: 0.85rem;
}
.user-chip img { width: 26px; height: 26px; border-radius: 50%; }
.user-chip a { color: var(--text-dim); text-decoration: none; font-size: 0.78rem; }
.user-chip a:hover { color: var(--rose); }

/* ---- layout ---------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 22px;
  padding: 22px;
  max-width: 1240px;
  margin: 0 auto;
  align-items: start;
}

/* ---- list pane ------------------------------------------------------- */

.list-pane, .editor-pane { min-width: 0; }
.list-head { display: flex; gap: 10px; margin-bottom: 14px; }
.search-wrap { flex: 1; }
.search-wrap input {
  width: 100%; padding: 10px 14px;
  background: rgba(24, 29, 51, 0.8);
  border: 1px solid var(--line); border-radius: 10px;
  outline: none;
}
.search-wrap input:focus { border-color: rgba(242, 201, 76, 0.45); }

.trigger-list { display: flex; flex-direction: column; gap: 10px; }

/* section headers dividing event triggers / quick autoresponders */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 20px 2px 2px;
}
.section-head:first-of-type { margin-top: 4px; }
.section-head h3 {
  margin: 0; font-size: 0.95rem; letter-spacing: -0.01em; color: var(--gold-soft);
}
.section-sub { margin: 0 2px 10px; font-size: 0.76rem; color: var(--text-dim); }
.mini-btn {
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 12px;
  background: rgba(24, 29, 51, 0.6); color: var(--text); font-size: 0.8rem;
}
.mini-btn:hover { border-color: var(--gold); color: var(--gold-soft); }
.list-empty { color: var(--text-dim); font-size: 0.85rem; margin: 4px 2px 0; }
.list-empty b { color: var(--gold-soft); font-weight: 600; }

.trigger-card {
  text-align: left; width: 100%;
  padding: 14px 16px;
  background: linear-gradient(160deg, rgba(34, 40, 72, 0.55), rgba(24, 29, 51, 0.7));
  border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color 0.15s, transform 0.12s;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  min-width: 0;
}
.trigger-card:hover { border-color: rgba(179, 157, 219, 0.4); transform: translateY(-1px); }
.trigger-card.selected { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(242, 201, 76, 0.35); }
.trigger-card.off { opacity: 0.55; }

.tc-trigger { grid-column: 1; grid-row: 1; font-weight: 700; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.tc-trigger .mode-chip {
  font-size: 0.68rem; font-weight: 600; color: var(--ink-0);
  border-radius: 999px; padding: 2px 8px; margin-left: 8px;
  vertical-align: 2px; white-space: nowrap;
}
.mode-exact { background: var(--gold); }
.mode-includes { background: var(--teal); }
.mode-startswith { background: var(--lav); }
.mode-endswith { background: var(--rose); }

.tc-response {
  grid-column: 1; color: var(--text-dim); font-size: 0.85rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46ch;
}
.tc-meta { grid-column: 1; display: flex; gap: 8px; font-size: 0.72rem; color: var(--text-dim); }

/* enable toggle inside the card */
.tc-switch { grid-column: 2; grid-row: 1 / span 3; align-self: center; }

/* ---- editor pane ------------------------------------------------------ */

.editor-pane, .playground-card {
  background: linear-gradient(165deg, rgba(34, 40, 72, 0.5), rgba(17, 21, 39, 0.85));
  border: 1px solid var(--line); border-radius: 18px;
  padding: 20px 22px 22px;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 50px rgba(4, 6, 14, 0.5);
}

.editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.editor-head h2 { margin: 0; font-size: 1.15rem; letter-spacing: -0.01em; }

.icon-btn {
  background: none; border: 1px solid transparent; border-radius: 8px;
  color: var(--text-dim); padding: 4px 9px;
}
.icon-btn:hover { border-color: var(--line); color: var(--text); }

.field { display: block; margin-top: 16px; }
.field-label { display: block; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 7px; }
.field-label .req { font-style: normal; color: var(--gold); font-size: 0.72rem; margin-left: 4px; }

.field input[type="text"], .field input[type="number"], .field textarea, #pg-input {
  width: 100%; padding: 11px 14px;
  background: rgba(11, 14, 26, 0.75);
  border: 1px solid var(--line); border-radius: 10px;
  outline: none; resize: vertical;
}
.field input:focus, .field textarea:focus, #pg-input:focus {
  border-color: rgba(242, 201, 76, 0.5);
  box-shadow: 0 0 0 3px rgba(242, 201, 76, 0.12);
}

.field-hint { margin: 8px 2px 0; font-size: 0.8rem; color: var(--text-dim); line-height: 1.5; }

/* segmented match-mode control */
.segmented {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  background: rgba(11, 14, 26, 0.75);
  border: 1px solid var(--line); border-radius: 11px; padding: 4px;
}
.segmented button {
  border: 0; border-radius: 8px; padding: 8px 4px;
  background: transparent; color: var(--text-dim); font-size: 0.8rem;
  transition: background 0.12s, color 0.12s;
}
.segmented button.on { background: var(--ink-3); color: var(--gold-soft); font-weight: 700; }

/* placeholder chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.chips-label { font-size: 0.75rem; color: var(--text-dim); margin-right: 4px; }
.chips button {
  border: 1px dashed rgba(179, 157, 219, 0.45); border-radius: 999px;
  background: rgba(179, 157, 219, 0.08); color: var(--lav);
  padding: 3px 11px; font-size: 0.78rem;
  transition: background 0.12s;
}
.chips button:hover { background: rgba(179, 157, 219, 0.2); }

/* ---- event editor: selects, condition pickers, action list ------------- */

.select {
  width: 100%; padding: 11px 14px;
  background: rgba(11, 14, 26, 0.75);
  border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font: inherit; outline: none;
}
.select:focus { border-color: rgba(242, 201, 76, 0.5); }
.select option, .select optgroup { background: var(--ink-1); }

.cond-block { margin-top: 4px; }
.cond-title { margin-top: 18px; color: var(--lav); font-weight: 600; }

.picker .picker-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.pick-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid rgba(179, 157, 219, 0.4); border-radius: 999px;
  background: rgba(179, 157, 219, 0.12); color: var(--text);
  padding: 3px 6px 3px 12px; font-size: 0.82rem;
}
.pick-chip button {
  border: 0; background: none; color: var(--text-dim);
  padding: 0 4px; font-size: 0.75rem;
}
.pick-chip button:hover { color: var(--rose); }

.action-list { display: flex; flex-direction: column; gap: 10px; }
.action-card {
  border: 1px solid var(--line); border-radius: 12px;
  background: rgba(11, 14, 26, 0.45);
  padding: 12px 14px 14px;
}
.action-card .field { margin-top: 10px; }
.action-head { display: flex; align-items: center; gap: 6px; }
.action-no {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  background: rgba(242, 201, 76, 0.16); color: var(--gold-soft);
  font-size: 0.75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.action-type { flex: 1; min-width: 0; padding: 8px 10px; }
.action-head .icon-btn:disabled { opacity: 0.3; cursor: default; }
.add-action { margin-top: 10px; width: 100%; }

.segmented.seg-sm { margin-top: 8px; }
.segmented.seg-sm button { padding: 6px 4px; font-size: 0.75rem; }

/* ---- discord mock ----------------------------------------------------- */

.preview-block { margin-top: 18px; }
.discord-mock {
  background: var(--dc-bg); border-radius: 10px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 12px;
  font-family: 'gg sans', 'Noto Sans KR', sans-serif;
  border: 1px solid rgba(0, 0, 0, 0.35);
}
.dc-msg { display: flex; gap: 12px; }
.dc-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: radial-gradient(circle at 35% 30%, #8b9bff, #4757c4);
}
.dc-avatar.bot { background: radial-gradient(circle at 35% 30%, var(--gold-soft), #b8860b); }
.dc-name { font-size: 0.88rem; font-weight: 600; color: #f2f3f5; }
.dc-name.user-name { color: #8b9bff; }
.dc-msg:not(.dc-user) .dc-name { color: var(--gold-soft); }
.dc-time { font-size: 0.68rem; font-weight: 400; color: #80848e; margin-left: 5px; }
.dc-bot-tag {
  background: #5865f2; color: #fff; font-size: 0.62rem; font-weight: 600;
  border-radius: 4px; padding: 1px 5px; vertical-align: 1px;
}
.dc-text { color: var(--dc-text); font-size: 0.92rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.dc-text .mention {
  background: rgba(88, 101, 242, 0.3); color: #c9cdfb;
  border-radius: 4px; padding: 0 3px; font-weight: 500;
}
.dc-text:empty::before { content: '응답을 입력하면 여기 보여요'; color: #6d7178; font-style: italic; }

/* ---- advanced / switches ---------------------------------------------- */

.advanced { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 4px; }
.advanced summary {
  cursor: pointer; color: var(--text-dim); font-size: 0.85rem; padding: 8px 0;
  list-style: none;
}
.advanced summary::before { content: '▸ '; }
.advanced[open] summary::before { content: '▾ '; }
.advanced-body { padding: 4px 2px 6px; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; font-size: 0.9rem; cursor: pointer;
}
.switch-row input { display: none; }
.switch {
  display: inline-block;
  width: 40px; height: 22px; border-radius: 999px; position: relative;
  background: var(--ink-3); border: 1px solid var(--line);
  transition: background 0.15s; flex-shrink: 0;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-dim); transition: transform 0.15s, background 0.15s;
}
input:checked + .switch { background: rgba(242, 201, 76, 0.85); }
input:checked + .switch::after { transform: translateX(18px); background: var(--ink-0); }

/* card toggle reuses the same switch */
.tc-switch input { display: none; }

/* ---- buttons ---------------------------------------------------------- */

.primary-btn {
  border: 0; border-radius: 10px; padding: 10px 20px;
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  color: #2a1f04; font-weight: 800; letter-spacing: -0.01em;
  box-shadow: 0 4px 16px rgba(242, 201, 76, 0.25);
  transition: transform 0.1s, box-shadow 0.15s;
  text-decoration: none; display: inline-block;
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(242, 201, 76, 0.35); }
.primary-btn:disabled { opacity: 0.5; transform: none; cursor: default; }

.ghost-btn {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px;
  background: rgba(24, 29, 51, 0.6); color: var(--text);
}
.ghost-btn:hover { border-color: rgba(179, 157, 219, 0.5); }

.danger-btn {
  border: 1px solid rgba(229, 72, 77, 0.4); border-radius: 10px; padding: 9px 16px;
  background: rgba(229, 72, 77, 0.1); color: #ff9096;
}
.danger-btn:hover { background: rgba(229, 72, 77, 0.22); }

.editor-actions { display: flex; align-items: center; margin-top: 20px; }
.spacer { flex: 1; }

/* idle placeholder where the editor will appear */
.editor-idle {
  border: 1px dashed var(--line); border-radius: 18px;
  min-height: 340px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; color: var(--text-dim); text-align: center; line-height: 1.7;
}
.idle-moon {
  width: 44px; height: 44px; border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, rgba(255, 233, 168, 0.5), rgba(242, 201, 76, 0.35) 55%, transparent 75%);
  box-shadow: 0 0 24px rgba(242, 201, 76, 0.18);
}
.editor-idle strong { color: var(--gold-soft); }

/* ---- empty state ------------------------------------------------------- */

.empty-state { text-align: center; padding: 48px 20px; }
.empty-moon {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 16px;
  background: radial-gradient(circle at 35% 32%, var(--gold-soft), var(--gold) 55%, #8a6a1e);
  box-shadow: 0 0 34px rgba(242, 201, 76, 0.35);
  animation: float 4s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-7px); } }
.empty-state h2 { margin: 0 0 6px; }
.empty-state p { color: var(--text-dim); line-height: 1.6; margin: 0 0 18px; }
.empty-samples { display: flex; flex-direction: column; gap: 8px; max-width: 260px; margin: 0 auto; }
.sample-btn {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  background: rgba(24, 29, 51, 0.7);
  transition: border-color 0.12s;
}
.sample-btn:hover { border-color: var(--gold); }

/* ---- playground -------------------------------------------------------- */

.playground {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(5, 7, 14, 0.66); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 10vh 16px 16px;
}
.playground-card { width: min(560px, 100%); }
#pg-input { margin-top: 10px; }
.pg-result { margin-top: 14px; }
.pg-result .pg-none { color: var(--text-dim); font-size: 0.88rem; padding: 8px 2px; }
.pg-result .pg-hit {
  font-size: 0.82rem; color: var(--teal); margin-bottom: 8px;
}

/* ---- toast ------------------------------------------------------------- */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink-3); border: 1px solid var(--line);
  border-radius: 999px; padding: 10px 22px; font-size: 0.88rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); z-index: 60;
  animation: pop 0.18s ease-out;
}
.toast.err { border-color: rgba(229, 72, 77, 0.6); color: #ff9096; }
@keyframes pop { from { transform: translate(-50%, 8px); opacity: 0; } }

/* ---- login ------------------------------------------------------------- */

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  text-align: center; max-width: 380px; width: 100%;
  background: linear-gradient(165deg, rgba(34, 40, 72, 0.5), rgba(17, 21, 39, 0.9));
  border: 1px solid var(--line); border-radius: 22px;
  padding: 42px 34px 30px;
  box-shadow: 0 24px 70px rgba(3, 4, 10, 0.6);
}
.login-card h1 { margin: 0 0 10px; font-size: 1.4rem; letter-spacing: -0.02em; }
.login-card p { color: var(--text-dim); line-height: 1.65; margin: 0 0 22px; font-size: 0.92rem; }
.discord-btn { width: 100%; padding: 13px; background: linear-gradient(135deg, #7983f5, #5865f2); color: #fff; }
.discord-btn:hover { box-shadow: 0 6px 22px rgba(88, 101, 242, 0.4); }
.login-error { color: #ff9096; font-size: 0.85rem; }
.login-foot { font-size: 0.75rem !important; margin-top: 18px !important; }

/* ---- responsive --------------------------------------------------------- */

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 14px; }
  .editor-pane {
    position: fixed; inset: 0; z-index: 30; border-radius: 0;
    overflow-y: auto;
  }
  .editor-idle { display: none; }
  .tc-response { max-width: none; }
  .topbar { padding: 10px 14px; gap: 8px; }
  .brand-text span { display: none; }
  .user-chip span { display: none; }
  .user-chip { padding: 5px 8px 5px 6px; }
}
