:root {
  color-scheme: dark;
  --background: #10161f;
  --panel: #151e29;
  --line: #293646;
  --text: #f0f4fa;
  --muted: #a6b4c5;
  --blue: #83b7ff;
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --mono: "Consolas", "SFMono-Regular", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(290px, 30%) minmax(0, 1fr);
  background: var(--background);
  color: var(--text);
  font: 16px / 1.75 var(--sans);
}
body:has(dialog[open]) { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }
h1, h2, h3, p, dl, dd, ul { margin: 0; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }
.skip {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 5;
  padding: 8px 12px;
  background: var(--panel);
  transform: translateY(-150%);
}
.skip:focus { transform: translateY(0); }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.hero {
  position: sticky;
  top: 0;
  height: 100svh;
  min-height: 520px;
  border-right: 1px solid #314156;
  background: linear-gradient(180deg, #0b1624 0%, #132a43 55%, #0a1422 100%);
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #08132366 0%, #0813234d 32%, #08132306 55%, #081323e6 100%), url("images/cover.jpg") center / cover;
}
.hero-inner {
  position: relative;
  min-height: 100%;
  width: min(100%, 560px);
  margin-inline: auto;
  padding: 44px clamp(28px, 4.1vw, 72px) 34px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font: 600 13px / 1.2 var(--sans);
  letter-spacing: .13em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid #8ebcff70;
  border-radius: 9px;
  background: #101c2a8c;
  color: var(--blue);
  font: 650 22px / 1 var(--sans);
  letter-spacing: -.07em;
}
.brand-sub { display: block; margin-top: 5px; color: #b9cbe1; font: 10px / 1 var(--mono); letter-spacing: .17em; }
.intro { margin-block: auto; padding-block: 48px 82px; }
.avatar {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border: 2px solid #aed0ffb3;
  border-radius: 50%;
  box-shadow: 0 0 0 5px #9ecaff22;
}
.greeting { margin-top: 22px; color: #d6e5f9; font-size: .92rem; letter-spacing: .11em; }
h1 {
  margin-left: -.055em;
  color: #f7faff;
  font-size: clamp(3.3rem, 5.15vw, 6.2rem);
  line-height: 1.08;
  letter-spacing: -.073em;
  font-weight: 720;
}
h1 span { color: var(--blue); }
.hero-note { color: #e0ebfa; margin-top: 14px; font-size: .95rem; }
.hero-button {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  margin-top: 28px;
  padding: 9px 15px 9px 17px;
  border: 1px solid #a1c8ff8c;
  border-radius: 7px;
  background: #0b1729ae;
  font-size: .87rem;
  font-weight: 600;
}
.hero-button span { color: var(--blue); }
.hero-button:hover { background: #223c59; }
.hero-contact { display: flex; align-items: center; gap: 9px; color: #c9d8eb; font-size: .82rem; }
.hero-contact span { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); }
.hero-contact b { font-weight: 400; color: var(--blue); }

.content {
  width: min(100%, 1140px);
  padding-inline: clamp(30px, 5vw, 82px);
  margin-inline: auto;
  min-width: 0;
}
.nav {
  display: flex;
  gap: clamp(16px, 2.6vw, 36px);
  align-items: center;
  min-height: 78px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .875rem;
}
.nav a {
  position: relative;
  display: grid;
  align-items: center;
  min-height: 78px;
  white-space: nowrap;
}
.nav a:hover, .nav a[aria-current] { color: var(--blue); }
.nav a[aria-current]::after {
  content: "";
  position: absolute;
  inset: auto 0 -1px;
  height: 2px;
  background: var(--blue);
}
.section { padding-block: 48px; border-bottom: 1px solid var(--line); scroll-margin-top: 20px; }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--blue);
  font: 600 .73rem / 1.4 var(--mono);
  letter-spacing: .16em;
  margin-bottom: 11px;
}
.eyebrow span { width: 19px; height: 1px; background: currentColor; }
h2 { font-size: clamp(1.9rem, 3vw, 2.65rem); font-weight: 680; line-height: 1.2; letter-spacing: -.045em; }
.about h2 { margin-bottom: 19px; }
.about p:not(.eyebrow, .lead) { max-width: 42em; color: var(--muted); line-height: 1.9; }
.about .lead { margin-bottom: 8px; max-width: 42em; color: #d9e3f1; line-height: 1.9; }
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px 24px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.section-heading p { color: var(--muted); font-size: .82rem; }

.project-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.project { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); min-width: 0; }
.project-image {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: 11px 11px 0 0;
  aspect-ratio: 16 / 9;
  background: #1d2d40;
}
.project-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.project-image:hover img, .project-image:focus-visible img { transform: scale(1.045); }
.zoom {
  position: absolute;
  display: grid;
  place-items: center;
  right: 12px;
  bottom: 12px;
  width: 36px;
  height: 36px;
  border: 1px solid #d2e3ff66;
  border-radius: 7px;
  background: #0c1829e6;
  color: #e1eeff;
  font-size: 1.1rem;
}
.project-image:hover .zoom { color: var(--blue); background: #0c1829; }
.project-info { padding: 15px 17px 18px; }
.category { color: var(--blue); font-size: .74rem; }
h3 { margin-block: 3px 4px; font-size: 1.13rem; line-height: 1.4; }
.project-description { font-size: .84rem; color: var(--muted); line-height: 1.65; }

.skills { display: grid; gap: 12px; margin-top: 24px; }
.skills > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 18px; }
.skills dt { min-width: 3.2em; font-weight: 650; }
.skills ul { padding: 0; display: flex; gap: 7px; flex-wrap: wrap; list-style: none; }
.skills li {
  padding: 3px 10px;
  border: 1px solid #314561;
  border-radius: 6px;
  color: #c9ddf8;
  background: #162233;
  font-size: .83rem;
}
.contacts { display: grid; gap: 8px; margin-top: 23px; }
.contact-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
a.contact-row:hover { border-color: var(--blue); }
.contact-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 7px;
  color: var(--blue);
  background: #1e2e44;
  font: 600 .85rem / 1 var(--mono);
}
.contact-row strong { display: block; font-size: .9rem; }
.contact-row div > span, .contact-row code { color: var(--muted); font-size: .79rem; overflow-wrap: anywhere; }
.contact-arrow { padding-inline: 6px; color: var(--blue); }
.copy {
  border: 1px solid #405670;
  border-radius: 5px;
  min-height: 36px;
  background: transparent;
  padding-inline: 9px;
  color: var(--blue);
  font-size: .8rem;
}
.copy:hover { background: #233850; }
.copy-status { margin-top: 8px; color: var(--blue); font-size: .83rem; }
.copy-status:empty { margin-top: 0; }
.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  padding-block: 23px 28px;
  font-size: .8rem;
}
.footer a:hover, .hero-contact:hover { color: var(--blue); }

.lightbox {
  width: min(900px, calc(100% - 24px));
  max-width: none;
  max-height: calc(100dvh - 24px);
  padding: 12px;
  background: #111a25;
  color: var(--text);
  border: 1px solid #415573;
  border-radius: 12px;
}
.lightbox::backdrop { background: #050911e8; }
.lightbox-header, .lightbox-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.lightbox-header { padding-bottom: 9px; }
.lightbox-header h2 { font-size: 1.05rem; }
.lightbox-image { width: 100%; aspect-ratio: 3 / 2; max-height: calc(100dvh - 155px); object-fit: contain; background: #090e16; border-radius: 5px; }
.lightbox-footer { padding-top: 9px; }
.image-count { color: var(--muted); font: .8rem / 1 var(--mono); }
.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #1c2939;
  font-size: 1.2rem;
  line-height: 1;
}
.icon-button:hover:not(:disabled) { background: #2c425d; }
.icon-button:disabled { opacity: .5; cursor: default; }

@media (max-width: 880px) {
  body { display: block; }
  .hero {
    position: relative;
    height: auto;
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid #314156;
  }
  .hero::before { background-position: center, center 55%; }
  .hero-inner { width: min(100%, 760px); padding: 25px clamp(22px, 6vw, 46px) 24px; }
  .intro { padding-block: 48px 40px; margin-block: 0; }
  h1 { font-size: clamp(3.5rem, 10vw, 5rem); }
  .hero-contact { display: none; }
  .content { width: min(100%, 760px); padding-inline: clamp(20px, 6vw, 46px); }
  .nav, .nav a { min-height: 58px; }
  .section { padding-block: 37px; scroll-margin-top: 12px; }
}
@media (max-width: 530px) {
  .nav { justify-content: space-between; gap: 9px; font-size: .8rem; }
  .project-grid { grid-template-columns: minmax(0, 1fr); gap: 17px; }
  .avatar { width: 72px; height: 72px; }
  .section-heading { gap: 7px 15px; }
}
@media (max-height: 620px) and (min-width: 881px) {
  .hero-inner { padding-block: 22px; }
  .intro { padding-block: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}


/* Portfolio filters and downloads */
[hidden] { display: none !important; }
.nav {
  position: sticky;
  z-index: 2;
  top: 0;
  background: var(--background);
}
.section { scroll-margin-top: 78px; }
.work-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 180px);
  gap: 12px;
  margin-bottom: 20px;
}
.work-filters label, .ledger-form label, .ledger-period {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: .82rem;
}
.work-filters input, .work-filters select, .tool-panel input:not([type="checkbox"]), .tool-panel select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101925;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}
.work-filters input::placeholder, .tool-panel input::placeholder { color: #8393a8; }
.project-download {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  gap: 8px;
  color: var(--blue);
  font-size: .82rem;
}
.project-download:hover { text-decoration: underline; text-underline-offset: 3px; }
.project-info .project-download { margin-top: 6px; }
.lightbox-details { display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 0 14px; }
.lightbox-download { padding-inline: 4px; }

/* Browser-local tools */
.tools-note { margin-top: 12px; color: var(--muted); font-size: .88rem; }
.tool-panel {
  margin-top: 20px;
  padding: clamp(15px, 2.2vw, 26px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.tool-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 15px; }
.tool-heading h3 { font-size: 1.25rem; }
.ledger-period { max-width: 190px; }
.ledger-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-block: 14px 18px;
}
.ledger-summary div { padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: #101925; }
.ledger-summary dt { color: var(--muted); font-size: .77rem; }
.ledger-summary dd { color: var(--blue); font-size: clamp(.88rem, 1.65vw, 1.15rem); font-variant-numeric: tabular-nums; font-weight: 650; overflow-wrap: anywhere; }
.ledger-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.ledger-note { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.tool-button {
  min-height: 36px;
  padding: 5px 11px;
  border: 1px solid #415773;
  border-radius: 6px;
  background: #1c2a3b;
  color: #d7e7ff;
  font-size: .82rem;
  white-space: nowrap;
}
.tool-button:hover:not(:disabled) { background: #263d57; }
.tool-button:disabled { opacity: .5; cursor: default; }
.primary-button { background: #9bc2ff; border-color: #9bc2ff; color: #101928; font-weight: 680; }
.primary-button:hover:not(:disabled) { background: #b2d1ff; }
.tool-status, .empty-message { color: var(--muted); font-size: .85rem; }
.tool-status:not(:empty) { margin-top: 8px; }
.tool-heading .tool-status { margin-top: 0; }
.empty-message { padding-block: 10px 2px; }
.gallery-empty { padding-block: 10px; }
.tool-list { padding: 0; list-style: none; }
.tool-list:not(:empty) { margin-top: 14px; }
.ledger-item, .todo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-block: 8px;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.ledger-item { flex-wrap: wrap; }
.ledger-item-text { min-width: 0; }
.ledger-item small { margin-left: 8px; color: var(--muted); }
.entry-note { color: var(--muted); font-size: .83rem; }
.ledger-item-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.entry-amount { margin-right: 5px; color: var(--blue); font-variant-numeric: tabular-nums; font-size: .91rem; }
.entry-amount[data-kind="expense"] { color: #f3b5a9; }
.remove-button { background: transparent; }
.todo-form { display: flex; gap: 8px; }
.todo-item label { display: flex; align-items: center; gap: 9px; min-width: 0; cursor: pointer; font-size: .9rem; }
.todo-item input { flex: none; width: 17px; height: 17px; margin: 0; accent-color: var(--blue); }
.todo-item input:checked + span { color: var(--muted); text-decoration: line-through; }
@media (max-width: 880px) {
  .section { scroll-margin-top: 58px; }
}
@media (max-width: 580px), (881px <= width <= 1080px) {
  .ledger-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 350px) {
  .nav { gap: 6px; font-size: .75rem; }
  .work-filters { grid-template-columns: minmax(0, 1fr) minmax(108px, .8fr); }
  .lightbox-details { gap: 0 6px; }
}
