/* ─── Design Tokens ──────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-base: #0a0b0e;
  --bg-surface: #111318;
  --bg-card: #161b24;
  --bg-card-hover: #1c2230;
  --bg-input: #1a1f2b;
  --bg-modal: #12151d;

  --accent: #7c6aff;
  --accent-light: #9d8eff;
  --accent-dark: #5b4de0;
  --accent-glow: rgba(124, 106, 255, 0.25);

  --success: #22d3a0;
  --success-bg: rgba(34, 211, 160, 0.12);
  --warning: #f0b429;
  --warning-bg: rgba(240, 180, 41, 0.12);
  --error: #ff5c7a;
  --error-bg: rgba(255, 92, 122, 0.12);
  --info: #3b9eff;
  --info-bg: rgba(59, 158, 255, 0.12);

  --text-primary: #f0f2f7;
  --text-secondary: #8892a4;
  --text-muted: #4a5568;
  --text-link: #9d8eff;

  --border: rgba(255,255,255,0.07);
  --border-focus: rgba(124,106,255,0.5);
  --border-strong: rgba(255,255,255,0.12);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
  --shadow-accent: 0 0 30px rgba(124,106,255,0.2);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --sidebar-width: 240px;
  --topbar-height: 64px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset & Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── Scrollbar ──────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(124,106,255,0.3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(124,106,255,0.6); }

/* ─── Login Page ─────────────────────────────────────────────────────── */
#login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 60% 50% at 50% -10%, rgba(124,106,255,0.18) 0%, transparent 70%),
    var(--bg-base);
  padding: 24px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 48px 44px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg), var(--shadow-accent);
  animation: slideUp 0.5s ease;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin-bottom: 16px;
  box-shadow: 0 0 24px var(--accent-glow);
}

.login-logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 30%, var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 6px;
}

.login-error {
  background: var(--error-bg);
  border: 1px solid rgba(255,92,122,0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--error);
  font-size: 0.85rem;
  margin-bottom: 20px;
  display: none;
}
.login-error.show { display: block; animation: shake 0.4s ease; }

/* ─── Form Elements ─────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder { color: var(--text-muted); }

select.form-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%238892a4'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

textarea.form-input {
  resize: vertical;
  min-height: 100px;
}

/* ─── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--transition);
}

.btn:hover::after { background: rgba(255,255,255,0.05); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 4px 15px rgba(124,106,255,0.35);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(124,106,255,0.5); transform: translateY(-1px); }

.btn-primary-full {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 0.95rem;
}

.btn-secondary {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); border-color: var(--border-strong); }

.btn-danger {
  background: rgba(255,92,122,0.12);
  color: var(--error);
  border: 1px solid rgba(255,92,122,0.2);
}
.btn-danger:hover { background: rgba(255,92,122,0.2); }

.btn-success {
  background: rgba(34,211,160,0.12);
  color: var(--success);
  border: 1px solid rgba(34,211,160,0.2);
}
.btn-success:hover { background: rgba(34,211,160,0.2); }

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}
.btn-icon:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); border-color: var(--border); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* ─── App Layout ────────────────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  transition: transform var(--transition);
}

/* 모바일: 사이드바 오버레이 배경 */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
  z-index: 99;
  animation: fadeIn 0.2s ease;
}
.sidebar-overlay.active { display: block; }

/* 모바일 사이드바 닫기 버튼 */
.sidebar-close-btn { display: none; margin-left: auto; }

.sidebar-logo {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--accent-glow);
}

.sidebar-logo span {
  font-size: 0.95rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff, var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  padding: 14px 12px;
  flex: 1;
}

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 8px;
  margin: 14px 0 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 2px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.nav-item.active {
  background: rgba(124,106,255,0.15);
  color: var(--accent-light);
  font-weight: 600;
}
.nav-item.active .nav-icon { color: var(--accent-light); }

.nav-icon { font-size: 1rem; width: 20px; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
}

.sidebar-user {
  padding: 14px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-info { flex: 1; overflow: hidden; }
.user-info-name { font-size: 0.82rem; font-weight: 600; color: var(--text-primary); }
.user-info-role { font-size: 0.72rem; color: var(--text-muted); }

/* ─── Main Content ─────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-height);
  background: rgba(10, 11, 14, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

/* 햄버거 버튼 (모바일 전용) */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 6px;
  flex-shrink: 0;
}
.hamburger-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 99px;
  transition: all var(--transition);
}
.hamburger-btn:hover { background: rgba(255,255,255,0.1); }

.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.page-content {
  padding: 28px;
  flex: 1;
}

/* 작업 추가 폼 */
.add-task-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

/* ─── Views ─────────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.25s ease; }

/* ─── Status Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge::before { content: '●'; font-size: 0.6rem; }

.badge-pending    { background: rgba(138,138,138,0.15); color: #aaa; }
.badge-collecting { background: var(--info-bg);    color: var(--info);    animation: pulse 1.5s infinite; }
.badge-collected  { background: rgba(124,106,255,0.15); color: var(--accent-light); }
.badge-scheduled  { background: var(--warning-bg); color: var(--warning); }
.badge-publishing { background: var(--info-bg);    color: var(--info);    animation: pulse 1.5s infinite; }
.badge-published  { background: var(--success-bg); color: var(--success); }
.badge-failed     { background: var(--error-bg);   color: var(--error); }

/* ─── Cards ─────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-strong); }

/* ─── Stats Row ─────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  background: var(--stat-color, var(--accent-glow));
  border-radius: 50%;
  transform: translate(30px, -30px);
  opacity: 0.5;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--stat-color, var(--text-primary));
  margin-bottom: 6px;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ─── Toolbar ───────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.toolbar-right { margin-left: auto; display: flex; gap: 10px; }

/* ─── Task Table ───────────────────────────────────────────────────── */
.task-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.task-table {
  width: 100%;
  border-collapse: collapse;
}

.task-table th {
  background: rgba(0,0,0,0.25);
  padding: 11px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.task-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 0.875rem;
}

.task-table tr:last-child td { border-bottom: none; }
.task-table tr:hover td { background: rgba(255,255,255,0.02); }

.task-table .cell-url {
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-link);
  font-size: 0.82rem;
}

.task-table .cell-actions { white-space: nowrap; }

/* 모바일 테이블 친 컨트롤 */
.hide-mobile { }

/* Checkbox */
.checkbox {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ─── Empty State ────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 0.85rem; }

/* ─── Task Detail Panel ──────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}

@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.detail-card-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Media Grid ────────────────────────────────────────────────────── */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.media-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  aspect-ratio: 1;
  background: var(--bg-input);
}

.media-item:hover { border-color: var(--accent); }
.media-item.selected { border-color: var(--accent); }
.media-item.selected::after {
  content: '✓';
  position: absolute;
  top: 6px; right: 6px;
  width: 20px; height: 20px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
}

.media-item img, .media-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* 모바일에서 먹디아 그리드를 더 크게 */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.media-type-tag {
  position: absolute;
  bottom: 5px; left: 5px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}

/* ─── Media Overlay Buttons ─────────────────────────────────────── */
.media-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  opacity: 0;
  transition: all 0.2s ease;
  flex-direction: column;
}

.media-item:hover .media-overlay {
  opacity: 1;
  background: rgba(0,0,0,0.45);
}

.media-preview-btn {
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(4px);
  border: 1.5px solid rgba(255,255,255,0.4);
  color: #fff;
  border-radius: 50%;
  width: 36px; height: 36px;
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.media-preview-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.12);
}

.media-toggle-btn {
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(4px);
  border: 1.5px solid rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.85);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.media-toggle-btn.toggled {
  background: rgba(34,211,160,0.3);
  border-color: var(--success);
  color: var(--success);
}
.media-toggle-btn:hover { transform: scale(1.05); }

/* ─── Logs ──────────────────────────────────────────────────────────── */
.log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  animation: fadeIn 0.2s ease;
}

.log-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.log-dot-info    { background: var(--info); }
.log-dot-success { background: var(--success); }
.log-dot-warning { background: var(--warning); }
.log-dot-error   { background: var(--error); }

.log-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-top: 1px;
}

.log-category {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.log-category-SYSTEM   { background: rgba(138,138,138,0.15); color: #aaa; }
.log-category-DOWNLOAD { background: var(--info-bg);    color: var(--info); }
.log-category-REWRITE  { background: rgba(124,106,255,0.15); color: var(--accent-light); }
.log-category-PUBLISH  { background: var(--success-bg); color: var(--success); }
.log-category-ERROR    { background: var(--error-bg);   color: var(--error); }

.log-message { flex: 1; color: var(--text-primary); line-height: 1.4; }

/* ─── Modal ─────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

/* 모바일 모달: 전체 화면 채우기 */
@media (max-width: 640px) {
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
  }
}

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

.modal-lg { max-width: 900px; }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title { font-size: 1rem; font-weight: 700; }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ─── Toast Notifications ───────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 13px 18px;
  min-width: 280px;
  max-width: 380px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: var(--shadow-md);
  animation: slideInRight 0.3s ease;
  border-left: 3px solid var(--accent);
}

.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--error); }
.toast-warning { border-left-color: var(--warning); }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; line-height: 1.4; }
.toast-content { flex: 1; }
.toast-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 2px; }
.toast-message { font-size: 0.8rem; color: var(--text-secondary); }

/* ─── Date/Time Picker ──────────────────────────────────────────────── */
input[type="datetime-local"].form-input {
  color-scheme: dark;
}

/* ─── Loading Spinner ───────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ─── Progress Bar ──────────────────────────────────────────────────── */
.progress-bar {
  height: 3px;
  background: var(--bg-input);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a855f7);
  border-radius: 99px;
  transition: width 0.3s ease;
}

.progress-fill.indeterminate {
  width: 40% !important;
  animation: progressIndeterminate 1.5s ease infinite;
}

/* ─── Divider ───────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ─── Util ──────────────────────────────────────────────────────────── */
.text-muted  { color: var(--text-secondary); }
.text-small  { font-size: 0.8rem; }
.mono        { font-family: 'JetBrains Mono', monospace; }
.flex        { display: flex; align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.mt-12       { margin-top: 12px; }
.mt-20       { margin-top: 20px; }
.mb-16       { margin-bottom: 16px; }
.hidden      { display: none !important; }

/* ─── Animations ────────────────────────────────────────────────────── */
@keyframes fadeIn     { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp    { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin       { to { transform: rotate(360deg); } }
@keyframes pulse      { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes shake      { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes progressIndeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(280%); }
}

/* ─── 벤더 Account Cards ──────────────────────────────────────────── */
.account-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  transition: border-color var(--transition);
}
.account-card:hover { border-color: var(--border-strong); }
.account-card.default-account { border-color: var(--accent); background: rgba(124,106,255,0.06); }

.account-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
  box-shadow: 0 0 10px var(--accent-glow);
}

.account-info { flex: 1; min-width: 0; }
.account-name { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.account-id   { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-token { font-size: 0.72rem; color: var(--text-secondary); font-family: 'JetBrains Mono', monospace; }

.account-badge-default {
  font-size: 0.65rem; font-weight: 700;
  padding: 2px 8px; border-radius: 99px;
  background: rgba(124,106,255,0.2); color: var(--accent-light);
}

.account-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ─── Template Cards ─────────────────────────────────────────────── */
.template-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  transition: border-color var(--transition);
}
.template-card:hover { border-color: var(--border-strong); }

.template-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.template-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.template-key-badge {
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  background: rgba(255,255,255,0.08);
  color: var(--accent-light);
  padding: 2px 7px;
  border-radius: 4px;
}
.template-prompt-preview {
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: rgba(0,0,0,0.25);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  white-space: pre-wrap;
  max-height: 80px;
  overflow-y: auto;
  line-height: 1.5;
}

/* ─── Media Preview Modal ───────────────────────────────────────── */
.media-preview-container {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.media-preview-container img,
.media-preview-container video {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: var(--radius);
  object-fit: contain;
  box-shadow: var(--shadow-lg);
}

.media-preview-container video {
  min-width: 320px;
}

.media-preview-close {
  position: absolute;
  top: -16px; right: -16px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  z-index: 10;
}
.media-preview-close:hover { background: var(--error-bg); color: var(--error); }

.media-preview-filename {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
  max-width: 80vw;
  word-break: break-all;
}

/* ─── Settings Layout ─────────────────────────────────────────────── */
.settings-layout { max-width: 700px; }

/* ─── Pagination UI ─────────────────────────────────────────────────── */
.pagination-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 12px 0;
}
.page-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-light);
  background: rgba(124,106,255,0.08);
}
.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}
.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: var(--border);
}
.page-term-btn {
  font-weight: 600;
  padding: 6px 10px;
}

/* ─── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* 탑바 */
  .topbar { padding: 0 16px; }
  .btn-label { display: none; }

  /* 햄버거 버튼 표시 */
  .hamburger-btn { display: flex; }

  /* 사이드바 모바일 동작 */
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
    width: 260px;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-close-btn { display: flex; }

  /* 바디 좌측 마진 제거 */
  .main-content { margin-left: 0; }

  /* 페이지 안쪽 여백 */
  .page-content { padding: 16px; }

  /* 스탈 그리드 */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.5rem; }

  /* 작업 추가 폼: 세로 배치 */
  .add-task-form { flex-direction: column; }
  .add-task-form .form-group { min-width: unset !important; }

  /* 다음 컴 테이블에서 숨기기 */
  .hide-mobile { display: none; }

  /* 테이블 로우 단린 */
  .task-table th, .task-table td { padding: 10px 10px; }
  .task-table .cell-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .task-table .cell-url { max-width: 160px; }

  /* 모달 */
  .modal { max-width: 100%; }
  .modal-lg { max-width: 100%; }
  .detail-grid { grid-template-columns: 1fr !important; }
  .modal-body { padding: 16px; }
  .modal-header { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; flex-wrap: wrap; }

  /* 미디어 그리드 */
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }

  /* 설정 */
  .settings-layout { max-width: 100%; }

  /* 토스트 */
  .toast-container { top: auto; bottom: 16px; right: 12px; left: 12px; }
  .toast { min-width: unset; max-width: 100%; }

  /* 로그 엔트리 */
  .log-entry { flex-wrap: wrap; gap: 6px; }
  .log-time { font-size: 0.65rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 1.3rem; }
  .media-grid { grid-template-columns: repeat(3, 1fr); }
  .account-card { flex-wrap: wrap; }
  .account-actions { width: 100%; justify-content: flex-end; }
}
