:root {
  --bg: #1B1D1E;                 /* Deep graphite background */
  --card: #232526;               /* Slightly lighter graphite */
  --card-hover: #2B2D2E;         /* Hover lift background */
  --text: #95a8a5;                /* Soft teal-tinted off-white */
  --muted: #9AA4A3;               /* Cool muted gray */
  --line: #3C3E3F;                /* Subtle graphite border */
  --accent: #4CB5A8;              /* Muted teal accent */
  --accent-2: #3A9B90;            /* Darker muted teal */
  --overlay-1: rgba(76, 181, 168, 0.18); /* Teal glow 1 */
  --overlay-2: rgba(58, 155, 144, 0.14); /* Teal glow 2 */
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  --radius: 8px;                  /* Flatter corners */
  --page-footer-h: 0px;
  --dock-h: 0px;
}



/* ========== Layout ========== */
#projects-container {
  display: flex;
  height: 85vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  isolation: isolate;
}
#projects-container::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 10% -10%, var(--overlay-1), transparent 60%),
    radial-gradient(800px 480px at 90% -8%, var(--overlay-2), transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, #151718 100%);
}

/* ========== Sidebar (toolbar + sections) ========== */
#project-list {
  width: 33%;
  min-width: 280px;
  max-width: 520px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .02), transparent), var(--bg);
  min-height: 0;
}

/* Sticky search toolbar */
.sidebar-toolbar {
  position: sticky;
  z-index: 3;
  margin: -10px -10px 10px;
  padding: 10px;
  background: linear-gradient(180deg, rgba(24, 26, 27, .95), rgba(24, 26, 27, .85));
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.sidebar-search { display: flex; align-items: center; }
.sidebar-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .02);
  color: var(--text);
  outline: none;
  font: 500 14px/36px ui-sans-serif, system-ui;
}
.sidebar-search input::placeholder { color: var(--muted); }

/* Section header: [label] ..... [count][chev] */
.sidebar-cat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 2px 12px;
  margin: 10px 0 6px;
  font: 800 12px/1 ui-sans-serif, system-ui;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .12em;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, .02), transparent);
  cursor: pointer;
  user-select: none;
}

.sidebar-cat .left { display: flex; align-items: center; gap: 8px; overflow: hidden; }
.sidebar-cat .left span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-cat .right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.sidebar-count {
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 11px;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  min-width: 40px;
}
.sidebar-cat .chev {
  width: 16px;
  height: 16px;
  opacity: .7;
  transition: transform .18s ease;
}
.sidebar-section.collapsed .chev { transform: rotate(-90deg); }

.sidebar-section {
  margin-top: 20px;
}

/* Project list */
.sidebar-list { margin: 0; padding: 0; list-style: none; }

/* Project row (compact) */
.project-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 10px;
  margin: 4px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .02);
  cursor: pointer;
  transition: background .18s ease, box-shadow .18s ease, border-color .18s ease, transform .1s ease;
}
.project-item:hover {
  background: var(--card-hover);
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .25);
}
.project-item.active {
  background: var(--card);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 20%, transparent),
              0 8px 20px rgba(0,0,0,.28);
  transform: translateY(-1px);
}
.project-item::before { content: none; }

.project-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.project-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text);}
.project-meta { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text);}
.project-updated { font-size: 12px; color: var(--muted); white-space: nowrap; color: var(--text);}
.fav-pin { color: var(--accent-2); margin-right: 6px; }

/* Empty-state */
.sidebar-empty {
  margin: 10px 6px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font: 500 13px/1.4 ui-sans-serif, system-ui;
}

/* ========== Content pane ========== */
#project-content {
  position: relative;
  width: 67%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 22px 22px calc(24px + var(--dock-h) + var(--page-footer-h) + env(safe-area-inset-bottom,0px));
  min-height: 0;
}
#project-content .content-wrap { max-width: 980px; margin: 0 auto; }

.project-info,
.project-html {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.project-html iframe {
  width: 100%;
  min-height: 400px;
  border: none;
  border-radius: 10px;
  background: #1b1d1e;
}

/* ========== Files (pill chips) ========== */
.project-files ul {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.project-files li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 12px;
  font-size: 14px;
  box-shadow: var(--shadow);
  transition: background .18s ease, transform .15s ease, border-color .18s ease;
}
.project-files li:hover {
  background: var(--card-hover);
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 5%, transparent);
}
.project-files a { color: var(--text); text-decoration: none; font-weight: 500; }
.project-files a:hover { text-decoration: underline; }

/* ========== Link/Download cards ========== */
.card-grid { margin-top: 16px; }
.card-grid .card-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.link-card, .download-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: background .18s ease, transform .15s ease, border-color .18s ease, box-shadow .18s ease;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.link-card:hover, .download-card:hover {
  background: var(--card-hover);
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 5%, transparent);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .34);
}
.link-card::before, .download-card::before {
  content: "";
  display: inline-block;
  width: 32px; /* icon button size */
  height: 32px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  flex: 0 0 32px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 40%; /* arrow will now be smaller inside */
}

/* Link arrow (up-right) */
.link-card::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M3 13L13 3M6 3h7v7' stroke='%234CB5A8' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}


/* Download arrow (down) */
.download-card::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M8 1v13M1 8l7 6 7-6' stroke='%234CB5A8' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}

/* ========== Responsive ========== */
@media (max-width: 560px) {
  .card-grid .card-container { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  #projects-container { flex-direction: column; height: auto; overflow: visible; }
  #project-list, #project-content { width: 100%; }
  #project-list {
    max-height: 40vh;
    border-right: none;
    border-bottom: 2px solid var(--accent);
    direction: rtl;
    overflow-y: auto;
    min-height: 0;
  }
  #project-list > * { direction: ltr; }
  #project-content { overflow-y: visible; min-height: auto; }
}
