@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/jetbrains-mono-regular.woff2') format('woff2');
}

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --bg-subtle: #f7f7f8;
  --fg: #17181a;
  --muted: #6b6f76;
  --border: #e5e6e9;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --accent-subtle: #eef3ff;
  --danger: #dc2626;
  --danger-fg: #ffffff;
  --success: #15803d;
  --success-bg: #ecfdf3;
  --error-bg: #fef2f2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 15, 20, 0.04), 0 1px 8px rgba(15, 15, 20, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121316;
    --bg-subtle: #1a1b1f;
    --fg: #edeef0;
    --muted: #9a9ca3;
    --border: #2a2c31;
    --accent: #6d94f5;
    --accent-fg: #0d1220;
    --accent-subtle: #1a2540;
    --danger: #f2685f;
    --danger-fg: #2a0d0b;
    --success: #4ade80;
    --success-bg: #12271a;
    --error-bg: #2b1414;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 8px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  font-size: 15px;
}

.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 28px 20px 100px;
}

/* ---------- nav ---------- */

nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

nav a, nav .navbtn {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 8px;
  font-weight: 500;
}

nav a:hover { color: var(--fg); background: var(--bg-subtle); }
nav a.active { color: var(--accent); background: var(--accent-subtle); }

nav a.brand {
  color: var(--fg);
  font-weight: 700;
  margin-right: auto;
  padding-left: 0;
  font-size: 15px;
}
nav a.brand:hover { background: none; }

.nav-user {
  color: var(--muted);
  font-size: 13px;
  padding: 0 8px;
}

/* ---------- typography ---------- */

h1 { font-size: 22px; margin: 4px 0 20px; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0 0 10px; }
a { color: var(--accent); }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- flash / alerts ---------- */

.flash {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 18px;
}
.flash-success { background: var(--success-bg); color: var(--success); }
.flash-error { background: var(--error-bg); color: var(--danger); }

.error {
  background: var(--error-bg);
  color: var(--danger);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}

/* ---------- forms ---------- */

label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }

input[type="text"], input[type="password"], input[type="email"], input[type="date"],
input[type="number"], input[type="file"], textarea, select {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  width: 100%;
}

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

textarea { min-height: 220px; resize: vertical; font-family: inherit; }

.field { margin-bottom: 16px; }

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.form-row .field { flex: 1; min-width: 140px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input[type="checkbox"] { width: auto; flex-shrink: 0; }

/* ---------- buttons ---------- */

button, .btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  line-height: 1.4;
}
button:hover, .btn:hover { filter: brightness(1.08); }
button:active, .btn:active { filter: brightness(0.95); }

button.secondary, .btn.secondary {
  background: var(--bg-subtle);
  color: var(--fg);
  border: 1px solid var(--border);
}

button.danger, .btn.danger { background: var(--danger); color: var(--danger-fg); }
button.ghost, .btn.ghost { background: transparent; color: var(--muted); padding: 6px 10px; }
button.ghost:hover { background: var(--bg-subtle); color: var(--fg); }
button.small { padding: 5px 10px; font-size: 13px; }

form.inline { display: inline; }

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- cards / lists ---------- */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  background: var(--bg);
}

.list-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.list-item:last-child { border-bottom: none; }
.list-item .title { font-weight: 600; font-size: 15px; }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 48px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}

/* ---------- table ---------- */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

.table-wrap { overflow-x: auto; margin-bottom: 16px; }

/* ---------- badges / stats ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-subtle);
  color: var(--muted);
}
a.badge { text-decoration: none; flex-shrink: 0; }
a.badge:hover { color: var(--fg); background: var(--accent-subtle); }

.cat-badge {
  background: color-mix(in srgb, var(--cat, var(--accent)) 16%, var(--bg-subtle));
  color: color-mix(in srgb, var(--cat, var(--accent)) 65%, var(--fg));
}
a.cat-badge:hover { color: color-mix(in srgb, var(--cat, var(--accent)) 65%, var(--fg)); background: color-mix(in srgb, var(--cat, var(--accent)) 28%, var(--bg-subtle)); }

.list-item-head { display: flex; align-items: center; gap: 8px; }
.list-item-head .title { flex: 1; min-width: 0; }
.list-item-head .post-number { flex-shrink: 0; min-width: 2ch; font-variant-numeric: tabular-nums; }

.cat-tag {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  color: color-mix(in srgb, var(--cat, var(--accent)) 80%, var(--fg));
}

.stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }

.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 18px;
  font-weight: 600;
}
.month-nav a { color: var(--muted); text-decoration: none; font-weight: 500; font-size: 14px; }
.month-nav a:hover { color: var(--fg); }

/* ---------- dropzone ---------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 20px;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 16px;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover { border-color: var(--accent); color: var(--fg); }
.dropzone.dragover { border-color: var(--accent); background: var(--accent-subtle); color: var(--fg); }
.dropzone input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0; overflow: hidden;
}
.dropzone-text { font-size: 14px; font-weight: 500; }
.dropzone-filename:empty { display: none; }

/* ---------- share link ---------- */

.share-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  flex-wrap: wrap;
}
.share-row input[readonly] {
  flex: 1;
  min-width: 180px;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg-subtle);
}

/* ---------- misc ---------- */

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head h1 { margin: 0; }

/* ---------- hero / home ---------- */

.hero {
  padding: 32px 0 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.hero-banner {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}
.hero-avatar {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--border);
  margin: 0 0 16px;
}
.hero-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.hero-tagline {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
  max-width: 46ch;
  margin: 0 0 18px;
}
.hero-tagline .line {
  display: block;
  opacity: 0;
  transform: translateY(5px);
  animation: line-in 0.28s ease-out forwards;
}
.hero-tagline .line:nth-child(1) { animation-delay: 0.05s; }
.hero-tagline .line:nth-child(2) { animation-delay: 0.38s; }

@keyframes line-in {
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-tagline .line { animation: none; opacity: 1; transform: none; }
}
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.hero-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.hero-contact {
  display: inline-flex;
  align-items: center;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.hero-contact:hover { color: var(--accent); }

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 12px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  margin-bottom: 32px;
}
.category-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-left: 3px solid color-mix(in srgb, var(--cat, var(--accent)) 50%, var(--border));
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--fg);
  font-weight: 600;
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
}
.category-card:hover { border-color: color-mix(in srgb, var(--cat, var(--accent)) 60%, var(--border)); background: color-mix(in srgb, var(--cat, var(--accent)) 10%, var(--bg-subtle)); }
.category-card-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.category-card-left .cat-tag { font-size: 13px; }
.category-card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-card-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-subtle);
  border-radius: 999px;
  padding: 2px 8px;
  flex-shrink: 0;
}
.category-card:hover .category-card-count { color: color-mix(in srgb, var(--cat, var(--accent)) 70%, var(--fg)); }

.editor-wrap { display: flex; gap: 14px; }
.editor-textarea { flex: 1; min-height: 420px; font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.editor-preview {
  display: none;
  flex: 1;
  min-height: 420px;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.editor-wrap.show-preview .editor-preview { display: block; }

@media (max-width: 700px) {
  .editor-wrap.show-preview { flex-direction: column; }
}

.markdown-body :first-child { margin-top: 0; }
.markdown-body pre {
  background: var(--bg-subtle);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.markdown-body code { background: var(--bg-subtle); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.markdown-body pre code { background: none; padding: 0; overflow-wrap: anywhere; }
.markdown-body img { max-width: 100%; }

.mail-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.attachment-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.attachment-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.attachment-list li a { overflow-wrap: anywhere; min-width: 0; }

.series-list { margin: 0; padding-left: 20px; }
.series-list li { margin-bottom: 6px; font-size: 14px; }
.series-list li.current { font-weight: 700; color: var(--fg); }

.series-nav {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.series-nav .btn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

.mail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 6px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--fg);
  border-radius: 8px;
}
.mail-item:hover { background: var(--bg-subtle); }
.mail-item:last-child { border-bottom: none; }

.mail-item-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  flex-shrink: 0;
  opacity: 0;
}
.mail-item.unread .mail-item-dot { opacity: 1; }

.mail-item-from {
  flex-shrink: 0;
  width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  color: var(--muted);
}
.mail-item.unread .mail-item-from { color: var(--fg); font-weight: 700; }

.mail-item-subject {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  color: var(--muted);
}
.mail-item.unread .mail-item-subject { color: var(--fg); font-weight: 600; }

.mail-item-date {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

@media (max-width: 560px) {
  .mail-item { flex-wrap: wrap; }
  .mail-item-from { width: auto; flex: 1 1 auto; }
  .mail-item-subject {
    flex-basis: 100%;
    order: 3;
    padding-left: 17px;
  }
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  padding-bottom: 4px;
}
.tabs a {
  padding: 7px 12px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  white-space: nowrap;
}
.tabs a:hover { color: var(--fg); background: var(--bg-subtle); }
.tabs a.active { color: var(--accent); background: var(--accent-subtle); font-weight: 600; }

/* ---------- terminal-style category filter ---------- */

.term-filter {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: var(--radius);
  margin-bottom: 22px;
  overflow: hidden;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
.term-filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  background: #1c2128;
  border-bottom: 1px solid #30363d;
}
.term-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.term-dot-r { background: #ff5f56; }
.term-dot-y { background: #ffbd2e; }
.term-dot-g { background: #27c93f; }
.term-filter-label { margin-left: 6px; font-size: 11px; color: #8b949e; }
.term-filter-body { padding: 12px 14px 14px; }
.term-prompt { display: block; font-size: 13px; color: #6d94f5; margin-bottom: 10px; }
.term-chips { display: flex; flex-wrap: wrap; gap: 8px 10px; }
.term-chip {
  font-size: 13px;
  font-weight: 600;
  color: #8b949e;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s, text-shadow 0.15s, background 0.15s;
}
.term-chip::before { content: "#"; opacity: 0.5; }
.term-chip:hover {
  color: color-mix(in srgb, var(--cat, #6d94f5) 80%, #e6edf3);
  border-color: color-mix(in srgb, var(--cat, #6d94f5) 40%, transparent);
}
.term-chip.active {
  color: var(--cat, #6d94f5);
  background: color-mix(in srgb, var(--cat, #6d94f5) 14%, transparent);
  border-color: color-mix(in srgb, var(--cat, #6d94f5) 55%, transparent);
  text-shadow: 0 0 10px color-mix(in srgb, var(--cat, #6d94f5) 70%, transparent);
}

/* ---------- calendar ---------- */

.calendar { margin-bottom: 18px; }

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding-bottom: 6px;
}

.calendar-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}

.calendar-cell {
  aspect-ratio: 1 / 0.85;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: var(--fg);
  font-size: 12px;
  min-height: 52px;
}
.calendar-cell.empty { border: none; }
.calendar-cell:not(.empty):hover { background: var(--bg-subtle); }
.calendar-cell.today { border-color: var(--accent); }
.calendar-cell.selected { background: var(--accent-subtle); border-color: var(--accent); }

.cell-day { font-weight: 600; color: var(--muted); }
.cell-amount { font-size: 11px; font-weight: 700; color: var(--danger); }

@media (max-width: 520px) {
  .calendar-cell { font-size: 10px; padding: 4px; min-height: 40px; }
  .cell-amount { font-size: 9px; }
}

@media (max-width: 520px) {
  .container { padding: 20px 14px 90px; }
  nav { padding: 12px 14px; }
}

/* ---------- copy-to-clipboard toast ---------- */

[data-copy], [data-copy-text] { position: relative; }

.copy-flash::after {
  content: "복사됨";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  margin-bottom: 6px;
  background: var(--fg);
  color: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI", sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  animation: copy-toast 1.5s ease forwards;
}

@keyframes copy-toast {
  0% { opacity: 0; transform: translateX(-50%) translateY(4px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  75% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(0); }
}
