/* ============================================
   CHABY Design System v1.0
   ============================================ */

/* === DESIGN TOKENS === */
:root {
  /* Colors - Light */
  --bg: #f5f5f7;
  --card: #ffffff;
  --surface: #eeeff1;
  --text: #1a1b2e;
  --text-secondary: #555568;
  --muted: #8b8b9e;
  --border: rgba(0, 0, 0, 0.06);
  --accent: #5c6270;
  --accent-hover: #4a5060;
  --accent-light: rgba(92, 98, 112, 0.07);
  --accent-gradient: linear-gradient(135deg, #5c6270 0%, #6e7380 100%);
  --danger: #E24B4A;
  --danger-light: rgba(226, 75, 74, 0.08);
  --success: #1a8c6a;
  --success-light: rgba(26, 140, 106, 0.08);

  /* Glass */
  --glass: rgba(255, 255, 255, 0.72);
  --glass-heavy: rgba(255, 255, 255, 0.88);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-blur: blur(20px) saturate(1.4);

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.10);
  --shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.14);
  --shadow-accent: 0 4px 16px rgba(92, 98, 112, 0.18);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.02);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 20px;
  --space-2xl: 28px;
  --space-3xl: 36px;

  /* Radius */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Typography */
  --font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'OkDandan', 'OkMallangB', 'Outfit', sans-serif;
  --font-xs: 11px;
  --font-sm: 12px;
  --font-base: 14px;
  --font-md: 15px;
  --font-lg: 17px;
  --font-xl: 20px;
  --font-2xl: 24px;
  --font-3xl: 32px;

  /* Transitions */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 0.15s;
  --duration-base: 0.2s;
  --duration-slow: 0.35s;
}

/* === DARK MODE TOKENS === */
[data-theme="dark"] {
  --bg: #0f1117;
  --card: #1a1b23;
  --surface: #22232e;
  --text: #eeeef2;
  --text-secondary: #b0b0c0;
  --muted: #7a7a90;
  --border: rgba(255, 255, 255, 0.07);
  --accent: #9ca3b0;
  --accent-hover: #b0b7c4;
  --accent-light: rgba(156, 163, 176, 0.10);
  --accent-gradient: linear-gradient(135deg, #9ca3b0 0%, #b0b7c4 100%);
  --danger: #FF6B6B;
  --danger-light: rgba(255, 107, 107, 0.10);
  --success: #34D399;
  --success-light: rgba(52, 211, 153, 0.10);
  --glass: rgba(26, 27, 35, 0.72);
  --glass-heavy: rgba(26, 27, 35, 0.88);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-blur: blur(20px) saturate(1.2);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.4);
  --shadow-accent: 0 4px 16px rgba(156, 163, 176, 0.15);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

/* === BASE RESET === */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body, #root { height: 100dvh; width: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--duration-slow) ease, color var(--duration-slow) ease;
}

/* === ANIMATIONS === */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(100%); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulseOnce {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* === COMPONENT CLASSES === */

/* -- Buttons -- */
.cb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--duration-base) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.cb-btn:active {
  transform: scale(0.97);
}

.cb-btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: var(--font-base);
  box-shadow: var(--shadow-accent);
}
.cb-btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.cb-btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: var(--font-sm);
}

.cb-btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: var(--font-sm);
}
.cb-btn-ghost:hover {
  background: var(--accent-light);
}

.cb-btn-danger {
  background: var(--danger);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: var(--font-sm);
}

.cb-btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--glass-heavy);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cb-btn-icon:hover {
  background: var(--surface);
}

/* -- Cards -- */
.cb-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--duration-base) ease, transform var(--duration-base) ease;
}

.cb-card-interactive {
  cursor: pointer;
}
.cb-card-interactive:active {
  transform: translateY(0) scale(0.995);
}

/* -- Glass surfaces -- */
.cb-glass {
  background: var(--glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
}
.cb-glass-heavy {
  background: var(--glass-heavy);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
}

/* -- Modals -- */
.cb-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  animation: fadeIn var(--duration-base) var(--ease-out);
}

.cb-modal {
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  animation: scaleIn var(--duration-slow) var(--ease-out);
  max-height: 90vh;
  overflow-y: auto;
}

/* -- Inputs -- */
.cb-input {
  width: 100%;
  padding: 12px 14px;
  font-size: var(--font-base);
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.cb-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.cb-input::placeholder {
  color: var(--muted);
}

/* -- Tabs -- */
.cb-tab {
  flex: 1;
  padding: 12px 0;
  text-align: center;
  font-size: var(--font-sm);
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2.5px solid transparent;
  transition: all var(--duration-base) ease;
  -webkit-tap-highlight-color: transparent;
}
.cb-tab-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.cb-tab:hover:not(.cb-tab-active) {
  color: var(--text-secondary);
}

/* -- Badge / Tags -- */
.cb-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: var(--font-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--accent-light);
  color: var(--accent);
}
.cb-badge-danger {
  background: var(--danger-light);
  color: var(--danger);
}
.cb-badge-success {
  background: var(--success-light);
  color: var(--success);
}

/* -- Avatar -- */
.cb-avatar {
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  transition: transform var(--duration-fast) ease;
}
.cb-avatar-border {
  border: 2.5px solid var(--card);
  box-shadow: var(--shadow-xs);
}

/* -- Divider -- */
.cb-divider {
  border: none;
  height: 1px;
  background: var(--border);
  margin: var(--space-md) 0;
}

/* -- Nav bar -- */
.cb-navbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border-top: 1px solid var(--glass-border);
  z-index: 40;
}

.cb-navbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  cursor: pointer;
  color: var(--muted);
  transition: color var(--duration-fast);
  -webkit-tap-highlight-color: transparent;
}
.cb-navbar-item-active {
  color: var(--accent);
}

/* -- Header -- */
.cb-header {
  padding: 16px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-bottom: 1px solid var(--glass-border);
}

/* -- Feed item -- */
.cb-feed-item {
  padding: var(--space-lg) var(--space-xl);
  margin: var(--space-sm) var(--space-md);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--duration-base), transform var(--duration-base);
}
.cb-feed-item:active {
  transform: scale(0.995);
}

/* -- Online indicator -- */
.cb-online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 2px var(--success-light);
  animation: pulseOnce 2s ease infinite;
}

/* -- Scrollbar -- */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* -- Selection -- */
::selection {
  background: var(--accent-light);
  color: var(--text);
}

/* -- Global transitions -- */
button, [role="button"], select, a {
  transition: all var(--duration-base) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
button:active, [role="button"]:active {
  opacity: 0.85;
}

/* Input focus global */
input:focus, textarea:focus, select:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-light), 0 0 0 1px var(--accent);
  border-color: var(--accent);
}


/* Like pulse */
svg[style*="fill: rgb(212, 74, 74)"],
svg[fill="#d44a4a"] {
  animation: pulseOnce 0.3s ease;
}

/* Toast */
.cb-toast {
  animation: slideUp 0.3s var(--ease-out);
}

/* === SESSION 2: Enhanced Component Styles === */


/* DM / notification list items hover */
#chaby-app [style*="padding: 14px 20px"][style*="border-bottom"],
#chaby-app [style*="padding:14px 20px"][style*="border-bottom"] {
  transition: background 0.12s ease !important;
}
#chaby-app [style*="padding: 14px 20px"][style*="border-bottom"]:hover,
#chaby-app [style*="padding:14px 20px"][style*="border-bottom"]:hover {
  background: var(--surface) !important;
}


/* Textarea focus */
#chaby-app textarea:focus {
  outline: none !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-light) !important;
}


/* Settings items hover */
#chaby-app [style*="justify-content: space-between"][style*="padding: 16px"],
#chaby-app [style*="justifyContent:space-between"][style*="padding:16px"] {
  transition: background 0.12s ease !important;
}

/* Accent buttons: gradient effect */
#chaby-app button[style*="background: var(--accent)"],
#chaby-app button[style*="background:var(--accent)"],
#chaby-app [style*="background: var(--accent)"][style*="cursor: pointer"],


/* === SESSION 3: Modals, Profile, Forms === */


/* Profile header area: gradient overlay */
#chaby-app [style*="border-radius: 0px 0px 16px 16px"],
#chaby-app [style*="borderRadius:0 0 16px 16px"],

/* Toggle switches: smooth */
#chaby-app [style*="width: 40px"][style*="height: 22px"],
#chaby-app [style*="width:40px"][style*="height:22px"],
#chaby-app [style*="width: 36px"][style*="height: 20px"] {
  transition: background 0.25s ease !important;
  cursor: pointer;
}

/* Form inputs global: consistent style */
#chaby-app input[style*="border-radius"],
#chaby-app textarea[style*="border-radius"],

/* Character cards in grid */

#chaby-app [style*="border: 1px solid var(--border)"][style*="padding: 12px"]:hover,
#chaby-app [style*="border:1px solid var(--border)"][style*="padding:12px"]:hover,

/* World/info section cards */
#chaby-app [style*="background: var(--surface)"][style*="border-radius: 10px"],
#chaby-app [style*="background:var(--surface)"][style*="borderRadius:10px"],


/* Stats numbers: bolder */
#chaby-app [style*="font-weight: 700"][style*="font-size: 16px"],
#chaby-app [style*="fontWeight:700"][style*="fontSize:16"] {
  letter-spacing: -0.02em;
}

/* Application form: section spacing */
#chaby-app [style*="border: 1px solid var(--border)"][style*="padding: 16px 18px"],

/* Suggestion box items */
#chaby-app [style*="padding: 14px"][style*="border-bottom: 1px solid"],
#chaby-app [style*="padding:14px"][style*="borderBottom:1px solid"] {
  transition: background 0.12s ease !important;
}

/* Empty state illustrations: softer */
#chaby-app [style*="text-align: center"][style*="padding: 40px"],
#chaby-app [style*="textAlign:center"][style*="padding:40px"],
#chaby-app [style*="text-align: center"][style*="padding: 48px"] {
  animation: fadeIn 0.4s ease !important;
}

/* Role badges (러너, 총괄, etc) */
#chaby-app [style*="border-radius: 6px"][style*="font-size: 10px"][style*="padding: 2px"],

/* Back button: consistent */


/* Balance display: bolder */
#chaby-app [style*="font-size: 18px"][style*="font-weight: 700"],
#chaby-app [style*="fontSize:18px"][style*="fontWeight:700"],
#chaby-app [style*="font-size: 18px"][style*="font-weight: 800"] {
  letter-spacing: -0.02em;
}


/* Settings section headers */
#chaby-app [style*="font-size: 12px"][style*="font-weight: 700"][style*="padding: 12px 20px"],
#chaby-app [style*="fontSize:12px"][style*="fontWeight:700"][style*="padding:12px 20px"] {
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  font-size: 11px !important;
}

/* Settings row hover */
#chaby-app [style*="padding: 16px 20px"][style*="justify-content: space-between"]:hover,
#chaby-app [style*="padding:16px 20px"][style*="justifyContent:space-between"]:hover {
  background: var(--surface) !important;
}


/* Bookmark items hover */
#chaby-app [style*="padding: 14px 20px"][style*="align-items: center"][style*="border-bottom"]:hover {
  background: var(--surface) !important;
}


/* Search results: subtle card style */
#chaby-app [style*="padding: 12px 20px"][style*="border-bottom"][style*="cursor: pointer"]:hover {
  background: var(--surface) !important;
}

/* === SESSION 4: Theme Presets Support === */


/* Theme color transition for smooth switching */
:root,
[data-theme="dark"] {
  transition: --accent 0.3s ease, --accent-light 0.3s ease;
}

/* Active theme indicator in settings */


/* Final polish: page-level fade */
#chaby-app > div > div[style*="overflow-y: auto"],
#chaby-app > div > div[style*="overflowY:auto"] {
  scroll-behavior: smooth;
}

/* Subtle hover on any clickable row */
#chaby-app [style*="cursor: pointer"][style*="padding"][style*="border-bottom"]:hover,
#chaby-app [style*="cursor:pointer"][style*="padding"][style*="border-bottom"]:hover {
  background: var(--surface) !important;
}

/* Version badge in settings */
#chaby-app [style*="font-size: 11px"][style*="color: var(--muted)"][style*="opacity"] {
  font-variant-numeric: tabular-nums;
}

/* Banner floating emoji animations */
@keyframes chabyFloat1 {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-6px) rotate(8deg); }
}
@keyframes chabyFloat2 {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-5px) rotate(-6deg); }
}
@keyframes chabyFloat3 {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-4px) rotate(5deg); }
}
