:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c2430;
  --muted: #6b7686;
  --accent: #2563eb;
  --danger: #dc2626;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

h1 { font-size: 1.15rem; margin: 0; }
h2 { font-size: 0.95rem; margin: 0 0 0.5rem; }

.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 0.8rem; }
.error { color: var(--danger); }
.row { display: flex; align-items: center; gap: 0.5rem; }
.spacer { flex: 1; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

button {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.4rem 0.8rem;
  cursor: pointer;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button.ghost { border-color: transparent; background: transparent; }
button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); }

input, select, textarea {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.6rem;
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: min(360px, 90vw);
}
.login-card form { display: grid; gap: 0.6rem; margin-top: 1rem; }
.login-card button { background: var(--accent); border-color: var(--accent); color: #fff; }

/* shell: exactly one viewport high; list and detail scroll on their own */
body.inbox {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.filters {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  flex-wrap: wrap;
}
.filters input[type="search"] { flex: 1; min-width: 180px; }
.status-filter {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.status-filter label { display: flex; align-items: center; gap: 0.3rem; white-space: nowrap; cursor: pointer; }
.status-filter input { margin: 0; }

.layout {
  flex: 1;
  min-height: 0;
  position: relative;
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 1rem;
  padding: 0 1.25rem 1.25rem;
}
.pane { min-height: 0; overflow-y: auto; }

#list-toggle { display: none; }

/* mobile: detail full width, list is a slide-in drawer from the left */
@media (max-width: 800px) {
  #list-toggle { display: inline-block; }
  .layout { grid-template-columns: 1fr; }
  #list {
    position: absolute;
    inset: 0 auto 0 0;
    z-index: 10;
    width: min(420px, 90vw);
    padding: 0 1rem 1rem;
    background: var(--bg);
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 16px rgb(0 0 0 / 0.12);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0.2s;
  }
  body.list-open #list { transform: none; visibility: visible; }
}

/* list */
.feedback-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.feedback-item {
  display: grid;
  gap: 0.3rem;
  width: 100%;
  text-align: left;
  padding: 0.7rem 0.8rem;
}
.feedback-item .excerpt { font-weight: 500; }
.feedback-item .url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.badge.status-open { background: #fef3c7; border-color: #fcd34d; }
.badge.status-in_progress { background: #dbeafe; border-color: #93c5fd; }
.badge.status-resolved { background: #dcfce7; border-color: #86efac; }
.badge.status-wont_fix { background: #f3f4f6; color: var(--muted); }
.badge.team { background: var(--accent); border-color: var(--accent); color: #fff; }

.list-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0 0 0.5rem;
  background: var(--bg);
}
.sentinel { padding: 0.75rem; text-align: center; }

.empty {
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}

/* detail */
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  display: grid;
  gap: 1rem;
}
.detail-card .message { white-space: pre-wrap; margin: 0; font-size: 1rem; }

.meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  margin: 0;
}
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }

.screenshot-link { display: block; width: fit-content; max-width: 100%; cursor: zoom-in; }
.screenshot {
  display: block;
  max-width: 100%;
  max-height: 50vh;
  object-fit: contain;
  object-position: left top;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.lightbox {
  max-width: 95vw;
  max-height: 95vh;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
  cursor: zoom-out;
}
.lightbox::backdrop { background: rgb(0 0 0 / 0.75); }
.lightbox img { display: block; max-width: 95vw; max-height: 95vh; object-fit: contain; }

.attachments { display: grid; gap: 0.5rem; }
.attachments h2 { font-size: 0.85rem; margin: 0; }
.attachment {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.6rem;
  text-decoration: none;
  color: inherit;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}
.attachment:hover { border-color: var(--muted); }
.attachment-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.attachment-pdf {
  display: grid;
  place-items: center;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 0.7rem;
  font-weight: 700;
}

.diagnostics {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 0.75rem;
  overflow: auto;
  max-height: 300px;
  font-size: 0.78rem;
}

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.actions form { display: flex; gap: 0.5rem; }

.thread { display: grid; gap: 0.6rem; }
.reply {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
}
.reply-admin { background: #eff6ff; border-color: #bfdbfe; }
.reply p { margin: 0.35rem 0 0; white-space: pre-wrap; }

.composer { display: grid; gap: 0.5rem; }
.composer textarea { resize: vertical; }
.composer button { justify-self: end; }
