/* CSS Variables - Refined minimalist palette */
:root {
  --color-bg: #000000;
  --color-bg-secondary: #0d0d0d;
  --color-bg-tertiary: #161616;
  --color-bg-hover: #1a1a1a;
  --color-border: #222;
  --color-border-subtle: #1a1a1a;
  --color-text: #f5f5f5;
  --color-text-secondary: #999;
  --color-text-muted: #666;
  --color-primary: #fff;
  --color-primary-hover: #e5e5e5;
  --color-accent: #3b82f6;
  --color-accent-hover: #60a5fa;
  --color-success: #10b981;
  --color-error: #ef4444;
  --color-warning: #f59e0b;
  --color-like: #f43f5e;
  --color-share: #22c55e;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", Menlo, monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);

  --transition-fast: 0.1s ease;
  --transition-normal: 0.2s ease;
}

/* Light theme */
[data-theme="light"] {
  --color-bg: #ffffff;
  --color-bg-secondary: #f7f7f7;
  --color-bg-tertiary: #eeeeee;
  --color-bg-hover: #e8e8e8;
  --color-border: #ddd;
  --color-border-subtle: #e8e8e8;
  --color-text: #111111;
  --color-text-secondary: #555;
  --color-text-muted: #888;
  --color-primary: #111;
  --color-primary-hover: #333;
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-success: #059669;
  --color-error: #dc2626;
  --color-warning: #d97706;
  --color-like: #e11d48;
  --color-share: #16a34a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
  overscroll-behavior-y: contain;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-accent-hover);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  transition: all var(--transition-fast);
}

input, textarea {
  font-family: inherit;
  font-size: inherit;
  border: none;
  outline: none;
  background: transparent;
  color: inherit;
}

/* Layout */
#app {
  max-width: 620px;
  margin: 0 auto;
  min-height: 100vh;
  border-left: 1px solid var(--color-border-subtle);
  border-right: 1px solid var(--color-border-subtle);
}

.container {
  padding: 20px;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--color-bg) 80%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--color-border-subtle);
  padding: 0 20px;
  height: 56px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header__logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

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

.header__nav {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
}

.header__link {
  color: var(--color-text-secondary);
  font-size: 0.867rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.header__link:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}

.header__link--active {
  color: var(--color-text);
  background: var(--color-bg-tertiary);
}

.header__link--dropdown {
  border-radius: 0;
  margin-right: -20px;
  padding-right: 20px;
  padding-top: 0;
  padding-bottom: 0;
}

.header__icon {
  display: none;
  vertical-align: -3px;
  flex-shrink: 0;
}

.header__label {
  /* shown by default on desktop */
}

.header__badge {
  position: absolute;
  top: -4px;
  right: -8px;
  background: var(--color-like);
  color: white;
  font-size: 0.65rem;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.header__user-trigger {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  height: 100%;
  overflow: hidden;
  line-height: 1.15;
}

.header__user-full {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
  font-size: 0.8rem;
}

.header__user-compact {
  display: none;
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border-subtle);
}

.tab {
  flex: 1;
  padding: 16px;
  text-align: center;
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 0.933rem;
  transition: all var(--transition-fast);
  position: relative;
}

.tab:hover {
  color: var(--color-text-secondary);
  background: var(--color-bg-secondary);
}

.tab--active {
  color: var(--color-text);
}

.tab--active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 2px;
  background: var(--color-text);
  border-radius: var(--radius-full);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.933rem;
  transition: all var(--transition-fast);
}

.btn--primary {
  background: var(--color-text);
  color: var(--color-bg);
}

.btn--primary:hover:not(:disabled) {
  background: var(--color-text-secondary);
}

.btn--primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

.btn--secondary:hover {
  background: var(--color-bg-tertiary);
  border-color: var(--color-text-muted);
}

.btn--ghost {
  color: var(--color-text-secondary);
  padding: 8px;
}

.btn--ghost:hover {
  color: var(--color-text);
  background: var(--color-bg-tertiary);
}

.btn--small {
  padding: 6px 14px;
  font-size: 0.8rem;
}

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

.btn--accent:hover:not(:disabled) {
  background: var(--color-accent-hover);
}

/* Form elements */
.input {
  width: 100%;
  padding: 12px 16px;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 1rem;
  transition: border-color var(--transition-fast);
}

.input:focus {
  border-color: var(--color-text-muted);
}

.input::placeholder {
  color: var(--color-text-muted);
}

textarea.input {
  resize: vertical;
  min-height: 100px;
}

/* Cards */
.card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

/* Loading states */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--color-text-muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.2s ease-out;
  font-size: 0.867rem;
}

.toast--success {
  border-left: 3px solid var(--color-success);
}

.toast--error {
  border-left: 3px solid var(--color-error);
}

.toast--info {
  border-left: 3px solid var(--color-accent);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease-out;
}

.modal {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.2s ease-out;
}

.modal__header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal__title {
  font-size: 1.067rem;
  font-weight: 600;
}

.modal__close {
  color: var(--color-text-muted);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.modal__close:hover {
  color: var(--color-text);
  background: var(--color-bg-tertiary);
}

.modal__body {
  padding: 20px;
}

.modal__footer {
  padding: 16px 20px;
  border-top: 1px solid var(--color-border-subtle);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Empty state */
.empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--color-text-secondary);
}

.empty__icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty__title {
  font-size: 1.067rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 8px;
}

/* Utilities */
.text-muted { color: var(--color-text-secondary); }
.text-small { font-size: 0.867rem; }
.text-mono { font-family: var(--font-mono); font-size: 0.8rem; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* Selection */
::selection {
  background: var(--color-accent);
  color: white;
}

/* Responsive */
@media (max-width: 640px) {
  html {
    font-size: 14px;
  }

  #app {
    border-left: none;
    border-right: none;
  }

  .header {
    padding: 0 10px;
  }

  .header__logo {
    font-size: 1.1rem;
  }

  .header__nav {
    gap: 2px;
  }

  .header__link {
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .header__icon {
    display: inline-block;
  }

  .header__label {
    display: none;
  }

  .header__badge {
    top: 0;
    right: 0;
    min-width: 14px;
    height: 14px;
    font-size: 0.6rem;
    padding: 0 3px;
  }

  .header__link--dropdown {
    margin-right: -10px;
    padding-right: 10px;
  }

  .header__user-full {
    display: none;
  }

  .header__user-compact {
    display: flex;
    align-items: center;
    color: var(--color-text-secondary);
  }

  .container {
    padding: 16px;
  }

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

  .toast {
    width: 100%;
  }
}

/* Pull-to-refresh */
.ptr-indicator {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  transition: height 0.2s ease-out;
}

.ptr-spinner {
  font-size: 18px;
  color: var(--color-text-muted);
  padding-bottom: 8px;
  transition: color 0.15s;
}

.ptr-spinner--ready {
  color: var(--color-text);
}

.ptr-spinner--active {
  padding-bottom: 10px;
}
