:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --text: #111315;
  --muted: #6c727a;
  --rule: #e6e8eb;
  --accent: #235d0d;
  --accent-bg: #235d0d;
  --code-bg: #f4f5f7;
  --err: #b42318;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1012;
    --text: #e6e8eb;
    --muted: #848b94;
    --rule: #22262b;
    --accent: #529c36;
    --accent-bg: #235d0d;
    --code-bg: #171a1e;
    --err: #f08076;
  }
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  margin: 56px auto;
  padding: 0 20px 56px;
  max-width: 580px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 15.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Header & Navigation */
.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 20px;
  padding-bottom: 14px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--rule);
}

.site-title {
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.site-title:hover {
  color: var(--accent);
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--text);
  text-decoration: none;
}

.site-nav a.active {
  color: var(--accent);
  font-weight: 600;
}

/* Typography */
h1, h2, h3 {
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--text);
}

h1 {
  font-size: 21px;
  font-weight: 600;
  margin: 0 0 18px;
}

h2 {
  font-size: 17px;
  font-weight: 600;
  margin: 1.8em 0 0.5em;
}

h3 {
  font-size: 15.5px;
  font-weight: 600;
  margin: 1.4em 0 0.4em;
}

p, ul, ol {
  margin-top: 0;
  margin-bottom: 0.95em;
}

li {
  margin-bottom: 0.35em;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 24px 0;
}

blockquote {
  margin: 0.9em 0;
  padding: 4px 12px;
  border-left: 2px solid var(--rule);
  color: var(--muted);
}

/* Homepage Sections */
.home-intro {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  margin: 0 0 28px;
}

.home-section {
  margin-bottom: 28px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}

.section-head h2 {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0;
}

.section-head a {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
}

.section-head a:hover {
  color: var(--accent);
}

.compact-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.compact-list li {
  padding: 9px 0;
  margin: 0;
  border-bottom: 1px solid var(--rule);
}

.compact-title {
  font-weight: 500;
  color: var(--text);
}

.compact-title:hover {
  color: var(--accent);
}

.compact-meta {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

/* Post List */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list li {
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding: 9px 0;
  margin: 0;
  border-bottom: 1px solid var(--rule);
}

.post-date {
  flex-shrink: 0;
  width: 92px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  color: var(--muted);
}

.post-list a {
  font-weight: 500;
  color: var(--text);
}

.post-list a:hover {
  color: var(--accent);
}

/* Programs List */
.program-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
}

.program-item:first-of-type {
  padding-top: 4px;
}

.program-item h2 {
  font-size: 16.5px;
  margin: 0 0 6px;
}

.privacy-note {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 8px;
  margin-bottom: 0;
}

/* Article Pages */
.article-header {
  padding-bottom: 14px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--rule);
}

.article-header h1 {
  font-size: 22px;
  line-height: 1.25;
  margin: 0 0 6px;
}

.article-date {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  color: var(--muted);
}

article p {
  margin-top: 0;
  margin-bottom: 1em;
}

article b,
article strong {
  font-weight: 600;
}

article pre {
  margin: 1em 0;
  overflow-x: auto;
}

.article-footer {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
}

.article-footer a {
  color: var(--muted);
}

.article-footer a:hover {
  color: var(--accent);
}

/* Code & Keyboard */
code,
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.84em;
}

code {
  background-color: var(--code-bg);
  border-radius: 3px;
  padding: 1px 4px;
}

pre code {
  display: block;
  padding: 11px 13px;
  border-radius: 3px;
  overflow-x: auto;
  line-height: 1.5;
}

kbd {
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0 4px;
  display: inline-block;
}

/* Quick Notes (Microblog) */
.notes-header {
  padding-bottom: 14px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}

.notes-header h1 {
  margin: 0 0 4px;
}

.notes-subtitle {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.notes-feed {
  display: flex;
  flex-direction: column;
}

.notes-feed > .note {
  padding: 14px 0;
  margin: 0;
}

.note-item {
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}

.note-date {
  flex-shrink: 0;
  width: 92px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
}

.note-date:hover {
  color: var(--accent);
}

.note-body {
  min-width: 0;
  flex: 1;
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.note-tag {
  color: var(--muted);
}

.note-body p {
  margin: 0 0 0.65em;
}

.note-body p:last-child {
  margin-bottom: 0;
}

/* Comments & Thalassa CGI */
.comments-section {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}

.comments-section h2 {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 6px;
}

.note {
  font-size: 13px;
  color: var(--muted);
}

.comments-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin: 10px 0 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
}

.btn-inline {
  display: inline-block;
  color: var(--accent);
  font-weight: 500;
}

.btn-inline:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.comments-actions a:not(.btn-inline) {
  color: var(--muted);
  padding-left: 14px;
  border-left: 1px solid var(--rule);
}

.comments-actions a:not(.btn-inline):hover {
  color: var(--text);
}

.comments-list {
  display: flex;
  flex-direction: column;
}

.comment-card,
.comment {
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}

.comment-children {
  margin-left: 16px;
  padding-left: 12px;
  border-left: 1px solid var(--rule);
  margin-top: 6px;
}

.comment-meta,
.comment_head p {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 4px;
}

.comment-title {
  font-size: 14.5px;
  font-weight: 600;
  margin: 0 0 4px;
}

.comment-body p:last-child {
  margin-bottom: 0;
}

.comment-links {
  margin-top: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.cgi-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}

.cgi-brand {
  font-weight: 600;
  color: var(--text);
}

.cgi-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
}

.messagebox_ok {
  padding: 8px 12px;
  border-left: 2px solid var(--accent);
  background: var(--code-bg);
  font-size: 13.5px;
  margin: 12px 0;
}

.messagebox_err {
  padding: 8px 12px;
  border-left: 2px solid var(--err);
  color: var(--err);
  background: var(--code-bg);
  font-size: 13.5px;
  margin: 12px 0;
}

.form_item {
  margin-bottom: 12px;
}

.form_item label {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

input[type="text"],
textarea {
  width: 100%;
  max-width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
}

input[type="submit"],
button[type="submit"] {
  padding: 6px 12px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--code-bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  cursor: pointer;
}

input[type="submit"]:hover,
button[type="submit"]:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tag {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  padding: 0 5px;
  background: var(--code-bg);
}

@media (max-width: 520px) {
  body {
    margin: 28px auto;
  }

  .post-list li {
    flex-direction: column;
    gap: 2px;
    padding: 10px 0;
  }

  .note-item {
    flex-direction: column;
    gap: 4px;
  }

  .comment-children {
    margin-left: 10px;
    padding-left: 8px;
  }
}
