/* GitHub Primer-inspired theme */
:root {
  --bg: #f6f8fa; --bg-card: #ffffff; --border: #d1d9e0;
  --fg: #1f2328; --fg-muted: #59636e;
  --accent: #0969da; --success: #1f883d; --danger: #cf222e; --warn-bg: #fff8c5;
  --add: #1a7f37; --del: #cf222e; --mod: #9a6700;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.5 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}
.mono, code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.topbar { background: #1f2328; color: #fff; padding: 12px 16px; }
.topbar-inner {
  display: flex; align-items: center; gap: 24px;
  max-width: 1080px; margin: 0 auto;
}
.topbar .brand { font-weight: 600; }
.topbar nav a { color: #d1d9e0; text-decoration: none; margin-right: 16px; font-weight: 500; }
.topbar nav a:hover { color: #fff; }
.topbar .logout { margin-left: auto; }
.topbar .logout button {
  background: none; border: 1px solid #59636e; color: #d1d9e0;
  border-radius: 6px; padding: 4px 12px; cursor: pointer;
}

main { max-width: 1080px; margin: 24px auto; padding: 0 16px; }
h1 { font-size: 24px; font-weight: 600; }
h2 { font-size: 16px; font-weight: 600; margin-top: 0; }

.gh-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; padding: 16px; margin: 16px 0;
}
.gh-box.warn { background: var(--warn-bg); }
details.gh-box > summary { cursor: pointer; font-weight: 600; }

.gh-table { width: 100%; border-collapse: collapse; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.gh-table th { text-align: left; background: var(--bg); border-bottom: 1px solid var(--border);
  padding: 8px 12px; font-weight: 600; color: var(--fg-muted); }
.gh-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.gh-table tr:last-child td { border-bottom: none; }
.gh-table a { color: var(--accent); text-decoration: none; }
.gh-table a:hover { text-decoration: underline; }
.gh-table th .sort-link { color: var(--fg-muted); user-select: none; }
.gh-table th .sort-link.active { color: var(--accent); }
.gh-table th.col-center, .gh-table td.col-center { text-align: center; }

.btn {
  display: inline-block; padding: 5px 16px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg);
  font-weight: 500; font-size: 14px;
}
.btn:hover { background: #eef1f4; }
.btn-primary { background: var(--success); border-color: var(--success); color: #fff; }
.btn-primary:hover { background: #1a7431; }
.btn-large { padding: 8px 24px; font-size: 15px; }
.btn-sm { padding: 3px 12px; font-size: 12px; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-link, .btn-danger-link { background: none; border: none; cursor: pointer; padding: 0; font-size: 13px; }
.btn-link { color: var(--accent); }
.btn-danger-link { color: var(--danger); }

.counter {
  display: inline-block; background: #818b981f; border-radius: 2em;
  padding: 0 8px; font-size: 12px; font-weight: 500;
}
.locale-tag {
  position: relative;
  display: inline-block; background: #ddf4ff; color: var(--accent);
  border-radius: 2em; padding: 0 8px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; cursor: help;
}
.locale-tag[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  margin-bottom: 5px;
  background: #24292f;
  color: #fff;
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  white-space: nowrap;
  padding: 3px 7px;
  border-radius: 4px;
  z-index: 20;
  pointer-events: none;
}
.label-warn { color: var(--mod); font-weight: 500; font-size: 12px; }
.flash-error {
  background: #ffebe9; border: 1px solid rgba(207,34,46,.4); color: var(--danger);
  border-radius: 6px; padding: 8px 12px;
}

.inline-form { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
input, textarea, select {
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 12px;
  font-size: 14px; font-family: inherit; background: var(--bg-card); color: var(--fg);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.wide { width: 100%; margin: 6px 0; }
.wide-input { width: 280px; }
.searchbar { display: flex; gap: 8px; margin: 16px 0; align-items: center; }
.bar-group { display: flex; gap: 8px; }
.bar-sort { margin-left: auto; }
.cat-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.cat-tabs a {
  padding: 4px 12px; border: 1px solid var(--border); border-radius: 2em;
  color: var(--fg); text-decoration: none; font-weight: 500; font-size: 13px;
  background: var(--bg-card); white-space: nowrap;
}
.cat-tabs a:hover { background: #eef1f4; }
.cat-tabs a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cat-tabs a.active .counter { background: rgba(255, 255, 255, .25); }

.tabs-row { display: flex; align-items: flex-start; gap: 12px; }
.tabs-row .cat-tabs { flex: 1; }
.tabs-row > .btn { white-space: nowrap; align-self: center; }

.new-mod-dialog {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 16px 20px; background: var(--bg-card); color: var(--fg);
  min-width: 320px;
}
.new-mod-dialog::backdrop { background: rgba(0, 0, 0, .4); }
.new-mod-dialog h2 { margin-bottom: 8px; }
.settings-tabs { border-bottom: 1px solid var(--border); padding-bottom: 16px; }
.pagination { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0; align-items: center; }
.pagination a, .pagination .current {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; font-weight: 500; color: var(--accent);
  text-decoration: none; background: var(--bg-card);
}
.pagination a:hover { background: #eef1f4; }
.pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; }
.row-actions { display: flex; gap: 12px; }
.drag-handle { cursor: grab; color: var(--fg-muted); width: 24px; user-select: none; }
tr.dragging { opacity: 0.5; }
tr.cat-edit-row td { background: var(--bg); }
.visibility { float: right; font-weight: 400; font-size: 13px; color: var(--fg-muted); }
.locale-check { display: inline-block; margin-right: 16px; }

.section-hint {
  color: var(--fg-muted); font-size: 13px; line-height: 1.5;
  margin: 4px 0 12px; padding-left: 10px; border-left: 3px solid var(--border);
}
.diff-table .diff-add { color: var(--add); }
.diff-table .diff-del { color: var(--del); }
.diff-table .diff-mod { color: var(--mod); }

/* назва займає всю ширину → колонка Delete не стрибає при фільтрі */
.orphan-table td:first-child { width: 100%; }
.orphan-table td:last-child { white-space: nowrap; text-align: right; }

.browse-panel {
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px;
  margin-top: 8px; max-height: 220px; overflow-y: auto; background: var(--bg);
}
.browse-panel a { display: block; color: var(--fg); text-decoration: none; padding: 2px 0; }
.browse-panel a:hover { color: var(--accent); }
.browse-path { color: var(--fg-muted); border-bottom: 1px solid var(--border); margin-bottom: 4px; }

/* ---------- image gallery ---------- */
.image-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  min-height: 84px;
}
.image-strip .thumb {
  position: relative;
  flex: 0 0 auto;
  margin: 0;
  cursor: grab;
}
.image-strip .thumb img {
  height: 72px;
  width: auto;
  display: block;
  border: 1px solid var(--border, #d0d7de);
  border-radius: 4px;
  background: #f6f8fa;
  object-fit: cover;
}
.image-strip .thumb img.broken {
  width: 72px;
  object-fit: contain;
  filter: grayscale(1);
  opacity: 0.6;
}
.image-strip .thumb.dragging { opacity: 0.5; }
.image-strip .thumb-del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  line-height: 18px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border, #d0d7de);
  background: #fff;
  color: #cf222e;
  font-size: 14px;
  cursor: pointer;
}
.image-strip .thumb-cover {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 3px;
  pointer-events: none;
}
.image-strip .strip-empty { color: var(--fg-muted, #6e7781); font-size: 13px; }

.field { margin: 6px 0; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox[hidden] { display: none; }
.lightbox .lb-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
}
.lightbox button {
  position: absolute;
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 40px;
  cursor: pointer;
  user-select: none;
}
.lightbox .lb-close { top: 12px; right: 20px; font-size: 32px; }
.lightbox .lb-prev { left: 16px; }
.lightbox .lb-next { right: 16px; }

/* ---------- mod editor tabs ---------- */
.mod-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
#save-status { font-size: 13px; min-height: 1em; color: var(--fg-muted); }
.save-status.ok { color: var(--success); }
.save-status.err { color: var(--danger); }
.mod-tabs {
  display: flex; flex-wrap: wrap; gap: 4px; margin: 16px 0 0;
  border-bottom: 1px solid var(--border);
}
.mod-tabs a {
  padding: 6px 14px; border: 1px solid transparent; border-bottom: none;
  border-radius: 6px 6px 0 0; color: var(--fg); text-decoration: none;
  font-weight: 500; font-size: 14px; margin-bottom: -1px;
}
.mod-tabs a:hover { background: #eef1f4; }
.mod-tabs a.active {
  background: var(--bg-card); border-color: var(--border);
  border-bottom-color: var(--bg-card);
}
.tab-panel[hidden] { display: none; }
.tab-panel.gh-box { margin-top: 0; border-top-left-radius: 0; }
.props-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 24px;
}
.props-row .field {
  margin: 0; padding-right: 24px; border-right: 1px solid var(--border);
}
.props-row .field:last-child { padding-right: 0; border-right: none; }
.props-row label { display: inline-flex; align-items: center; gap: 6px; }
.props-row.avail-row { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); gap: 16px; }
.avail-row .avail-label { font-weight: 600; }
.avail-row .locale-check { margin: 0; text-transform: uppercase; }
@keyframes flash-ok-anim { from { background: #dafbe1; } to { background: transparent; } }
@keyframes flash-err-anim { from { background: #ffebe9; } to { background: transparent; } }
.flash-ok { animation: flash-ok-anim 1s ease-out; }
.flash-err { animation: flash-err-anim 1s ease-out; }

/* ---------- translations tab ---------- */
.tr-section + .tr-section {
  margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--border);
}
.tr-fields { display: flex; flex-direction: column; gap: 10px; }
.tr-field { display: flex; align-items: flex-start; gap: 10px; margin: 0; }
.tr-field .tr-locale { flex: 0 0 72px; padding-top: 6px; }
.tr-field .wide { margin: 0; }
.tr-ai { margin-top: 20px; }

.ai-dialog {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 20px; max-width: 420px; color: var(--fg);
}
.ai-dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.ai-dialog .dialog-x {
  float: right; background: none; border: none; padding: 0;
  font-size: 20px; line-height: 1; cursor: pointer; color: var(--fg-muted);
}
.ai-dialog-actions { margin-top: 16px; display: flex; align-items: center; gap: 12px; }

/* htmx loads JS only (no bundled CSS), so define the indicator convention here */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline; }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-box {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
  padding: 32px; width: 320px; display: flex; flex-direction: column; gap: 12px; text-align: center;
}

/* ---------- mods grid ---------- */
.mod-grid { display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.mod-card { display: block; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; text-decoration: none; color: var(--fg); }
.mod-card:hover { box-shadow: 0 2px 8px rgba(31, 35, 40, .12); }
.mod-card.dragging { opacity: .5; }
.mod-card-cover { position: relative; aspect-ratio: 16 / 10; background: var(--bg); }
.mod-card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mod-slider { position: absolute; inset: 0; overflow: hidden; }
.mod-slides { display: flex; height: 100%; transition: transform .25s ease; }
.mod-slides img { flex: 0 0 100%; width: 100%; height: 100%;
  object-fit: cover; display: block; }
.mod-slide-nav { position: absolute; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border: none; border-radius: 50%;
  background: rgba(0, 0, 0, .45); color: #fff; cursor: pointer; font-size: 16px;
  line-height: 1; display: none; align-items: center; justify-content: center; }
.mod-slide-nav.prev { left: 8px; }
.mod-slide-nav.next { right: 8px; }
.mod-card-cover:hover .mod-slide-nav { display: flex; }
.mod-slide-nav:hover { background: rgba(0, 0, 0, .7); }
.mod-dots { position: absolute; left: 0; right: 0; bottom: 8px; display: flex;
  gap: 5px; justify-content: center; }
.mod-dot { width: 7px; height: 7px; padding: 0; border: none; border-radius: 50%;
  background: rgba(255, 255, 255, .55); cursor: pointer; }
.mod-dot.on { background: #fff; }
.mod-card-noimg { width: 100%; height: 100%; display: flex; align-items: center;
  justify-content: center; font-size: 34px; opacity: .35; }
.mod-card-del { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px;
  border: none; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff;
  cursor: pointer; font-size: 14px; line-height: 1; display: flex;
  align-items: center; justify-content: center; }
.mod-card-del:hover { background: var(--danger); }
.mod-card-body { padding: 10px 12px; }
.mod-card-name { font-weight: 600; margin: 0 0 2px; }
.mod-card-cat { color: var(--fg-muted); font-size: 12px; margin: 0 0 8px; }
.mod-card-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  font-size: 12px; }
.mc-rating { color: var(--mod); font-weight: 600; }
.mc-prem { background: #ddf4ff; color: var(--accent); font-weight: 600;
  padding: 1px 7px; border-radius: 20px; }

.image-dropzone {
  border: 2px dashed var(--border, #d0d7de);
  border-radius: 8px;
  padding: 12px;
  transition: border-color .15s, background .15s;
}
.image-dropzone.dragover {
  border-color: #0969da;
  background: #ddf4ff;
}
.dropzone-hint {
  margin: 8px 0 0;
  font-size: 13px;
  color: #57606a;
  text-align: center;
}
.dropzone-hint .link-label {
  color: #0969da;
  cursor: pointer;
  text-decoration: underline;
}

.adv-paths {
  margin-top: 6px;
}
.adv-paths > summary {
  cursor: pointer;
  font-size: 13px;
  color: #57606a;
  user-select: none;
}
.adv-paths[open] > summary {
  margin-bottom: 6px;
}
.file-dropzone {
  border: 2px dashed var(--border, #d0d7de);
  border-radius: 8px;
  padding: 12px;
  transition: border-color .15s, background .15s;
}
.file-dropzone.dragover {
  border-color: #0969da;
  background: #ddf4ff;
}
.file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.file-list .strip-empty {
  color: var(--fg-muted, #6e7781);
  font-size: 13px;
}
.file-chip {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 8px 10px;
  background: #f6f8fa;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  transition: background .12s;
}
.file-chip:hover {
  background: #eef1f4;
}
.file-chip-ext {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: #fff;
  background: #6e7781;
  border-radius: 4px;
  padding: 2px 6px;
}
.file-chip-name {
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
  color: #0969da;
  text-decoration: none;
}
.file-chip-name:hover {
  text-decoration: underline;
}
.file-chip-del {
  flex: none;
  width: 22px;
  height: 22px;
  padding: 0;
  line-height: 20px;
  border: 1px solid var(--border, #d0d7de);
  border-radius: 50%;
  background: #fff;
  color: #cf222e;
  font-size: 14px;
  cursor: pointer;
}
.file-chip-del:hover {
  background: #ffebe9;
  border-color: #cf222e;
}
