:root {
  --bg: #FAFAF7;
  --text: #2B2B2B;
  --muted: #7a7770;
  --accent: #F4C64A;
  --accent-strong: #e0b031;
  --line: #E8E6E0;
  --card: #ffffff;
  --danger: #c0392b;
  --shadow: 0 1px 2px rgba(43, 43, 43, 0.04), 0 8px 24px rgba(43, 43, 43, 0.05);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

img, video { max-width: 100%; height: auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(250, 250, 247, 0.9);
  backdrop-filter: saturate(1.2) blur(10px);
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  flex: 1;
}

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

.view { animation: fade-in 220ms ease-out; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 버튼 */
.primary-btn, .ghost-btn, .danger-btn, .icon-btn {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  padding: 9px 14px;
  border: 1px solid transparent;
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease;
}
.primary-btn {
  background: var(--accent);
  color: #2B2B2B;
  border-color: var(--accent);
  font-weight: 600;
}
.primary-btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.primary-btn:active { transform: translateY(1px); }

.ghost-btn {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}
.ghost-btn:hover { background: #f0eee7; }

.danger-btn {
  background: transparent;
  color: var(--danger);
  border-color: var(--line);
}
.danger-btn:hover { background: #fbeeeb; border-color: #f2c8bf; }

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  border-radius: 10px;
}
.icon-btn:hover { background: #f0eee7; }

/* 공용 안내 배너 */
.shared-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #FBF3D6;
  border: 1px solid #F0E2A6;
  color: #6a5b1c;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 20px;
}
.shared-notice-mark {
  font-size: 16px;
  line-height: 1;
}

/* 그리드 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.memo-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 16px 14px;
  cursor: pointer;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
  animation: fade-in 220ms ease-out;
  position: relative;
  overflow: hidden;
}
.memo-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  border-color: #dcd9d1;
}
.memo-card.leaving {
  animation: fade-out 220ms ease-out forwards;
}
@keyframes fade-out {
  to { opacity: 0; transform: translateY(-4px) scale(0.98); }
}

.memo-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.memo-title.untitled { color: var(--muted); font-weight: 500; }
.memo-preview {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  flex: 1;
  white-space: pre-wrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.memo-date {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* 빈 상태 */
.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
  animation: fade-in 260ms ease-out;
}
.empty-mark {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #f3efe1;
  color: var(--accent-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  margin-bottom: 14px;
}
.empty h2 {
  font-size: 18px;
  color: var(--text);
  margin: 0 0 6px;
  font-weight: 600;
}
.empty p { margin: 0 0 20px; font-size: 14px; }

/* 편집기 */
.editor {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
  max-width: 720px;
  margin: 0 auto;
}
.title-input, .content-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  resize: vertical;
}
.title-input {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 4px 0 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.title-input::placeholder { color: #b6b2a8; font-weight: 600; }
.content-input {
  font-size: 16px;
  line-height: 1.7;
  min-height: 320px;
  padding: 4px 0;
}
.content-input::placeholder { color: #b6b2a8; }

.editor-meta {
  margin-top: 16px;
  min-height: 20px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.meta-text { color: var(--muted); font-size: 12px; }

.editor-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

/* 모달 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.is-open { display: flex; animation: fade-in 160ms ease-out; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 30, 28, 0.35);
}
.modal-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.modal-card h3 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.modal-card p { margin: 0 0 16px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* 토스트 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 20px);
  background: #2B2B2B;
  color: #FAFAF7;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
  z-index: 200;
  max-width: calc(100% - 40px);
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 모바일 */
@media (max-width: 640px) {
  .topbar-inner { padding: 12px 16px; }
  .container { padding: 20px 16px 96px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .editor { padding: 18px; border-radius: 14px; }
  .title-input { font-size: 22px; }
  .content-input { font-size: 15px; min-height: 260px; }
  .brand { font-size: 18px; }
  .primary-btn, .ghost-btn, .danger-btn { padding: 9px 12px; font-size: 14px; }
}
