/* Paruna Ava Obsidian — Mobile-first dark glassmorphism */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg-0: #07090f;
  --bg-1: #0d1220;
  --bg-2: #161d2e;
  --bg-3: #1f2840;
  --line: rgba(255, 255, 255, 0.06);
  --line-2: rgba(255, 255, 255, 0.10);
  --text: #eaf0fb;
  --text-dim: #9aa5be;
  --text-mute: #5b6783;
  --accent: #7c5cff;
  --accent-2: #4fd1c5;
  --accent-3: #ff6ec7;
  --green: #4ade80;
  --red: #f87171;
  --yellow: #fbbf24;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-1: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-2: 0 12px 40px rgba(0,0,0,0.5);
}

html, body {
  margin: 0; padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg-0);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(124, 92, 255, 0.20), transparent 60%),
    radial-gradient(ellipse 80% 50% at 100% 30%, rgba(79, 209, 197, 0.12), transparent 60%),
    radial-gradient(ellipse 60% 50% at 50% 100%, rgba(255, 110, 199, 0.10), transparent 60%);
  pointer-events: none;
}

button {
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

input, textarea {
  font-family: inherit;
}

/* ===================== LOGIN ===================== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-0);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}
.login-overlay[hidden],
[hidden] { display: none !important; }
.login-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 30% 30%, rgba(124, 92, 255, 0.25), transparent 60%),
    radial-gradient(ellipse 80% 50% at 70% 70%, rgba(79, 209, 197, 0.20), transparent 60%);
  pointer-events: none;
}
.login-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: linear-gradient(135deg, rgba(31, 40, 64, 0.6), rgba(13, 18, 32, 0.8));
  border: 1px solid var(--line-2);
  border-radius: 20px;
  padding: 36px 28px 28px;
  text-align: center;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-2);
}
.login-logo {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 40px rgba(124, 92, 255, 0.5);
}
.login-card h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: 0.2px;
}
.login-sub {
  font-size: 12px;
  color: var(--text-mute);
  margin: 0 0 24px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-form input {
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
}
.login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
}
.login-form input::placeholder { color: var(--text-mute); }
.login-form .btn {
  margin-top: 4px;
  padding: 12px;
  font-size: 14px;
}
.login-form .btn:disabled { opacity: 0.6; cursor: wait; }
.login-error {
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
}

/* ===================== SPLASH ===================== */
.splash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-0);
  z-index: 999;
  transition: opacity 0.5s, visibility 0.5s;
}
.splash.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-inner { text-align: center; }
.splash-logo {
  width: 80px; height: 80px;
  margin: 0 auto 20px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 60px rgba(124, 92, 255, 0.6);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 60px rgba(124, 92, 255, 0.6); }
  50%      { transform: scale(1.05); box-shadow: 0 0 80px rgba(79, 209, 197, 0.5); }
}
.splash h1 { font-size: 18px; margin: 0 0 16px; font-weight: 600; letter-spacing: 0.3px; }
.splash-text { color: var(--text-mute); font-size: 13px; margin: 16px 0 0; }
.splash-loader {
  width: 32px; height: 32px;
  border: 2.5px solid rgba(124, 92, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== APP SHELL ===================== */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ===================== TOPBAR ===================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(13, 18, 32, 0.85), rgba(13, 18, 32, 0.6));
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 12px rgba(124, 92, 255, 0.4);
  flex-shrink: 0;
}
.brand-title { font-size: 15px; font-weight: 700; letter-spacing: 0.2px; line-height: 1.1; }
.brand-sub {
  font-size: 10px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-top: 2px;
}

.conn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 100px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  font-weight: 600;
}
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px currentColor;
  transition: background 0.3s;
}
.dot.live { background: var(--green); color: var(--green); animation: blink 2s infinite; }
@keyframes blink { 50% { opacity: 0.4; } }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover, .icon-btn:active { background: var(--bg-3); border-color: var(--accent); }
.icon-btn.ghost { background: transparent; border-color: transparent; }
.icon-btn.ghost:hover { background: var(--bg-2); }

/* ===================== SEARCH ===================== */
.search-section {
  padding: 12px 16px;
  background: rgba(7, 9, 15, 0.4);
  position: sticky;
  top: 61px;
  z-index: 99;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-mute);
  pointer-events: none;
}
#search {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  color: var(--text);
  padding: 10px 14px 10px 40px;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
#search::-webkit-search-cancel-button { -webkit-appearance: none; }
#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
  background: var(--bg-1);
}

/* ===================== TABS ===================== */
.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background: rgba(7, 9, 15, 0.4);
  position: sticky;
  top: 121px;
  z-index: 98;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { background: var(--bg-2); color: var(--text); }
.tab.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 12px rgba(124, 92, 255, 0.4);
}
.badge {
  display: inline-block;
  padding: 1px 7px;
  background: rgba(255,255,255,0.15);
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}
.tab.active .badge { background: rgba(255,255,255,0.25); }

/* ===================== CONTENT ===================== */
.content {
  flex: 1;
  padding: 16px 16px 100px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}
.view { display: none; animation: fadeUp 0.3s ease; }
.view.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ===================== HERO ===================== */
.hero {
  position: relative;
  padding: 28px 20px 20px;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.18), rgba(79, 209, 197, 0.10));
  border: 1px solid var(--line-2);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 20px;
}
.hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 80% 20%, rgba(255, 110, 199, 0.25), transparent 50%),
    radial-gradient(circle at 20% 80%, rgba(79, 209, 197, 0.20), transparent 50%);
  pointer-events: none;
}
.hero-title { font-size: 24px; margin: 0 0 4px; font-weight: 700; position: relative; }
.hero-sub { font-size: 13px; color: var(--text-dim); margin: 0 0 20px; position: relative; }
.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  position: relative;
}
.stat {
  background: rgba(13, 18, 32, 0.6);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 12px 10px;
  text-align: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.stat-num {
  font-size: 22px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text), var(--text-dim));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
  margin-bottom: 2px;
}
.stat-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-mute);
  font-weight: 600;
}

/* ===================== SECTION ===================== */
.section { margin-bottom: 24px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-head h2 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
}
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
}
.link-btn:hover { background: rgba(124, 92, 255, 0.12); }

.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 28px; font-weight: 700; margin: 0 0 4px; }
.muted { color: var(--text-mute); font-size: 13px; margin: 0; }

/* ===================== FILTERS ===================== */
.filter-bar { margin-bottom: 16px; }
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ===================== CARDS ===================== */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  background: linear-gradient(135deg, rgba(31, 40, 64, 0.7), rgba(13, 18, 32, 0.5));
  border: 1px solid var(--line-2);
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}
.card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  opacity: 0;
  transition: opacity 0.2s;
}
.card:hover, .card:active {
  background: linear-gradient(135deg, rgba(31, 40, 64, 0.9), rgba(13, 18, 32, 0.7));
  transform: translateY(-1px);
}
.card:hover::before, .card:active::before { opacity: 1; }
.card.flash {
  animation: flash 1.5s ease-out;
}
@keyframes flash {
  0%   { background: linear-gradient(135deg, rgba(124, 92, 255, 0.4), rgba(79, 209, 197, 0.3)); }
  100% { background: linear-gradient(135deg, rgba(31, 40, 64, 0.7), rgba(13, 18, 32, 0.5)); }
}

.card-title {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.35;
  margin: 0 0 6px;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-mute);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.card-folder { color: var(--accent-2); }
.card-status {
  padding: 1px 6px;
  background: rgba(79, 209, 197, 0.15);
  color: var(--accent-2);
  border-radius: 4px;
  font-size: 10px;
}
.card-status.archiv, .card-status.done { background: rgba(154, 165, 190, 0.15); color: var(--text-dim); }
.card-body {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.45;
  margin: 6px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.tag {
  font-size: 10px;
  padding: 2px 8px;
  background: rgba(124, 92, 255, 0.18);
  color: #b8a8ff;
  border-radius: 100px;
  font-weight: 600;
}

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-mute);
  font-size: 14px;
}
.empty-icon { font-size: 40px; margin-bottom: 8px; opacity: 0.5; }

/* ===================== FAB ===================== */
.fab {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0));
  right: 20px;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), #9d7eff);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(124, 92, 255, 0.5);
  z-index: 50;
  transition: all 0.2s;
}
.fab:hover { transform: scale(1.05); }
.fab:active { transform: scale(0.95); }

/* ===================== EDITOR ===================== */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-0);
  z-index: 200;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.editor {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-0);
}
.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 18, 32, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding-top: calc(12px + env(safe-area-inset-top, 0));
}
.editor-actions { display: flex; gap: 8px; }
.btn {
  padding: 8px 16px;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { background: var(--bg-3); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 4px 12px rgba(124, 92, 255, 0.3);
}
.btn.primary:hover { background: #6a4cff; }
.btn.danger {
  background: rgba(248, 113, 113, 0.15);
  border-color: var(--red);
  color: var(--red);
}
.btn.ghost { background: transparent; border-color: transparent; }

.editor-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 20px 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.editor-title-input {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
  outline: none;
  padding: 4px 0;
  width: 100%;
  margin-bottom: 12px;
}
.editor-title-input::placeholder { color: var(--text-mute); }
.editor-tags-input {
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  width: 100%;
  margin-bottom: 8px;
}
.editor-tags-input:focus { border-color: var(--accent); }
.editor-path {
  font-size: 11px;
  margin-bottom: 12px;
  font-family: "SF Mono", Menlo, monospace;
  word-break: break-all;
}
.editor-textarea {
  flex: 1;
  background: var(--bg-0);
  color: var(--text);
  border: none;
  outline: none;
  padding: 0 0 100px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: none;
  width: 100%;
  min-height: 200px;
}
.editor-textarea::placeholder { color: var(--text-mute); }
.editor-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: rgba(13, 18, 32, 0.6);
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
}

/* ===================== TOAST ===================== */
.toast {
  position: fixed;
  bottom: calc(90px + env(safe-area-inset-bottom, 0));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-3);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-2);
  border: 1px solid var(--line-2);
  z-index: 300;
  animation: toastIn 0.3s;
  max-width: 90vw;
  text-align: center;
}
@keyframes toastIn { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ===================== SCROLLBAR ===================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--line-2); }

/* ===================== RESPONSIVE ===================== */
@media (min-width: 640px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 20px 20px 100px; }
  .hero { padding: 36px 28px 24px; }
  .hero-title { font-size: 28px; }
  .stat-num { font-size: 26px; }
  .tabs { padding: 10px 20px; }
  .topbar { padding: 14px 20px; }
  .search-section { padding: 14px 20px; }
  #search { font-size: 15px; }
  .editor-body { padding: 28px 28px 0; }
}

@media (min-width: 1024px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
  .content { padding: 24px 32px 100px; }
  .hero-stats { gap: 14px; }
  .stat-num { font-size: 32px; }
  .hero-title { font-size: 32px; }
  .page-head h1 { font-size: 36px; }
}

@media (min-width: 1280px) {
  .card-grid { grid-template-columns: repeat(4, 1fr); }
}
