:root {
  --bg: #000000;
  --bg-raised: #0d0d0d;
  --panel-bg: rgba(255, 255, 255, 0.03);
  --border: rgba(255, 255, 255, 0.05);
  --text: #f0f0f0;
  --text-dim: #a3a3a3;
  --text-faint: #6b6b6b;
  --accent-bg: #ffffff;
  --accent-text: #111111;
  --green: rgb(7, 230, 74);
  --radius: 20px;
  --radius-sm: 12px;
  --maxw: 760px;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Bakes in the ~75% Safari page-zoom look as the default render scale for
   the main page content only — applied to #app, not html/body, and never
   to #overlay-root (login/project modals). A project's full-screen detail
   view uses position:fixed + 100vh; whether that stays truly full-screen
   inside a zoomed ancestor is inconsistent across browser engines, so
   modals are kept outside the zoomed subtree entirely rather than relying
   on that. Only ever set on one element in a subtree — zoom compounds
   multiplicatively on nested elements. */
#app { zoom: 0.75; }

:root[data-theme="light"] {
  --bg: #f5f5f3;
  --bg-raised: #ffffff;
  --panel-bg: #ffffff;
  --border: rgba(0, 0, 0, 0.09);
  --text: #111111;
  --text-dim: #55534f;
  --text-faint: #93918c;
  --accent-bg: #111111;
  --accent-text: #ffffff;
}

* { box-sizing: border-box; }

/* ---------- Motion ----------
   One shared, cheap transition (border/color/opacity/transform only —
   never layout properties like width/height) applied to every clickable
   control, plus a light press-down on :active for tactile feedback.
   Respects prefers-reduced-motion at the bottom of this file. */
.icon-btn, .btn, .social-circle, .jump-pill, .mini-btn, .add-btn,
.project-card, .gallery-media, .link-chip, .panel-badge, .file-chip,
.cover-img, .save-bar, .toast {
  transition: border-color .15s ease, color .15s ease, background-color .15s ease,
    opacity .15s ease, transform .15s ease, filter .15s ease;
}
.icon-btn:active, .btn:active, .social-circle:active, .jump-pill:active,
.mini-btn:active, .add-btn:active, .project-card:active {
  transform: scale(.96);
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  transition: background .2s ease, color .2s ease;
}

body {
  font-size: 15px;
  line-height: 1.55;
  padding-bottom: 120px;
}

img { max-width: 100%; display: block; }

a { color: inherit; text-decoration: none; }

/* Horizontal gutter + max-width centering, kept separate from any element's
   own vertical padding — a combined class like `hero wrap` using a
   `padding: Ypx 0` shorthand on `.hero` would otherwise zero out the
   horizontal padding set here (shorthand always sets all four sides). */
.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-left: clamp(20px, 6vw, 40px);
  padding-right: clamp(20px, 6vw, 40px);
}

.icon { flex: none; display: inline-block; vertical-align: middle; }

/* ---------- Nav ---------- */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 24px;
  padding-bottom: 24px;
  font-size: 13px;
  color: var(--text-dim);
}
.nav .nav-name { color: var(--text); font-weight: 600; letter-spacing: .02em; display: flex; align-items: center; gap: 6px; }
.nav-right { display: flex; align-items: center; gap: 10px; flex: none; }

.icon-btn {
  width: 36px; height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 15px;
  flex: none;
}
.icon-btn:hover { border-color: var(--text-dim); }

/* ---------- Hero ---------- */
.hero { padding-top: 8px; padding-bottom: 4px; }
.hero-photo {
  width: 100%; aspect-ratio: 958 / 236;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  background: transparent;
}
.hero-photo img { width: 100%; height: 100%; object-fit: cover; }
.hero-photo .initials {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 600; color: var(--text-faint);
  background: var(--bg-raised);
}

.name-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.hero h1 {
  font-size: 42px;
  letter-spacing: -0.02em;
  margin: 20px 0 8px;
  font-weight: 700;
  line-height: 1.1;
}
.name-size-controls {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-faint);
}
.name-size-value { min-width: 34px; text-align: center; }
.hero .tagline { color: var(--text-dim); font-size: 16.5px; margin: 14px 0 26px; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
}
.btn-primary { background: var(--accent-bg); color: var(--accent-text); border-color: transparent; }
.btn-ghost { background: var(--bg-raised); color: var(--text); }
.btn:hover { opacity: .85; }

.social-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.social-circle {
  width: 42px; height: 42px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
}
.social-circle:hover { border-color: var(--text-dim); }
.social-circle-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.social-circle-wrap .wrap-actions { display: flex; gap: 4px; }

.jump-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.jump-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
}
.jump-pill:hover { color: var(--text); border-color: var(--text-dim); }

/* ---------- Section ---------- */
.section { padding-top: 24px; padding-bottom: 24px; }
/* First block right after the hero sits almost flush under the jump row. */
.hero + div .section { padding-top: 6px; }

/* Big rounded outer panel each section lives in, with a pill badge label
   in place of the old plain uppercase heading. */
.panel {
  border: 1px solid var(--border);
  background: var(--panel-bg);
  border-radius: var(--radius);
  padding: 12px;
}
.panel-badge {
  display: inline-flex; align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12.5px; font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head .panel-badge { margin-bottom: 6px; }
.block-move { display: flex; gap: 6px; margin-bottom: 16px; }

/* Individual entry card nested inside a .panel */
.entry-card {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 18px;
}
.entry-card + .entry-card { margin-top: 12px; }
.entry-head { display: flex; align-items: flex-start; gap: 12px; }
.entry-logo {
  flex: none; width: 44px; height: 44px;
  border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  position: relative;
}
.entry-logo img { width: 100%; height: 100%; object-fit: cover; }
.entry-logo .mono {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600; color: var(--text-faint);
}
.entry-logo .photo-upload-btn { font-size: 0; }
.entry-main { flex: 1; min-width: 0; }
.entry-title { font-size: 16.5px; font-weight: 600; margin: 0; }
.entry-sub { font-size: 14.5px; color: var(--text-dim); margin: 2px 0 10px; }
.entry-desc { font-size: 13.5px; color: var(--text-dim); margin: 0 0 12px; white-space: pre-wrap; line-height: 1.6; }
.entry-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  font-size: 12.5px; color: var(--text-faint);
}
.entry-meta .meta-row { display: flex; align-items: center; gap: 6px; }
.entry-meta .meta-row[data-editable] { cursor: text; }

/* ---------- Projects ---------- */
.projects-list { display: flex; flex-direction: column; gap: 16px; }
.project-card {
  border: 1px solid var(--border);
  background: var(--bg-raised);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.project-card:hover { border-color: var(--text-dim); transform: translateY(-2px); }
.project-thumb {
  width: 100%; aspect-ratio: 3/1;
  background: #000; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.project-thumb img { width: 100%; height: 100%; object-fit: cover; }
/* Project covers are expected to be black-on-white/white-on-black line art —
   inverting them in light mode keeps them matching the page instead of
   staying dark-mode-styled against a light background. Transition lives
   in the shared Motion block above. */
:root[data-theme="light"] .cover-img { filter: grayscale(1) invert(1); }
.project-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; }
.project-title { font-weight: 600; font-size: 16px; }
.project-cat { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }
.arrow-btn {
  flex: none; width: 40px; height: 40px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
}

/* ---------- Footer ---------- */
.footer {
  padding-top: 40px; padding-bottom: 40px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-faint);
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; align-items: center;
}
/* ---------- Editing ---------- */
[data-editable="true"] { outline: 1px dashed transparent; border-radius: 4px; }
body.editing [data-editable="true"]:hover { outline-color: var(--green); }
body.editing [contenteditable="true"]:focus { outline: 1px solid var(--green); background: rgba(7,230,74,.06); }

.edit-row { display: flex; gap: 8px; align-items: center; }
.mini-btn {
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-dim);
  border-radius: 8px;
  width: 24px; height: 24px;
  display: none;
  align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 12px;
  flex: none;
}
body.editing .mini-btn { display: inline-flex; }
.mini-btn:disabled { opacity: .35; cursor: default; }
.mini-btn:hover { color: var(--text); border-color: var(--text-dim); }
.mini-btn.danger:hover { color: #ff6b6b; border-color: #ff6b6b; }

.add-row { display: none; }
body.editing .add-row { display: block; margin-top: 10px; }
.add-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px dashed var(--border);
  background: none;
  color: var(--text-faint);
  border-radius: var(--radius-sm);
  padding: 10px;
  width: 100%;
  cursor: pointer;
  font-size: 13px;
}
.add-btn:hover { color: var(--text); border-color: var(--text-dim); }

.photo-upload-btn {
  display: none;
  position: absolute; inset: 0;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,.45);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
  border: none;
}
body.editing .hero-photo .photo-upload-btn,
body.editing .project-thumb .photo-upload-btn,
body.editing .entry-logo .photo-upload-btn { display: flex; }

/* The project cover sits inside a clickable card (opens the project) — the
   upload trigger must stay a small corner badge, not a full-bleed overlay,
   or it swallows every click meant to open/navigate the project instead. */
.project-thumb .photo-upload-btn {
  inset: auto;
  right: 12px; bottom: 12px;
  width: 38px; height: 38px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.entry-remove { align-self: flex-start; }

/* ---------- Auth / modal ---------- */
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalPop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
  animation: fadeIn .15s ease;
}
.modal {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%; max-width: 340px;
  animation: modalPop .18s cubic-bezier(.2, .8, .2, 1) both;
}
.modal h2 { font-size: 16px; margin: 0 0 16px; }
.modal label { font-size: 12.5px; color: var(--text-dim); display: block; margin: 12px 0 6px; }
.modal input {
  width: 100%; padding: 10px 12px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 14px;
}
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }
.modal-error { color: #ff6b6b; font-size: 12.5px; margin-top: 10px; }
.modal-close { position: absolute; top: 16px; right: 16px; }

/* ---------- Save bar ---------- */
.save-bar {
  position: fixed; left: 50%; bottom: 24px;
  transform: translate(-50%, 12px);
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: 999px; padding: 10px 10px 10px 18px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
  z-index: 90; font-size: 13px;
  opacity: 0; pointer-events: none;
}
.save-bar.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.save-bar .btn { padding: 8px 16px; font-size: 13px; }

.edit-fab {
  position: fixed; right: 20px; bottom: 24px; z-index: 80;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
}

.toast {
  position: fixed; left: 50%; top: 20px;
  transform: translate(-50%, -6px);
  background: var(--bg-raised); border: 1px solid var(--border);
  padding: 10px 18px; border-radius: 999px; font-size: 13px; z-index: 200;
  opacity: 0; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Project detail (overlay styled like a dedicated page) ---------- */
.project-modal {
  max-width: 640px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  padding: 0 0 24px;
}
.project-modal .detail-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}
.project-modal .detail-title { font-size: 20px; font-weight: 700; margin: 0; flex: 1; }
.project-modal .detail-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.info-card, .desc-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 18px;
}
.info-row { display: flex; flex-direction: column; gap: 2px; }
.info-row + .info-row { margin-top: 14px; }
.info-row .info-label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.info-row .info-value { font-size: 14px; color: var(--text-dim); }
.desc-card .info-label { margin-bottom: 6px; }
.desc-card p { margin: 0; font-size: 14px; color: var(--text-dim); line-height: 1.6; white-space: pre-wrap; }
.gallery { display: flex; flex-direction: column; gap: 16px; }
.gallery-media { position: relative; cursor: pointer; }
.gallery img { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; }
.gallery-media:hover img { opacity: .9; }
.gallery-caption { margin: 6px 2px 0; font-size: 12.5px; color: var(--text-faint); }

/* Non-image gallery entries (HTML tools, PDFs, any file) get a project-cover-
   style horizontal preview box instead of a plain filename row. Height is an
   explicit inline px value (owner-resizable via .resize-handle) rather than
   an aspect-ratio, so it holds steady while being dragged. */
.gallery-media.file-media {
  width: 100%;
  background: #000;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.resize-handle {
  position: absolute; right: 8px; bottom: 8px;
  width: 26px; height: 26px;
  border-radius: 8px;
  background: rgba(0,0,0,.6);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: ns-resize;
  touch-action: none;
}
.file-preview-frame-wrap { position: absolute; inset: 0; overflow: hidden; }
.file-preview-frame {
  position: absolute; top: 0; left: 0;
  width: 400%; height: 400%;
  border: none; pointer-events: none;
  transform: scale(0.25);
  transform-origin: top left;
  background: #fff;
}
.file-preview-frame-flat {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: none; pointer-events: none;
  background: #fff;
}
.file-preview-fallback {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  color: var(--text-faint);
}
.file-preview-tag {
  position: absolute; bottom: 8px; right: 8px;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; color: #fff;
  background: rgba(0,0,0,.55);
  border-radius: 999px; padding: 3px 8px;
}
.gallery-filename {
  display: flex; align-items: center; gap: 6px;
  margin: 8px 2px 0;
  font-size: 12.5px; color: var(--text-dim);
}
.gallery-filename span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Fullscreen file/tool viewer ---------- */
.file-viewer-backdrop { padding: 0; z-index: 150; }
.file-viewer {
  width: 100%; height: 100%; max-width: none;
  border-radius: 0; padding: 0;
  display: flex; flex-direction: column;
  animation: fadeIn .15s ease;
}
.file-viewer-head {
  flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}
.file-viewer-title {
  flex: 1; font-size: 13.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-viewer-body {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); overflow: auto;
}
.file-viewer-body iframe { width: 100%; height: 100%; border: none; }
.file-viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.file-viewer-body video { max-width: 100%; max-height: 100%; }
.file-viewer-fallback {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  color: var(--text-dim); padding: 40px; text-align: center;
}
.link-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 14px; font-size: 13px; margin: 4px 6px 4px 0;
  background: var(--bg-raised);
}
.link-chip:hover { border-color: var(--text-dim); }

@media (max-width: 640px) {
  .btn-row { flex-direction: column; align-items: stretch; }
  .btn-row .btn { justify-content: center; }
  .entry-head { flex-wrap: wrap; }
  .modal-backdrop { padding: 0; }
  .project-modal { max-width: 100%; max-height: 100vh; height: 100vh; border-radius: 0; }
}

/* ---------- Desktop: two-column split ----------
   Below this breakpoint everything renders as the single stacked column
   sectionOrder describes, unchanged. At and above it, the hero plus every
   non-project section forms a left column and Projects becomes a second,
   parallel column — sized via inline grid-column/grid-row set in JS, which
   are otherwise inert since .split-grid isn't a grid until this query hits. */
@media (min-width: 960px) {
  :root { --maxw: 1180px; }
  .split-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
    column-gap: 40px;
    align-items: start;
    max-width: var(--maxw);
    margin: 0 auto;
    padding-left: clamp(20px, 6vw, 40px);
    padding-right: clamp(20px, 6vw, 40px);
  }
  /* .split-grid now owns the page gutter/max-width as a single grid, so
     the .wrap padding/centering each child normally carries on its own
     (for the single-column mobile/tablet layout) would double up here. */
  .split-grid .wrap {
    max-width: none;
    margin: 0;
    padding-left: 0;
    padding-right: 0;
  }
  .split-grid .hero-photo { margin-top: 4px; }
}

/* Respect the OS-level motion preference: collapse every transition/
   animation added above to near-instant instead of removing them outright,
   so layout-triggering state changes (save bar, modals) still resolve
   cleanly without a jarring hard cut. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
