:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #1c1f26;
  --muted: #6b7280;
  --border: #e3e5ea;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #e8efff;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --surface: #1b1e26;
    --surface-2: #232732;
    --text: #e7e9ee;
    --muted: #9aa1ad;
    --border: #2d323d;
    --accent: #5b8cff;
    --accent-hover: #7aa2ff;
    --accent-soft: #1f2a44;
    --danger: #f87171;
    --danger-soft: #3b1d1d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.wrap {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
}

main.wrap { flex: 1; padding-bottom: 32px; }

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---- Topbar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  font-size: 17px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.count {
  font-weight: 500;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 9px;
}

.count:empty { display: none; }

/* ---- Buttons ---- */
.btn {
  font: inherit;
  font-weight: 550;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}

.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }

.link {
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.link:hover { color: var(--text); text-decoration: underline; }

.icon-btn {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background .12s, color .12s;
}

.icon-btn:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.confirming { background: var(--danger); color: #fff; }

/* ---- Cards / forms ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-top: 20px;
}

.card h2 { margin: 0 0 4px; font-size: 20px; }
.card h2 + p { margin-top: 0; }

.login { max-width: 400px; margin: 60px auto 0; }
.login.shake { animation: shake .35s; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.field { display: block; margin: 14px 0; }
.field > span { display: block; font-size: 13px; font-weight: 550; color: var(--muted); margin-bottom: 5px; }

input[type="text"], input[type="password"], textarea {
  font: inherit;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}

input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea { resize: vertical; min-height: 60px; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.error { color: var(--danger); font-size: 13px; margin: 8px 0 0; }

/* ---- Drop zone ---- */
.drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .12s, background .12s;
  outline: none;
}

.drop:hover, .drop:focus, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-preview { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.drop-preview img { max-width: 100%; max-height: 320px; border-radius: 8px; border: 1px solid var(--border); }

/* ---- Filter chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 6px; }
.chips:empty { display: none; }

.chip {
  font: inherit;
  font-size: 13px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .n { opacity: .7; margin-left: 4px; }

/* ---- Feedback items ---- */
.item { margin-top: 16px; padding: 0; overflow: hidden; }
.item-body { padding: 18px 20px; }

.item-head { display: flex; align-items: center; gap: 12px; }

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 650;
  color: #fff;
  flex-shrink: 0;
}

.avatar.sm { width: 26px; height: 26px; font-size: 12px; }

.who { flex: 1; min-width: 0; }
.who .name { font-weight: 650; }
.who .time { font-size: 13px; color: var(--muted); }

.item-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 14px 0 0;
}

.item-img {
  display: block;
  margin-top: 14px;
  max-width: 100%;
  max-height: 360px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: zoom-in;
}

/* ---- Comments ---- */
.comments {
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  padding: 14px 20px 16px;
}

.comment { display: flex; gap: 10px; padding: 8px 0; }
.comment + .comment { border-top: 1px solid var(--border); }
.comment .c-body { flex: 1; min-width: 0; }
.comment .c-meta { font-size: 13px; }
.comment .c-meta .name { font-weight: 600; }
.comment .c-meta .time { color: var(--muted); margin-left: 6px; }
.comment .c-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }

.comment-form { display: grid; grid-template-columns: 180px 1fr auto; gap: 8px; margin-top: 10px; align-items: start; }
.comment-form textarea { min-height: 38px; height: 38px; }
.comment-form textarea:focus { min-height: 72px; }
.comment-form .error { grid-column: 1 / -1; margin: 0; }

@media (max-width: 560px) {
  .comment-form { grid-template-columns: 1fr; }
  .comment-form .btn { justify-self: end; }
}

.empty { text-align: center; color: var(--muted); margin-top: 60px; }

/* ---- Footer ---- */
.footer {
  padding: 18px 16px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.footer .dot { margin: 0 8px; }

/* ---- Dialog ---- */
dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 20px;
  width: min(360px, calc(100vw - 32px));
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}

dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog h3 { margin: 0; }

/* ---- Lightbox ---- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .85);
  display: grid;
  place-items: center;
  padding: 24px;
  cursor: zoom-out;
}

.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }
