@font-face {
  font-family: 'Pretendard';
  src: url('https://cdn.jsdelivr.net/npm/pretendard@1.3.9/dist/web/variable/woff2/PretendardVariable.woff2')
    format('woff2-variations');
  font-weight: 45 920;
  font-display: swap;
}

:root {
  --paper: #f6f3ee;
  --paper-raised: #fdfbf7;
  --ink: #1d1c1a;
  --ink-soft: #45423d;
  --muted: #736d64;
  --line: #e2dcd1;
  --line-strong: #cfc7b9;
  --accent: #9c4a3c;
  --accent-soft: #f1e4df;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(29, 28, 26, 0.04), 0 8px 24px -16px rgba(29, 28, 26, 0.24);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
}

input,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.hidden {
  display: none !important;
}

/* ---------- 상단 바 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(246, 243, 238, 0.92);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.wordmark span {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12.5px;
  color: var(--muted);
}

.link-button {
  border: 0;
  background: none;
  padding: 6px 4px;
  color: var(--muted);
  font-size: 12.5px;
  border-bottom: 1px solid transparent;
}

.link-button:hover {
  color: var(--ink);
  border-bottom-color: var(--line-strong);
}

/* ---------- 레이아웃 ---------- */
.shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 20px 120px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 34px 0 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-transform: uppercase;
}

.section-head .count {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- 빠른 메모 ---------- */
.composer {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 12px;
  box-shadow: var(--shadow);
}

.composer:focus-within {
  border-color: var(--line-strong);
}

.composer textarea {
  width: 100%;
  min-height: 64px;
  max-height: 46vh;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-size: 15.5px;
  line-height: 1.65;
}

.composer textarea::placeholder {
  color: #a49c90;
}

.composer-title {
  width: 100%;
  min-height: 34px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  padding: 0 0 6px;
  border-bottom: 1px solid transparent;
}

.composer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 10px;
}

.chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 6px 12px;
  min-height: 30px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.chip.on {
  background: var(--accent-soft);
  border-color: #dcc3b8;
  color: #7c3a2e;
}

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

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 9px;
  font-size: 13px;
  color: var(--ink-soft);
}

.icon-button:hover {
  border-color: var(--line-strong);
}

.primary {
  min-height: 38px;
  padding: 0 18px;
  border: 1px solid #1d1c1a;
  background: var(--ink);
  color: #fbf8f2;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
}

.primary:disabled {
  opacity: 0.45;
  cursor: default;
}

.primary:hover:not(:disabled) {
  background: #33302c;
}

.attached {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.attached figure {
  position: relative;
  margin: 0;
  width: 74px;
  height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

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

.attached button {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: rgba(29, 28, 26, 0.72);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- 필터 ---------- */
.controls {
  display: grid;
  gap: 10px;
  margin-top: 26px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  height: 42px;
}

.search svg {
  flex: 0 0 auto;
  color: var(--muted);
}

.search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  min-width: 0;
  height: 100%;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 4px;
  border-bottom: 1px solid var(--line);
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  border: 0;
  background: none;
  padding: 9px 10px 10px;
  font-size: 13.5px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  margin-bottom: -1px;
}

.tab .n {
  margin-left: 4px;
  font-size: 11.5px;
  color: #a49c90;
  font-variant-numeric: tabular-nums;
}

.tab.on {
  color: var(--ink);
  font-weight: 620;
  border-bottom-color: var(--accent);
}

.tags-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 2px;
}

/* ---------- 노트 목록 ---------- */
.list {
  border-top: 1px solid var(--line);
}

.note-row {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 16px 4px 15px;
}

.note-row:hover {
  background: rgba(253, 247, 237, 0.7);
}

.note-row .row-title {
  font-size: 16px;
  font-weight: 640;
  letter-spacing: -0.015em;
  margin: 0 0 3px;
}

.note-row .row-excerpt {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.row-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 7px;
  font-size: 12px;
  color: #8b8478;
  font-variant-numeric: tabular-nums;
}

.row-tags {
  display: inline-flex;
  gap: 5px;
  flex-wrap: wrap;
}

.tag {
  color: #8a6a58;
  background: #efe6dd;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11.5px;
}

.folder-badge {
  color: #6f6a63;
}

.empty {
  padding: 44px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.empty strong {
  display: block;
  color: var(--ink-soft);
  font-weight: 600;
  margin-bottom: 4px;
}

/* ---------- 프로젝트 카드 ---------- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.project-card {
  position: relative;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 132px;
}

.project-card h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 660;
  letter-spacing: -0.015em;
}

.project-card h3 button {
  display: block;
  width: 100%;
  padding: 6px 0;
  text-align: left;
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  background: none;
  border: 0;
}

.project-card p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-card .go {
  align-self: flex-start;
  font-size: 12.5px;
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: transparent;
  color: var(--ink-soft);
  text-decoration: none;
}

.project-card .go:hover {
  border-color: var(--ink);
  color: var(--ink);
}

/* ---------- 상세 패널 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(29, 28, 26, 0.32);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0;
}

.sheet {
  width: 100%;
  max-width: 760px;
  height: 100%;
  max-height: 100%;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sheet-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 243, 238, 0.96);
}

.sheet-head .left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sheet-head button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.sheet-head .link-button {
  white-space: nowrap;
}

.sheet-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 26px 22px 80px;
  -webkit-overflow-scrolling: touch;
}

.sheet-body .note-head h1 {
  font-size: 24px;
  line-height: 1.35;
  letter-spacing: -0.025em;
  margin: 0 0 8px;
}

.note-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 22px;
}

.markdown {
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink-soft);
}

.markdown h2,
.markdown h3,
.markdown h4 {
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.4;
  margin: 26px 0 8px;
}

.markdown h2 {
  font-size: 19px;
}

.markdown h3 {
  font-size: 16.5px;
}

.markdown h4 {
  font-size: 15px;
}

.markdown p {
  margin: 0 0 12px;
}

.markdown ul,
.markdown ol {
  margin: 0 0 14px;
  padding-left: 20px;
}

.markdown li {
  margin: 3px 0;
}

.markdown li.task {
  list-style: none;
  margin-left: -20px;
}

.markdown li.task label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.markdown li.task input {
  margin-top: 5px;
  accent-color: var(--accent);
}

.markdown blockquote {
  margin: 0 0 14px;
  padding: 6px 0 6px 14px;
  border-left: 2px solid var(--line-strong);
  color: var(--muted);
}

.markdown code {
  background: #efe9de;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.markdown pre {
  background: #2b2926;
  color: #f2eee6;
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0 0 16px;
}

.markdown pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 12.5px;
  line-height: 1.6;
}

.markdown img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  margin: 6px 0 16px;
  display: block;
}

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

.markdown .wiki {
  color: var(--accent);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

/* 편집 */
.edit-area {
  width: 100%;
  min-height: 52vh;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: var(--paper-raised);
  font-size: 15px;
  line-height: 1.7;
  resize: vertical;
  outline: 0;
}

.edit-title {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 0 0 8px;
  margin-bottom: 14px;
  font-size: 22px;
  font-weight: 680;
  letter-spacing: -0.02em;
  outline: 0;
}

.edit-tags {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--paper-raised);
  margin-top: 12px;
  outline: 0;
  font-size: 13.5px;
}

.edit-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
}

.danger {
  border: 1px solid #d9b8b2;
  color: #8d3325;
  background: transparent;
  border-radius: 9px;
  padding: 0 14px;
  min-height: 38px;
  font-size: 13.5px;
}

.danger:hover {
  background: #f7e9e5;
}

/* ---------- 토스트 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  z-index: 60;
  background: #26241f;
  color: #f7f2e9;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  max-width: calc(100vw - 40px);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: #7c2f24;
}

/* ---------- 플로팅 쓰기 버튼(모바일) ---------- */
.fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  display: none;
  align-items: center;
  gap: 6px;
  height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fbf8f2;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 24px -12px rgba(29, 28, 26, 0.6);
}

/* ---------- 반응형 ---------- */
@media (max-width: 720px) {
  .shell {
    padding: 18px 16px 120px;
  }

  .topbar {
    padding: 12px 16px;
  }

  .projects-grid {
    grid-template-columns: 1fr;
  }

  .fab {
    display: inline-flex;
  }

  .sheet {
    max-width: none;
    border-radius: 0;
  }

  .sheet-body {
    padding: 22px 18px 90px;
  }

  .composer-row {
    align-items: flex-end;
  }

  .composer-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .desktop-only {
    display: none !important;
  }
}

@media (min-width: 721px) {
  .overlay {
    padding: 40px 20px;
    align-items: center;
  }

  .sheet {
    height: auto;
    max-height: calc(100vh - 80px);
    border-radius: 14px;
    border: 1px solid var(--line);
    box-shadow: 0 24px 60px -30px rgba(20, 19, 17, 0.5);
  }
}

/* ---------- 로그인 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
}

.login-card .mark {
  font-size: 20px;
  font-weight: 720;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}

.login-card .sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 22px;
}

.login-card input[type='password'] {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--paper-raised);
  padding: 0 14px;
  outline: 0;
  font-size: 15px;
}

.login-card input[type='password']:focus {
  border-color: var(--ink-soft);
}

.login-card .primary {
  width: 100%;
  height: 46px;
  margin-top: 10px;
}

.login-error {
  min-height: 20px;
  margin-top: 8px;
  font-size: 12.5px;
  color: #8d3325;
}

.login-foot {
  margin-top: 26px;
  font-size: 12px;
  color: #948d81;
  line-height: 1.6;
}
