:root{
  --bg: #F6F3EE;
  --bg-soft: #EFEAE1;
  --ink: #221F1A;
  --ink-soft: #6B655C;
  --card: #FFFDF9;
  --accent: #8C2F3F;
  --accent-soft: #F3DFDF;
  --tag: #33665C;
  --border: #DED6C7;
  --shadow: rgba(34,31,26,0.08);
}
[data-theme="dark"]{
  --bg: #17161A;
  --bg-soft: #201F24;
  --ink: #EDE8DE;
  --ink-soft: #A39B8E;
  --card: #1F1E23;
  --accent: #E08A96;
  --accent-soft: #3A2226;
  --tag: #6FBBA9;
  --border: #333039;
  --shadow: rgba(0,0,0,0.35);
}

*{ box-sizing: border-box; }

body{
  margin:0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  transition: background .35s ease, color .35s ease;
  min-height: 100vh;
}

a{ color: inherit; text-decoration:none; }

header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 28px 6vw;
  border-bottom: 1px solid var(--border);
}

.logo{
  display:flex;
  align-items:baseline;
  gap:10px;
}

.logo .mark{
  font-family:'Fraunces', serif;
  font-size: 26px;
  font-weight:600;
  letter-spacing: -0.5px;
}

.logo .mark span{ color: var(--accent); }

.logo .sub{
  color: var(--ink-soft);
  font-family:'Caveat', cursive;
  font-size: 18px;
}

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

nav.main-nav a{
  font-size: 14px;
  color: var(--ink-soft);
  font-weight:500;
  transition: color .2s ease;
}

nav.main-nav a:hover,
nav.main-nav a.active{ color: var(--accent); }

.header-right{
  display:flex;
  align-items:center;
  gap: 18px;
}

.theme-toggle{
  display:flex;
  align-items:center;
  gap:8px;
  border:1px solid var(--border);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 6px;
  cursor:pointer;
  user-select:none;
}

.theme-toggle .knob{
  width: 30px; height:30px;
  border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  background: var(--bg-soft);
  font-size: 15px;
}

.theme-toggle span.label{
  font-size:13px;
  color: var(--ink-soft);
  padding-right:6px;
}

main{
  max-width: 720px;
  margin: 0 auto;
  padding: 60px 6vw 100px;
}

main.wide{ max-width: 960px; }

.hero{ margin-bottom: 46px; }

.hero h1{
  font-family:'Fraunces', serif;
  font-weight:600;
  font-size: clamp(28px, 4vw, 42px);
  line-height:1.2;
  margin:0 0 14px;
}

.hero h1 em{ font-style: normal; color: var(--accent); }

.hero p{
  color: var(--ink-soft);
  font-size:15px;
  line-height:1.6;
  max-width: 50ch;
}

.btn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  border:none;
  border-radius: 8px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight:600;
  cursor:pointer;
  font-family:'Inter', sans-serif;
  transition: opacity .2s ease, transform .2s ease;
}

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

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

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

.hero-actions{
  display:flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.stats{
  display:flex;
  gap: 36px;
  margin: 40px 0 6px;
  flex-wrap: wrap;
}

.stats .stat b{
  font-family:'Fraunces', serif;
  font-size: 26px;
  display:block;
  color: var(--accent);
}

.stats .stat span{
  font-size: 13px;
  color: var(--ink-soft);
}

.section-title{
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--ink-soft);
  margin: 56px 0 18px;
  display:flex;
  align-items:center;
  gap: 10px;
}

.section-title::after{
  content:"";
  flex:1;
  height:1px;
  background: var(--border);
}

.how-steps{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.how-step{
  border-left: 2px solid var(--accent);
  padding-left: 14px;
}

.how-step .num{
  font-family:'Fraunces', serif;
  color: var(--accent);
  font-size: 20px;
  display:block;
  margin-bottom: 6px;
}

.how-step p{
  margin:0;
  font-size: 14px;
  color: var(--ink-soft);
  line-height:1.5;
}

.composer{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 48px;
  box-shadow: 0 8px 24px var(--shadow);
}

.composer textarea{
  width:100%;
  border:none;
  background:transparent;
  color: var(--ink);
  font-family:'Inter', sans-serif;
  font-size:15px;
  resize:none;
  min-height: 64px;
  outline:none;
}

.composer textarea::placeholder{ color: var(--ink-soft); }

.composer-row{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-top: 10px;
  gap: 10px;
  flex-wrap: wrap;
}

select{
  background: var(--bg-soft);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-family:'Inter', sans-serif;
}

.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  margin-bottom: 16px;
  position: relative;
  box-shadow: 0 6px 18px var(--shadow);
  transition: transform .25s ease, box-shadow .25s ease;
}

.card:hover{
  transform: translateY(-3px);
  box-shadow: 0 12px 28px var(--shadow);
}

.card::before{
  content:"";
  position:absolute;
  top:0; left: 22px; right: 22px;
  height:1px;
  background: repeating-linear-gradient(90deg, var(--border) 0 6px, transparent 6px 12px);
}

.card-top{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom: 10px;
  font-size:12px;
}

.time{ color: var(--ink-soft); }

.card p{
  margin:0;
  font-size: 15px;
  line-height: 1.6;
}

.reactions-bar{
  display:flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.reaction-btn{
  display:flex;
  align-items:center;
  gap: 5px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 14px;
  cursor: pointer;
  color: var(--ink);
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
  font-family: 'Inter', sans-serif;
}

.reaction-btn .c{
  font-size: 12px;
  font-weight:600;
  color: var(--ink-soft);
}

.reaction-btn:hover{ transform: translateY(-1px); border-color: var(--accent); }

.reaction-btn.active{
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-color: var(--accent);
}

.reaction-btn.active .c{ color: var(--accent); }

.card-foot{
  display:flex;
  gap: 16px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-soft);
}

.card-foot span{
  display:flex;
  align-items:center;
  gap:5px;
  cursor:pointer;
}

.card-foot span:hover{ color: var(--accent); }

footer{
  text-align:center;
  padding: 30px;
  color: var(--ink-soft);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

@media (max-width: 700px){
  .how-steps{ grid-template-columns: 1fr; }
}

@media (max-width: 560px){
  header{ padding: 20px 5vw; }
  .theme-toggle span.label{ display:none; }
  nav.main-nav{ gap: 14px; }
}

/* ---------- Animations ---------- */

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

@keyframes float{
  0%,100%{ transform: translateY(0) rotate(0deg); }
  50%{ transform: translateY(-14px) rotate(3deg); }
}

@keyframes floatSlow{
  0%,100%{ transform: translateY(0); }
  50%{ transform: translateY(12px); }
}

@keyframes popIn{
  from{ opacity:0; transform: scale(.94); }
  to{ opacity:1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce){
  *{ animation: none !important; transition: none !important; }
}

.reveal{
  opacity:0;
  transform: translateY(22px);
  transition: opacity .7s ease, transform .7s ease;
}

.reveal.is-visible{
  opacity:1;
  transform: translateY(0);
}

.hero-shell{ position: relative; overflow: visible; }

.hero-deco{
  position:absolute;
  border-radius:50%;
  filter: blur(2px);
  opacity:.35;
  pointer-events:none;
  z-index:0;
}

.hero-deco.d1{
  width:130px; height:130px;
  background: var(--accent);
  top:-30px; right: 8%;
  animation: float 7s ease-in-out infinite;
}

.hero-deco.d2{
  width:70px; height:70px;
  border: 2px solid var(--tag);
  background:none;
  bottom: -10px; right: 24%;
  animation: floatSlow 6s ease-in-out infinite;
}

.hero-shell > *{ position:relative; z-index:1; }

.hero-shell .mark, .hero h1{ animation: fadeUp .7s ease both; }
.hero p{ animation: fadeUp .7s ease .12s both; }
.hero-actions{ animation: fadeUp .7s ease .22s both; }
.stats{ animation: fadeUp .7s ease .32s both; }

/* ---------- CTA row (chat + suggest) ---------- */

.cta-row{
  display:flex;
  align-items:center;
  gap: 14px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.btn-chat{
  background: var(--accent);
  color: var(--card);
  box-shadow: 0 8px 20px var(--shadow);
}

.btn-suggest{
  background: var(--bg-soft);
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn svg{ width:16px; height:16px; }

/* ---------- Modal: Предложить новость ---------- */

.modal-overlay{
  position: fixed; inset:0;
  background: rgba(0,0,0,.45);
  display:none;
  align-items:center;
  justify-content:center;
  z-index: 100;
  padding: 20px;
}

.modal-overlay.open{
  display:flex;
  animation: fadeUp .25s ease both;
}

.modal{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  padding: 24px;
  box-shadow: 0 20px 60px var(--shadow);
  animation: popIn .25s ease both;
}

.modal h3{
  font-family:'Fraunces', serif;
  margin: 0 0 4px;
  font-size: 20px;
}

.modal .sub-hint{
  color: var(--ink-soft);
  font-size: 13px;
  margin: 0 0 16px;
}

.modal textarea{
  width:100%;
  min-height: 90px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--ink);
  padding: 12px;
  font-family:'Inter', sans-serif;
  font-size: 14px;
  resize:none;
  outline:none;
  margin-bottom: 12px;
}

.modal-row{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap: 10px;
  flex-wrap: wrap;
}

.attach-btn{
  display:inline-flex;
  align-items:center;
  gap:6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor:pointer;
  color: var(--ink-soft);
}

.attach-btn:hover{ color: var(--accent); border-color: var(--accent); }

.attach-previews{
  display:flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 4px;
}

.attach-thumb{
  position:relative;
  width: 64px; height:64px;
  border-radius: 8px;
  overflow:hidden;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.attach-thumb img, .attach-thumb video{
  width:100%; height:100%; object-fit:cover;
}

.attach-thumb .remove{
  position:absolute; top:2px; right:2px;
  width:18px; height:18px;
  background: rgba(0,0,0,.55);
  color:#fff;
  border-radius:50%;
  font-size: 11px;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
}

.modal-close{
  position:absolute;
  top:16px; right:16px;
  background:none; border:none;
  font-size: 18px;
  color: var(--ink-soft);
  cursor:pointer;
}

.modal-inner{ position:relative; }

.modal-footer-row{
  display:flex;
  justify-content:flex-end;
  margin-top: 16px;
}

/* ---------- Chat page ---------- */

.chat-input-row{
  display:flex;
  gap: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 12px;
  padding: 8px 8px 8px 16px;
  align-items:center;
}

.chat-input-row input{
  flex:1;
  border:none;
  background:transparent;
  color: var(--ink);
  font-size: 14px;
  outline:none;
  font-family:'Inter', sans-serif;
}

.chat-input-row button{
  background: var(--accent);
  color: var(--card);
  border:none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight:600;
  cursor:pointer;
}

.chat-input-row button:disabled{
  opacity:.6;
  cursor:default;
}

/* ---------- Auth (регистрация/вход) ---------- */

.auth-wrap{
  max-width: 400px;
  width: 100%;
  margin: 60px auto;
  padding: 0 20px;
}

.auth-card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 12px 32px var(--shadow);
  animation: popIn .35s ease both;
}

.auth-card h2{
  font-family:'Fraunces', serif;
  margin: 0 0 4px;
  font-size: 22px;
}

.auth-card .sub-hint{
  color: var(--ink-soft);
  font-size: 13px;
  margin: 0 0 20px;
}

.auth-tabs{
  display:flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow:hidden;
  margin-bottom: 20px;
}

.auth-tab{
  flex:1;
  text-align:center;
  padding: 9px 4px;
  font-size: 13px;
  font-weight:600;
  cursor:pointer;
  color: var(--ink-soft);
  background: var(--bg-soft);
  white-space: nowrap;
  transition: background .2s ease, color .2s ease;
}

.auth-tab.active{
  background: var(--accent);
  color: var(--card);
}

.field{
  margin-bottom: 14px;
}

.field label{
  display:block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.field input{
  width:100%;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--ink);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 14px;
  font-family:'Inter', sans-serif;
  outline:none;
}

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

.auth-error{
  color: var(--accent);
  font-size: 13px;
  margin: -4px 0 12px;
  min-height: 16px;
}

.auth-submit{ width:100%; justify-content:center; }

.auth-remember{
  display:flex;
  align-items:center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  margin: 4px 0 18px;
}

/* ---------- Chat (между пользователями) ---------- */

.chat-page{
  display:flex;
  flex-direction:column;
  min-height: 100vh;
}

.chat-page.in-chat{
  height: 100vh;
  overflow: hidden;
}

.chat-page header{ flex-shrink:0; }

.chat-app{
  display:grid;
  grid-template-columns: 240px 1fr;
  width: 100%;
  margin: 0;
  flex: 1;
  min-height: 0;
  border-top: 1px solid var(--border);
}

.chat-sidebar{
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display:flex;
  flex-direction:column;
  min-height: 0;
  overflow-y: auto;
}

.me-card{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  margin-bottom: 18px;
}

.avatar{
  width: 34px; height:34px;
  border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  color:#fff;
  font-size: 13px;
  font-weight:700;
  flex-shrink:0;
}

.me-card .nick{ font-size:14px; font-weight:600; }
.me-card .role{ font-size:11px; color: var(--ink-soft); }

.logout-link{
  font-size: 12px;
  color: var(--ink-soft);
  cursor:pointer;
  margin-left:auto;
}

.logout-link:hover{ color: var(--accent); }

.online-title{
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.online-count{
  font-family:'Fraunces', serif;
  font-size: 34px;
  color: var(--accent);
}

.chat-main{
  display:flex;
  flex-direction:column;
  width: 100%;
  min-width:0;
  min-height: 0;
}

.chat-main-header{
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  font-weight:600;
  color: var(--ink-soft);
}

.chat-main .chat-messages{
  flex:1;
  width: 100%;
  min-height: 0;
  overflow-y: auto;
  padding: 28px 32px;
  display:flex;
  flex-direction:column;
  gap: 18px;
}

.msg-row{
  display:flex;
  gap: 12px;
  max-width: 62%;
  animation: fadeUp .35s ease both;
}

.msg-row.out{ align-self:flex-end; flex-direction:row-reverse; }

.msg-row .bubble{
  background: var(--card);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  font-size: 16px;
  line-height:1.55;
}

.msg-row.out .bubble{
  background: var(--accent);
  color: var(--card);
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 4px;
  border:none;
}

.msg-row .meta{
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.chat-main .chat-input-row{
  margin: 16px 32px 24px;
  padding: 12px 12px 12px 20px;
}

.chat-main .chat-input-row input{
  font-size: 15px;
}

@media (max-width: 780px){
  .chat-page.in-chat{ height:auto; overflow: visible; }
  .chat-app{ grid-template-columns: 1fr; flex: none; }
  .chat-sidebar{ border-right:none; border-bottom: 1px solid var(--border); flex-direction:row; align-items:center; }
  .online-count{ display:none; }
  .chat-main .chat-messages{ height: 50vh; }
}

/* ---- Динамическая лента (медиа, лайки, комментарии) ---- */
.card-foot span.liked{ color: var(--accent); font-weight: 600; }

.card-media{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.card-media img, .card-media video{
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--border);
}

.comments-box{
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  display: none;
}
.comments-box.open{ display: block; }

.comment-item{
  font-size: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft, var(--border));
  line-height: 1.5;
}
.comment-item:last-child{ border-bottom: none; }
.comment-item .c-time{
  font-size: 12px;
  color: var(--ink-soft);
  margin-right: 6px;
}

.comment-form{
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.comment-form input{
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
}
.comment-form button{
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0 16px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.feed-status{
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  padding: 20px 0;
}
.feed-error{
  color: var(--error, #c0392b);
  font-size: 14px;
  margin-top: 8px;
}
