:root {
  --mar8: 8px;
  --h1: 55px;
  --w1: 0px;
  --w2: 180px;

  --bg-dark: #1e1e1e;
  --bg-panel: #2a2a2a;
  --bg-accent: #333;
  --text-light: #eee;
  --text-muted: #aaa;
  --highlight: #cce;
  --border-radius: 6px;
  
  --code-bg-light: #f4f4f4;
  --code-bg-dark: #2a2a2a;
  --code-fg-light: #222;
  --code-fg-dark: #f0f0f0;
  --inline-code-fg: #ff6f6f;
}
 
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100;
  font-family: sans-serif;
  background: var(--bg-dark);
  color: var(--text-light);
}

#wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ──────────────── Top Section ──────────────── */
.top {
  background: var(--bg-panel);
  padding: 12px 16px;
  border-bottom: 1px solid #444;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.repo-header {
  margin-bottom: 6px;
}

.repo-header h1 {
  margin: 0;
  font-size: 1.4em;
  font-weight: bold;
  color: var(--text-light);
}

.repo-header p {
  margin: 2px 0 0;
  font-size: 0.95em;
  color: var(--text-muted);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5em;
  padding: 0.8em 1.2em;
  min-height: 48px;
  background-color: #1e1e1e; /* or inherit from .top */
  border-bottom: 1px solid #333;
}

/* ──────────────── Breadcrumbs ──────────────── */

.topbar .breadcrumbs {
  flex: 1;
  font-size: 1rem;
  white-space: nowrap;
}

.topbar .branch-selector select {
  padding: 0.3em 0.6em;
  font-size: 0.95rem;
}

.breadcrumbs .current-path {
  margin-left: 0.5em;
  font-weight: bold;
  color: #eee;
}

/* ──────────────── Repo Settings Button ──────────────── */
.topbar
.repo-settings-btn {
  display: inline-block;
  padding: 0.4em 0.8em;
  background-color: #444;
  color: #fff;
  border: none;
  border-radius: 4px;
  text-decoration: none;
  font-size: 1em;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.repo-settings-btn:hover {
  background-color: #666;
}


/* ──────────────── Branch Selector ──────────────── */
.branch-selector select {
  padding: 4px 8px;
  font-size: 0.9em;
  background: var(--bg-accent);
  color: var(--text-light);
  border: 1px solid #555;
  border-radius: var(--border-radius);
}

/* ──────────────── Clone URL ──────────────── */
.topbar .clone-url {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-size: 0.95em;
}

.topbar .clone-url input {
  width: 444px;
  border: none;
  background: #222;
  color: #ccc;
  padding: 4px 8px;
  font-family: monospace;
  border-radius: var(--border-radius);
}

.topbar .clone-url input.copied {
  outline: 2px solid limegreen;
}

.topbar .clone-url button {
  background: #444;
  color: white;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: var(--border-radius);
}

.topbar .clone-url button:hover {
  background: #666;
}

/* ──────────────── Layout ──────────────── */
.hrest {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.lefta {
  width: var(--w1);
  background: #222;
  overflow: auto;
  transition: all 0.3s ease;
  border-right: 1px solid #444;
}

.leftb {
  position: relative;
  width: var(--w2);
  min-width: 100px;
  max-width: 600px;
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  border-right: 1px solid #444;
}

.leftb-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
  background: rgba(255,255,255,0.1);
  z-index: 10;
}

/* ──────────────── File List ──────────────── */
.leftb ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.leftb li {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leftb a {
  display: block;
  padding: 4px 8px;
  text-decoration: none;
  color: var(--text-light);
  border-radius: var(--border-radius);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leftb a:hover {
  background: var(--bg-accent);
}

/* ──────────────── Toggle Icons ──────────────── */
.toggle-container {
  position: absolute;
  bottom: 2px;
  left: 2px;
  display: flex;
}

.toggle-icon {
  font-size: 16px;
  color: white;
  cursor: pointer;
  user-select: none;
}

.toggle-icon.inside-leftb {
  position: absolute;
  top: 0;
  right: 16px;
  background: none;
  border: none;
  font-size: 16px;
  color: white;
  cursor: pointer;
  user-select: none;
}

.toggle-icon.inside-leftb::before {
  content: "➖";
}

#toggle-leftb:checked ~ #wrapper .leftb .toggle-icon.inside-leftb::before {
  content: "➕";
}

/* ──────────────── Main Content ──────────────── */
.vrest1 {
  position: relative;
  flex: 1;
  background-color: var(--bg-dark);
  overflow: auto;
  padding: 0;
  border-radius: var(--border-radius);
}

/* ──────────────── Toggle Logic ──────────────── */
#toggle-lefta:checked ~ #wrapper .lefta {
  display: none;
}

#toggle-leftb:checked ~ #wrapper .leftb {
  max-width: 20px;
  width: 20px;
  overflow: hidden;
}

/* ──────────────── Responsive ──────────────── */
@media (max-width: 368px) {
  .hrest {
    flex-direction: column;
  }

  .lefta,
  .leftb,
  .vrest1 {
    width: 100%;
    height: auto;
    max-height: 40vh;
  }

  .vrest1 {
    flex: none;
    max-height: none;
  }
}

/* ──────────────── View Toggle ──────────────── */
.view-toggle-local {
  position: absolute;
  top: 0;
  right: 12px;
  display: flex;
  justify-content: flex-end;
  z-index: 10;
}

.view-toggle-local a {
  background: #333;
  color: white;
  padding: 6px 10px;
  border-radius: var(--border-radius);
  font-size: 0.95em;
  text-decoration: none;
  box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

.view-toggle-local a:hover {
  background: #555;
}

/* ──────────────── Markdown Content ──────────────── */
#content.markdown {
  font-family: system-ui, sans-serif;
  line-height: 1.5;
  color: #e0e0e0;
  background: transparent;
  padding: 16px;
  margin-right: 16px;
  border-radius: var(--border-radius);
  max-width: 1200px;
}

/* Lists */
#content.markdown ul, #content.markdown ol {
  margin-left: 1.5em;
  margin-top: 0;
  margin-bottom: 0;
  padding-left: 0;
}

#content.markdown li {
  margin-bottom: 0.3em;
}

/* Inline code */
#content.markdown code {
  background: var(--code-bg-dark);
  color: var(--inline-code-fg);
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 0.9em;
  padding: 0 4px;
  border-radius: 4px;
}

/* Pre blocks inside Markdown */
#content.markdown pre {
  background: var(--code-bg-dark);
  color: var(--code-fg-dark);
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 0.9em;
  padding: 12px;
  overflow-x: auto;
  box-shadow: inset 0 0 0 1px #444;
  margin: 1em 0;
  border-radius: var(--border-radius);
}

/* Links */
#content.markdown a {
  color: #66ccff;
  text-decoration: underline;
}

#content.markdown a:hover {
  color: #99ddff;
  text-decoration: none;
}

#content.markdown a:visited {
  color: #cc99ff;
}

/* ──────────────── Raw Code View ──────────────── */
.code-wrapper {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  background-color: var(--bg-dark);
  color: var(--code-fg-dark);
  font-family: 'Fira Code', monospace;
  font-size: 1em;
  line-height: 1.1em;
  border-radius: var(--border-radius);
  overflow: auto;
  margin: 0;
  white-space: pre;
  height: calc(100vh - var(--h1) - var(--mar8));
}

.code-content {
  padding: 0 0.5em;
  margin: 0;
}

/* Line numbers */
.line-numbers {
  font-size: 0.9em;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  text-align: right;
  color: #888;
  user-select: none;
  border-right: 1px solid #444;
  overflow: unset;
  position: sticky;
  left: 0;
  z-index: 1;
  background-color: var(--code-bg-dark);
}

/* ──────────────── Featured ──────────────── */

.featured-user {
  margin: 2em 0;
  padding: 1em;
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 6px;
}

.featured-user h3 a {
  color: #66ccff;
  text-decoration: none;
}

.featured-user h3 a:hover {
  text-decoration: underline;
}

/* ──────────────── Login Styling ──────────────── */
.account-controls {
  display: flex;
  align-items: center;
  gap: 0.8em;
}

.account-controls a,
.account-controls button {
  font-size: 1.2em;
  background: none;
  border: none;
  cursor: pointer;
  color: #ccc;
}


.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #1e1e1e;
  padding: 2em;
  border-radius: 6px;
  width: 300px;
  color: #fff;
}

.modal-content label {
  display: block;
  margin-top: 1em;
}

.modal-content input {
  width: 100%;
  padding: 0.5em;
  margin-top: 0.3em;
  background: #2a2a2a;
  border: 1px solid #444;
  color: #fff;
}

.modal-content button {
  margin-top: 1.5em;
  width: 100%;
  padding: 0.6em;
  background: #66ccff;
  border: none;
  color: #000;
  font-weight: bold;
  cursor: pointer;
}

/* ──────────────── Notifications ──────────────── */
.error-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.overlay-error {
  background: #330000;
  color: #ffcccc;
  padding: 0.6em 1em;
  margin: 0.5em;
  border-radius: 6px;
  font-size: 0.95em;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  opacity: 1;
  transition: opacity 1s ease-out;
  animation: fadeOutAndCollapse 10s forwards;
}

@keyframes fadeOutAndCollapse {
  0%   { opacity: 1; max-height: 100px; }
  90%  { opacity: 1; }
  100% {
    opacity: 0;
    max-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }
}

/* ──────────────── Repo Form ──────────────── */
.repo-settings-form {
  display: flex;
  flex-direction: column;
  gap: 0.8em;
  max-width: 600px;
}

.repo-settings-form label {
  font-weight: bold;
  margin-bottom: 0.2em;
}

.repo-settings-form input,
.repo-settings-form select {
  padding: 0.4em;
  font-size: 1em;
}
