:root {
  --bg: #0f1220;
  --bg-2: #171b30;
  --card: #1c2138;
  --card-2: #232a47;
  --text: #eef1ff;
  --muted: #9aa3c7;
  --accent: #6c8cff;
  --accent-2: #a06cff;
  --green: #37d67a;
  --red: #ff5d73;
  --yellow: #ffce54;
  --radius: 18px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1000px 500px at 10% -10%, rgba(108, 140, 255, 0.22), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(160, 108, 255, 0.18), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.container { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
[hidden] { display: none !important; }

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(14px);
  background: rgba(15, 18, 32, 0.78);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: 12px; }
.logo {
  font-size: 22px; font-weight: 800; text-decoration: none; color: var(--text);
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.nav { display: flex; gap: 10px; }

/* ===== Buttons ===== */
.btn {
  border: none; cursor: pointer; font-weight: 700; font-size: 15px;
  padding: 11px 18px; border-radius: 12px; transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  font-family: inherit; color: var(--text);
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px rgba(108, 140, 255, 0.35);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 10px 30px rgba(108, 140, 255, 0.5); transform: translateY(-2px); }
.btn-ghost { background: rgba(255, 255, 255, 0.06); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }
.btn-block { width: 100%; margin-top: 8px; padding: 14px; font-size: 17px; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.icon-btn {
  background: rgba(255, 255, 255, 0.08); border: none; color: var(--text);
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 16px;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.16); }

/* ===== Feed ===== */
.feed-head { padding: 34px 0 20px; }
.feed-head h1 { margin: 0 0 6px; font-size: 32px; }
.feed-head p { margin: 0; }

.feed {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px; padding-bottom: 60px;
}

.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer; display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-6px); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); }
.card-img {
  height: 170px; width: 100%; object-fit: cover; display: block;
  background: linear-gradient(135deg, var(--card-2), var(--bg-2));
}
.card-img-fallback {
  height: 170px; display: flex; align-items: center; justify-content: center;
  font-size: 54px; background: linear-gradient(135deg, #2a3157, #1b2040);
}
.card-media { display: block; line-height: 0; }
.card-links {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.1); padding-top: 10px; margin-top: 4px;
}
.link-btn {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-size: 12px; font-weight: 700; font-family: inherit; padding: 0; flex-shrink: 0;
}
.link-btn:hover { text-decoration: underline; }
.link-plain {
  font-size: 11px; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.card-body { padding: 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-title { margin: 0; font-size: 19px; line-height: 1.25; }
.card-author { font-size: 13px; color: var(--muted); }
.card-desc {
  margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.tag {
  font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px;
}
.tag-live { background: rgba(55, 214, 122, 0.15); color: var(--green); }
.tag-warn { background: rgba(255, 93, 115, 0.16); color: var(--red); }
.tag-done { background: rgba(154, 163, 199, 0.15); color: var(--muted); }
.tag-votes { background: rgba(108, 140, 255, 0.16); color: var(--accent); }
.tag-cmt { background: rgba(255, 206, 84, 0.12); color: var(--yellow); }
.card-top { font-size: 13px; color: var(--muted); }
.card-top b { color: var(--text); }
.card-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: auto;
}
.deadline-hint { font-size: 12px; color: var(--muted); }

.skeleton-card {
  border-radius: var(--radius); height: 340px;
  background: linear-gradient(100deg, var(--card) 40%, #262c4c 50%, var(--card) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.empty {
  grid-column: 1 / -1; text-align: center; padding: 70px 20px;
  color: var(--muted); font-size: 17px;
  background: var(--card); border-radius: var(--radius);
}

/* ===== Detail ===== */
.back-btn { margin: 22px 0 16px; }
.detail-hero {
  display: grid; grid-template-columns: 340px 1fr; gap: 24px;
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06); box-shadow: var(--shadow);
  margin-bottom: 26px;
}
.detail-img { width: 100%; height: 100%; min-height: 240px; object-fit: cover; display: block; background: linear-gradient(135deg, #2a3157, #1b2040); }
.detail-info { padding: 22px 24px 22px 0; display: flex; flex-direction: column; gap: 10px; }
.detail-info h1 { margin: 4px 0 0; font-size: 30px; line-height: 1.15; }
.detail-desc { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.countdown {
  font-weight: 800; font-variant-numeric: tabular-nums; font-size: 16px;
  background: rgba(255, 206, 84, 0.12); color: var(--yellow);
  padding: 9px 14px; border-radius: 12px; align-self: flex-start;
}
.share-row { display: flex; gap: 8px; margin-top: 4px; }
.share-link {
  flex: 1; min-width: 0; background: var(--card-2); color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 12px;
  padding: 10px 12px; font-size: 13px; font-family: inherit;
}

.options-title { font-size: 21px; margin: 26px 0 14px; }
.options { display: flex; flex-direction: column; gap: 12px; }

.option {
  position: relative; overflow: hidden; width: 100%; text-align: left;
  background: var(--card); border: 2px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px; color: var(--text); cursor: pointer; font-family: inherit;
  padding: 0; transition: border-color 0.15s, transform 0.12s;
}
.option:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-2px); }
.option:disabled { cursor: default; }
.option-bar {
  position: absolute; left: 0; top: 0; bottom: 0; z-index: 0;
  background: linear-gradient(90deg, rgba(108, 140, 255, 0.32), rgba(160, 108, 255, 0.22));
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.option-voted { border-color: var(--green); }
.option-voted .option-bar { background: linear-gradient(90deg, rgba(55, 214, 122, 0.4), rgba(55, 214, 122, 0.16)); }
.option-inner {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 14px;
  padding: 13px 16px;
}
.option-rank {
  font-weight: 800; color: var(--muted); font-size: 15px; min-width: 30px;
  font-variant-numeric: tabular-nums;
}
.option-img {
  width: 58px; height: 58px; border-radius: 12px; object-fit: cover; flex-shrink: 0;
  background: var(--card-2); display: flex; align-items: center; justify-content: center;
  font-size: 26px;
}
.option-img-ph { display: flex; }
.option-main { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.option-name { font-weight: 700; font-size: 16px; }
.option-count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.hint { font-size: 13px; margin: 14px 0 0; }

/* ===== Comments ===== */
.comments { margin: 34px 0 70px; }
.comment-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.comment-form input {
  background: var(--card); border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px; padding: 11px 14px; color: var(--text);
  font-size: 14px; font-family: inherit;
}
.comment-form input:focus { outline: none; border-color: var(--accent); }
#c-author { width: 170px; }
#c-text { flex: 1; min-width: 220px; }
.comment-list { display: flex; flex-direction: column; gap: 12px; }
.comment {
  display: flex; gap: 12px; background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.06); border-radius: 14px; padding: 13px 15px;
}
.comment-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px; color: #fff;
}
.comment-body { min-width: 0; }
.comment-head { font-size: 13px; margin-bottom: 3px; }
.comment-text { font-size: 14px; line-height: 1.5; word-break: break-word; }

/* ===== 404 ===== */
.notfound { text-align: center; padding: 80px 20px; }
.notfound-emoji { font-size: 70px; margin-bottom: 10px; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5, 7, 15, 0.75); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--bg-2); border-radius: 20px; width: 100%; max-width: 600px;
  max-height: 90vh; overflow-y: auto; padding: 26px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: var(--shadow);
  animation: popIn 0.25s cubic-bezier(0.22, 1.4, 0.36, 1);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-head h2 { margin: 0; font-size: 22px; }

.form { display: flex; flex-direction: column; gap: 15px; }
.form label { display: flex; flex-direction: column; gap: 7px; font-weight: 700; font-size: 14px; flex: 1; }
.form input, .form textarea {
  background: var(--card); border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px; padding: 12px 14px; color: var(--text);
  font-size: 15px; font-family: inherit; resize: vertical; transition: border-color 0.15s;
}
.form input:focus, .form textarea:focus { outline: none; border-color: var(--accent); }
.form-row { display: flex; gap: 12px; }
.file-label { cursor: pointer; }
.file-label input { display: none; }
.file-btn {
  display: inline-block; padding: 12px 14px; border-radius: 12px;
  background: var(--card); border: 2px dashed rgba(255, 255, 255, 0.18);
  font-size: 14px; font-weight: 700; color: var(--muted); text-align: center;
}
.file-label:hover .file-btn { border-color: var(--accent); color: var(--text); }
.image-preview { max-width: 100%; border-radius: 12px; margin-top: 4px; }

.positions-head {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; font-size: 15px; margin-top: 4px;
}
.positions-list { display: flex; flex-direction: column; gap: 9px; }
.pos-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px; padding: 8px 10px;
}
.pos-num {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  background: rgba(108, 140, 255, 0.18); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
}
.pos-name {
  flex: 1; min-width: 0; background: transparent; border: none;
  color: var(--text); font-size: 14px; font-family: inherit; padding: 6px 4px;
}
.pos-name:focus { outline: none; }
.pos-img-label { cursor: pointer; position: relative; display: flex; align-items: center; }
.pos-img-btn {
  width: 34px; height: 34px; border-radius: 9px;
  background: rgba(255, 255, 255, 0.07); display: flex; align-items: center;
  justify-content: center; font-size: 16px;
}
.pos-img-label:hover .pos-img-btn { background: rgba(108, 140, 255, 0.3); }
.pos-img-prev {
  width: 34px; height: 34px; border-radius: 9px; object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.pos-del {
  width: 30px; height: 30px; border-radius: 8px; border: none; cursor: pointer;
  background: rgba(255, 93, 115, 0.12); color: var(--red); font-size: 14px;
}
.pos-del:hover { background: rgba(255, 93, 115, 0.25); }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  z-index: 100; background: var(--bg-2); color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 13px 20px; border-radius: 14px; font-weight: 700; font-size: 15px;
  box-shadow: var(--shadow); animation: popIn 0.25s cubic-bezier(0.22, 1.4, 0.36, 1);
  max-width: calc(100vw - 40px); text-align: center;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(0.96); } to { opacity: 1; transform: none; } }

/* ===== Responsive ===== */
@media (max-width: 760px) {
  .detail-hero { grid-template-columns: 1fr; }
  .detail-img { min-height: 180px; max-height: 240px; }
  .detail-info { padding: 0 18px 20px; }
  .form-row { flex-direction: column; }
  .feed-head h1 { font-size: 26px; }
  .detail-info h1 { font-size: 24px; }
  .nav .btn { padding: 9px 12px; font-size: 13px; }
}
