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

:root {
  /* Theme accent (green) */
  --accent: #063308;
  --accent-2: #0a4a0d; /* slightly brighter */
  --accent-3: #0f6b14; /* brightest accent for focus/active */
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #17191a;
  color: #e5e7eb;
  /* Ensure no overflow during resize */
  overflow-x: hidden;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  /* Ensure the container defines the height clearly */
  min-height: min-content;
}

.app--wide {
  max-width: 1280px;
}

.header {
  text-align: center;
  margin-bottom: 24px;
}

.header h1 {
  margin: 0 0 8px;
  font-size: 1.8rem;
}

.subtitle {
  margin: 0;
  color: #9ca3af;
  font-size: 0.95rem;
}

.archive-updated {
  margin: 6px 0 0;
  color: #9ca3af;
  font-size: 0.9rem;
}

.card {
  background-color: #212425;
  border-radius: 12px;
  padding: 16px 18px 18px;
  margin-bottom: 16px;
  border: 1px solid #1f3720;
  box-shadow: none;
}

.label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.9rem;
  color: #cbd5e1;
}

.input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #374151;
  background-color: #17191a;
  color: #e5e7eb;
  font-size: 0.95rem;
}

.input:focus {
  outline: none;
  border-color: var(--accent-3);
  box-shadow: none;
}

.form-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: flex-end;
}

.form-field {
  flex: 1;
}

.button-field {
  flex: 0 0 auto;
}

.button {
  padding: 8px 16px;
  border-radius: 999px;
  border: none;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--accent-3);
  color: #020617;
}

.button:disabled {
  opacity: 0.6;
  cursor: default;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  min-height: 20px;
  font-size: 0.9rem;
  color: #9ca3af;
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid #4b5563;
  border-top-color: var(--accent-2);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.answer {
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 0.97rem;
}

.unauth-section {
  display: flex;
  justify-content: center;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  text-align: center;
  padding: 20px;
}

.unauth-card {
  max-width: 400px;
  width: 100%;
  padding: 32px;
}

.unauth-card h2 {
  margin-top: 0;
  color: var(--accent-3);
}

.unauth-card p {
  color: #9ca3af;
  margin-bottom: 24px;
}

.unauth-actions {
  display: flex;
  justify-content: center;
}

.unauth-actions .button {
  text-decoration: none;
  display: inline-block;
}

.hidden {
  display: none !important;
}

.sources-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.source-item {
  padding: 8px 0;
  border-bottom: 1px solid #111827;
}

.source-item:last-child {
  border-bottom: none;
}

.source-title {
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.source-title a {
  /* Keep links blue */
  color: #38bdf8;
  text-decoration: none;
}

.source-title a:hover {
  text-decoration: underline;
}

.source-meta {
  font-size: 0.8rem;
  color: #6b7280;
}

.feedback {
  margin-top: 16px;
  border-top: 1px solid #111827;
  padding-top: 10px;
}

.feedback-title {
  margin: 0 0 6px;
  font-size: 0.9rem;
}

.feedback-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.feedback-btn {
  border-radius: 999px;
  border: 1px solid #374151;
  background-color: #020617;
  color: #e5e7eb;
  cursor: pointer;
  padding: 6px 10px;
  font-size: 0.95rem;
}

.feedback-btn.active {
  border-color: var(--accent-2);
  background-color: #0f172a;
}

.feedback-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.feedback-comment {
  flex: 1;
  min-width: 260px;
  font-size: 0.85rem;
}

.feedback-submit {
  padding: 8px 14px;
  font-size: 0.9rem;
  white-space: nowrap;
}

.feedback-status {
  font-size: 0.85rem;
  color: #9ca3af;
}

.stats-controls {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.stat {
  border: 1px solid #111827;
  border-radius: 12px;
  padding: 10px 12px;
  background-color: rgba(2, 6, 23, 0.6);
}

.stat-label {
  color: #9ca3af;
  font-size: 0.85rem;
}

.stat-value {
  margin-top: 2px;
  font-size: 1.3rem;
  font-weight: 650;
}

.small-muted {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #9ca3af;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 8px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  table-layout: auto;
}

.table th,
.table td {
  border-bottom: 1px solid #111827;
  padding: 8px 10px;
  vertical-align: top;
}

.table th:nth-child(2),
.table td:nth-child(2) {
  width: 35%;
}

.table th:last-child,
.table td:last-child {
  width: 10%;
}

.table th {
  text-align: left;
  color: #cbd5e1;
  font-weight: 600;
}

.td-num {
  text-align: right;
  white-space: nowrap;
}

.td-center {
  text-align: center;
  white-space: nowrap;
}

.td-wrap {
  word-break: break-word;
}

.td-pre {
  white-space: pre-wrap;
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.recent-item {
  border: 1px solid #111827;
  border-radius: 12px;
  padding: 10px 12px;
  background-color: rgba(2, 6, 23, 0.6);
}

.recent-item > summary {
  cursor: pointer;
  list-style: none;
}

.recent-item > summary::-webkit-details-marker {
  display: none;
}

.recent-q {
  display: block;
  font-weight: 650;
  margin-bottom: 4px;
}

.recent-meta {
  display: block;
  color: #9ca3af;
  font-size: 0.85rem;
}

.recent-body {
  margin-top: 10px;
}

.pre {
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #111827;
  background-color: #020617;
  overflow-x: auto;
  white-space: pre-wrap;
  line-height: 1.45;
}

@media (max-width: 640px) {
  .form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .button-field {
    width: 100%;
  }

  .button {
    width: 100%;
    text-align: center;
  }

  .feedback-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Help / Tips Styles */
.help-container {
  margin-bottom: 16px;
  text-align: center;
}

.help-toggle-btn {
  background: none;
  border: 1px solid #1f3720;
  color: #9ca3af;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.help-toggle-btn:hover {
  color: #e5e7eb;
  border-color: var(--accent-3);
  background-color: rgba(10, 74, 13, 0.1);
}

.help-content {
  margin-top: 12px;
  text-align: left;
}

.help-card {
  border-style: dashed !important;
  background-color: rgba(2, 6, 23, 0.4) !important;
}

.help-card h3 {
  margin-top: 0;
  font-size: 1rem;
  color: var(--accent-3);
}

.help-section {
  font-size: 0.9rem;
  color: #9ca3af;
  margin-bottom: 16px;
  line-height: 1.4;
}

.help-section p {
  margin: 0 0 8px;
}

.help-list {
  margin: 8px 0 16px;
  padding-left: 20px;
  font-size: 0.9rem;
  color: #cbd5e1;
}

.help-list li {
  margin-bottom: 8px;
  line-height: 1.4;
}

.help-warning {
  margin-top: 12px;
  padding: 10px;
  background-color: rgba(153, 27, 27, 0.1);
  border-left: 3px solid #991b1b;
  font-size: 0.85rem;
  color: #fca5a5;
}

