/* Remnawave-inspired: dark GitHub-like shell, blue/teal accents */
:root {
  --bg-deep: #010409;
  --bg-base: #0d1117;
  --bg-elevated: #161b22;
  --bg-card: #161b22;
  --border: #30363d;
  --border-muted: #21262d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-dim: #6e7681;
  --accent: #218bff;
  --accent-hover: #388bfd;
  --accent-soft: rgba(33, 139, 255, 0.12);
  --teal: #3fb950;
  --teal-soft: rgba(63, 185, 80, 0.12);
  --danger: #f85149;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  --font: "Inter", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background: radial-gradient(ellipse 120% 80% at 50% -20%, rgba(33, 139, 255, 0.08), transparent),
    linear-gradient(180deg, var(--bg-base) 0%, var(--bg-deep) 100%);
}

.app {
  min-height: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
}

.hidden {
  display: none !important;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top, 0));
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-muted);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(33, 139, 255, 0.25);
}

.brand-icon svg {
  width: 22px;
  height: 22px;
}

.brand-title {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Views */
.view {
  padding: 16px;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.stat-card.accent {
  border-color: rgba(63, 185, 80, 0.35);
  background: linear-gradient(145deg, var(--bg-elevated), rgba(63, 185, 80, 0.06));
}

.stat-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.stat-value.stat-small {
  font-size: 15px;
  font-weight: 600;
  color: var(--teal);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-head h1 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Buttons */
.btn {
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 10px 16px;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: rgba(139, 148, 158, 0.18);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(139, 148, 158, 0.28);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
  margin-top: 8px;
}

/* Bot list */
.bots-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bot-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.bot-card:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
}

.bot-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.bot-card-body {
  flex: 1;
  min-width: 0;
}

.bot-card-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 2px;
}

.bot-card-handle {
  font-size: 12px;
  color: var(--teal);
  margin-bottom: 4px;
}

.bot-card-preview {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bot-card-chevron {
  color: var(--text-dim);
  font-size: 18px;
  align-self: center;
}

.empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 32px 16px;
  line-height: 1.6;
}

/* Detail */
.back-link {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 0 0 12px;
  margin-bottom: 4px;
}

.detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}

.detail-header {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-muted);
}

.bot-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
  overflow: hidden;
}

.bot-avatar--img {
  background: var(--bg-card);
  padding: 0;
}

.bot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detail-header h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.detail-link {
  font-size: 13px;
  color: var(--teal);
  text-decoration: none;
}

.field-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.message-preview {
  background: var(--bg-base);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 14px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 80px;
}

/* Edit */
.edit-title {
  font-size: 18px;
  margin-bottom: 8px;
}

.edit-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.5;
}

.anonymity-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.anonymity-option {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-base);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.anonymity-option:disabled {
  opacity: 0.6;
  cursor: wait;
}

.anonymity-option.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.anonymity-option-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  color: var(--accent);
  margin-top: 2px;
}

.anonymity-option-icon svg {
  width: 22px;
  height: 22px;
}

.anonymity-option-body {
  flex: 1;
  min-width: 0;
}

.anonymity-option-title {
  display: block;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.anonymity-option-desc {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

.textarea {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 12px;
  resize: vertical;
  min-height: 140px;
}

.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.edit-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

/* Loading / error */
.view-loading,
.view-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.view-error p {
  margin-bottom: 16px;
  color: var(--danger);
}

/* Icon button & sidebar */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn-svg,
.icon-btn-svg svg,
.stat-icon svg,
.metrics-title-icon svg,
.sidebar-icon svg,
.sort-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.stat-icon {
  display: flex;
  color: var(--accent);
  margin-bottom: 8px;
}

.stat-card.accent .stat-icon {
  color: var(--teal);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(1, 4, 9, 0.65);
  z-index: 40;
  backdrop-filter: blur(2px);
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(280px, 86vw);
  z-index: 50;
  background: var(--bg-base);
  border-right: 1px solid var(--border);
  padding: calc(16px + env(safe-area-inset-top, 0)) 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transform: translateX(0);
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

.sidebar-head {
  padding: 8px 10px 16px;
  border-bottom: 1px solid var(--border-muted);
  margin-bottom: 8px;
}

.sidebar-bot {
  font-weight: 600;
  font-size: 15px;
  color: var(--accent-hover);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 11px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
}

.sidebar-item:hover:not(.disabled) {
  background: var(--bg-elevated);
}

.sidebar-item.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.sidebar-item.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sidebar-icon {
  width: 20px;
  color: var(--text-muted);
  display: flex;
}

.sidebar-item.active .sidebar-icon {
  color: var(--accent);
}

.sidebar-soon {
  margin-left: auto;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.sidebar-back {
  margin-top: auto;
  color: var(--text-muted);
  font-size: 13px;
}

/* Dashboard */
.bot-hero {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-muted);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  min-height: 76px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric-card .metric-icon {
  color: var(--accent);
  width: 18px;
  height: 18px;
}

.metric-card .metric-icon svg {
  width: 18px;
  height: 18px;
}

.metric-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.metric-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.metrics-section {
  margin-bottom: 20px;
}

.metrics-section--in .metrics-title-icon {
  color: var(--teal);
}

.metrics-section--out .metrics-title-icon {
  color: var(--accent);
}

.metrics-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.metrics-section--in .metrics-title {
  color: var(--teal);
}

.metrics-section--out .metrics-title {
  color: var(--accent-hover);
}

.metrics-title-icon {
  display: flex;
}

.metrics-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metric-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.metric-row-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
}

.metric-row-icon svg {
  width: 22px;
  height: 22px;
}

.metric-row--in .metric-row-icon {
  background: var(--teal-soft);
  border-color: rgba(63, 185, 80, 0.35);
  color: var(--teal);
}

.metric-row--out .metric-row-icon {
  background: var(--accent-soft);
  border-color: rgba(33, 139, 255, 0.35);
  color: var(--accent-hover);
}

.metric-row-body {
  flex: 1;
  min-width: 0;
}

.metric-row-period {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.metric-row-main {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.metric-row-count {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1.1;
}

.metric-row-trend {
  font-size: 12px;
  font-weight: 500;
}

.metric-row-trend--up {
  color: var(--teal);
}

.metric-row-trend--down {
  color: var(--danger);
}

.metric-row-trend--flat {
  color: var(--text-dim);
}

/* Topics table */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table-header,
.table-row {
  display: grid;
  grid-template-columns: 1.4fr 0.7fr 0.9fr 1fr;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
}

.table-header {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.th {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sort-icon {
  display: inline-flex;
  opacity: 0.35;
}

.table-body .table-row {
  border-bottom: 1px solid var(--border-muted);
  font-size: 12px;
}

.table-body .table-row:last-child {
  border-bottom: none;
}

.topic-cell {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
  background: var(--teal);
  box-shadow: 0 0 8px rgba(63, 185, 80, 0.5);
}

.status-dot[data-status="banned"],
.status-dot[data-status="anti_spam"],
.status-dot[data-status="deleted_bot"] {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(248, 81, 73, 0.45);
}

.status-dot[data-status="anti_spam"] {
  background: #ff6b4a;
  box-shadow: 0 0 8px rgba(255, 107, 74, 0.5);
}

.status-dot[data-status="archived"] {
  background: var(--text-dim);
  box-shadow: none;
}

.topic-title-btn {
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.topic-title-btn:hover {
  color: var(--accent-hover);
}

.topic-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.topic-link {
  color: var(--accent-hover);
  text-decoration: none;
  font-size: 11px;
  word-break: break-all;
}

.topic-link:hover {
  text-decoration: underline;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-neutral {
  background: rgba(139, 148, 158, 0.15);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-banned {
  background: rgba(248, 81, 73, 0.12);
  color: var(--danger);
  border: 1px solid rgba(248, 81, 73, 0.35);
}

.badge-anti-spam {
  background: rgba(248, 81, 73, 0.12);
  color: #ff6b4a;
  border: 1px solid rgba(255, 107, 74, 0.4);
}

.badge-deleted {
  background: rgba(248, 81, 73, 0.1);
  color: var(--danger);
  border: 1px solid rgba(248, 81, 73, 0.3);
}

.badge-archived {
  background: rgba(139, 148, 158, 0.12);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge svg {
  width: 12px;
  height: 12px;
}

.seen-cell {
  color: var(--text-muted);
  font-size: 11px;
}

.bot-card-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Topic sheet */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(1, 4, 9, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.topic-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 12px 16px 20px;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
  animation: sheet-up 0.22s ease-out;
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
    opacity: 0.6;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.topic-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 0 auto 12px;
}

.topic-sheet-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 14px;
}

.topic-sheet-meta {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
}

.topic-sheet-meta div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.topic-sheet-meta dt {
  color: var(--text-muted);
  margin: 0;
}

.topic-sheet-meta dd {
  margin: 0;
  text-align: right;
  color: var(--text);
  word-break: break-word;
}

.topic-sheet-meta a {
  color: var(--teal);
  text-decoration: none;
}

.topic-sheet-meta a:hover {
  text-decoration: underline;
}

.topic-sheet-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.topic-sheet-status-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.topic-sheet-anonymity-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.topic-actions-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.topic-action-btn {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-base);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.topic-action-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.topic-action-btn.active-pending {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.topic-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.topic-sheet-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.topic-sheet-footer .btn {
  min-width: 108px;
}
