/* ═══════════════════════════════════════════════
   CutKit · Shared Design System
   ═══════════════════════════════════════════════ */

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

/* ── TOKENS ── */
:root {
  --bg: #0a0a0f;
  --surface: #10101a;
  --card: #16161f;
  --card-hover: #1c1c28;
  --border: #252535;
  --border-light: #32324a;
  --text: #f0f0f8;
  --text2: #9090b0;
  --text3: #555570;
  --blue: #4f8ef7;
  --blue-light: #6ba3ff;
  --blue-dim: rgba(79,142,247,.12);
  --blue-glow: rgba(79,142,247,.25);
  --magenta: #c060ff;
  --magenta-dim: rgba(192,96,255,.12);
  --green: #3dd68c;
  --green-dim: rgba(61,214,140,.12);
  --amber: #f5a623;
  --red: #ff5c5c;
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --shadow: 0 8px 32px rgba(0,0,0,.5);
  --shadow-glow: 0 0 40px var(--blue-glow);
  --transition: .2s cubic-bezier(.4,0,.2,1);
  --nav-h: 60px;
  --tab-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tab-h) + var(--safe-bottom) + 12px);
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, textarea { font: inherit; color: inherit; background: none; border: none; outline: none; }
.mono { font-family: 'JetBrains Mono', monospace; }
img { max-width: 100%; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 99px; }

/* ── TOP HEADER ── */
.top-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: rgba(10,10,15,.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px; gap: 12px;
}
.header-logo {
  display: flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 800; color: var(--text);
  flex-shrink: 0;
}
.header-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--blue), var(--magenta));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff; letter-spacing: -.5px;
  box-shadow: 0 4px 16px var(--blue-glow);
}
.header-title { font-size: 15px; font-weight: 700; flex: 1; text-align: center; }
.header-action { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--text2); transition: all var(--transition); }
.header-action:hover { background: var(--card); color: var(--text); }

/* ── PAGE WRAPPER ── */
.page-wrap {
  padding-top: var(--nav-h);
  min-height: 100vh;
}

/* ── BOTTOM TAB BAR ── */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  height: calc(var(--tab-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(10,10,15,.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--border);
  display: flex; align-items: flex-start;
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; padding: 8px 4px 6px;
  color: var(--text3); transition: all var(--transition);
  position: relative; cursor: pointer;
}
.tab-item:active { transform: scale(.92); }
.tab-item.active { color: var(--blue); }
.tab-item.active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 24px; height: 3px; background: var(--blue);
  border-radius: 0 0 3px 3px;
  box-shadow: 0 0 12px var(--blue);
}
.tab-icon { font-size: 22px; line-height: 1; }
.tab-label { font-size: 9.5px; font-weight: 600; letter-spacing: .3px; }

/* ── CARD ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.card::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--blue-dim) 0%, transparent 50%);
  opacity: 0; transition: opacity var(--transition);
  pointer-events: none;
}
.card:hover { border-color: var(--border-light); background: var(--card-hover); transform: translateY(-2px); box-shadow: var(--shadow); }
.card:hover::after { opacity: 1; }
.card.pressed { transform: scale(.965) translateY(0) !important; transition: transform .05s !important; }
.card:active { transform: scale(.97); }

.card-top { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.card-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--blue-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.card-icon.magenta { background: var(--magenta-dim); }
.card-icon.green { background: var(--green-dim); }
.card-body { flex: 1; min-width: 0; }
.card-title { font-size: 13.5px; font-weight: 600; color: var(--text); line-height: 1.35; }
.card-core { font-size: 11px; color: var(--magenta); font-weight: 500; margin-top: 3px; }
.card-desc {
  font-size: 12px; color: var(--text2); line-height: 1.55; margin-top: 5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.card-tag {
  font-size: 10px; padding: 2px 7px; border-radius: 5px;
  background: var(--surface); color: var(--text3);
  border: 1px solid var(--border);
}
.card-tag.blue { background: var(--blue-dim); color: var(--blue-light); border-color: rgba(79,142,247,.3); }
.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--border);
}
.card-level {
  font-size: 9.5px; padding: 2px 7px; border-radius: 5px;
  background: var(--magenta-dim); color: var(--magenta); font-weight: 700; letter-spacing: .5px;
}
.card-arrow { font-size: 14px; color: var(--text3); transition: all var(--transition); }
.card:hover .card-arrow { color: var(--blue); transform: translateX(3px); }

/* ── GRID ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 0 16px 32px;
}

/* ── SECTION HEADER ── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 16px 12px; gap: 12px;
}
.section-title { font-size: 18px; font-weight: 800; color: var(--text); }
.section-badge {
  font-size: 10.5px; padding: 3px 10px; border-radius: 99px;
  background: var(--blue-dim); color: var(--blue-light);
  border: 1px solid rgba(79,142,247,.3); font-weight: 600;
  flex-shrink: 0;
}
.section-subtitle { font-size: 11.5px; color: var(--text3); margin-top: 2px; }

/* ── SEARCH BAR ── */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
  margin: 0 16px 12px;
  transition: all var(--transition);
}
.search-bar:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-dim), 0 0 20px var(--blue-glow);
}
.search-bar .icon { font-size: 14px; color: var(--text3); flex-shrink: 0; }
.search-bar input { flex: 1; font-size: 13.5px; }
.search-bar input::placeholder { color: var(--text3); }
.search-clear {
  font-size: 10px; color: var(--text3); padding: 3px 7px;
  background: var(--card-hover); border-radius: 5px;
  cursor: pointer; display: none; transition: all var(--transition);
}
.search-clear.show { display: block; }
.search-clear:hover { color: var(--text); }

/* ── FILTER CHIPS ── */
.filter-row {
  display: flex; gap: 6px; overflow-x: auto; padding: 0 16px 12px;
  scrollbar-width: none; scroll-snap-type: x mandatory;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  padding: 5px 13px; border-radius: 99px; font-size: 12px; font-weight: 600;
  color: var(--text2); background: var(--card); border: 1px solid var(--border);
  cursor: pointer; transition: all var(--transition); white-space: nowrap;
  scroll-snap-align: start; flex-shrink: 0;
}
.filter-chip:hover { border-color: var(--border-light); color: var(--text); }
.filter-chip.active {
  background: var(--blue-dim); border-color: var(--blue);
  color: var(--blue-light);
  box-shadow: 0 0 12px var(--blue-glow);
}

/* ── EMPTY STATE ── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 24px; text-align: center; gap: 12px;
}
.empty-icon { font-size: 48px; opacity: .25; }
.empty-title { font-size: 15px; font-weight: 700; color: var(--text2); }
.empty-desc { font-size: 12.5px; color: var(--text3); max-width: 260px; line-height: 1.6; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.75); backdrop-filter: blur(6px);
  display: none; align-items: flex-end; justify-content: center;
  padding: 0 0 env(safe-area-inset-bottom, 0px);
}
.modal-overlay.open { display: flex; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%; max-width: 680px; max-height: 88vh;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 -8px 60px rgba(0,0,0,.8);
  animation: slideUp .25s cubic-bezier(.4,0,.2,1);
}
@keyframes slideUp { from { transform: translateY(100%) } to { transform: translateY(0) } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 15px; font-weight: 800; color: var(--text); flex: 1; }
.modal-close {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--text2); background: var(--card);
  cursor: pointer; transition: all var(--transition);
}
.modal-close:hover { background: var(--card-hover); color: var(--text); }
.modal-body { overflow-y: auto; flex: 1; padding: 18px; }
.modal-section { margin-bottom: 18px; }
.modal-section:last-child { margin-bottom: 0; }
.modal-section-title {
  font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: var(--text3); margin-bottom: 8px;
}
.modal-text { font-size: 13px; color: var(--text2); line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.modal-code {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  color: var(--green); line-height: 1.6; white-space: pre-wrap;
  word-break: break-word; max-height: 200px; overflow-y: auto;
}
.modal-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.modal-tag {
  font-size: 11px; padding: 3px 10px; border-radius: 99px;
  background: var(--blue-dim); color: var(--blue-light);
  border: 1px solid rgba(79,142,247,.3); font-weight: 600;
}
.modal-footer {
  padding: 14px 18px; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0;
}
.btn {
  padding: 9px 18px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 700;
  cursor: pointer; transition: all var(--transition); display: flex; align-items: center; gap: 6px;
  border: none; letter-spacing: .2px;
}
.btn:active { transform: scale(.95); }
.btn.pressed { transform: scale(.93) !important; }
.side-chip.pressed { transform: scale(.94); }
.filter-chip.pressed { transform: scale(.94); }
.btn-ghost {
  background: var(--card); border: 1px solid var(--border); color: var(--text2);
}
.btn-ghost:hover { border-color: var(--border-light); color: var(--text); }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 4px 16px var(--blue-glow); }
.btn-primary:hover { background: var(--blue-light); box-shadow: 0 6px 24px var(--blue-glow); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.copied { background: var(--green) !important; box-shadow: 0 4px 16px rgba(61,214,140,.25) !important; }

/* ── INPUT / TEXTAREA ── */
.input-field {
  width: 100%; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; font-size: 14px;
  color: var(--text); line-height: 1.5; resize: none;
  transition: all var(--transition);
}
.input-field:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-dim), 0 0 20px var(--blue-glow);
}
.input-field::placeholder { color: var(--text3); }

/* ── LOADING SPINNER ── */
.spinner {
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.2);
  border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg) } }

/* ── DIVIDER ── */
.divider { height: 1px; background: var(--border); margin: 12px 16px; }

/* ── ANIMATIONS ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.anim-item { animation: fadeUp .3s ease both; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }
.pulse { animation: pulse 1.5s ease infinite; }

/* ── RESPONSIVE ── */
@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; padding: 0 12px 32px; }
  .section-header, .search-bar, .filter-row { padding-left: 12px; padding-right: 12px; }
  .search-bar { margin-left: 12px; margin-right: 12px; }
  .modal { border-radius: 20px 20px 0 0; }
}
