:root {
  --bg-dark: #0a0c10;
  --bg-card: rgba(22, 27, 34, 0.65);
  --bg-card-hover: rgba(30, 36, 45, 0.8);
  --border-color: rgba(255, 255, 255, 0.1);
  --text-main: #f0f6fc;
  --text-muted: #8b949e;
  --accent-color: #58a6ff;
  --accent-glow: rgba(88, 166, 255, 0.3);
  --success-color: #238636;
  --danger-color: #da3633;
  --warning-color: #d29922;
  
  --font-ui: 'Inter', sans-serif;
  --font-heading: 'Outfit', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-ui);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
}

/* Typography */
h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 700; margin-bottom: 0.5rem; }
.muted { color: var(--text-muted); font-size: 0.875rem; }
.highlight-text { color: var(--accent-color); font-weight: 600; }

/* Background Animation → 성능: 블로그 애니메이션/블러 과부하 방지 위해 정적 처리 */
.bg-gradient {
  position: fixed;
  border-radius: 50%;
  filter: blur(60px);
  z-index: -1;
  opacity: 0.25;
  animation: none; /* 100px 블러 + 20s 무한 변환이 GPU를 오래 잡아먹어 제거 */
}
@media (prefers-reduced-motion: reduce) {
  .bg-gradient { display: none; }
}
.bg-blob-1 {
  background: linear-gradient(135deg, #58a6ff, #8957e5);
  width: 500px; height: 500px;
  top: -100px; left: -100px;
}
.bg-blob-2 {
  background: linear-gradient(135deg, #d29922, #da3633);
  width: 400px; height: 400px;
  bottom: -50px; right: -50px;
}

/* Layout */
.view-container {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.w-100 { width: 100%; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.ml-auto { margin-left: auto; }

/* Glassmorphism Panel — 성능: 중첩 backdrop-filter가 무겁기 때문에 blur 축소 */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  padding: 1.5rem;
}

/* Auth View */
#authView {
  justify-content: center;
  align-items: center;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.logo { font-size: 2rem; background: linear-gradient(to right, #fff, #8b949e); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.logo span { color: var(--accent-color); -webkit-text-fill-color: var(--accent-color); font-weight: 900; font-style: italic; }
.subtitle { margin-bottom: 2rem; color: var(--text-muted); }

.auth-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; background: rgba(0,0,0,0.3); padding: 0.3rem; border-radius: 12px; }
.auth-tabs button { flex: 1; padding: 0.6rem; border: none; background: transparent; color: var(--text-muted); border-radius: 8px; cursor: pointer; transition: all 0.3s; font-weight: 500; }
.auth-tabs button.active { background: var(--bg-card-hover); color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }

/* Inputs */
.input-group { margin-bottom: 1rem; text-align: left; }
.input-group label { display: block; font-size: 0.75rem; margin-bottom: 0.4rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
input[type=text], input[type=password], input[type=email], textarea, select {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-family: var(--font-ui);
  transition: all 0.3s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input-glow { box-shadow: inset 0 0 20px rgba(88, 166, 255, 0.05); }
.glow-textarea { min-height: 120px; resize: vertical; box-shadow: inset 0 0 20px rgba(88, 166, 255, 0.05); }

/* Buttons */
button {
  font-family: var(--font-ui);
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
button:active { transform: scale(0.97); }

.btn-primary { background: linear-gradient(135deg, var(--accent-color), #2f81f7); color: #fff; box-shadow: 0 4px 15px rgba(88, 166, 255, 0.3); width: 100%; }
.btn-primary:hover { background: linear-gradient(135deg, #79b8ff, #58a6ff); box-shadow: 0 6px 20px rgba(88, 166, 255, 0.5); }
.btn-secondary { background: rgba(255,255,255,0.1); color: #fff; border: 1px solid var(--border-color); }
.btn-secondary:hover { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.3); }
.btn-success { background: var(--success-color); color: #fff; box-shadow: 0 4px 15px rgba(35, 134, 54, 0.3); }
.btn-success:hover { background: #2ea043; }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 0.5rem 0.75rem; }
.btn-ghost:hover { color: #fff; background: rgba(255,255,255,0.05); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-large { padding: 1rem 1.5rem; font-size: 1.1rem; }

/* Main Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  border-radius: 0;
  border-left: none; border-right: none; border-top: none;
  z-index: 100;
  position: sticky;
  top: 0;
}
.logo-sm { font-size: 1.25rem; font-weight: 700; background: linear-gradient(to right, #fff, var(--accent-color)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.nav-right { display: flex; align-items: center; gap: 1rem; }
.credit-badge { background: rgba(88, 166, 255, 0.1); color: var(--accent-color); padding: 0.4rem 0.8rem; border-radius: 999px; font-weight: 600; font-size: 0.875rem; border: 1px solid var(--accent-glow); }

/* App Layout */
.app-layout {
  display: flex;
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 1.5rem;
  gap: 1.5rem;
}

/* Sidebar */
.sidebar {
  width: 250px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.5rem 1rem;
  height: fit-content;
  position: sticky;
  top: 90px;
}
.nav-item {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 0.8rem 1rem;
  font-weight: 500;
  transition: background-color 0.2s, color 0.2s;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-item.active { background: rgba(88, 166, 255, 0.1); color: var(--accent-color); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; margin-right: 0.5rem; }

/* Content Area */
.content-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.page-content { animation: fadeIn 0.4s ease-out; display: flex; flex-direction: column; gap: 1.5rem; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(30px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Asset Grid */
.asset-grid-container { flex: 1; }
.filter-row { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border-color); }
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.mini-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.asset-card {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  aspect-ratio: 16/10;
  display: flex;
  flex-direction: column;
}
.asset-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.4); border-color: rgba(255,255,255,0.2); }
.asset-card.selected { border-color: var(--success-color); box-shadow: 0 0 0 2px var(--success-color); }
.asset-img { width: 100%; flex: 1; object-fit: cover; }
.asset-meta { padding: 0.5rem; font-size: 0.75rem; color: var(--text-muted); background: rgba(16,20,26,0.9); position: absolute; bottom: 0; width: 100%; display: flex; justify-content: space-between; align-items: center; }
.asset-badge { background: var(--success-color); color: #fff; position: absolute; top: 0.5rem; left: 0.5rem; font-size: 0.7rem; padding: 0.2rem 0.5rem; border-radius: 6px; font-weight: bold; opacity: 0; transition: opacity 0.2s; }
.asset-card.selected .asset-badge { opacity: 1; }
.btn-delete-asset { position: absolute; top: 0.5rem; right: 0.5rem; background: rgba(218, 54, 51, 0.8); color: white; border: none; width: 24px; height: 24px; border-radius: 50%; font-size: 12px; display: flex; align-items: center; justify-content: center; cursor: pointer; opacity: 0; transition: all 0.2s; }
.btn-delete-asset:hover { background: var(--danger-color); transform: scale(1.1); }
.asset-card:hover .btn-delete-asset { opacity: 1; }

/* Chat UI — messages는 flex:0 1 auto로 두어 resize(드래그)가 실제 높이에 반영되게 함 */
.chat-container { display: flex; flex-direction: column; height: auto; min-height: 480px; max-height: 90vh; padding: 0; overflow: hidden; }
.chat-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border-color); background: rgba(0,0,0,0.2); flex-shrink: 0; }
.chat-messages { flex: 0 1 auto; overflow-y: auto; overflow-x: hidden; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; resize: vertical; min-height: 220px; max-height: 58vh; }
.chat-input-area { flex-shrink: 0; }
.chat-actions { flex-shrink: 0; }
.chat-bubble { max-width: 80%; padding: 1rem; border-radius: 16px; font-size: 0.95rem; line-height: 1.5; animation: slideUp 0.3s ease; }
.chat-user { align-self: flex-end; background: var(--accent-color); color: #fff; border-bottom-right-radius: 4px; }
.chat-ai { align-self: flex-start; background: rgba(255,255,255,0.08); border: 1px solid var(--border-color); border-bottom-left-radius: 4px; }
.chat-input-area { padding: 1rem 1.5rem; border-top: 1px solid var(--border-color); background: rgba(0,0,0,0.2); display: flex; gap: 0.5rem; }
.chat-input-area input { flex: 1; margin: 0; background: rgba(0,0,0,0.5); }
.chat-actions { padding: 1rem 1.5rem; border-top: 1px solid var(--border-color); background: rgba(35, 134, 54, 0.05); }

/* Pre (H3 Prompt) */
pre.h3 { white-space: pre-wrap; font-size: 0.8rem; color: var(--text-muted); background: rgba(0,0,0,0.5); border: 1px solid var(--border-color); border-radius: 10px; padding: 1rem; max-height: 260px; overflow: auto; font-family: 'Consolas', monospace; }
.approve-details summary { list-style: none; }
.approve-details summary::-webkit-details-marker { display: none; }

/* Job Cards */
.job-list-container { display: flex; flex-direction: column; gap: 1.5rem; }
.job-card { display: flex; flex-direction: column; gap: 1rem; position: relative; overflow: hidden; }
.job-card-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 0.75rem; }
.job-card-media { display: flex; gap: 1rem; flex-wrap: wrap; }
.job-card-media video, .job-card-media img.prev { border-radius: 8px; border: 1px solid var(--border-color); max-height: 250px; width: auto; max-width: 100%; object-fit: contain; background: #000; }
.job-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; padding-top: 1rem; border-top: 1px solid var(--border-color); }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 0.25rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.b-ok { background: rgba(35, 134, 54, 0.15); color: var(--success-color); border: 1px solid rgba(35, 134, 54, 0.4); }
.b-bad { background: rgba(218, 54, 51, 0.15); color: var(--danger-color); border: 1px solid rgba(218, 54, 51, 0.4); }
.b-pen { background: rgba(210, 153, 34, 0.15); color: var(--warning-color); border: 1px solid rgba(210, 153, 34, 0.4); }
.b-run { background: rgba(88, 166, 255, 0.15); color: var(--accent-color); border: 1px solid rgba(88, 166, 255, 0.4); animation: pulse 2s infinite; }

@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(88, 166, 255, 0.4); } 70% { box-shadow: 0 0 0 6px rgba(88, 166, 255, 0); } 100% { box-shadow: 0 0 0 0 rgba(88, 166, 255, 0); } }

/* Toast */

/* ---- Job Gallery (grid/tile) ---- */
.job-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap:1rem; }
.job-tile { padding:0.6rem; cursor:pointer; transition: transform .15s ease; }
.job-tile:hover { transform: translateY(-2px); }
.job-tile a { display:block; }
.tile-media { width:100%; aspect-ratio:16/10; object-fit:cover; border-radius:8px; background:#0d1117; }
.tile-empty { display:flex; align-items:center; justify-content:center; color:var(--text-muted); font-size:0.8rem; }
.tile-meta { margin-top:0.5rem; }
.ok-text { color:var(--success-color); font-size:0.9rem; }

.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { background: rgba(22, 27, 34, 0.95); backdrop-filter: blur(8px); border: 1px solid var(--border-color); color: #fff; padding: 1rem 1.5rem; border-radius: 12px; font-size: 0.9rem; box-shadow: 0 10px 30px rgba(0,0,0,0.5); display: flex; align-items: center; gap: 0.75rem; animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.toast.ok { border-left: 4px solid var(--success-color); }
.toast.bad { border-left: 4px solid var(--danger-color); }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Progress Bar */
.progress-bar-container { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 9999; background: transparent; }
.progress-bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-color), #8957e5); transition: width 0.3s ease; box-shadow: 0 0 10px var(--accent-glow); }

/* Tables (Admin) */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th { text-align: left; padding: 1rem; color: var(--text-muted); border-bottom: 1px solid var(--border-color); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
td { padding: 1rem; border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: middle; }
tr:hover td { background: rgba(255,255,255,0.02); }

@media (max-width: 768px) {
  .app-layout { flex-direction: column; padding: 1rem; }
  .sidebar { width: 100%; position: static; flex-direction: row; overflow-x: auto; padding: 1rem; }
  .nav-item { width: auto; white-space: nowrap; }
  .navbar { padding: 1rem; }
}
.role-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.5rem; line-height: 1.5; min-height: 1rem; }
.res-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.res-label { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
