@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&display=swap');

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

:root {
  --bg: #f5f5f0;
  --surface: #ececec;
  --border: #c0c0c0;
  --text: #1a1a1a;
  --muted: #666666;
  --accent: #1a1aff;
  --accent-hover: #0000cc;
  --danger: #cc0000;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --border: #2e2e2e;
    --text: #d4d4d4;
    --muted: #666666;
    --accent: #6b9fff;
    --accent-hover: #9bbfff;
    --danger: #ff4444;
  }
}

body {
  font-family: "IBM Plex Mono", "Courier New", monospace;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3 {
  font-weight: 600;
  line-height: 1.3;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

small, .meta {
  font-size: 0.875rem;
  color: var(--muted);
}

code {
  font-size: 0.875rem;
  font-family: inherit;
}

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

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

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* Nav */

.nav {
  position: sticky;
  top: 0;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.nav-brand {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

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

.nav-links a:hover {
  text-decoration: underline;
  color: var(--accent);
}

.nav-links a.active {
  text-decoration: underline;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--text);
  line-height: 1;
  touch-action: manipulation;
}

.nav-toggle svg {
  pointer-events: none;
}

@media (max-width: 600px) {
  .nav {
    height: auto;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.75rem 1.5rem;
    gap: 0;
  }

  .nav-toggle {
    display: flex;
    align-items: center;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    gap: 0.4rem;
    align-items: flex-start;
    width: 100%;
    margin-top: 0.5rem;
  }

  .nav-links.open {
    display: flex;
  }
}

/* Layout */

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Section list */

.section-list {
  list-style: none;
  margin-top: 1.5rem;
}

.section-list li {
  margin-bottom: 0.75rem;
}

.section-list .section-desc {
  color: var(--muted);
}

/* Buttons */

.btn {
  display: inline-block;
  border: 1px solid currentColor;
  padding: 0.4rem 0.9rem;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  background: transparent;
  color: var(--text);
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Forms */

label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 600;
}

input, textarea, select {
  font-family: inherit;
  font-size: 1rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  width: 100%;
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
}

.field-error {
  color: var(--danger);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.form-row {
  margin-bottom: 1.5rem;
}

.error {
  color: var(--danger);
  margin-bottom: 1.5rem;
}

/* Tables */

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  text-align: left;
  padding: 0.5rem 0.75rem;
}

td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

tr:nth-child(even) td {
  background: var(--surface);
}

td.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Code blocks */

pre {
  background: #1a1a1a;
  color: #d4d4d4;
  padding: 1rem;
  overflow-x: auto;
  white-space: pre;
}

pre code {
  background: none;
  color: inherit;
}

/* Tags */

.tag {
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid currentColor;
  padding: 0.1rem 0.4rem;
}

.incomplete td {
  color: var(--muted);
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Blog */

.blog-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.blog-search {
  margin-bottom: 1.5rem;
}

.search-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.search-row input {
  flex: 1;
}

.search-row .btn {
  flex-shrink: 0;
}

.clear-search {
  font-size: 0.875rem;
  display: inline-block;
  margin-top: 0.5rem;
}

.search-summary {
  margin-bottom: 1rem;
}

.post-list {
  list-style: none;
  margin-top: 1rem;
}

.post-item {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
}

.post-item:first-child {
  border-top: 1px solid var(--border);
}

.post-meta {
  margin-bottom: 0.375rem;
}

.post-item h2 {
  margin-bottom: 0.5rem;
}

.post-item h2 a {
  color: var(--text);
  text-decoration: none;
}

.post-item h2 a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.post-excerpt {
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  max-width: 65ch;
}

.read-more {
  font-size: 0.875rem;
}

/* Single post */

.post {
  max-width: 65ch;
}

.post-header {
  margin-bottom: 2rem;
}

.post-header h1 {
  margin: 0.5rem 0;
}

.post-body {
  line-height: 1.7;
}

.post-body h2 {
  margin: 2rem 0 0.75rem;
}

.post-body h3 {
  margin: 1.5rem 0 0.5rem;
}

.post-body p {
  margin-bottom: 1rem;
  max-width: 65ch;
}

.post-body ul,
.post-body ol {
  margin: 0 0 1rem 1.5rem;
}

.post-body li {
  margin-bottom: 0.25rem;
}

.post-body code {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.1rem 0.3rem;
}

.post-body pre {
  margin-bottom: 1rem;
}

.post-body pre code {
  background: none;
  border: none;
  padding: 0;
}

/* New post form */

.blog-new textarea {
  font-family: inherit;
  resize: vertical;
  min-height: 300px;
}

/* Gallery */

.gallery-page {}

.gallery-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.gallery-filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.gallery-filters a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.gallery-filters a:hover,
.gallery-filters a.active {
  color: var(--text);
  text-decoration: underline;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1px;
  border: 1px solid var(--border);
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--surface);
}

.gallery-item a {
  display: block;
  width: 100%;
  height: 100%;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-controls {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  display: flex;
  gap: 0.25rem;
  opacity: 0;
}

.gallery-item:hover .gallery-controls {
  opacity: 1;
}

.gallery-ctrl-btn {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 0.75rem;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  cursor: pointer;
}

.gallery-delete-btn {
  color: var(--danger);
}

.gallery-upload {
  max-width: 480px;
}

/* Margin gallery */

.margin-gallery {
  position: fixed;
  top: calc(48px + 2rem);
  left: max(0.5rem, calc(50vw - 360px - 106px));
  width: 90px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: 1px solid var(--border);
}

.margin-gallery a {
  display: block;
  text-decoration: none;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--surface);
}

.margin-gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: grayscale(100%);
}

.margin-gallery img:hover {
  filter: grayscale(100%);
}

@media (max-width: 900px) {
  .margin-gallery { display: none; }
}

/* Quote footer */

.quote-footer {
  border-top: 1px solid var(--muted, #ccc);
  margin-top: 4rem;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted, #888);
  font-size: 0.875rem;
}

.quote-footer blockquote {
  margin: 0;
  font-style: italic;
}

.quote-footer cite {
  display: block;
  margin-top: 0.5rem;
  font-style: normal;
}

/* Wide container for dashboard pages */
.container-wide {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Wealth page */
.net-worth-headline {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}

.net-worth-headline .muted {
  font-size: 1rem;
  color: var(--muted);
}

.admin-panel {
  margin: 1rem 0 1.5rem;
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
}

.admin-panel summary {
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--muted);
}

.projection-detail {
  margin-bottom: 1.5rem;
}

.projection-detail > summary {
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  align-items: center;
}

.inline-form input,
.inline-form select {
  font-family: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 0.25rem 0.5rem;
}

.projection-form .form-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.projection-form .form-row label {
  width: 220px;
  font-size: 0.875rem;
  color: var(--muted);
}

.projection-form .form-row input {
  font-family: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 0.25rem 0.5rem;
  width: 120px;
}

.projection-table {
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

tr.retirement-row td {
  border-top: 2px solid var(--accent);
  color: var(--accent);
}

canvas {
  margin-bottom: 2rem;
}

.table-scroll {
  overflow-x: auto;
}

/* Today page */
.today-totals {
  display: flex;
  gap: 2rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.today-total-label {
  font-size: 0.875rem;
  color: var(--muted);
  display: block;
}

.today-total-value {
  font-size: 1.2rem;
  font-weight: 600;
}

.week-tracker {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.week-day {
  text-align: center;
  min-width: 52px;
}

.week-day-label {
  font-size: 0.75rem;
  color: var(--muted);
  display: block;
}

.week-day-status {
  font-size: 0.875rem;
}
