:root {
  --bg: #fafafa;
  --card: #ffffff;
  --ink: #111111;
  --ink-soft: #2a2a2a;
  --muted: #8a8a8a;
  --line: #ececec;
  --line-strong: #e0e0e0;
  --accent: #ffe58a;
  --accent-strong: #ffd94d;
  --danger: #d93b3b;
  --danger-soft: #fdecec;
  --shadow-sm: 0 1px 2px rgba(17, 17, 17, 0.04), 0 2px 6px rgba(17, 17, 17, 0.04);
  --shadow-md: 0 6px 18px rgba(17, 17, 17, 0.08);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --sans: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

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

[hidden] { display: none !important; }

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

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250, 250, 250, 0.85);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 18px;
  padding-bottom: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 229, 138, 0.35);
}

.brand-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  transition: transform 0.06s ease, background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(0,0,0,0.02), 0 6px 18px rgba(255, 217, 77, 0.35);
}
.btn-primary:hover { background: var(--accent-strong); }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--line-strong);
}
.btn-ghost:hover { background: #f2f2f2; }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:hover { background: #fbdcdc; }

.btn-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}
.icon-btn:hover { background: #f2f2f2; color: var(--ink); }

/* Section */
.main { padding-top: 32px; padding-bottom: 80px; }

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

.section-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.section-sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* Empty state */
.empty-state {
  margin: 24px auto;
  padding: 48px 24px;
  max-width: 480px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.empty-illustration {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 20px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-6deg);
  box-shadow: 0 8px 20px rgba(255, 217, 77, 0.4);
}
.empty-note {
  font-weight: 700;
  color: var(--ink);
  font-size: 15px;
  letter-spacing: 0.02em;
}

.empty-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
}
.empty-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14px;
}

/* Memo grid */
.memo-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.memo-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  text-align: left;
  overflow: hidden;
}

.memo-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}

.memo-card:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.memo-card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.memo-card-body {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1;
}

.memo-card-meta {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 12px;
}

.memo-card-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
}

.memo-card.is-enter {
  animation: memo-enter 320ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.memo-card.is-leave {
  animation: memo-leave 260ms cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none;
}

@keyframes memo-enter {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes memo-leave {
  to { opacity: 0; transform: translateY(6px) scale(0.96); }
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.is-open { display: flex; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 17, 17, 0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fade-in 180ms ease;
}

.modal-panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(17, 17, 17, 0.2);
  animation: panel-in 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.modal-panel-sm { max-width: 400px; }

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 8px;
}

.modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.modal-body {
  padding: 8px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}
.textarea {
  resize: vertical;
  min-height: 160px;
  line-height: 1.6;
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 6px;
}

/* Detail view */
.detail-body { gap: 12px; }
.detail-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.detail-headline {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
  word-break: break-word;
}
.detail-content {
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 6px 0 4px;
}

.confirm-title {
  margin: 4px 0 4px;
  font-size: 18px;
  font-weight: 700;
}
.confirm-sub {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 24px);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.25s ease;
  z-index: 100;
  max-width: calc(100% - 32px);
  text-align: center;
}
.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast.is-error { background: var(--danger); }

/* Responsive */
@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .header-inner { padding-top: 14px; padding-bottom: 14px; }
  .brand-title { font-size: 18px; }
  .section-title { font-size: 20px; }
  .btn { padding: 9px 14px; font-size: 13px; }
  .memo-grid { grid-template-columns: 1fr; gap: 12px; }
  .memo-card { min-height: 130px; padding: 16px; }
  .modal { padding: 12px; }
  .modal-header { padding: 16px 18px 6px; }
  .modal-body { padding: 6px 18px 18px; }
  .detail-headline { font-size: 20px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 auto; }
}

@media (max-width: 400px) {
  .brand-title { font-size: 17px; }
  .btn-primary .btn-plus { display: none; }
}
