/* -------------------------------------------------------------
 SomeChat Global & Root Variables  VER5 (Final Stable)
------------------------------------------------------------- */
:root {
  --indigo-50: #f5f3ff;
  --indigo-100: #e0e7ff;
  --indigo-600: #4f46e5;
  --indigo-700: #4338ca;
  --slate-50: #f8fafc;
  --slate-200: #e2e8f0;
  --slate-500: #64748b;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --border: #e2e8f0;
  --panel: #ffffff;
  --panel2: #f1f5f9;
  --text: #1e293b;
  --accent: #4f46e5;
  --accentSoft: rgba(79, 70, 229, 0.1);
}

/* -------------------------------------------------------------
 Base Reset & Mobile Optimization
------------------------------------------------------------- */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* -------------------------------------------------------------
 🔥 핵심: iOS + 인앱 브라우저 대응 Layout
------------------------------------------------------------- */
html {
  height: -webkit-fill-available;
}

body, html {
  margin: 0;
  padding: 0;

  height: 100%;
  height: 100dvh;

  min-height: -webkit-fill-available;

  width: 100%;
  overflow: hidden;

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--slate-50);

  /* Safe Area */
  padding-bottom: env(safe-area-inset-bottom);
  padding-bottom: constant(safe-area-inset-bottom);

  /* iOS 텍스트 확대 방지 */
  -webkit-text-size-adjust: 100%;

  /* 키보드 튐 방지 */
  position: fixed;
}

/* -------------------------------------------------------------
 Chat Area
------------------------------------------------------------- */
#chat-box {
  -ms-overflow-style: none;
  scrollbar-width: none;

  overflow-y: auto;
  height: 100%;
  max-height: 100%;

  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;

  overscroll-behavior: contain;

  transform: translateZ(0);
  will-change: transform;
}

#chat-box::-webkit-scrollbar {
  display: none;
}

/* -------------------------------------------------------------
 Input Bar (🔥 핵심)
------------------------------------------------------------- */
.input-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;

  width: 100%;
  background: #fff;

  padding-bottom: env(safe-area-inset-bottom);
  padding-bottom: constant(safe-area-inset-bottom);

  z-index: 50;

  transform: translateZ(0);
  will-change: transform;
}

/* -------------------------------------------------------------
 Input / Textarea (iOS zoom 방지)
------------------------------------------------------------- */
input, textarea {
  font-size: 16px;
  -webkit-appearance: none;
  border-radius: 0;
}

/* -------------------------------------------------------------
 Sidebar & UI
------------------------------------------------------------- */
#sidebar { 
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
  will-change: transform; 
}

#hover-trigger { 
  position: fixed; 
  top: 0; 
  left: 0; 
  width: 20px; 
  height: 100%; 
  z-index: 40; 
  padding-left: 5px; 
}

/* -------------------------------------------------------------
 Animation
------------------------------------------------------------- */
@keyframes fade-out { 
  from { opacity: 1; transform: scale(1); } 
  to { opacity: 0; transform: scale(0.95); } 
}
.msg-exit { animation: fade-out 0.5s forwards; }

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

/* -------------------------------------------------------------
 Fast Reply
------------------------------------------------------------- */
.fast-reply-item { 
  transition: all 0.2s ease; 
  cursor: pointer; 
  border: none;
  background: transparent;
}
.fast-reply-item:hover { 
  font-weight: 800 !important; 
  color: var(--indigo-600) !important; 
  transform: translateX(5px); 
}

/* -------------------------------------------------------------
 Button System
------------------------------------------------------------- */
.sc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 9999px;
  font-weight: 800;
  line-height: 1;
  user-select: none;
  transition: transform .08s ease, background-color .15s ease;
  transform: translateZ(0);
  white-space: nowrap;
  cursor: pointer;
}
.sc-btn:active { transform: scale(0.97); }

.sc-btn-sm { padding: 10px 14px; font-size: 14px; }
.sc-btn-lg { padding: 12px 14px; font-size: 18px; border-radius: 16px; }

.sc-outline-indigo { background: #fff; color: #4f46e5; border: 1px solid #4f46e5; }
.sc-outline-indigo:hover { background: rgba(79,70,229,.08); }

.sc-outline-red { background: #fff; color: #dc2626; border: 1px solid #dc2626; }
.sc-outline-red:hover { background: rgba(220,38,38,.08); }

/* -------------------------------------------------------------
 Nickname Lock
------------------------------------------------------------- */
#nickname-input:disabled {
  cursor: not-allowed;
  opacity: .6;
}

.sc-nick-fixed {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-weight: 800;
  font-size: 12px;
  color: var(--text);
}

.sc-nick-fixed .dot {
  width: 8px; 
  height: 8px; 
  border-radius: 9999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accentSoft);
}

.sc-nickwrap.locked { display:none; }

/* -------------------------------------------------------------
 Chip UI
------------------------------------------------------------- */
.sc-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--panel2);
  border-radius: 12px;
  padding: 1px 2px;
}

.sc-chip select {
  background: transparent;
  border: none;
  outline: none;
  font-weight: 800;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  -webkit-appearance: none;
}

/* -------------------------------------------------------------
 Toast
------------------------------------------------------------- */
#toast {
  pointer-events: none;
}

/* -------------------------------------------------------------
 터치 UX 개선
------------------------------------------------------------- */
button, input, textarea {
  touch-action: manipulation;
}