:root {
  color-scheme: light;
  --background: #f5f5f7;
  --surface: #ffffff;
  --surface-muted: #f0f0f2;
  --text: #1d1d1f;
  --secondary: #6e6e73;
  --line: #d8d8dc;
  --blue: #007aff;
  --blue-pressed: #0066d6;
  --green: #248a3d;
  --orange: #c93400;
  --red: #d70015;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--background);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(216, 216, 220, 0.85);
  background: rgba(245, 245, 247, 0.92);
  backdrop-filter: saturate(180%) blur(18px);
}
.header-inner, .intro, .content-grid, .footer-inner {
  width: min(1160px, calc(100% - 40px));
  margin-inline: auto;
}
.header-inner {
  min-height: 64px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
}
.brand img { border-radius: 8px; }
.section-nav {
  display: flex;
  align-items: center;
  gap: 28px;
  color: var(--secondary);
  font-size: 14px;
}
.section-nav a { text-decoration: none; }
.section-nav a:hover { color: var(--text); }
.header-compose { justify-self: end; }

.primary-button {
  min-height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
}
.primary-button:hover { background: var(--blue-pressed); }
.primary-button:disabled { cursor: default; opacity: 0.55; }
.text-button {
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 550;
}
.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 28px;
  line-height: 32px;
}

.intro {
  min-height: 250px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 64px 0 44px;
  border-bottom: 1px solid var(--line);
}
.today-label, .section-kicker {
  margin: 0 0 8px;
  color: var(--secondary);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}
.intro h1 {
  max-width: 720px;
  margin: 0;
  font-size: 48px;
  line-height: 1.13;
  font-weight: 680;
}
.daily-quote {
  max-width: 680px;
  margin: 24px 0 0;
  padding-left: 16px;
  border-left: 2px solid var(--blue);
  color: var(--secondary);
  font-size: 14px;
}
.daily-quote p { margin: 2px 0; }
.daily-quote cite { display: block; margin-top: 7px; color: var(--text); font-size: 13px; font-style: normal; }
.intro-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.intro-compose { min-width: 118px; }
.business-switch {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.business-switch:disabled { cursor: default; opacity: 0.5; }
.switch-track {
  position: relative;
  width: 46px;
  height: 28px;
  flex: 0 0 46px;
  border-radius: 14px;
  background: #8e8e93;
  transition: background 180ms ease;
}
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.24);
  transition: transform 180ms ease;
}
.business-switch[aria-checked="true"] { color: var(--text); }
.business-switch[aria-checked="true"] .switch-track { background: #34c759; }
.business-switch[aria-checked="true"] .switch-thumb { transform: translateX(18px); }
.business-switch:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; border-radius: 4px; }

.composer-section { width: 100%; padding-bottom: 38px; scroll-margin-top: 76px; }
.composer-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.composer-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 12px;
}
.composer-heading h2 { margin: 0; font-size: 24px; line-height: 1.2; }
.composer-heading > span { padding-top: 5px; color: var(--secondary); font-size: 13px; }
.markdown-editor {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.markdown-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  background: var(--background);
}
.format-tools { display: flex; align-items: center; gap: 3px; }
.format-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
}
.format-button:hover, .emoji-toggle[aria-expanded="true"] { background: #e5e5e9; color: var(--blue); }
.format-button:disabled { cursor: default; opacity: 0.35; }
.format-italic { font-family: Georgia, serif; font-style: italic; }
.format-code { font-size: 10px; }
.emoji-toggle { font-size: 19px; font-weight: 400; }
.mode-control {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 104px;
  padding: 2px;
  border-radius: 7px;
  background: #e5e5e9;
}
.mode-button {
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--secondary);
  font-size: 12px;
}
.mode-button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.editor-wrap { position: relative; }
.emoji-menu {
  position: absolute;
  z-index: 5;
  top: 10px;
  right: 10px;
  width: min(286px, calc(100% - 20px));
  display: grid;
  grid-template-columns: repeat(6, 40px);
  justify-content: center;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.emoji-option {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 22px;
}
.emoji-option:hover { background: var(--surface-muted); }
.composer-footer {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 8px;
  color: var(--secondary);
  font-size: 12px;
}
.composer-footer .form-error { margin-top: 3px; }
.composer-footer .primary-button { min-width: 112px; }
.footer-meta { min-width: 112px; }
.publish-row {
  display: grid;
  grid-template-columns: minmax(130px, 180px) auto;
  align-items: center;
  gap: 8px;
}
.publish-row input { height: 40px; }
.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;
}
.counter-separator { padding-inline: 7px; }
.markdown-editor textarea {
  min-height: 150px;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  box-shadow: none;
  resize: vertical;
}
.markdown-editor textarea:focus { border: 0; box-shadow: inset 0 0 0 2px rgba(0, 122, 255, 0.2); }
.markdown-preview { min-height: 150px; padding: 16px; background: var(--surface); }

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 740px) 340px;
  justify-content: space-between;
  gap: 40px;
  padding-block: 52px 80px;
}
.section-heading, .panel-heading, .panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-heading { min-height: 54px; margin-bottom: 24px; }
.section-heading h2, .tool-panel h2 { margin: 0; font-size: 24px; line-height: 1.2; }
.timeline-actions { display: flex; justify-content: flex-end; }
.timeline-actions:has(.hidden) { display: none; }
.timeline { position: relative; }
.timeline::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 0;
  left: 9px;
  width: 1px;
  background: var(--line);
}
.day-group { position: relative; padding: 0 0 34px 40px; }
.day-group::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 4px;
  width: 10px;
  height: 10px;
  border: 3px solid var(--background);
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 1px var(--blue);
}
.day-heading { margin: 0 0 12px; font-size: 15px; font-weight: 650; }
.entry-card {
  margin-bottom: 12px;
  padding: 18px 18px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.entry-card:last-child { margin-bottom: 0; }
.entry-content {
  margin: 0;
  color: #2c2c2e;
  line-height: 1.75;
  overflow-wrap: anywhere;
}
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body p { margin: 0 0 11px; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 20px 0 10px; line-height: 1.3; }
.markdown-body h1 { font-size: 24px; }
.markdown-body h2 { font-size: 21px; }
.markdown-body h3 { font-size: 18px; }
.markdown-body ul, .markdown-body ol { margin: 8px 0 12px; padding-left: 24px; }
.markdown-body blockquote { margin: 12px 0; padding-left: 13px; border-left: 3px solid var(--line); color: var(--secondary); }
.markdown-body code { padding: 2px 5px; border-radius: 4px; background: var(--surface-muted); font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.9em; }
.markdown-body pre { overflow-x: auto; padding: 12px; border-radius: 6px; background: #1d1d1f; color: #f5f5f7; }
.markdown-body pre code { padding: 0; background: transparent; color: inherit; }
.markdown-body a { color: var(--blue); }
.entry-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  color: var(--secondary);
  font-size: 13px;
}
.delete-button {
  min-width: 44px;
  min-height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--secondary);
  font-size: 13px;
}
.delete-button:hover { color: var(--red); }

.side-column { display: flex; flex-direction: column; gap: 24px; }
.tool-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.calendar-panel { padding: 18px; }
.panel-heading h2 { font-size: 17px; }
.weekdays, .calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 38px);
  justify-content: center;
  text-align: center;
}
.weekdays { margin-top: 18px; color: var(--secondary); font-size: 12px; }
.calendar-grid { margin-top: 6px; row-gap: 3px; }
.calendar-day {
  position: relative;
  width: 36px;
  height: 36px;
  justify-self: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}
.calendar-day:hover { background: var(--surface-muted); }
.calendar-day.outside { color: #aeaeb2; }
.calendar-day.today { box-shadow: inset 0 0 0 1px var(--blue); color: var(--blue); font-weight: 650; }
.calendar-day.selected { background: var(--blue); color: #fff; box-shadow: none; }
.calendar-day.has-entry::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--blue);
  transform: translateX(-50%);
}
.calendar-day.selected::after { background: #fff; }

.resources-panel { padding: 22px 18px 8px; }
.panel-title-row { margin-bottom: 20px; }
.resource-group { margin-bottom: 22px; }
.resource-group h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 7px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 650;
}
.resource-dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-blue { background: var(--blue); }
.dot-green { background: var(--green); }
.dot-orange { background: var(--orange); }
.resource-group a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  border-bottom: 1px solid #ececef;
  text-decoration: none;
  font-size: 14px;
}
.resource-group a:hover { color: var(--blue); }
.resource-group a:last-child { border-bottom: 0; }
.resource-group a span:last-child { color: var(--secondary); }

.empty-state { padding: 12px 0 40px 40px; text-align: center; }
.empty-state h3 { margin: 0 0 18px; font-size: 18px; }
.hidden { display: none !important; }

footer { border-top: 1px solid var(--line); background: var(--surface); }
.footer-inner {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: var(--secondary);
  font-size: 13px;
}
.footer-inner a { text-decoration: none; }
.footer-inner a:hover { color: var(--blue); }

.dialog-shell {
  width: min(620px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.dialog-shell::backdrop { background: rgba(0, 0, 0, 0.28); backdrop-filter: blur(4px); }
.dialog-content { padding: 0 22px 22px; }
.dialog-header {
  min-height: 62px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.dialog-header h2 { margin: 0; font-size: 17px; }
.dialog-header .text-button:last-child { justify-self: end; }
.action-text { font-weight: 650; }
.destructive-text { color: var(--red); }
.field-label { display: block; margin: 14px 0 7px; color: var(--secondary); font-size: 13px; font-weight: 600; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: var(--background);
  color: var(--text);
}
input { height: 44px; padding: 0 12px; }
select { height: 44px; padding: 0 34px 0 12px; }
textarea { min-height: 260px; padding: 13px; resize: vertical; line-height: 1.65; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12); }
.editor-footer { display: flex; justify-content: space-between; margin-top: 9px; color: var(--secondary); font-size: 12px; }
.form-error { min-height: 20px; margin: 12px 0 0; color: var(--red); font-size: 13px; }
.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }
.compact-dialog { width: min(430px, calc(100% - 32px)); }
.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  min-width: 180px;
  max-width: calc(100% - 40px);
  padding: 11px 16px;
  border-radius: 8px;
  background: rgba(29, 29, 31, 0.92);
  color: #fff;
  text-align: center;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1040px) {
  .content-grid { grid-template-columns: 1fr; gap: 44px; }
  .timeline-section { width: min(740px, 100%); }
  .side-column { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
}

@media (max-width: 820px) {
  .header-inner, .intro, .content-grid, .footer-inner { width: min(100% - 28px, 680px); }
  .header-inner { grid-template-columns: 1fr auto; }
  .section-nav { display: none; }
  .intro { min-height: 210px; padding: 44px 0 34px; }
  .intro h1 { font-size: 38px; }
  .content-grid { padding-block: 40px 64px; }
}

@media (max-width: 580px) {
  .header-inner { min-height: 58px; }
  .brand img { width: 32px; height: 32px; }
  .header-compose { min-height: 36px; padding-inline: 14px; }
  .intro { min-height: 190px; align-items: flex-start; flex-direction: column; gap: 24px; }
  .intro h1 { font-size: 34px; }
  .daily-quote { margin-top: 18px; font-size: 13px; }
  .intro-actions { width: 100%; justify-content: space-between; gap: 12px; }
  .intro-compose { flex: 1 1 auto; }
  .composer-section { padding-bottom: 32px; }
  .composer-card { padding: 18px 16px; }
  .composer-heading { margin-bottom: 8px; }
  .composer-heading h2 { font-size: 22px; }
  .markdown-toolbar { align-items: flex-start; flex-wrap: wrap; }
  .format-tools { width: 100%; justify-content: space-between; }
  .mode-control { margin-left: auto; }
  .markdown-editor textarea, .markdown-preview { min-height: 150px; }
  .composer-footer { align-items: stretch; flex-direction: column; gap: 8px; padding-top: 12px; }
  .publish-row { grid-template-columns: minmax(0, 1fr) 112px; }
  .composer-footer .primary-button { width: 100%; }
  .side-column { grid-template-columns: 1fr; }
  .day-group { padding-left: 30px; }
  .timeline::before { left: 7px; }
  .day-group::before { left: 2px; }
  .entry-card { padding: 16px; }
  .empty-state { padding-left: 30px; }
  .footer-inner { min-height: 104px; flex-direction: column; justify-content: center; gap: 6px; }
  .dialog-shell { width: 100%; max-height: calc(100dvh - 12px); margin: auto 0 0; border-radius: 8px 8px 0 0; }
  .dialog-content { padding-inline: 16px; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .switch-track, .switch-thumb { transition: none; }
  .toast { transition: none; }
}
