* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f4f6fb; color: #172033; }
a { color: inherit; text-decoration: none; }
img, svg { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; align-self: start; min-height: 50px; padding: 3px 8px 3px 12px; background: rgba(247,249,253,.95); backdrop-filter: blur(8px); border-bottom: 1px solid #dde3ef; gap: 10px; }
.brand { font-weight: 800; letter-spacing: .02em; line-height: 1; font-size: 15px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.language-form { margin: 0; }
.language-select { min-height: 38px; padding: 8px 12px; border: 1px solid #cfd7e6; border-radius: 12px; background: #fff; font: inherit; max-width: 132px; }
.menu-button { display: grid; place-items: center; width: 44px; height: 44px; border: 0; background: #e7ecf7; border-radius: 10px; padding: 0; font-size: 18px; line-height: 1; flex: 0 0 44px; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: min(82vw, 300px); background: #fff; padding: 76px 16px 16px; transform: translateX(-105%); transition: transform .2s ease; z-index: 40; box-shadow: 12px 0 40px rgba(16,24,40,.16); display: grid; gap: 10px; }
.sidebar.open { transform: translateX(0); }
.sidebar a, .sidebar button { display: block; width: 100%; text-align: left; padding: 12px 14px; border-radius: 12px; background: #f3f6fb; border: 0; }
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.38); opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 35; }
.overlay.open { opacity: 1; pointer-events: auto; }
.content { width: min(100%, 1100px); margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.card { background: #fff; border: 1px solid #e3e8f3; border-radius: 20px; padding: 16px; box-shadow: 0 8px 24px rgba(19,30,61,.04); }
.hero h1, h1, h2 { margin-top: 0; }
.button, button.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 12px 16px; background: #e7ecf7; color: #172033; font-weight: 700; }
.button.primary { background: #5a45d6; color: #fff; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.button-row.compact { justify-content: flex-end; }
.form-card form, .card form { display: grid; gap: 12px; }
.input, input, select, textarea { width: 100%; max-width: 100%; padding: 12px 14px; border: 1px solid #cfd7e6; border-radius: 14px; font: inherit; background: #fff; }
label { display: grid; gap: 6px; font-weight: 600; }
.summary-grid, .grid-2, .grid-3 { display: grid; gap: 12px; }
.summary-grid { grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.summary-tile, .list-row { background: #f7f9fe; border-radius: 16px; padding: 14px; display: grid; gap: 4px; }
.stack { display: grid; gap: 10px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.eyebrow { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #5a45d6; }
.muted { color: #52607a; }
.helper-text { font-size: 13px; color: #52607a; font-weight: 500; }
.field-error { font-size: 13px; color: #b42318; font-weight: 700; }
.help-grid { align-items: start; }
.help-steps, .checklist { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.flash-stack { display: grid; gap: 8px; }
.flash { padding: 12px 14px; border-radius: 14px; background: #eff6ff; }
.flash.success { background: #dcfce7; }
.flash.error { background: #fee2e2; }
.empty-state { border: 1px dashed #cfd7e6; border-radius: 16px; padding: 16px; background: #fbfcff; }
.compact-empty { padding: 12px 14px; }
.jump-form { display: grid; gap: 10px; align-items: end; }
.calendar-shell { display: grid; gap: 8px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.calendar-head { font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: #52607a; }
.calendar-head span { padding: 4px 0; text-align: center; }
.calendar-day { min-height: 84px; border: 1px solid #dfe6f2; border-radius: 16px; padding: 10px; background: #fff; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; }
.calendar-day.is-outside { opacity: .45; background: #f7f9fd; }
.calendar-day.is-today { border-color: #5a45d6; box-shadow: inset 0 0 0 1px #5a45d6; }
.calendar-day.is-selected { background: #eef1ff; }
.calendar-day.has-data { border-color: #9eb2ff; }
.calendar-day-number { font-weight: 800; }
.calendar-day-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.day-chip { display: inline-flex; align-items: center; justify-content: center; min-height: 22px; padding: 3px 8px; border-radius: 999px; background: #eef2ff; color: #384684; font-size: 12px; font-weight: 700; }
.day-chip.saved { background: #dcfce7; color: #166534; }
.bleeding-marker { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; font-size: 13px; line-height: 1; }
.entry-list, .saved-summary { display: grid; gap: 10px; }
.entry-card { display: grid; gap: 4px; padding: 12px 14px; border-radius: 16px; background: #f7f9fe; border: 1px solid #e3e8f3; }
.fold-card { padding: 0; overflow: hidden; }
.fold-card > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; cursor: pointer; }
.fold-card > summary::-webkit-details-marker { display: none; }
.fold-card[open] > summary { border-bottom: 1px solid #e3e8f3; background: #fbfcff; }
.fold-title-block { display: grid; gap: 4px; }
.fold-title-block h2 { margin: 0; }
.fold-meta-row { display: flex; align-items: center; gap: 10px; }
.fold-meta { color: #52607a; font-weight: 700; font-size: 14px; white-space: nowrap; }
.fold-chevron::before { content: '▾'; display: inline-block; font-size: 14px; color: #52607a; transition: transform .18s ease; }
.fold-card[open] .fold-chevron::before { transform: rotate(180deg); }
.fold-body { padding: 16px; display: grid; gap: 10px; }
.day-shell { overflow: hidden; }
.day-head { align-items: start; }
.draft-banner { margin-top: 4px; }
.form-grid { align-items: start; }

@media (max-width: 767px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .button-row.compact { width: 100%; justify-content: stretch; }
  .button-row.compact .button { flex: 1 1 calc(50% - 10px); }
  .jump-form { grid-template-columns: 1fr; }
  .calendar-grid { gap: 6px; }
  .calendar-day { min-height: 72px; padding: 8px; border-radius: 14px; }
  .calendar-day-number { font-size: 14px; }
  .day-chip { min-height: 18px; padding: 2px 6px; font-size: 10px; }
}

@media (min-width: 700px) {
  .jump-form { grid-template-columns: minmax(0, 1fr) auto; }
}

@media (min-width: 900px) {
  .app-shell { grid-template-columns: 260px 1fr; grid-template-rows: auto 1fr; align-items: start; }
  .topbar { grid-column: 2; grid-row: 1; align-self: start; }
  .sidebar { position: sticky; transform: none; width: auto; padding: 20px; margin: 16px 0 16px 16px; height: calc(100vh - 32px); border-radius: 20px; box-shadow: 0 8px 24px rgba(19,30,61,.04); grid-column: 1; grid-row: 1 / span 2; align-self: start; }
  .menu-button, .overlay { display: none; }
  .content { grid-column: 2; grid-row: 2; align-self: start; }
}
