:root {
  --bg: #fdf8f4;
  --bg-side: #1f1c1b;
  --bg-side-2: #2a2624;
  --card: #ffffff;
  --primary: #d97757;
  --primary-hover: #c46a4f;
  --primary-soft: #f4ebe4;
  --text: #1f1c1b;
  --text-side: #f4ebe4;
  --muted: #6b6360;
  --muted-side: #9c9591;
  --border: #ece4dd;
  --border-side: #3a3431;
  --error: #c0392b;
  --success: #2c8a4a;
  --warn: #d4a017;
  --shadow: 0 1px 3px rgba(40, 30, 20, 0.06), 0 4px 12px rgba(40, 30, 20, 0.04);
  --shadow-strong: 0 8px 28px rgba(40, 30, 20, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

button, input, textarea { font-family: inherit; }

.hidden { display: none !important; }
.mobile-only { display: none; }

/* ─── 비번 게이트 ─── */
.login-overlay {
  position: fixed; inset: 0;
  background: linear-gradient(160deg, #fdf8f4 0%, #f4ebe4 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 32px 28px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: var(--shadow-strong);
}
.login-card h1 {
  margin: 12px 0 4px;
  font-size: 24px;
  letter-spacing: -0.02em;
}
.login-sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 24px;
}
.login-card input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 16px;
  background: #fdfbf9;
  outline: none;
  margin-bottom: 12px;
}
.login-card input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.18);
}
.login-error {
  color: var(--error);
  font-size: 13px;
  margin: 8px 0 0;
}
.brand-dot {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 12px rgba(217, 119, 87, 0.6);
}

/* ─── 앱 셸 ─── */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ─── 사이드바 ─── */
.sidebar {
  background: var(--bg-side);
  color: var(--text-side);
  display: flex;
  flex-direction: column;
  position: sticky; top: 0;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--border-side);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid var(--border-side);
  margin-bottom: 14px;
}
.brand-name {
  font-size: 17px; font-weight: 700; letter-spacing: -0.02em;
}
.sidebar-nav { flex: 1; overflow-y: auto; }
.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-side);
  padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-side);
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  margin: 1px 0;
  transition: background 0.12s;
}
.nav-item:hover { background: var(--bg-side-2); }
.nav-item.active {
  background: var(--primary);
  color: #fff;
}
.nav-ico { font-size: 16px; width: 22px; text-align: center; }
.nav-label { flex: 1; }
.badge-soon {
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(212, 160, 23, 0.2);
  color: var(--warn);
  border-radius: 999px;
  font-weight: 600;
}

.sidebar-foot {
  border-top: 1px solid var(--border-side);
  padding-top: 14px;
  margin-top: 10px;
}
.credits-box {
  background: var(--bg-side-2);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.credits-label {
  font-size: 11px;
  color: var(--muted-side);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.credits-value {
  font-size: 18px; font-weight: 700;
  margin: 4px 0 8px;
}
.credits-unit {
  font-size: 12px;
  color: var(--muted-side);
  font-weight: 500;
}
.credits-bar {
  height: 4px;
  background: var(--border-side);
  border-radius: 999px;
  overflow: hidden;
}
.credits-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #e89572);
}
.model-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-side-2);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--muted-side);
}
.model-dot {
  width: 6px; height: 6px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(44, 138, 74, 0.7);
}
.sidebar-foot .footer-text {
  font-size: 11px;
  color: var(--muted-side);
  margin: 14px 0 0;
  text-align: center;
}

/* ─── 메인 ─── */
.main {
  min-width: 0;
  padding-bottom: 96px;
}
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 28px;
  background: rgba(253, 248, 244, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.topbar-title {
  flex: 1;
  font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em;
}
.topbar-right {
  display: flex; align-items: center; gap: 12px;
}
.icon-btn {
  background: transparent; border: none;
  font-size: 18px;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 8px;
  color: var(--text);
}
.icon-btn:hover { background: var(--primary-soft); }
.credits-mini {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow);
}

.pane { padding: 32px 28px 60px; max-width: 1100px; margin: 0 auto; }

/* ─── 히어로 ─── */
.hero {
  text-align: center;
  padding: 32px 0 40px;
}
.hero-eyebrow {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px; font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  margin-bottom: 14px;
}
.hero h1 {
  font-size: 36px; font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 14px;
  line-height: 1.2;
}
.hero p {
  font-size: 16px; color: var(--muted);
  margin: 0;
  line-height: 1.6;
}

/* ─── 에이전트(역할) 행 ─── */
.agents-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 8px 0 48px;
}
.agent-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
  box-shadow: var(--shadow);
}
.agent-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-strong);
}
.agent-hash {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  color: var(--primary);
  font-size: 13px; font-weight: 600;
  margin-bottom: 6px;
}
.agent-role {
  font-size: 14px; font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.agent-ex {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  line-height: 1.5;
}

.section-h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 12px 0 6px;
}
.section-sub {
  color: var(--muted);
  margin: 0 0 22px;
  font-size: 14px;
}

/* ─── 도구 그리드 ─── */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}
.tool-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  display: flex; flex-direction: column;
  gap: 8px;
  text-align: left;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.tool-card:hover:not(.disabled) {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-strong);
}
.tool-card.disabled {
  cursor: not-allowed;
  opacity: 0.65;
}
.tool-slash {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12px;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-block;
  align-self: flex-start;
}
.tool-name {
  font-size: 15px; font-weight: 700;
  letter-spacing: -0.01em;
  margin-top: 2px;
}
.tool-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.tool-cost {
  font-size: 11px;
  color: var(--muted);
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  display: flex; gap: 8px; align-items: center;
}
.cost-tag {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}
.cost-free {
  background: rgba(44, 138, 74, 0.1);
  color: var(--success);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}
.cost-soon {
  background: rgba(212, 160, 23, 0.15);
  color: var(--warn);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}

/* ─── #yam 신규 도구 강조 ─── */
.tool-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.tool-tag-yam {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  color: #2d7a72;
  background: #e3f0ee;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.02em;
}
.tool-card.is-yam {
  border-left: 3px solid #2d7a72;
  background: linear-gradient(180deg, #f4faf8 0%, var(--card) 36%);
}
.tool-card.is-yam:hover:not(.disabled) {
  border-color: #2d7a72;
  border-left-color: #2d7a72;
}
.tool-card.is-yam::after {
  content: "NEW";
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: #2d7a72;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

/* ─── 홈 섹션 헤더 ─── */
.home-section-head {
  margin: 8px 0 0;
}
.home-section-head--basic {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px dashed var(--border);
}
.home-section-head .section-h2 {
  display: flex;
  align-items: center;
  gap: 10px;
}
.yam-chip {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  color: #2d7a72;
  background: #e3f0ee;
  padding: 4px 10px;
  border-radius: 8px;
  letter-spacing: 0.02em;
}

/* 기본 도구는 조금 더 압축된 카드 */
.tool-grid-basic {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.tool-grid-basic .tool-card {
  padding: 14px 16px;
  gap: 6px;
}
.tool-grid-basic .tool-name {
  font-size: 14px;
}
.tool-grid-basic .tool-desc {
  font-size: 12.5px;
  -webkit-line-clamp: 2;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tool-grid-basic .tool-cost {
  display: none;
}

/* ─── 콜아웃 ─── */
.callout {
  background: var(--primary-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 24px 0;
}
.callout-title {
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 14px;
}
.callout p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

/* ─── 카테고리 페인 헤더 ─── */
.cat-header {
  margin-bottom: 24px;
}
.cat-header h1 {
  font-size: 30px;
  letter-spacing: -0.02em;
  margin: 8px 0 4px;
}
.cat-header p {
  color: var(--muted);
  margin: 0;
  font-size: 14px;
}

/* ─── 모달 ─── */
.modal {
  position: fixed; inset: 0;
  background: rgba(20, 16, 14, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 50;
  backdrop-filter: blur(4px);
}
.modal-card {
  background: var(--card);
  border-radius: 18px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-strong);
}
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 {
  flex: 1;
  font-size: 17px;
  margin: 0;
  letter-spacing: -0.01em;
}
.modal-tag {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}
.modal-body {
  padding: 18px;
  overflow-y: auto;
}
.modal-body label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}
.modal-body textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  background: #fdfbf9;
  resize: vertical;
  outline: none;
}
.modal-body textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.15);
}
.hint {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 0;
}
.task-result {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* ─── 공용 버튼 ─── */
button.primary, button.ghost-pill {
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  font-size: 15px;
}
button.primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  margin-top: 12px;
  transition: background 0.12s;
}
button.primary:hover { background: var(--primary-hover); }
button.primary:disabled { background: #d4cbc4; cursor: not-allowed; }

button.ghost-pill {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
}
button.ghost-pill:hover { background: var(--primary); color: #fff; }

/* ─── 상태 ─── */
.status {
  text-align: center;
  padding: 14px;
  color: var(--muted);
  font-size: 14px;
  margin-top: 12px;
}
.status.error { color: var(--error); }
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── 결과(초안 카드들) ─── */
.draft {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.draft-style {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  margin-bottom: 10px;
}
.draft-text {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 10px;
}
.copy-btn {
  background: var(--primary-soft);
  color: var(--primary);
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.copy-btn.copied {
  background: var(--success);
  color: #fff;
}
.script-box {
  background: #1f1c1b;
  color: #f4ebe4;
  border-radius: 12px;
  padding: 16px 18px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: keep-all;
  overflow-x: auto;
  margin: 12px 0;
  max-height: 55vh;
  overflow-y: auto;
}

/* ─── 슬래시 입력바 ─── */
.slash-bar {
  position: fixed;
  bottom: 18px;
  left: calc(var(--sidebar-w) + 28px);
  right: 28px;
  max-width: 1044px;
  margin: 0 auto;
  z-index: 30;
}
.slash-bar-inner {
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px 10px 16px;
  box-shadow: var(--shadow-strong);
}
.slash-prefix {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  color: var(--primary);
  font-weight: 700;
  font-size: 17px;
}
#slash-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
}
.slash-suggest {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-strong);
  max-height: 320px;
  overflow-y: auto;
}
.slash-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.slash-item:last-child { border-bottom: none; }
.slash-item:hover, .slash-item.focused { background: var(--primary-soft); }
.slash-item-cmd {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
}
.slash-item-desc {
  font-size: 12px;
  color: var(--muted);
  flex: 1;
}
.slash-item-cost {
  font-size: 11px;
  color: var(--muted);
}

/* ─── 모바일 ─── */
@media (max-width: 880px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -100%;
    width: 80%; max-width: 280px;
    z-index: 40;
    transition: left 0.25s;
  }
  .sidebar.open { left: 0; }
  .mobile-only { display: inline-flex; }
  .slash-bar { left: 12px; right: 12px; bottom: 12px; }
  .pane { padding: 20px 16px 40px; }
  .hero h1 { font-size: 28px; }
  .topbar { padding: 12px 16px; }
}
