/* ═══════════════════════════════════════════════════════════
   StoryVital — Global Shared Styles  (sv-shared.css)
   ═══════════════════════════════════════════════════════════ */

/* ── Fonts ─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&family=Noto+Serif+KR:wght@300;400;600;700&display=swap');

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  background: #08080c;
  color: #e8e4f2;
  font-family: 'Manrope', sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }
img { display: block; max-width: 100%; }

/* ── CSS Variables ───────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg:            #08080c;
  --s0:            #08080c;
  --s1:            #0d0d12;
  --s2:            #121218;
  --s3:            #18181f;
  --s4:            #1e1e27;
  --s5:            #252530;

  /* Brand */
  --primary:       #b89eff;
  --primary-dim:   #7b4fff;
  --primary-deep:  #3d1fa0;
  --secondary:     #c28bff;
  --secondary-dim: #9a5ef0;
  --tertiary:      #ff95b8;
  --tertiary-dim:  #e5557a;
  --success:       #3ecfa6;
  --warning:       #f5c842;
  --danger:        #e5557a;

  /* Text */
  --t1: #e8e4f2;
  --t2: #a09ab8;
  --t3: #5c5870;
  --t4: #38354a;

  /* Border */
  --b1: rgba(184,158,255,0.13);
  --b2: rgba(184,158,255,0.07);
  --b3: rgba(184,158,255,0.04);

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

  /* Shadow */
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:  0 8px 24px rgba(0,0,0,0.4);
  --shadow-lg:  0 20px 50px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 24px rgba(123,79,255,0.35), 0 0 60px rgba(123,79,255,0.1);
  --shadow-glow-sm: 0 0 12px rgba(123,79,255,0.3);

  /* Timing */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Glass Morphism ──────────────────────────────────────── */
.glass {
  background: rgba(18,18,24,0.65);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--b1);
}
.glass-sm {
  background: rgba(13,13,18,0.8);
  backdrop-filter: blur(12px);
  border: 1px solid var(--b1);
}
.glass-card {
  background: rgba(24,24,31,0.7);
  backdrop-filter: blur(16px);
  border: 1px solid var(--b1);
  border-radius: var(--r-lg);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.2s;
}
.glass-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(184,158,255,0.22);
}

/* ── Inputs ──────────────────────────────────────────────── */
.field {
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(184,158,255,0.1);
  border-radius: var(--r-md);
  padding: 10px 14px;
  color: var(--t1);
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  line-height: 1.5;
}
.field:focus {
  border-color: var(--primary-dim);
  box-shadow: 0 0 0 3px rgba(123,79,255,0.18);
}
.field::placeholder { color: var(--t3); }
textarea.field { resize: none; line-height: 1.8; }
select.field option { background: var(--s3); color: var(--t1); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.18s var(--ease);
  white-space: nowrap;
  font-family: 'Manrope', sans-serif;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--primary-dim);
  color: #fff;
  box-shadow: var(--shadow-glow-sm);
}
.btn-primary:hover { background: #8a5fff; box-shadow: var(--shadow-glow); }
.btn-secondary {
  background: rgba(123,79,255,0.12);
  color: var(--primary);
  border: 1px solid rgba(123,79,255,0.28);
}
.btn-secondary:hover { background: rgba(123,79,255,0.22); }
.btn-ghost {
  background: transparent;
  color: var(--t2);
  border: 1px solid var(--b1);
}
.btn-ghost:hover { background: rgba(255,255,255,0.04); color: var(--t1); }
.btn-danger {
  background: rgba(229,85,122,0.12);
  color: var(--danger);
  border: 1px solid rgba(229,85,122,0.28);
}
.btn-danger:hover { background: rgba(229,85,122,0.22); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: var(--r-sm); }
.btn-lg { padding: 13px 24px; font-size: 15px; border-radius: var(--r-lg); }
.btn-icon { padding: 8px; border-radius: var(--r-sm); }

/* ── Icon (Material Symbols) ─────────────────────────────── */
.icon {
  font-family: 'Material Symbols Outlined';
  font-style: normal;
  font-weight: 400;
  font-size: 20px;
  line-height: 1;
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-sm { font-size: 16px; }
.icon-lg { font-size: 24px; }
.icon-xl { font-size: 32px; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-purple  { background: rgba(123,79,255,0.18); color: var(--primary);   border: 1px solid rgba(123,79,255,0.3); }
.badge-pink    { background: rgba(229,85,122,0.14); color: var(--tertiary);   border: 1px solid rgba(229,85,122,0.25); }
.badge-green   { background: rgba(62,207,166,0.14); color: var(--success);   border: 1px solid rgba(62,207,166,0.25); }
.badge-amber   { background: rgba(245,200,66,0.14); color: var(--warning);   border: 1px solid rgba(245,200,66,0.25); }
.badge-outline { background: transparent;            color: var(--t3);        border: 1px solid var(--b1); }
.badge-pro     { background: linear-gradient(135deg, #7b4fff, #c28bff); color: #fff; }

/* ── Nav ─────────────────────────────────────────────────── */
.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  z-index: 100;
  background: rgba(8,8,12,0.88);
  backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--b2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.sidebar {
  position: fixed;
  left: 0; top: 60px; bottom: 0;
  width: 220px;
  background: var(--s1);
  border-right: 1px solid var(--b2);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  z-index: 90;
  overflow-y: auto;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  color: var(--t2);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  text-decoration: none;
  border-left: 2px solid transparent;
}
.sidebar-link:hover { background: rgba(255,255,255,0.04); color: var(--t1); }
.sidebar-link.active {
  background: rgba(123,79,255,0.14);
  color: var(--primary);
  border-left-color: var(--primary-dim);
}
.main {
  margin-left: 220px;
  padding-top: 60px;
  min-height: 100vh;
}

/* ── Progress ────────────────────────────────────────────── */
.progress-track {
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary-dim), var(--primary));
  box-shadow: 0 0 8px rgba(123,79,255,0.5);
  transition: width 0.8s var(--ease);
}

/* ── Toggle ──────────────────────────────────────────────── */
.toggle {
  position: relative;
  width: 42px; height: 24px;
  border-radius: 12px;
  background: var(--s4);
  border: 1px solid var(--b1);
  transition: background 0.2s;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle.on { background: var(--primary-dim); border-color: rgba(123,79,255,0.5); }
.toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--t3);
  transition: all 0.2s var(--ease);
}
.toggle.on::after { left: 21px; background: #fff; }

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

/* ── Overlay / Modal ─────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--s3);
  border: 1px solid var(--b1);
  border-radius: var(--r-2xl);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.3s var(--ease-spring);
}
.overlay.open .modal { transform: translateY(0) scale(1); }

/* ── Side Panel ──────────────────────────────────────────── */
.side-panel {
  position: fixed;
  right: 0; top: 60px; bottom: 0;
  width: 480px;
  background: var(--s2);
  border-left: 1px solid var(--b1);
  z-index: 150;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s var(--ease);
  overflow: hidden;
}
.side-panel.open { transform: translateX(0); }
@media (max-width: 600px) { .side-panel { width: 100%; top: 0; } }

/* ── Kanban ──────────────────────────────────────────────── */
.kanban-col {
  min-height: 200px;
  border-radius: var(--r-lg);
  padding: 12px;
  border: 1px solid transparent;
  transition: border-color 0.2s, background 0.2s;
}
.kanban-col.drag-over {
  border-color: var(--primary-dim);
  background: rgba(123,79,255,0.06);
}
.kanban-card {
  background: var(--s3);
  border: 1px solid var(--b1);
  border-radius: var(--r-md);
  padding: 12px;
  margin-bottom: 8px;
  cursor: grab;
  transition: all 0.2s;
  user-select: none;
}
.kanban-card:hover { border-color: rgba(184,158,255,0.25); box-shadow: var(--shadow-sm); }
.kanban-card.dragging { opacity: 0.4; cursor: grabbing; transform: rotate(2deg); }

/* ── Streak calendar ─────────────────────────────────────── */
.streak-cell {
  width: 13px; height: 13px;
  border-radius: 3px;
  background: rgba(255,255,255,0.04);
  transition: background 0.2s;
  cursor: default;
  flex-shrink: 0;
}
.streak-cell[data-level="1"] { background: rgba(123,79,255,0.3); }
.streak-cell[data-level="2"] { background: rgba(123,79,255,0.55); }
.streak-cell[data-level="3"] { background: var(--primary-dim); box-shadow: 0 0 5px rgba(123,79,255,0.5); }
.streak-cell.today { outline: 1.5px solid var(--primary); outline-offset: 1px; }

/* ── Tooltip ─────────────────────────────────────────────── */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--s5);
  color: var(--t1);
  padding: 4px 8px;
  border-radius: var(--r-sm);
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  border: 1px solid var(--b1);
  z-index: 999;
}
[data-tip]:hover::after { opacity: 1; }

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeUp   { from { opacity:0; transform:translateY(14px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn   { from { opacity:0; } to { opacity:1; } }
@keyframes scaleIn  { from { opacity:0; transform:scale(0.92); } to { opacity:1; transform:scale(1); } }
@keyframes slideL   { from { transform:translateX(30px); opacity:0; } to { transform:translateX(0); opacity:1; } }
@keyframes shimmer  { from { background-position: -200% 0; } to { background-position: 200% 0; } }
@keyframes pulse    { 0%,100% { opacity:1; } 50% { opacity:0.45; } }
@keyframes spin     { from { transform:rotate(0); } to { transform:rotate(360deg); } }
@keyframes glow-pulse { 0%,100% { box-shadow: 0 0 12px rgba(123,79,255,0.3); } 50% { box-shadow: 0 0 24px rgba(123,79,255,0.6); } }

.anim-fade-up  { animation: fadeUp  0.45s var(--ease) forwards; }
.anim-fade-in  { animation: fadeIn  0.3s  var(--ease) forwards; }
.anim-scale-in { animation: scaleIn 0.3s  var(--ease-spring) forwards; }
.anim-slide-l  { animation: slideL  0.35s var(--ease) forwards; }
.d1 { animation-delay: 0.06s; opacity: 0; }
.d2 { animation-delay: 0.13s; opacity: 0; }
.d3 { animation-delay: 0.20s; opacity: 0; }
.d4 { animation-delay: 0.28s; opacity: 0; }

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--s3) 25%, var(--s4) 50%, var(--s3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(184,158,255,0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(184,158,255,0.35); }

/* ── Toast notification ──────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: all;
  animation: slideL 0.3s var(--ease);
  background: var(--s4);
  border: 1px solid var(--b1);
  box-shadow: var(--shadow-md);
  max-width: 320px;
}
.toast-success { border-color: rgba(62,207,166,0.3); }
.toast-success .icon { color: var(--success); }
.toast-error   { border-color: rgba(229,85,122,0.3); }
.toast-error .icon { color: var(--danger); }
.toast-info    { border-color: rgba(123,79,255,0.3); }
.toast-info .icon { color: var(--primary); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1023px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .topnav { padding: 0 16px; }
}
@media (max-width: 767px) {
  .hide-mobile { display: none !important; }
  .main { padding-bottom: 72px; }
}

/* ── Utility ─────────────────────────────────────────────── */
.text-primary  { color: var(--primary); }
.text-dim      { color: var(--t2); }
.text-muted    { color: var(--t3); }
.truncate      { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.line-clamp-2  { display: -webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.line-clamp-3  { display: -webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
.pointer       { cursor: pointer; }
.select-none   { user-select: none; }
.no-scrollbar  { scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }
