:root {
  --bg: #000000;
  --fg: #ffffff;
  --muted: rgba(255, 255, 255, 0.5);
  --line: rgba(255, 255, 255, 0.16);
  --line-strong: rgba(255, 255, 255, 0.82);
  --hover: rgba(255, 255, 255, 0.055);
  --button-bg: #ffffff;
  --button-fg: #000000;
  --danger: #ff8c8c;
  --font-sans: "Segoe UI Variable Display", "Segoe UI", "Helvetica Neue", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --font-mono: "Cascadia Mono", "SFMono-Regular", "Roboto Mono", "Consolas", monospace;
}

[data-theme="light"] {
  --bg: #ffffff;
  --fg: #000000;
  --muted: rgba(0, 0, 0, 0.5);
  --line: rgba(0, 0, 0, 0.16);
  --line-strong: rgba(0, 0, 0, 0.82);
  --hover: rgba(0, 0, 0, 0.04);
  --button-bg: #000000;
  --button-fg: #ffffff;
  --danger: #b42318;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  background: var(--bg);
  color-scheme: dark;
}

[data-theme="light"] {
  color-scheme: light;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button {
  font: inherit;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 3px;
}

::selection {
  background: var(--fg);
  color: var(--bg);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* -------------------------------------------------------------------------- */
/* Buttons                                                                    */
/* -------------------------------------------------------------------------- */

.icon-button {
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--line);
  background: var(--hover);
  color: var(--fg);
}

.icon-button svg {
  width: 16px;
  height: 16px;
}

.theme-icon--moon {
  display: none;
}

[data-theme="light"] .theme-icon--sun {
  display: none;
}

[data-theme="light"] .theme-icon--moon {
  display: block;
}

/* -------------------------------------------------------------------------- */
/* Projects                                                                   */
/* -------------------------------------------------------------------------- */

.projects-shell {
  width: min(1000px, calc(100% - 48px));
  min-height: 100vh;
  margin: 0 auto;
  animation: page-in 400ms ease both;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.projects-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 80px;
  border-bottom: 1px solid var(--line);
}

.projects-brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.projects-brand img {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.projects-actions {
  display: flex;
  gap: 5px;
  align-items: center;
}

.projects-main {
  padding: clamp(48px, 8vw, 100px) 0 80px;
}

.projects-hero h1 {
  margin: 0;
  font-size: clamp(58px, 9vw, 100px);
  font-weight: 400;
  letter-spacing: -0.07em;
  line-height: 0.92;
}

.projects-hero-row {
  display: flex;
  gap: 24px;
  align-items: flex-end;
  justify-content: space-between;
}

.projects-hero p {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.project-list {
  margin-top: clamp(48px, 7vw, 84px);
  border-top: 1px solid var(--line);
}

.project-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 22px;
  gap: 24px;
  align-items: center;
  padding: 22px 4px;
  border-bottom: 1px solid var(--line);
  transition:
    padding 180ms ease,
    background-color 180ms ease;
}

.project-row:hover,
.project-row:focus-visible {
  padding-right: 10px;
  padding-left: 10px;
  background: var(--hover);
}

.project-name {
  font-size: clamp(18px, 2.2vw, 23px);
  letter-spacing: -0.03em;
}

.project-meta {
  max-width: 360px;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.05em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-arrow {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 16px;
  text-align: right;
  transition: color 160ms ease;
}

.project-row:hover .project-arrow {
  color: var(--fg);
}

/* -------------------------------------------------------------------------- */
/* Project detail                                                             */
/* -------------------------------------------------------------------------- */

.project-detail {
  padding: clamp(44px, 7vw, 82px) 0 80px;
}

.project-detail h1 {
  margin: 0;
  font-size: clamp(44px, 6vw, 72px);
  font-weight: 400;
  letter-spacing: -0.06em;
  line-height: 0.98;
}

.project-summary {
  max-width: 640px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.project-summary p {
  margin: 0 0 0.9em;
}

.project-summary p:last-child {
  margin-bottom: 0;
}

.project-summary h3,
.project-summary h4,
.project-summary h5,
.project-summary h6 {
  margin: 1.1em 0 0.4em;
  color: var(--fg);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.3;
}

.project-summary h3 {
  font-size: 20px;
}

.project-summary h4,
.project-summary h5,
.project-summary h6 {
  font-size: 15px;
}

.project-summary ul,
.project-summary ol {
  margin: 0 0 0.9em;
  padding-left: 1.4em;
}

.project-summary a,
.project-version-notes a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.project-summary code,
.project-version-notes code {
  padding: 0.1em 0.3em;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.project-summary pre,
.project-version-notes pre {
  margin: 1em 0;
  padding: 10px 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--hover);
  line-height: 1.55;
}

.project-summary pre code,
.project-version-notes pre code {
  padding: 0;
  border: 0;
  font-size: 10px;
}

.project-summary .code-block,
.project-version-notes .code-block {
  margin: 1em 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--hover);
}

.project-summary .code-block-head,
.project-version-notes .code-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 4px 10px;
  border-bottom: 1px solid var(--line);
}

.project-summary .code-lang,
.project-version-notes .code-lang {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  text-transform: uppercase;
}

.project-summary .code-copy,
.project-version-notes .code-copy {
  display: none;
}

.project-summary .code-block pre,
.project-version-notes .code-block pre {
  margin: 0;
  padding: 10px 12px;
  border: 0;
  background: transparent;
}

.project-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 30px;
}

.project-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  color: var(--fg);
  font-size: 10px;
  line-height: 1;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    opacity 160ms ease;
}

.project-button:hover,
.project-button:focus-visible {
  border-color: var(--line-strong);
  background: var(--hover);
}

.project-button--solid {
  border-color: var(--fg);
  background: var(--fg);
  color: var(--bg);
}

.project-button--solid:hover,
.project-button--solid:focus-visible {
  border-color: var(--fg);
  opacity: 0.82;
}

.project-button--small {
  height: 30px;
  padding: 0 10px;
  font-size: 9px;
}

.project-button:disabled {
  cursor: wait;
  opacity: 0.45;
}

.project-button.is-danger {
  border-color: var(--danger);
  color: var(--danger);
}

.project-button.is-danger:hover,
.project-button.is-danger:focus-visible {
  border-color: var(--danger);
  background: var(--hover);
}

.project-versions {
  margin-top: clamp(42px, 6vw, 68px);
  border-top: 1px solid var(--line);
}

.project-section-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
}

.project-section-head h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.project-version-list {
  border-top: 1px solid var(--line);
}

.project-version {
  padding: 16px 2px;
  border-bottom: 1px solid var(--line);
}

.project-version-head {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

.project-version-mark {
  display: flex;
  gap: 9px;
  align-items: center;
  min-width: 0;
}

.project-version-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

.project-version-date {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
}

.project-version-download {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.project-version-download:hover,
.project-version-download:focus-visible {
  color: var(--fg);
}

.project-version-notes {
  max-width: 680px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.project-version-notes p {
  margin: 0 0 0.7em;
}

.project-version-notes p:last-child {
  margin-bottom: 0;
}

.project-version-notes ul,
.project-version-notes ol {
  margin: 0 0 0.7em;
  padding-left: 1.3em;
}

.project-version-notes h3,
.project-version-notes h4,
.project-version-notes h5,
.project-version-notes h6 {
  margin: 0.9em 0 0.35em;
  color: var(--fg);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.project-version-notes h3 {
  font-size: 15px;
}

.project-version-notes h4,
.project-version-notes h5,
.project-version-notes h6 {
  font-size: 13px;
}

.project-attachments {
  margin-top: clamp(44px, 7vw, 78px);
  border-top: 1px solid var(--line);
}

.project-attachments-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
}

.project-attachments-head h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.project-attachment-list {
  border-top: 1px solid var(--line);
}

.project-attachment {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}

.project-attachment a {
  overflow: hidden;
  padding: 12px 2px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-attachment a:hover,
.project-attachment a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.project-attachment-size {
  flex: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
}

.project-muted {
  margin: 0;
  padding: 18px 2px;
  color: var(--muted);
  font-size: 10px;
}

.project-status {
  min-height: 15px;
  margin: 8px 0 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1.4;
}

.project-status.is-error {
  color: var(--danger);
}

.project-login-dialog {
  width: min(92vw, 360px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--bg);
  color: var(--fg);
}

.project-form-dialog {
  width: min(94vw, 470px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--bg);
  color: var(--fg);
}

.project-login-dialog::backdrop,
.project-form-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

[data-theme="light"] .project-login-dialog::backdrop,
[data-theme="light"] .project-form-dialog::backdrop {
  background: rgba(255, 255, 255, 0.62);
}

.project-login-dialog form,
.project-form-dialog form {
  padding: 24px;
}

.project-form-dialog form {
  max-height: 88vh;
  overflow-y: auto;
}

.project-login-dialog h2,
.project-form-dialog h2 {
  margin: 0 0 18px;
  font-size: 30px;
  font-weight: 400;
  letter-spacing: -0.05em;
  line-height: 1.1;
}

.project-form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 13px;
}

.project-form-field span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
}

.project-form-field input,
.project-form-field textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: 0;
  background: transparent;
  color: var(--fg);
  font-size: 11px;
  line-height: 1.5;
  resize: vertical;
}

.project-form-field input[type="file"] {
  height: auto;
  padding: 6px 0;
  border: 0;
  font-size: 9px;
}

.project-form-field input[type="file"]::file-selector-button {
  height: 26px;
  margin-right: 8px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  cursor: pointer;
}

.project-form-field input {
  height: 38px;
}

.project-form-field textarea {
  min-height: 70px;
}

.project-form-field input:focus,
.project-form-field textarea:focus {
  border-color: var(--line-strong);
}

.project-form-field input::placeholder,
.project-form-field textarea::placeholder {
  color: var(--muted);
}

.project-login-field input {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: 0;
  background: transparent;
  color: var(--fg);
  font-size: 11px;
}

.project-login-field input:focus {
  border-color: var(--line-strong);
}

.project-dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* -------------------------------------------------------------------------- */
/* Markdown editor                                                            */
/* -------------------------------------------------------------------------- */

.md-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

.md-topbar {
  display: flex;
  flex: none;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 18px 0 22px;
  border-bottom: 1px solid var(--line);
}

.md-title {
  display: flex;
  gap: 9px;
  align-items: center;
  min-width: 0;
  font-size: 12px;
  white-space: nowrap;
}

.md-back {
  color: var(--muted);
  transition: color 160ms ease;
}

.md-back:hover,
.md-back:focus-visible {
  color: var(--fg);
}

.md-separator {
  color: var(--line-strong);
}

.md-actions {
  display: flex;
  gap: 5px;
  align-items: center;
}

.md-button {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.md-button:hover,
.md-button:focus-visible {
  border-color: var(--line-strong);
  background: var(--hover);
  color: var(--fg);
}

.md-button.is-done {
  color: var(--fg);
  border-color: var(--line-strong);
}

.md-workspace {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 0;
}

.md-input,
.md-preview {
  min-width: 0;
  min-height: 0;
}

.md-input {
  width: 100%;
  height: 100%;
  padding: 28px;
  border: 0;
  outline: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.75;
  resize: none;
  tab-size: 2;
}

.md-input::placeholder {
  color: var(--muted);
}

.md-preview {
  padding: 28px 34px 80px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.85;
  overflow-wrap: anywhere;
}

.md-preview > :first-child {
  margin-top: 0;
}

.md-preview h3,
.md-preview h4,
.md-preview h5,
.md-preview h6 {
  margin: 1.5em 0 0.55em;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.25;
}

.md-preview h3 {
  font-size: 28px;
}

.md-preview h4 {
  font-size: 22px;
}

.md-preview h5,
.md-preview h6 {
  font-size: 16px;
}

.md-preview p {
  margin: 0 0 1.1em;
}

.md-preview ul,
.md-preview ol {
  margin: 0 0 1.1em;
  padding-left: 1.5em;
}

.md-preview li {
  margin: 0.25em 0;
}

.md-preview li.is-task {
  list-style: none;
}

.md-preview li.is-task input {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--fg);
  vertical-align: -1px;
}

.md-preview blockquote {
  margin: 1.2em 0;
  padding-left: 1em;
  border-left: 1px solid var(--line-strong);
  color: var(--muted);
}

.md-preview hr {
  height: 1px;
  margin: 1.7em 0;
  border: 0;
  background: var(--line);
}

.md-preview a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.md-preview strong {
  font-weight: 600;
}

.md-preview code {
  padding: 0.12em 0.35em;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.md-preview .code-block {
  margin: 1.2em 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--hover);
}

.md-preview .code-block-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px 5px 12px;
  border-bottom: 1px solid var(--line);
}

.md-preview .code-lang {
  overflow: hidden;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  line-height: 1.2;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.md-preview .code-copy {
  flex: none;
  height: 22px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  line-height: 1;
}

.md-preview .code-copy:hover,
.md-preview .code-copy:focus-visible {
  border-color: var(--line-strong);
  color: var(--fg);
}

.md-preview pre {
  margin: 0;
  padding: 13px 14px;
  overflow-x: auto;
  border: 0;
  background: transparent;
  line-height: 1.6;
}

.md-preview pre code {
  padding: 0;
  border: 0;
  font-size: 11px;
}

.md-preview img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.2em 0;
  border-radius: 6px;
}

.md-preview del {
  color: var(--muted);
}

.md-preview:empty::before {
  color: var(--muted);
  content: "预览";
}

.tok-comment {
  color: var(--muted);
  font-style: italic;
}

.tok-string {
  color: var(--fg);
  opacity: 0.72;
}

.tok-number {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 2px;
}

.tok-keyword {
  color: var(--fg);
  font-weight: 600;
}

.tok-boolean {
  color: var(--fg);
  font-style: italic;
}

.tok-function {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.tok-tag {
  color: var(--fg);
  font-weight: 500;
}

.tok-attr {
  color: var(--muted);
}

/* -------------------------------------------------------------------------- */
/* Responsive                                                                 */
/* -------------------------------------------------------------------------- */

@media (max-width: 760px) {
  .projects-shell {
    width: calc(100% - 30px);
  }

  .projects-topbar {
    min-height: 68px;
  }

  .projects-main {
    padding-top: 44px;
  }

  .projects-hero h1 {
    font-size: clamp(56px, 18vw, 78px);
  }

  .projects-hero-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 20px;
  }

  .projects-hero-row .project-button {
    height: 34px;
  }

  .project-list {
    margin-top: 44px;
  }

  .project-row {
    grid-template-columns: minmax(0, 1fr) 20px;
    gap: 8px;
    padding: 18px 2px;
  }

  .project-meta {
    display: none;
  }

  .project-detail {
    padding-top: 40px;
  }

  .project-detail h1 {
    font-size: clamp(38px, 12vw, 54px);
  }

  .project-actions {
    margin-top: 24px;
  }

  .project-attachments {
    margin-top: 42px;
  }

  .md-page {
    height: auto;
    min-height: 100svh;
    overflow: auto;
  }

  .md-topbar {
    min-height: 52px;
    padding: 0 12px;
  }

  .md-actions {
    gap: 3px;
  }

  .md-button {
    height: 28px;
    padding: 0 8px;
  }

  .md-workspace {
    display: flex;
    flex-direction: column;
  }

  .md-input {
    min-height: 44vh;
    padding: 18px 15px;
    border-bottom: 1px solid var(--line);
  }

  .md-preview {
    min-height: 45vh;
    padding: 22px 16px 60px;
    border-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
