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

:root {
  --red:        #ff4655;
  --s-red:      #FA7885;
  --green:      #4ade80;
  --bg-page:    #0f101a;
  --bg-card:    #141A24;
  --bg-block:   #1e2035;
  --border:     #252840;
  --text:       #ECE8E1;
  --text-muted: #8b91ad;
}

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg-page);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;

}

.input-section {
  text-align: center;
  width: 100%;
  max-width: 860px;
}

.app-title {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 8px;
}

.app-title span {
  color: var(--red);
}

.input-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text);
  font-family: 'Poppins', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn.active,
.tab-btn:hover {
  color: var(--text);
  border-bottom-color: var(--red);
}

.scrape-form {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.scrape-form input,
.scrape-form select,
textarea#jsonPaste {
  background: var(--bg-block);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'Poppins', sans-serif;
  font-size: 0.875rem;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s;
}

#usernameInput {
  flex: 2;
  min-width: 0;
}

.year-input {
  flex: 0 0 130px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b91ad' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.year-input option {
  background: var(--bg-block);
  color: var(--text);
}

.scrape-form input:focus,
.scrape-form select:focus,
textarea#jsonPaste:focus {
  border-color: var(--red);
}

textarea#jsonPaste {
  width: 100%;
  resize: vertical;
  margin-top: 16px;
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  line-height: 1.5;
}

.btn-submit {
  background: var(--red);
  color: #ECE8E1;
  border: none;
  padding: 10px 22px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, padding 0.15s, min-width 0.15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 100px;
}

.btn-submit:hover { opacity: 0.85; }
.btn-submit:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-submit.loading {
  padding: 10px;
  min-width: 44px;
  pointer-events: none;
}

.btn-submit .loader {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-bottom-color: #fff;
  flex-shrink: 0;
}

.btn-upload {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-block);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

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

.btn-upload input[type="file"] {
  display: none;
}

.input-status {
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  min-height: 1.2em;
  font-variant-numeric: tabular-nums;
}

.input-status.error {
  color: var(--red);
}

.quota-status {
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
  min-height: 1.1em;
}

.quota-status.exhausted {
  color: var(--red);
}

.loader {
  width: 48px;
  height: 48px;
  border: 5px solid #FFF;
  border-bottom-color: var(--red);
  border-radius: 50%;
  display: inline-block;
  box-sizing: border-box;
  animation: rotation 1s linear infinite;
}

@keyframes rotation {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.card-section {
  width: 100%;
  max-width: 1200px;
}

.card {
  background-color: var(--bg-card);
  background-image:
    radial-gradient(ellipse 120% 120% at 0% 0%, rgba(255, 70, 85, 0.07) 0%, transparent 60%),
    radial-gradient(circle, rgba(236, 232, 225, 0.1) 1px, transparent 1px);
  background-size: 100% 100%, 22px 22px;
  padding: 36px 30px 15px;
  overflow: hidden;
  min-width: 0;
  box-shadow: none;
  position: relative;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.card-title-text {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--red);
  letter-spacing: 1px;
  line-height: 1;
  margin-bottom: 4px;
}

.card-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 500;
}

.fi {
  width: 28px !important;
  height: 21px !important;
  flex-shrink: 0;
  display: block;
  transform: translateY(-3px);
}

.card-username {
  color: var(--s-red);
  font-weight: 400;
  font-size: 1.5rem;
}

.card-flair {
  width: 84px;
  height: 84px;
  object-fit: contain;
  position: absolute;
  top: 36px;
  right: 30px;
}

.card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: stretch;
}

.card-left {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.stat-block {
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid var(--red);
  padding: 8px 18px;
  border-radius: 8px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat-label {
  /* font-size: 0.6rem; */
  /* letter-spacing: 2px; */
  font-weight: 500;
  color: var(--s-red);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stat-big {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
  color: var(--text);
}

.stat-big.negative { color: var(--text); }
.stat-big.positive { color: var(--text); }

.votes-bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 10px 0 6px;
}

.votes-bar-track {
  width: 100%;
  height: 5px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.votes-bar-fill {
  height: 100%;
  transition: width 0.5s ease;
  min-width: 2px;
}

.votes-up   { background: var(--green); }
.votes-down { background: var(--red); }

.stat-sub {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--red);
  text-transform: uppercase;
  /* margin-top: 4px; */
}

.top-posts {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 6px;
}

.post-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px 16px;
  gap: 14px;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s;
  height: 56px;
}

.post-row:hover {
  background: rgba(255, 255, 255, 0.07);
}

.post-info {
  flex: 1;
  min-width: 0;
}

.post-slug {
  font-size: 0.85rem;
  /* font-weight: 600; */
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-text {
  font-size: 0.69rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.post-text::before {
  content: '▶';
  font-size: 0.5rem;
  color: var(--red);
  flex-shrink: 0;
  line-height: 1;
}

.post-frags {
  font-size: 0.9rem;
  /* font-weight: 700; */
  flex-shrink: 0;
  text-decoration: none;
  width: 52px;
  text-align: right;
}

.post-frags.positive { color: var(--green); }
.post-frags.negative { color: var(--red); }

.biggest-fans {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.fan-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 20px;
  padding: 5px 10px 5px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  max-width: 160px;
  min-width: 0;
}

.fan-tag > span:first-child {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}

.fan-count {
  background: var(--red);
  color: black;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 40%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-footer {
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mini-stats-row {
  display: flex;
  gap: 14px;
  margin-top: 0;
  margin-bottom: 0;
}

.mini-stat {
  flex: 1;
    border-radius: 8px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  background: rgba(255,255,255,0.04);
  border-left: 3px solid var(--red);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.mini-stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--red);
  line-height: 1;
}

.mini-stat-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.vlr-logo {
  height: 26px;
}

.card-footer-credit {
  font-size: .9rem;
  color: var(--text-muted);
  font-weight: 400;
}
