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

:root {
  --bg: #ffffff;
  --bg-alt: #fafafa;
  --bg-card: #ffffff;
  --text: #0a0a0a;
  --text-secondary: #737373;
  --text-muted: #a3a3a3;
  --border: #e5e5e5;
  --accent: #0a0a0a;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow: rgba(0, 0, 0, 0.06);
  --shadow-lg: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-alt: #141414;
  --bg-card: #171717;
  --text: #fafafa;
  --text-secondary: #a3a3a3;
  --text-muted: #737373;
  --border: #262626;
  --accent: #fafafa;
  --danger: #ef4444;
  --success: #22c55e;
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-lg: rgba(0, 0, 0, 0.5);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(var(--bg), 0.8);
}

.header-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
}

.menu-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.menu-btn:hover {
  border-color: var(--text);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -0.5px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
}

.search-container {
  flex: 1;
  max-width: 500px;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 10px 40px 10px 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--text);
  background: var(--bg);
}

.search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
}

.nav {
  display: flex;
  gap: 24px;
  align-items: center;
}

.nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s ease;
}

.nav a:hover {
  color: var(--text);
}

.theme-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.theme-btn:hover {
  border-color: var(--text);
}

.sidebar {
  position: fixed;
  top: 0;
  left: -300px;
  width: 300px;
  height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  z-index: 200;
  transition: left 0.3s ease;
  overflow-y: auto;
}

.sidebar.active {
  left: 0;
  box-shadow: 4px 0 16px var(--shadow);
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.sidebar-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.sidebar-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.sidebar-section-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 0 24px 12px;
  font-weight: 600;
  letter-spacing: 0.8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.sidebar-link:hover,
.sidebar-link.active {
  color: var(--text);
  background: var(--bg-alt);
}

.sidebar-link i {
  font-size: 18px;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
  backdrop-filter: blur(2px);
}

.sidebar-backdrop.active {
  display: block;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 48px 24px;
}

.page-header {
  margin-bottom: 48px;
  text-align: center;
}

.page-title {
  font-size: 48px;
  font-weight: 800;
  margin-bottom: 12px;
  letter-spacing: -1.5px;
  line-height: 1.1;
}

.page-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  font-weight: 500;
}

.snippets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 24px;
  width: 100%;
  max-width: 100%;
}

.snippet-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 28px;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 140px;
}

.snippet-card:hover {
  border-color: var(--text);
  box-shadow: 0 8px 24px var(--shadow);
  transform: translateY(-2px);
}

.snippet-header-simple {
  margin-bottom: 20px;
}

.snippet-title-with-lock {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.snippet-lock-icon {
  color: var(--text-muted);
  font-size: 18px;
  flex-shrink: 0;
}

.snippet-description {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.snippet-meta {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.lang-badge-simple {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.password-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s ease;
  padding: 20px;
}

.password-modal.show {
  opacity: 1;
}

.password-modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 40px;
  max-width: 450px;
  width: 100%;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.password-modal.show .password-modal-content {
  transform: translateY(0);
}

.password-modal-header {
  text-align: center;
  margin-bottom: 32px;
}

.password-modal-header i {
  font-size: 48px;
  color: var(--text-muted);
  margin-bottom: 16px;
  display: block;
}

.password-modal-header h3 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.password-modal-header p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

.password-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.password-actions {
  display: flex;
  gap: 12px;
}

.password-actions .btn {
  flex: 1;
  justify-content: center;
}

.lang-icon {
  width: 10px;
  height: 10px;
}

.lang-icon.js { background: #f7df1e; }
.lang-icon.py { background: #3776ab; }
.lang-icon.html { background: #e34c26; }
.lang-icon.css { background: #264de4; }
.lang-icon.php { background: #777bb4; }
.lang-icon.java { background: #007396; }
.lang-icon.cpp { background: #00599c; }
.lang-icon.rb { background: #cc342d; }
.lang-icon.go { background: #00add8; }
.lang-icon.rust { background: #ce422b; }
.lang-icon.default { background: var(--text-muted); }

.snippet-code {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 16px;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
  overflow: hidden;
  position: relative;
  max-height: 100px;
  width: 100%;
}

.snippet-code code {
  display: block;
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  word-break: break-all;
}

.snippet-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  border-color: var(--text);
  color: var(--text);
}

.icon-btn.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.btn {
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-family: inherit;
  transition: all 0.2s ease;
  letter-spacing: -0.2px;
}

.btn:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--text);
  opacity: 1;
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-danger:hover {
  opacity: 0.85;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.form-container {
  max-width: 900px;
  margin: 0 auto;
}

.form-group {
  margin-bottom: 24px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: all 0.2s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--text);
  background: var(--bg);
}

.form-textarea {
  min-height: 400px;
  font-family: 'Monaco', 'Courier New', monospace;
  resize: vertical;
  line-height: 1.7;
  font-size: 13px;
}

.form-helper {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
}

.form-checkbox input {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
}

.view-header {
  margin-bottom: 32px;
}

.view-title {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 12px;
  letter-spacing: -1px;
  line-height: 1.2;
}

.view-description {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.code-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 32px;
  overflow: hidden;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}

.code-actions {
  display: flex;
  gap: 8px;
}

.code-content {
  padding: 24px;
  background: var(--bg-alt);
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text);
  overflow-x: auto;
  margin: 0;
  max-width: 100%;
}

.code-content code {
  display: block;
  overflow-x: auto;
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

.view-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.empty-state {
  text-align: center;
  padding: 120px 24px;
}

.empty-icon {
  font-size: 64px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.empty-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.empty-text {
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-size: 16px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  text-align: center;
}

.loading-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

.loading-logo {
  width: 64px;
  height: 64px;
  background: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 32px;
  letter-spacing: -1px;
}

.loading-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.8px;
}

.loading-bar {
  width: 200px;
  height: 2px;
  background: var(--border);
  margin: 0 auto 24px;
  overflow: hidden;
}

.loading-progress {
  height: 100%;
  width: 40%;
  background: var(--accent);
  animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(250%); }
  100% { transform: translateX(-100%); }
}

.loading-text {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.toast {
  position: fixed;
  bottom: 32px;
  right: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 16px 20px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px var(--shadow-lg);
  z-index: 1000;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 360px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: var(--danger);
  color: var(--danger);
}

.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 48px;
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo {
  width: 64px;
  height: 64px;
  background: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 32px;
  margin: 0 auto 24px;
}

.auth-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.auth-form {
  margin-bottom: 24px;
}

.auth-footer {
  text-align: center;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.auth-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s ease;
}

.auth-link:hover {
  color: var(--text);
}

.error-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.error-content {
  max-width: 480px;
}

.error-code {
  font-size: 120px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 24px;
  letter-spacing: -4px;
  color: var(--text-muted);
}

.error-title {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 16px;
  letter-spacing: -1px;
}

.error-text {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  line-height: 1.6;
}

.spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1024px) {
  .snippets-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  }
}

@media (max-width: 768px) {
  .menu-btn {
    display: flex;
  }

  .nav {
    display: none;
  }

  .header-wrapper {
    flex-wrap: wrap;
  }

  .search-container {
    order: 3;
    width: 100%;
    max-width: none;
    margin-top: 16px;
  }

  .container {
    padding: 32px 16px;
  }

  .page-title {
    font-size: 36px;
  }

  .page-subtitle {
    font-size: 16px;
  }

  .snippets-grid {
    grid-template-columns: 1fr;
  }

  .snippet-card {
    padding: 20px;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .view-actions {
    flex-direction: column;
  }

  .view-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .view-title {
    font-size: 28px;
  }

  .toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .auth-card {
    padding: 32px 24px;
  }

  .error-code {
    font-size: 80px;
  }

  .error-title {
    font-size: 24px;
  }
}

@media (max-width: 480px) {
  .page-title {
    font-size: 28px;
  }

  .loading-logo {
    width: 48px;
    height: 48px;
    font-size: 24px;
  }

  .loading-title {
    font-size: 20px;
  }

  .logo-text {
    display: none;
  }
}