:root {
  --bg: #0b0d10;
  --bg-soft: #12151a;
  --card: #161a21;
  --card-border: #242a33;
  --text: #e8eaed;
  --text-dim: #9aa3af;
  --positive: #34d399;
  --positive-dim: rgba(52, 211, 153, 0.14);
  --negative: #fb7185;
  --negative-dim: rgba(251, 113, 133, 0.14);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(52, 211, 153, 0.07), transparent 60%),
    radial-gradient(1000px 500px at 10% -10%, rgba(251, 113, 133, 0.06), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---------- header ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--card-border);
  background: rgba(11, 13, 16, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--card-border);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.04);
}

.brand-name {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.brand-name em {
  font-style: normal;
  color: var(--text-dim);
  font-weight: 500;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}

.tab {
  position: relative;
  padding: 9px 14px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 9px;
  transition: color 0.15s, background 0.15s;
}

.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }

.tab.active { color: var(--text); background: rgba(255, 255, 255, 0.07); }

.tab.active.tab-positive { color: var(--positive); background: var(--positive-dim); }
.tab.active.tab-negative { color: var(--negative); background: var(--negative-dim); }

.tab-divider {
  width: 1px;
  height: 20px;
  background: var(--card-border);
  margin: 0 6px;
}

/* ---------- layout ---------- */

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.page-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 0 0 8px;
}

.page-title span { color: var(--text-dim); font-weight: 600; }
.page-title .word-positive { color: var(--positive); }
.page-title .word-negative { color: var(--negative); }

.page-sub {
  color: var(--text-dim);
  margin: 0 0 28px;
  font-size: 0.95rem;
}

/* ---------- entry ---------- */

.entry-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 34px 32px 38px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.accent-positive { border-top: 3px solid var(--positive); }
.accent-negative { border-top: 3px solid var(--negative); }

.entry-row {
  display: flex;
  gap: 12px;
}

.field-wrap {
  position: relative;
  flex: 1;
}

.entry-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.accent-positive .entry-input:focus {
  border-color: var(--positive);
  box-shadow: 0 0 0 3px var(--positive-dim);
}

.accent-negative .entry-input:focus {
  border-color: var(--negative);
  box-shadow: 0 0 0 3px var(--negative-dim);
}

.enter-btn {
  padding: 0 26px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: #06110c;
  transition: transform 0.1s, filter 0.15s;
}

.enter-btn:hover { filter: brightness(1.1); }
.enter-btn:active { transform: scale(0.97); }

.btn-positive { background: var(--positive); }
.btn-negative { background: var(--negative); color: #160607; }

/* ---------- suggestions ---------- */

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #1b2028;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  z-index: 20;
  max-height: 320px;
  overflow-y: auto;
}

.suggestions li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.92rem;
}

.suggestions li .sugg-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestions li .sugg-text mark {
  background: none;
  color: var(--text);
  font-weight: 700;
}

.suggestions li:hover,
.suggestions li.selected {
  background: rgba(255, 255, 255, 0.07);
}

.accent-positive .suggestions li.selected { outline: 1px solid var(--positive-dim); }
.accent-negative .suggestions li.selected { outline: 1px solid var(--negative-dim); }

.sugg-count {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 9px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

/* ---------- ranked list ---------- */

.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  counter-reset: rank;
}

.rank-list li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  overflow: hidden;
}

.rank-list li .bar {
  position: absolute;
  inset: 0;
  opacity: 0.1;
  pointer-events: none;
}

.rank-positive .bar { background: linear-gradient(90deg, var(--positive), transparent); }
.rank-negative .bar { background: linear-gradient(90deg, var(--negative), transparent); }

.rank-num {
  flex-shrink: 0;
  width: 30px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.rank-list li:nth-child(-n+3) .rank-num { color: var(--text); }

.rank-text {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.rank-count {
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.rank-positive .rank-count { color: var(--positive); background: var(--positive-dim); }
.rank-negative .rank-count { color: var(--negative); background: var(--negative-dim); }

.empty-note {
  color: var(--text-dim);
  text-align: center;
  padding: 40px 0;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 22px;
  background: #1b2028;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  z-index: 100;
  animation: toast-in 0.2s ease-out;
}

.toast.toast-positive { border-color: var(--positive); }
.toast.toast-negative { border-color: var(--negative); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  .topbar { padding: 12px 16px; gap: 14px; }
  .tabs { margin-left: 0; width: 100%; }
  .entry-row { flex-direction: column; }
  .enter-btn { padding: 13px; }
  .container { padding: 32px 16px 60px; }
}
