* { box-sizing: border-box; }

body {
  margin: 0;
  background: #fafafa;
  color: #222;
  font-family: system-ui, sans-serif;
}

h1 { margin: 0 0 20px; font-size: 32px; line-height: 1.1; }
h2 { margin: 0 0 16px; font-size: 24px; }

.container { max-width: 560px; margin: 48px auto; padding: 0 20px; }

.card {
  padding: 20px;
  border: 1px solid #d9d9d9;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 4%);
}

label { display: block; margin: 16px 0 6px; color: #333; font-size: 14px; font-weight: 600; }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1px solid #bdbdbd; border-radius: 8px; background: #fff; color: #222; font: inherit; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #176b3a; box-shadow: 0 0 0 3px rgb(23 107 58 / 14%); outline: none; }

button, .button-link {
  display: inline-block;
  margin-top: 16px;
  padding: 10px 16px;
  border: 1px solid #222;
  border-radius: 8px;
  background: #222;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
}
button:hover:not(:disabled), .button-link:hover { border-color: #444; background: #444; }
button:disabled { border-color: #cfcfcf; background: #ececec; color: #888; cursor: not-allowed; }
button:focus-visible { box-shadow: 0 0 0 3px rgb(34 34 34 / 18%); outline: none; }
.delete-button { border-color: #9b2424; background: #9b2424; }
.delete-button:hover:not(:disabled) { border-color: #be3333; background: #be3333; }

.msg { min-height: 1.2em; margin: 12px 0 0; color: #b00020; }
.msg:not(:empty) { padding: 10px 12px; border: 1px solid #f0b8c0; border-radius: 8px; background: #fff5f6; font-size: 14px; line-height: 1.4; }
.flash-message { margin: 0; padding: 10px 12px; border: 1px solid #b9dfc8; border-radius: 8px; background: #f1fbf5; color: #176b3a; font-size: 14px; font-weight: 600; }

.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.topbar-meta { display: flex; flex-direction: column; gap: 4px; }
.topbar-user { margin: 0; color: #666; font-size: 14px; line-height: 1.35; }
.topbar-user-label { margin-right: 4px; }
.topbar-email { overflow-wrap: anywhere; font-weight: 500; }
.topbar nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px 12px; }
.topbar nav a { color: #333; font-size: 14px; font-weight: 600; text-decoration-thickness: 1px; text-underline-offset: 3px; }

.timeline-view { display: flex; flex-direction: column; gap: 16px; }
.timeline-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.timeline-intro { margin: 0; color: #555; }
.year-picker { display: flex; align-items: center; gap: 8px; margin: 0; white-space: nowrap; }
.year-picker span { color: #555; font-size: 14px; font-weight: 600; }
.year-picker select { width: auto; padding: 8px 10px; }
.timeline-panel { border-style: dashed; }
.timeline-loading { color: #666; }
.timeline-error { border-color: #f0b8c0; background: #fff5f6; color: #b00020; line-height: 1.45; }
.timeline-empty { border-color: #d6d6d6; background: #f7f7f7; color: #555; line-height: 1.45; text-align: center; }
.timeline-list { display: flex; flex-direction: column; gap: 16px; }
.timeline-month-group { display: flex; flex-direction: column; gap: 12px; }
.timeline-month-header { margin: 6px 2px 0; color: #444; font-size: 16px; font-weight: 700; }
.timeline-entry-card { padding: 14px; border: 1px solid #d9d9d9; border-radius: 8px; background: #fff; }
.timeline-entry-card-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.timeline-entry-day { color: #222; font-size: 14px; font-weight: 600; }
.timeline-entry-edit { color: #333; font-size: 14px; font-weight: 600; }
.timeline-entry-content { margin: 10px 0 0; color: #333; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.timeline-entry-note { margin-top: 12px; padding-top: 12px; border-top: 1px solid #e3e3e3; }
.timeline-entry-note h4 { margin: 0 0 4px; color: #555; font-size: 12px; text-transform: uppercase; }
.timeline-entry-note p { margin: 0; color: #555; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.empty-state p { margin: 0 0 12px; }
.empty-state .button-link { margin-top: 0; }

.back-link { display: inline-block; margin-bottom: 12px; }
.entry-form-view h2 { margin-bottom: 16px; }
.entry-form { display: flex; flex-direction: column; }
.entry-form label:first-of-type, #loginForm label:first-of-type { margin-top: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.form-actions button { margin-top: 16px; }

@media (max-width: 640px) {
  .container { margin: 20px auto; padding: 0 16px; }
  .card { padding: 16px; }
  .topbar { align-items: stretch; flex-direction: column; }
  .topbar nav { justify-content: flex-start; }
  .timeline-heading { align-items: stretch; flex-direction: column; }
  .year-picker { justify-content: space-between; }
  .timeline-entry-card { padding: 12px; }
}

@media (max-width: 380px) { .container { padding: 0 12px; } }
