:root {
  --paper: #faf7f2;
  --ink: #3a352f;
  --muted: #8a8378;
  --accent: #c8896b;
  --accent-dark: #a8664a;
  --card: #ffffff;
  --border: #ece6dd;
  --danger: #c0554a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* 로그인 화면 */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--card);
  padding: 48px 40px;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.06);
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.brand { font-size: 40px; margin-bottom: 8px; }

.login-card h1 {
  font-size: 22px;
  margin: 0 0 6px;
  font-weight: 700;
}

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

#login-form { display: flex; flex-direction: column; gap: 12px; }

input, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
  width: 100%;
}

input:focus, textarea:focus { border-color: var(--accent); }

button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
}

button.primary { background: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-dark); }
button.ghost { background: transparent; color: var(--muted); }
button.ghost:hover { color: var(--ink); }
button.danger { background: var(--danger); color: #fff; }

.error {
  color: var(--danger);
  font-size: 12px;
  min-height: 16px;
  margin: 10px 0 0;
  white-space: pre-wrap;
}

/* 메인 화면 */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 48px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.header-left h1 {
  font-size: 24px;
  margin: 0;
  font-weight: 700;
}

.today-date {
  font-size: 13px;
  color: var(--muted);
}

.header-right { display: flex; gap: 10px; }

.board {
  max-width: 860px;
  margin: 0 auto;
  padding: 36px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.entry-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 22px;
  display: flex;
  gap: 18px;
  align-items: center;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}

.entry-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.05);
  transform: translateY(-1px);
}

.entry-card .thumb {
  width: 76px;
  height: 76px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
}

.entry-card .thumb-broken {
  width: 76px;
  height: 76px;
  border-radius: 12px;
  flex-shrink: 0;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 4px;
}

.entry-body { flex: 1; min-width: 0; }

.entry-date {
  font-size: 12px;
  color: var(--accent-dark);
  font-weight: 600;
  margin-bottom: 4px;
}

.entry-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.entry-snippet {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loading, .empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 0;
  font-size: 14px;
}

/* 모달 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(58, 53, 47, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}

.modal-content {
  background: var(--card);
  border-radius: 18px;
  padding: 32px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-content h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.field-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: -4px;
}

textarea { resize: vertical; }

.file-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--accent-dark);
  cursor: pointer;
  width: fit-content;
}

.media-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preview-thumb-wrap {
  position: relative;
  width: 72px;
  height: 72px;
}

.preview-thumb {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--border);
}

.remove-media-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  padding: 4px 8px;
}

.detail-content { max-width: 640px; }

.detail-date {
  font-size: 12px;
  color: var(--accent-dark);
  font-weight: 600;
}

.detail-title {
  font-size: 22px;
  margin: 6px 0 14px;
}

.detail-content-text {
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  margin-bottom: 16px;
}

.detail-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.detail-media {
  width: 100%;
  border-radius: 12px;
  object-fit: cover;
  max-height: 220px;
  background: var(--border);
}

.detail-media-broken {
  width: 100%;
  min-height: 100px;
  border-radius: 12px;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--danger);
  text-align: center;
  padding: 10px;
}

@media (max-width: 600px) {
  .app-header { padding: 20px; }
  .board { padding: 24px 16px 60px; }
}
