:root {
  --bg: #f4f5f7; --card: #fff; --ink: #1f2326; --muted: #6a7178; --line: #dfe3e8;
  --brand: #3a3c39; --accent: #3d6fb6; --accent-ink: #fff;
  --bug: #c0392b; --feature: #7b4fc9;
  --s-open: #3d6fb6; --s-progress: #d98b0b; --s-fixed: #1f9d55; --s-closed: #6a7178; --s-wontfix: #6a7178;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a; --card: #1e2227; --ink: #e8eaed; --muted: #98a0a8; --line: #323a42;
    --brand: #101214; --accent: #6b9be0; --accent-ink: #0d1318;
    --bug: #e5766a; --feature: #b394ee;
    --s-open: #6b9be0; --s-progress: #eeaa3c; --s-fixed: #4cc17e; --s-closed: #98a0a8; --s-wontfix: #98a0a8;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.top { background: var(--brand); color: #fff; padding: 10px 16px; display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 5; }
.top img { width: 32px; height: 32px; background: #fff; border-radius: 6px; padding: 2px; }
.top .title { font-weight: 600; flex: 1; }
.top a, .top button { color: #fff; background: none; border: 0; cursor: pointer; text-decoration: none; padding: 6px 8px; border-radius: 8px; }
.top a:hover, .top button:hover { background: rgba(255,255,255,.15); }

main { max-width: 860px; margin: 0 auto; padding: 16px 16px 120px; }
h1 { font-size: 1.25rem; margin: 0 0 12px; }
h2 { font-size: 1.05rem; margin: 20px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }

.btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer; font-weight: 600; min-height: 44px; }
.btn.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.good { background: var(--s-fixed); color: #fff; }
.btn.warn { background: var(--bug); color: #fff; }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.grow > * { flex: 1; }
.spacer { flex: 1; }

input[type=text], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); min-height: 44px;
}
textarea { min-height: 120px; resize: vertical; }
label { display: block; font-weight: 600; margin: 14px 0 6px; }
.field-hint { color: var(--muted); font-weight: 400; font-size: .85rem; }

.fab { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); width: 64px; height: 64px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: 40px; line-height: 60px; text-align: center; text-decoration: none;
  box-shadow: 0 4px 14px rgba(0,0,0,.3); z-index: 6; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: .9rem; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
@media (prefers-color-scheme: dark) { .chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); } }

.banner { background: color-mix(in srgb, var(--s-fixed) 15%, var(--card)); border: 1px solid var(--s-fixed); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; cursor: pointer; }

.item { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; color: inherit; text-decoration: none; }
.item:hover { border-color: var(--accent); }
.item .head { display: flex; gap: 8px; align-items: baseline; }
.item .id { color: var(--muted); font-variant-numeric: tabular-nums; }
.item .t { font-weight: 600; flex: 1; overflow-wrap: anywhere; }
.item .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; font-size: .85rem; color: var(--muted); }

.pill { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: .78rem; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.pill.s-open { color: var(--s-open); } .pill.s-progress { color: var(--s-progress); } .pill.s-fixed { color: var(--s-fixed); }
.pill.s-closed, .pill.s-wontfix { color: var(--s-closed); }
.pill.bug { color: var(--bug); } .pill.feature { color: var(--feature); }
.pill.sev-crash { color: var(--bug); } .pill.sev-annoying { color: var(--s-progress); } .pill.sev-cosmetic { color: var(--muted); }
.pill.plain { color: var(--ink); border-color: var(--line); background: var(--bg); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tile { border: 2px solid var(--line); background: var(--card); border-radius: var(--radius); padding: 14px 8px; text-align: center; font-weight: 600; cursor: pointer; min-height: 56px; overflow-wrap: anywhere; }
.tile.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--card)); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }

.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 16px; text-align: center; color: var(--muted); background: var(--card); }
.drop.over, .drop:focus { border-color: var(--accent); outline: none; }
.files { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.file { position: relative; border: 1px solid var(--line); border-radius: 10px; background: var(--card); overflow: hidden; width: 128px; }
.file .pic { height: 90px; background: var(--bg); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); cursor: pointer; }
.file .pic img { width: 100%; height: 100%; object-fit: cover; }
.file .nm { font-size: .75rem; padding: 4px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; }
.file .bar { height: 4px; background: var(--accent); width: 0; }

.notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment { border-top: 1px solid var(--line); padding: 10px 0; }
.comment .who { font-size: .85rem; color: var(--muted); display: flex; gap: 8px; }
.event { padding: 6px 0; color: var(--muted); font-size: .88rem; border-top: 1px solid var(--line); }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }

.login { max-width: 360px; margin: 12vh auto 0; padding: 0 16px; text-align: center; }
.login img { width: 96px; height: 96px; }
.login form { text-align: left; }
.err { color: var(--bug); margin: 10px 0 0; min-height: 1.2em; }

table.simple { width: 100%; border-collapse: collapse; }
table.simple td, table.simple th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }

#toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 30; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.bad { background: var(--bug); }

.item.unread { border-left: 4px solid var(--accent); }
.item.unread .t { font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); align-self: center; flex: none; }
.top a.count { background: var(--bug); color: #fff; border-radius: 999px; padding: 0 9px; font-size: .8rem; font-weight: 700; line-height: 1.5; }
