:root {
  --bg: #0d0d0f;
  --panel: #17171b;
  --border: #2a2a30;
  --accent: #ff6b3d;
  --text: #f2f2f2;
  --muted: #9a9aa2;
  --danger: #ff4d4f;
  --success: #3ddc97;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

.hidden { display: none !important; }

.topbar {
  padding: 24px 20px 12px;
  text-align: center;
  position: relative;
}
.header-auth-actions,
.header-user-actions {
  position: absolute;
  top: 18px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-auth-actions .btn-primary,
.header-auth-actions .btn-secondary { width: auto; margin: 0; padding: 9px 13px; }
.header-user-actions { font-size: 13px; color: var(--muted); }
.logo-mark {
  width: 220px;
  max-width: 80%;
  height: auto;
  display: block;
  margin: 0 auto;
}
.tagline { color: var(--muted); margin: 8px 0 0; font-size: 14px; }

.tip-link {
  display: block;
  margin: 12px auto 0;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
}
.tip-link:hover { border-color: var(--accent); color: var(--accent); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 20px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}
.modal-box h2 { margin: 0 0 8px; font-size: 20px; }
.modal-sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.qr-img {
  width: 160px;
  height: 160px;
  border-radius: 10px;
  margin: 0 auto 14px;
  display: block;
  background: #fff;
  padding: 8px;
}
.sol-label { color: var(--muted); font-size: 12px; margin: 0 0 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.address-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.address-row code {
  flex: 1;
  font-size: 11px;
  word-break: break-all;
  text-align: left;
  color: var(--text);
}
.btn-icon-small {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.modal-note { color: var(--muted); font-size: 11px; margin: 12px 0 0; }

#app { max-width: 480px; margin: 0 auto; padding: 12px 20px 40px; }

.view { display: none; }
.view.active { display: block; }

.upload-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
}

.preview-box {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 2px dashed var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  margin-bottom: 16px;
  overflow: hidden;
}
.preview-box img { width: 100%; height: 100%; object-fit: cover; }
.photo-source-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-source-row .btn-primary,
.photo-source-row .btn-secondary { margin: 0; }

.btn-primary, .btn-secondary {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }

.section-label { color: var(--muted); font-size: 13px; margin: 24px 0 8px; }

.ai-note { color: var(--muted); font-size: 12px; margin: 10px 0 0; }

.divider {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 24px 0;
  position: relative;
}
.divider::before, .divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border);
}
.divider::before { left: 0; }
.divider::after { right: 0; }

.back-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  padding: 0;
  margin-bottom: 12px;
  cursor: pointer;
}

.symptom-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.symptom-btn {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 15px;
  cursor: pointer;
}
.symptom-btn:hover { border-color: var(--accent); }

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.category-chip {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
  font-size: 13px;
  cursor: pointer;
}
.category-chip:hover { border-color: var(--accent); }
.category-chip .icon { font-size: 22px; display: block; margin-bottom: 4px; }

#view-analyzing {
  text-align: center;
  padding: 80px 0;
  color: var(--muted);
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}
.badge {
  display: inline-block;
  background: rgba(255,107,61,0.15);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  margin: 0 0 8px;
}
.result-card h2 { margin: 0 0 6px; font-size: 20px; }
.confidence { color: var(--muted); font-size: 13px; margin: 0; }
.safety-warning {
  margin-top: 12px;
  background: rgba(255,77,79,0.12);
  color: var(--danger);
  border: 1px solid rgba(255,77,79,0.4);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

.steps-list {
  margin: 20px 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.steps-list li {
  counter-increment: step;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px 14px 46px;
  margin-bottom: 10px;
  position: relative;
}
.steps-list li::before {
  content: counter(step);
  position: absolute;
  left: 14px; top: 14px;
  width: 22px; height: 22px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.steps-list .warning {
  display: block;
  color: var(--danger);
  font-size: 12px;
  margin-top: 6px;
}

.feedback-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin: 20px 0;
  color: var(--muted);
}
.btn-icon {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 18px;
  cursor: pointer;
}
.btn-icon.selected { border-color: var(--accent); }

/* ============================================================
   Tab navigation
   ============================================================ */
.tab-nav {
  display: flex;
  gap: 8px;
  padding: 0 20px 16px;
  max-width: 480px;
  margin: 0 auto;
  overflow-x: auto;
}
.tab-btn {
  flex: 1;
  white-space: nowrap;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============================================================
   Not-helpful comment box + community CTA
   ============================================================ */
.not-helpful-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin: 12px 0;
}
.not-helpful-box textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  margin-bottom: 10px;
}
.community-cta {
  text-align: center;
  background: rgba(255,107,61,0.08);
  border: 1px dashed var(--accent);
  border-radius: 12px;
  padding: 14px;
  margin: 12px 0;
}
.community-cta p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }

/* ============================================================
   Forum — list view
   ============================================================ */
.forum-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.forum-header h2 { margin: 0 0 4px; font-size: 20px; }
.forum-header .btn-primary { width: auto; padding: 10px 16px; margin: 0; white-space: nowrap; }

.auth-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
}
.auth-note { color: var(--muted); }
.forum-auth-actions { display: flex; gap: 8px; }
.forum-auth-actions .btn-primary,
.forum-auth-actions .btn-secondary { width: auto; margin: 0; }
.ai-provider-row {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr);
  gap: 8px 10px;
  align-items: center;
  margin: 14px 0 4px;
  text-align: left;
}
.ai-provider-row select,
.ai-model-label {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  padding: 9px 10px;
}
.ai-provider-status { color: var(--muted); font-size: 12px; margin: 4px 0 12px; }

@media (max-width: 640px) {
  .topbar { padding-top: 70px; }
  .header-auth-actions,
  .header-user-actions { top: 14px; right: 14px; }
}
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 0;
}

.forum-search-row { margin-bottom: 10px; }
.forum-search-row input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
}

.forum-filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.filter-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.forum-post-list { display: flex; flex-direction: column; gap: 10px; }
.forum-post-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
}
.forum-post-card:hover { border-color: var(--accent); }
.forum-post-card h3 { margin: 6px 0; font-size: 15px; line-height: 1.35; }

.post-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}
.status-badge.open { background: rgba(255,107,61,0.15); color: var(--accent); }
.status-badge.solved { background: rgba(61,220,151,0.15); color: var(--success); }
.category-tag {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
}
.post-meta-right { margin-left: auto; font-size: 12px; color: var(--muted); }
.post-desc-preview { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.post-card-bottom {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}
.view-answers-link { color: var(--accent); font-weight: 600; }

/* ============================================================
   Forum — thread detail view
   ============================================================ */
.thread-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
}
.thread-card h2 { margin: 4px 0 6px; font-size: 19px; }
.post-meta { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.malfunction-box {
  background: rgba(255,107,61,0.08);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 10px 0;
}
.malfunction-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.5px;
  margin: 0 0 4px;
}
.malfunction-box p:last-child { margin: 0; font-size: 14px; }

.answers-heading { font-size: 15px; margin: 0 0 10px; }
.replies-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.reply-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.reply-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.reply-card p { margin: 0; font-size: 14px; }
.passkey-badge {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 10px;
  margin-left: 4px;
}
.reply-date { white-space: nowrap; }

.post-answer-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.post-answer-box textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  margin: 8px 0 10px;
}

/* ============================================================
   Auth modal
   ============================================================ */
.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-tab-btn {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.auth-tab-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.auth-tab-panel { display: none; text-align: left; }
.auth-tab-panel.active { display: block; }

.form-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.modal-box input[type="text"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 6px;
}
.modal-box textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  margin-bottom: 12px;
}
.username-status { font-size: 12px; margin: 0 0 12px; min-height: 16px; }
.username-suggest { width: auto; margin: 9px 0 0; padding: 7px 10px; font-size: 12px; }
.username-status.ok { color: var(--success); }
.username-status.taken { color: var(--danger); }
.auth-error {
  color: var(--danger);
  background: rgba(255,77,79,0.1);
  border: 1px solid rgba(255,77,79,0.3);
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  margin-top: 12px;
}

/* ============================================================
   History modal
   ============================================================ */
.empty-state { text-align: center; padding: 20px 0; color: var(--muted); }
.empty-icon { font-size: 32px; margin-bottom: 8px; }
.history-item {
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  text-align: left;
}
.history-item:hover,
.history-item:focus-visible { border-color: var(--accent); transform: translateY(-1px); }
.history-item:disabled { opacity: 0.65; cursor: wait; }
.history-device { font-size: 12px; color: var(--accent); font-weight: 700; margin: 0 0 4px; text-transform: uppercase; }
.history-issue { font-size: 14px; margin: 0 0 4px; }
.history-date { font-size: 12px; color: var(--muted); margin: 0; }

/* ============================================================
   Welcome banner
   ============================================================ */
.welcome-banner {
  color: var(--muted);
  font-size: 12px;
  margin: 6px 0 0;
  font-style: italic;
}

/* ============================================================
   Interactive repair checklist
   ============================================================ */
.checklist-progress {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: -4px 0 14px;
}
.checklist-item {
  cursor: pointer;
  transition: opacity 0.15s;
}
.checklist-item::before {
  content: counter(step);
}
.checklist-item.checked {
  opacity: 0.55;
}
.checklist-item.checked::before {
  content: "✓";
  background: var(--success);
}
.checklist-item.checked .checklist-text {
  text-decoration: line-through;
}
.checklist-text { display: block; }

/* ============================================================
   Ask SiraNiko AI (follow-up box)
   ============================================================ */
.ask-ai-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin: 16px 0;
}
.ask-ai-title { font-weight: 600; margin: 0 0 2px; font-size: 14px; }
.ask-ai-input-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.ask-ai-input-row input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
}
.followup-answer {
  margin-top: 12px;
  background: var(--bg);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
}
.followup-answer.irrelevant {
  border-left-color: var(--muted);
  color: var(--muted);
  font-style: italic;
}

/* ============================================================
   Terms of Service page
   ============================================================ */
.terms-doc { max-width: 480px; margin: 0 auto; padding-bottom: 40px; }
.terms-doc h1 { font-size: 22px; margin: 16px 0 4px; }
.terms-updated { color: var(--muted); font-size: 12px; margin: 0 0 20px; }
.terms-doc h2 { font-size: 15px; margin: 20px 0 6px; color: var(--accent); }
.terms-doc p { font-size: 14px; line-height: 1.6; color: var(--text); margin: 0 0 4px; }

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  text-align: center;
  padding: 24px 20px 40px;
  color: var(--muted);
  font-size: 12px;
}
.site-footer a { color: var(--muted); text-decoration: underline; }
.site-footer a:hover { color: var(--accent); }

/* ============================================================
   Report button
   ============================================================ */
.report-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.report-link:hover { color: var(--danger); }

/* ============================================================
   Image attach UI (create post + reply forms)
   ============================================================ */
.image-attach-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.btn-small {
  width: auto;
  padding: 8px 12px;
  margin: 0;
  font-size: 13px;
}
.attach-preview {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* ============================================================
   Photos shown in forum posts/replies
   ============================================================ */
.post-photo {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 10px;
  margin: 10px 0;
  display: block;
}
.reply-photo {
  max-width: 200px;
  max-height: 200px;
  object-fit: cover;
  border-radius: 8px;
  margin: 8px 0;
  display: block;
}
.thread-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}
.reply-card .report-link { margin-top: 8px; display: inline-block; }

/* ============================================================
   History thumbnails
   ============================================================ */
.history-item { display: flex; gap: 12px; align-items: flex-start; }
.history-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.history-item-text { flex: 1; min-width: 0; }
