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

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

:root {
  --bg: #f5f5f7;
  --bg-card: #ffffff;
  --surface: #ffffff;
  --surface-hover: #f0f0f2;
  --fg: #1d1d1f;
  --fg-2: #6e6e73;
  --fg-3: #aeaeb2;
  --accent: #ff3e00;
  --accent-light: rgba(255,62,0,0.08);
  --accent-glow: rgba(255,62,0,0.15);
  --blue: #007aff;
  --green: #34c759;
  --border: #e5e5ea;
  --border-light: #f0f0f2;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --fs-hero: clamp(2.5rem, 6vw, 5rem);
  --fs-h1: clamp(1.6rem, 3vw, 2.8rem);
  --fs-h2: clamp(1.2rem, 2vw, 2rem);
  --fs-h3: clamp(1rem, 1.4vw, 1.4rem);
  --fs-body: clamp(0.95rem, 1.1vw, 1.1rem);
  --fs-small: clamp(0.8rem, 0.9vw, 0.9rem);
  --fs-xs: clamp(0.7rem, 0.75vw, 0.78rem);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --header-h: 52px;
  --sidebar-w: 300px;
  --right-panel-w: 320px;
}

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--fg-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-2); }

::selection { background: var(--accent); color: #fff; }

a { color: var(--fg); text-decoration: none; transition: all 0.15s; }
a:hover { color: var(--accent); }
ul { list-style: none; }
img { max-width: 100%; display: block; }

h1, h2, h3, h4 { font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }

/* ====== HEADER ====== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-h);
  z-index: 100;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header__logo {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header__logo-mark {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 4px;
}

.header__logo-mark svg { width: 11px; height: 11px; }

.header__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ====== BUTTONS ====== */
.btn {
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 24px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  color: var(--fg);
}

.btn:hover {
  background: #e5e5ea;
  transform: translateY(-1px);
}

.btn--primary {
  background: var(--fg);
  color: #fff;
}

.btn--primary:hover {
  background: #000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.btn--ghost {
  background: transparent;
  color: var(--fg-2);
  padding: 8px 16px;
}

.btn--ghost:hover {
  background: var(--surface-hover);
  color: var(--fg);
}

.btn--sm {
  font-size: 0.78rem;
  padding: 6px 14px;
}

/* ====== MAIN LAYOUT ====== */
.main-layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: calc(var(--header-h) + 20px) 20px 20px;
  display: grid;
  grid-template-columns: 1fr var(--right-panel-w);
  gap: 24px;
  min-height: 100vh;
}

/* ====== LEFT SIDEBAR (overlay, hover-activated) ====== */
.sidebar-zone {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: 24px;
  z-index: 90;
}

.sidebar {
  position: fixed;
  top: var(--header-h);
  left: calc(-1 * var(--sidebar-w) - 10px);
  bottom: 0;
  width: var(--sidebar-w);
  z-index: 89;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--border);
  padding: 24px 20px;
  overflow-y: auto;
  transition: left 0.12s ease;
  box-shadow: var(--shadow-lg);
}

.sidebar.open {
  left: 0;
}

.sidebar__title {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-3);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar__genre-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--fg-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.12s;
}

.sidebar__genre-btn:hover {
  background: var(--surface-hover);
  color: var(--fg);
}

.sidebar__genre-btn.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.sidebar__saved-item {
  padding: 10px 14px;
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.12s;
}

.sidebar__saved-item:hover {
  background: #e5e5ea;
}

.sidebar__saved-item-title {
  font-size: 0.85rem;
  font-weight: 500;
  display: block;
  margin-bottom: 2px;
}

.sidebar__saved-item-date {
  font-size: var(--fs-xs);
  color: var(--fg-3);
}

/* ====== FEED (center) ====== */
.feed {
  min-width: 0;
  padding-bottom: 40px;
}

.feed__header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.feed__title {
  font-size: var(--fs-h1);
  margin-bottom: 4px;
}

.feed__subtitle {
  color: var(--fg-2);
  font-size: var(--fs-small);
}

/* Create post */
.create-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.create-card input {
  width: 100%;
  border: none;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 8px 0;
  outline: none;
  font-family: var(--font);
  letter-spacing: -0.01em;
}

.create-card input::placeholder { color: var(--fg-3); }

.create-card textarea {
  width: 100%;
  border: none;
  resize: vertical;
  font-size: var(--fs-body);
  line-height: 1.7;
  padding: 8px 0;
  outline: none;
  font-family: var(--font);
  min-height: 80px;
  margin-top: 4px;
}

.create-card textarea::placeholder { color: var(--fg-3); }

.create-card__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  margin-top: 8px;
}

.create-card__ai {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 10px;
  margin-top: 8px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
}

.create-card__ai-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 4px;
}

.create-card__ai .btn--sm {
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
}

.create-card__ai .btn--sm:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.create-card__ai-status {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  margin-left: auto;
}

.create-card__ai-sep {
  color: var(--border);
  font-size: 0.7rem;
  user-select: none;
}

.create-card__topic {
  margin-top: 8px;
}

.create-card__topic input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: var(--font);
  font-size: 0.78rem;
  color: var(--fg);
  background: var(--bg-card);
  outline: none;
  transition: border-color 0.2s;
}

.create-card__topic input:focus {
  border-color: var(--accent);
}

.create-card__topic input::placeholder {
  color: var(--fg-3);
}

.create-card__meta select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 0.82rem;
  color: var(--fg-2);
  background: var(--bg);
  outline: none;
}

/* Post cards */
.posts-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
  animation: fadeUp 0.3s ease;
}

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

.post-card:hover {
  box-shadow: var(--shadow);
  border-color: #d0d0d5;
}

.post-card__genre {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 10px;
}

.post-card__title {
  font-size: var(--fs-h2);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  line-height: 1.2;
}

.post-card__text {
  color: var(--fg-2);
  font-size: var(--fs-small);
  line-height: 1.7;
  margin-bottom: 14px;
  white-space: pre-line;
  word-break: break-word;
}

.post-card__meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  color: var(--fg-3);
  margin-bottom: 14px;
}

.post-card__author {
  color: var(--fg);
  font-weight: 500;
}

.post-card__actions {
  display: flex;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.post-card__action-btn {
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 6px 16px;
  border: 1px solid var(--border);
  background: none;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--fg-2);
  font-family: var(--font);
}

.post-card__action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.post-card__action-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

/* Skeleton */
.skeleton-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.skeleton {
  background: linear-gradient(90deg, #eee 25%, #e5e5e5 50%, #eee 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
  height: 16px;
  margin-bottom: 12px;
}

.skeleton.short { width: 60%; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ====== RIGHT PANEL ====== */
.right-panel {
  position: sticky;
  top: calc(var(--header-h) + 20px);
  height: fit-content;
  max-height: calc(100vh - var(--header-h) - 40px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.right-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.right-card__title {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-3);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

/* Contact info */
.contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  font-size: var(--fs-small);
  color: var(--fg-2);
  border-bottom: 1px solid var(--border-light);
}

.contact-item:last-child { border-bottom: none; }

.contact-item__icon {
  width: 36px;
  height: 36px;
  background: var(--surface-hover);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.9rem;
}

/* Legal links */
.legal-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.legal-links a {
  font-size: var(--fs-small);
  color: var(--fg-2);
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  transition: all 0.12s;
}

.legal-links a:last-child { border-bottom: none; }
.legal-links a:hover { color: var(--accent); padding-left: 4px; }

/* Auth in right panel */
.auth-mini {
  text-align: center;
}

.auth-mini p {
  font-size: var(--fs-small);
  color: var(--fg-2);
  margin-bottom: 12px;
}

.auth-mini .btn {
  width: 100%;
  justify-content: center;
  margin-bottom: 8px;
}

/* Stats mini */
.stats-mini {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-mini {
  text-align: center;
  padding: 14px 8px;
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
}

.stat-mini__num {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
}

.stat-mini__label {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  margin-top: 4px;
}

/* ====== LEGAL MODAL ====== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal__close {
  float: right;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--fg-3);
  line-height: 1;
}

.modal__close:hover { color: var(--fg); }

.modal h2 {
  font-size: var(--fs-h2);
  margin-bottom: 20px;
}

.modal h3 {
  font-size: 1.1rem;
  margin: 20px 0 8px;
  color: var(--fg);
}

.modal p {
  color: var(--fg-2);
  margin-bottom: 12px;
  line-height: 1.7;
}

.modal ul {
  list-style: disc;
  padding-left: 20px;
  margin-bottom: 12px;
}

.modal li {
  color: var(--fg-2);
  margin-bottom: 4px;
  line-height: 1.6;
}

.modal .form-group {
  margin-bottom: 14px;
}

.modal .form-group label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--fg-2);
  margin-bottom: 4px;
}

.modal .form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: var(--fs-body);
  outline: none;
  transition: border-color 0.15s;
  background: var(--bg);
}

.modal .form-group input:focus {
  border-color: var(--fg);
}

.modal .auth-switch {
  text-align: center;
  margin-top: 14px;
  font-size: var(--fs-small);
  color: var(--fg-3);
}

.modal .auth-switch a { color: var(--accent); font-weight: 500; }

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

.toast {
  padding: 12px 20px;
  font-size: var(--fs-small);
  color: #fff;
  background: var(--fg);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease;
  max-width: 360px;
}

.toast.success { background: var(--green); }
.toast.error { background: var(--accent); }
.toast.info { background: var(--blue); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ====== LEGAL TAB CONTENT (inside modal) ====== */
.legal-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.legal-tabs a {
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--fg-3);
  transition: all 0.12s;
}

.legal-tabs a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.legal-tabs a.active {
  background: var(--fg);
  color: #fff;
  border-color: var(--fg);
}

/* ====== RESPONSIVE ====== */
@media (max-width: 900px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .right-panel {
    position: static;
    max-height: none;
  }

  .sidebar { width: 260px; left: calc(-260px - 10px); }
}

@media (max-width: 640px) {
  .header__inner { padding: 0 12px; }
  .main-layout { padding: calc(var(--header-h) + 12px) 12px 12px; gap: 16px; }
  .post-card { padding: 16px; }
  .right-card { padding: 16px; }
  .feed__title { font-size: 1.4rem; }
}

/* ====== EMPTY STATE ====== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--fg-3);
}

.empty-state p { font-size: var(--fs-small); }
