* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1f2328; background: #f6f8fa;
}
body.has-layer { overflow: hidden; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.err { color: #cf222e; }

.btn {
  display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 12px;
  border: 1px solid #d0d7de; border-radius: 6px; background: #fff; color: #1f2328;
  font: inherit; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #f3f4f6; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: #1f883d; border-color: #1a7f37; color: #fff; }
.btn.primary:hover { background: #1a7f37; }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: #24292f; color: #fff;
}
.brand { font-weight: 600; font-size: 16px; white-space: nowrap; }
.search { flex: 1; }
.search input {
  width: 100%; height: 34px; padding: 0 12px; border-radius: 6px; border: 1px solid #57606a;
  background: #32383f; color: #fff; font: inherit; outline: none;
}
.search input:focus { background: #fff; color: #1f2328; border-color: #0969da; }
.statusbar { padding: 6px 20px; font-size: 12px; color: #57606a; background: #fff; border-bottom: 1px solid #d0d7de; }

.content { max-width: 1100px; margin: 20px auto; padding: 0 20px; }
.empty { padding: 40px; text-align: center; color: #57606a; background: #fff; border: 1px dashed #d0d7de; border-radius: 8px; }

.tree { background: #fff; border: 1px solid #d0d7de; border-radius: 8px; padding: 8px 12px; }
.tree:empty { display: none; }
.tree ul { list-style: none; margin: 0; padding-left: 18px; }
.tree > ul { padding-left: 0; }
.tree summary { cursor: pointer; padding: 3px 4px; border-radius: 4px; user-select: none; }
.tree summary:hover { background: #f6f8fa; }
.tree a.file { display: flex; align-items: baseline; gap: 10px; padding: 3px 6px; border-radius: 4px; color: #0969da; text-decoration: none; }
.tree a.file:hover { background: #ddf4ff; }
.ftitle { color: #57606a; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-block; padding: 0 6px; border-radius: 10px; background: #fff8c5; border: 1px solid #d4a72c; color: #7d4e00; font-size: 11px; }

.results { display: flex; flex-direction: column; gap: 8px; }
.rcount { color: #57606a; font-size: 12px; }
.result { display: block; padding: 10px 14px; background: #fff; border: 1px solid #d0d7de; border-radius: 8px; color: inherit; text-decoration: none; }
.result:hover { border-color: #0969da; box-shadow: 0 1px 4px rgba(9,105,218,.15); }
.rhead { display: flex; gap: 8px; align-items: center; }
.rhead .fname { font-weight: 600; color: #0969da; }
.rpath { font-size: 12px; color: #57606a; font-family: ui-monospace, monospace; }
.rsnip { margin-top: 4px; color: #424a53; font-size: 13px; }
.rsnip mark { background: #fff8c5; padding: 0 1px; border-radius: 2px; }

/* ---------- Layer ---------- */
.layer { position: fixed; inset: 0; z-index: calc(100 + var(--depth, 0)); }
.layer-backdrop { position: absolute; inset: 0; background: rgba(31, 35, 40, .45); animation: fade .15s; }
.layer-panel {
  position: absolute; display: flex; flex-direction: column; background: #fff; border-radius: 10px;
  box-shadow: 0 12px 48px rgba(0,0,0,.3); overflow: hidden; animation: pop .18s ease-out;
  inset: calc(2vh + var(--depth, 0) * 14px) calc(2vw + var(--depth, 0) * 14px);
}
.layer.editing .layer-panel { inset: 1.5vh 1.5vw; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.99); } }

.layer-header {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid #d0d7de; background: #f6f8fa;
}
.layer-title { flex: 1; min-width: 0; }
.layer-title .title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-title .path { font-size: 12px; color: #57606a; font-family: ui-monospace, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.commit-msg { height: 32px; width: 260px; padding: 0 10px; border: 1px solid #d0d7de; border-radius: 6px; font: inherit; }

.seg { display: inline-flex; border: 1px solid #d0d7de; border-radius: 6px; overflow: hidden; }
.seg button { height: 30px; padding: 0 10px; border: 0; background: #fff; font: inherit; cursor: pointer; }
.seg button + button { border-left: 1px solid #d0d7de; }
.seg button.active { background: #0969da; color: #fff; }
.seg.disabled { opacity: .5; pointer-events: none; }

.layer-body { flex: 1; min-height: 0; display: flex; }
.layer-body .view { flex: 1; overflow: auto; }
.layer-body .markdown-body { max-width: none; margin: 0 auto; padding: 32px clamp(24px, 4vw, 72px) 64px; }
.layer.narrow .layer-body .markdown-body { max-width: 980px; }
.layer-body .editor { flex: 1; min-width: 0; }
.markdown-body pre.mermaid { background: transparent; text-align: center; }
.markdown-body .header-anchor { color: inherit; text-decoration: none; }

/* ---------- Toast ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; max-width: 480px; }
.toast { padding: 10px 14px; border-radius: 6px; background: #24292f; color: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.2); animation: pop .2s; }
.toast.success { background: #1a7f37; }
.toast.error { background: #cf222e; }
.toast a { color: #fff; font-weight: 600; }
.toast code { background: rgba(255,255,255,.15); padding: 1px 4px; border-radius: 3px; }

/* ---------- Új fájl ---------- */
#new-file { background: transparent; color: #fff; border-color: #57606a; }
#new-file:hover { background: #32383f; }
.badge.new { background: #dafbe1; border-color: #4ac26b; color: #116329; }
.new-path {
  display: flex; align-items: center; flex: 1; max-width: 520px; height: 32px;
  border: 1px solid #0969da; border-radius: 6px; background: #fff; overflow: hidden;
}
.new-path-prefix { padding: 0 2px 0 10px; color: #57606a; font-family: ui-monospace, monospace; font-size: 12px; white-space: nowrap; }
.new-path-input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; padding: 0 10px 0 0; font: 13px ui-monospace, monospace; }

/* ---------- Toolbar / szűrő ---------- */
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.btn.toggle .count { min-width: 20px; padding: 0 6px; border-radius: 10px; background: #eaeef2; font-size: 12px; text-align: center; }
.btn.toggle.active { background: #ddf4ff; border-color: #0969da; color: #0969da; }
.btn.toggle.active .count { background: #0969da; color: #fff; }
.btn.sm { height: 26px; padding: 0 10px; font-size: 12px; }
.crow, .result { cursor: pointer; }
.crow { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: #fff; border: 1px solid #d0d7de; border-radius: 8px; }
.crow:hover { border-color: #0969da; box-shadow: 0 1px 4px rgba(9,105,218,.15); }
.cmain { flex: 1; min-width: 0; }
.rtop { display: flex; align-items: center; gap: 12px; }
.branch { color: #8250df; }

/* ---------- Sync napló ---------- */
.sync-dialog { position: fixed; inset: 0; z-index: 900; display: flex; align-items: center; justify-content: center; }
.sync-backdrop { position: absolute; inset: 0; background: rgba(31,35,40,.45); animation: fade .15s; }
.sync-box {
  position: relative; width: min(860px, 94vw); max-height: 80vh; display: flex; flex-direction: column;
  background: #fff; border-radius: 10px; box-shadow: 0 12px 48px rgba(0,0,0,.3); overflow: hidden; animation: pop .18s ease-out;
}
.sync-box header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #f6f8fa; border-bottom: 1px solid #d0d7de; }
.sync-box header b { flex: 1; }
.sync-state { font-size: 12px; padding: 1px 8px; border-radius: 10px; }
.sync-state.running { background: #ddf4ff; color: #0969da; }
.sync-state.ok { background: #dafbe1; color: #116329; }
.sync-state.error { background: #ffebe9; color: #cf222e; }
.progress { height: 6px; background: #eaeef2; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: #1f883d; transition: width .3s; }
.progress.error .bar { background: #cf222e; }
.progress.indeterminate .bar { width: 30% !important; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.sync-current { min-height: 20px; padding: 6px 14px; font: 12px ui-monospace, monospace; color: #57606a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync-log {
  flex: 1; margin: 0; padding: 12px 14px; min-height: 220px; overflow: auto;
  background: #0d1117; color: #c9d1d9; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap;
}
#sync.running { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .7; } }
