:root {
  --bg: #070707;
  --panel: rgba(12, 12, 12, 0.96);
  --border: rgba(255, 255, 255, 0.07);
  --text: #f2f0ec;
  --muted: #8a8680;
  --accent: #f0a020;
  --accent2: #ffc04a;
  --good: #3dd68c;
  --bad: #ff5d6c;
  --radius: 16px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}
body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, #1a1208 0%, transparent 55%),
    var(--bg);
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select {
  font: inherit;
  color: inherit;
}

.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: rgba(7, 7, 7, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
}

.brand img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}
.brand small {
  display: block;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.nav-links a:hover { color: var(--text); }
.nav-user {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent);
}

.wrap {
  width: min(960px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3.5rem;
}

.page-enter {
  animation: page-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes page-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.5rem;
}
h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.7rem, 3.5vw, 2.2rem);
  letter-spacing: -0.02em;
}
.lead {
  color: var(--muted);
  margin: 0 0 1.5rem;
  max-width: 36rem;
  line-height: 1.55;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 1.05rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(232, 160, 32, 0.45);
}
.btn.primary {
  background: #e8a020;
  border-color: transparent;
  color: #12100c;
  box-shadow: 0 8px 24px rgba(232, 160, 32, 0.28);
}
.btn.danger {
  border-color: rgba(255, 93, 108, 0.35);
  color: #ffb0b8;
}
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1.25rem;
}
.toolbar .spacer { flex: 1; }

/* Cards / lists */
.cat-list, .thread-list {
  display: grid;
  gap: 0.75rem;
}
.card {
  display: block;
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  animation: card-in 0.4s ease both;
}
.card:hover {
  border-color: rgba(232, 160, 32, 0.35);
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.cat-list .card:nth-child(1) { animation-delay: 0.05s; }
.cat-list .card:nth-child(2) { animation-delay: 0.1s; }
.cat-list .card:nth-child(3) { animation-delay: 0.15s; }
.cat-list .card:nth-child(4) { animation-delay: 0.2s; }
.cat-list .card:nth-child(5) { animation-delay: 0.25s; }

.card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}
.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  margin-top: 0.7rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}
.badge {
  display: inline-flex;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}
.badge.pin {
  color: var(--accent);
  border-color: rgba(232, 160, 32, 0.4);
}
.badge.lock { color: #ffb070; }
.badge.admin {
  color: #d4b0ff;
  border-color: rgba(167, 139, 250, 0.4);
}

/* Auth */
.auth-shell {
  min-height: calc(100vh - 70px);
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}
.auth-card {
  width: min(420px, 100%);
  padding: 1.6rem 1.5rem 1.4rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  animation: page-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.auth-card h1 {
  font-size: 1.55rem;
  margin-bottom: 0.35rem;
}
.field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}
.field label {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input, .field textarea, .field select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: rgba(232, 160, 32, 0.5);
  box-shadow: 0 0 0 3px rgba(232, 160, 32, 0.12);
}
.field textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.5;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.4rem;
}
.form-error {
  color: #ff9aa5;
  font-size: 0.88rem;
  margin: 0 0 0.75rem;
  min-height: 1.2em;
}
.form-hint {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.form-hint a { color: var(--accent); }

/* Thread */
.posts {
  display: grid;
  gap: 0.85rem;
  margin: 1.25rem 0;
}
.post {
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  animation: card-in 0.35s ease both;
}
.post-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  align-items: center;
  margin-bottom: 0.65rem;
  font-size: 0.88rem;
}
.post-head .author { font-weight: 700; }
.post-head .time {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}
.post-body {
  white-space: pre-wrap;
  line-height: 1.55;
  color: #e8e4dc;
  font-size: 0.96rem;
}
.reply-box {
  margin-top: 1.25rem;
  padding: 1.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.empty {
  text-align: center;
  padding: 2.5rem 1.25rem;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  color: var(--muted);
  animation: page-in 0.4s ease both;
}
.empty strong {
  display: block;
  color: var(--text);
  margin-bottom: 0.35rem;
}

/* Admin */
.admin-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr 1fr;
}
.panel {
  padding: 1.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
}
.panel h2 {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.table th, .table td {
  text-align: left;
  padding: 0.5rem 0.35rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.table th {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  background: rgba(12, 12, 12, 0.95);
  border: 1px solid rgba(232, 160, 32, 0.35);
  font-size: 0.88rem;
  z-index: 100;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 720px) {
  .admin-grid { grid-template-columns: 1fr; }
  .nav { flex-wrap: wrap; }
}

.wrap.admin-wrap {
  width: min(1180px, calc(100% - 2rem));
}

/* Support ticket inbox (admin) */
.ticket-inbox {
  margin-bottom: 1.25rem;
}
.ticket-inbox-grid {
  display: grid;
  gap: 1rem;
}
@media (min-width: 960px) {
  .ticket-inbox-grid {
    grid-template-columns: 1fr 1.2fr;
    align-items: start;
  }
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.9rem;
}
.filter-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}
.filter-chip:hover {
  border-color: rgba(232, 160, 32, 0.45);
  color: var(--text);
}
.filter-chip.is-active {
  color: #0c0c0c;
  background: #e8a020;
  border-color: #e8a020;
}
.filter-chip.is-active:hover { color: #0c0c0c; }

.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-height: min(70vh, 720px);
  overflow-y: auto;
}
.ticket-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.7rem 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ticket-row:hover {
  background: rgba(255, 255, 255, 0.03);
  border-left-color: rgba(232, 160, 32, 0.4);
}
.ticket-row.is-selected {
  border-color: transparent;
  border-left: 3px solid #e8a020;
  background: rgba(232, 160, 32, 0.07);
  box-shadow: none;
}
.ticket-row strong {
  display: block;
  margin-bottom: 0.18rem;
  font-size: 0.9rem;
  font-weight: 600;
}
.ticket-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.6rem;
  font-size: 0.74rem;
  color: var(--muted);
  font-family: var(--mono);
}

.status-pill {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--border);
}
.status-open, .status-waiting {
  color: #f0a020;
  border-color: rgba(240, 160, 32, 0.35);
}
.status-answered {
  color: #3dd68c;
  border-color: rgba(61, 214, 140, 0.55);
  background: rgba(61, 214, 140, 0.12);
  font-weight: 700;
}
.status-closed { color: var(--muted); }

.ticket-thread { min-height: 12rem; }
.ticket-thread-head h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}
.ticket-thread-meta {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.thread {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  margin: 0 0 0.85rem;
  max-height: min(48vh, 480px);
  overflow-y: auto;
  padding-right: 0.15rem;
}
.bubble {
  max-width: 82%;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
}
.bubble.staff {
  margin-left: auto;
  background: rgba(232, 160, 32, 0.08);
  border-color: rgba(232, 160, 32, 0.35);
}
.bubble .who {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.28rem;
}
.staff-chip {
  display: inline-block;
  padding: 0.04rem 0.34rem;
  border-radius: 999px;
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 700;
  color: #e8a020;
  border: 1px solid #e8a020;
  line-height: 1.3;
}
.bubble p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
}

.ticket-reply .reply-bar {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}
.ticket-reply .reply-bar textarea {
  flex: 1;
  min-height: 52px;
  max-height: 110px;
  resize: vertical;
  width: 100%;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  font: inherit;
}
.ticket-reply .reply-bar .btn.primary {
  flex-shrink: 0;
  padding: 0.5rem 0.95rem;
}
.ticket-status-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.5rem;
}
.status-chip {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}
.status-chip:hover {
  border-color: rgba(232, 160, 32, 0.45);
  color: var(--text);
}
.status-chip.is-current {
  border-color: #e8a020;
  color: #e8a020;
  background: rgba(232, 160, 32, 0.08);
}
.reply-kbd {
  margin: -0.35rem 0 0.7rem;
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--mono);
}
