:root {
  color-scheme: light;
  --ink: #171717;
  --muted: #737373;
  --line: rgba(255, 255, 255, 0.54);
  --paper: rgba(255, 255, 255, 0.48);
  --paper-strong: rgba(255, 255, 255, 0.7);
  --field: rgba(255, 255, 255, 0.48);
  --accent: #262626;
  --accent-strong: #171717;
  --accent-soft: rgba(23, 23, 23, 0.08);
  --warm: #737373;
  --glass-border: rgba(255, 255, 255, 0.58);
  --glass-shadow: 0 22px 60px rgba(0, 0, 0, 0.12);
  --inner-line: rgba(23, 23, 23, 0.08);
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.16);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(118deg, rgba(244, 244, 245, 0.96) 0%, rgba(255, 255, 255, 0.92) 38%, rgba(229, 229, 229, 0.76) 72%, rgba(250, 250, 250, 0.94) 100%),
    linear-gradient(180deg, #f5f5f5, #ededed);
  background-attachment: fixed;
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 22px;
  min-height: 100vh;
  padding: 22px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 44px);
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.36)),
    rgba(255, 255, 255, 0.4);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(24px) saturate(145%);
}

.brand {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 14px;
  background:
    linear-gradient(145deg, rgba(38, 38, 38, 0.98), rgba(10, 10, 10, 0.96));
  color: white;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
  font-size: 24px;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.quick-actions,
.tag-line,
.editor-topline,
.meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.primary-action,
.install-action,
.backup-panel button,
.import-button,
.calendar-head button,
.markdown-toolbar button {
  border: 0;
  border-radius: 12px;
  min-height: 44px;
  transition:
    transform 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex: 1;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background:
    linear-gradient(145deg, rgba(38, 38, 38, 1), rgba(10, 10, 10, 0.98));
  color: white;
  font-weight: 750;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.18);
}

.primary-action span {
  font-size: 24px;
  line-height: 1;
}

.install-action {
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  background: rgba(255, 255, 255, 0.5);
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 850;
}

.search-box svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-action:hover,
.install-action:hover,
.backup-panel button:hover,
.import-button:hover,
.calendar-head button:hover,
.markdown-toolbar button:hover {
  transform: translateY(-1px);
}

.search-box {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  min-height: 46px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.46);
  color: var(--muted);
}

.search-box input,
.title-field input,
.tag-line input,
.date-field input,
.meta-row select {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.entry-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 236px;
  overflow: auto;
  padding-right: 2px;
}

.entry-button {
  position: relative;
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.28);
  color: var(--ink);
  text-align: left;
}

.entry-button:hover,
.entry-button.active {
  border-color: rgba(23, 23, 23, 0.18);
  background: rgba(255, 255, 255, 0.56);
}

.entry-button::before {
  content: "";
  position: absolute;
  inset: 12px auto 12px 0;
  width: 3px;
  border-radius: 999px;
  background: var(--mood-color, #737373);
}

.entry-button-title {
  overflow: hidden;
  font-size: 15px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-button-meta {
  color: var(--muted);
  font-size: 13px;
}

.calendar-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.28));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.48);
}

.calendar-panel[hidden] {
  display: none;
}

.calendar-head {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 8px;
}

.calendar-head strong {
  text-align: center;
  font-size: 15px;
}

.calendar-head button {
  display: grid;
  place-items: center;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.46);
  color: var(--accent-strong);
  font-size: 22px;
  line-height: 1;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.calendar-weekdays span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

.calendar-day {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.22);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.calendar-day.empty {
  pointer-events: none;
}

.calendar-day.has-entry {
  background: rgba(255, 255, 255, 0.46);
  border-color: rgba(23, 23, 23, 0.12);
}

.calendar-day.has-entry::after {
  content: "";
  position: absolute;
  bottom: 5px;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--mood-color, #737373);
}

.calendar-day.selected {
  background:
    linear-gradient(145deg, rgba(38, 38, 38, 1), rgba(10, 10, 10, 0.98));
  color: white;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.calendar-day.selected::after {
  background: white;
}

.insight-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0.28));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.48);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.section-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.memory-list,
.mood-chart {
  display: grid;
  gap: 10px;
}

.memory-item {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.memory-item strong {
  font-size: 14px;
}

.memory-item span,
.empty-insight {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.mood-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.mood-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.52);
}

.mood-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--mood-color, #737373);
}

.backup-panel {
  display: block;
}

.backup-panel button,
.import-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.46);
  color: var(--accent-strong);
  font-weight: 700;
}

.backup-menu {
  position: relative;
}

.backup-menu summary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.46);
  color: var(--accent-strong);
  font-weight: 850;
  list-style: none;
  cursor: pointer;
}

.backup-menu summary::-webkit-details-marker {
  display: none;
}

.backup-menu summary::after {
  content: "⌄";
  margin-left: 8px;
  color: var(--muted);
}

.backup-menu[open] summary::after {
  transform: rotate(180deg);
}

.backup-menu button,
.backup-menu .import-button {
  width: 100%;
  margin-top: 8px;
}

.workspace {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: calc(100vh - 44px);
}

.editor-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  padding: clamp(24px, 4vw, 44px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.42)),
    rgba(255, 255, 255, 0.42);
  box-shadow: var(--shadow);
  backdrop-filter: blur(26px) saturate(145%);
}

.editor-topline {
  justify-content: space-between;
  flex-wrap: wrap;
}

.date-field,
.meta-row label,
.tag-line label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.date-field input,
.meta-row select,
.tag-line input {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 12px;
  background: var(--field);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}

.title-field input {
  min-height: 72px;
  color: var(--ink);
  font-size: clamp(30px, 5vw, 58px);
  font-weight: 850;
  letter-spacing: 0;
}

.title-field input::placeholder,
.body-field textarea::placeholder,
.tag-line input::placeholder,
.search-box input::placeholder {
  color: #8a938f;
}

.markdown-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.markdown-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.44);
  color: var(--accent-strong);
  font-size: 15px;
  font-weight: 850;
}

.markdown-toolbar button[aria-pressed="true"] {
  background: var(--accent);
  color: white;
}

.body-field {
  display: flex;
  flex: 1;
  min-height: 330px;
}

.body-field textarea {
  flex: 1;
  width: 100%;
  min-height: 100%;
  resize: none;
  border: 0;
  outline: 0;
  background:
    linear-gradient(transparent 35px, rgba(23, 23, 23, 0.08) 36px),
    transparent;
  background-size: 100% 36px;
  color: var(--ink);
  font-size: 19px;
  line-height: 36px;
}

.markdown-preview {
  flex: 1;
  width: 100%;
  min-height: 100%;
  overflow: auto;
  color: var(--ink);
  font-size: 19px;
  line-height: 1.75;
}

.markdown-preview h3 {
  margin: 0 0 14px;
  font-size: 28px;
  letter-spacing: 0;
}

.markdown-preview p,
.markdown-preview ul,
.markdown-preview blockquote {
  margin: 0 0 14px;
}

.markdown-preview ul {
  padding-left: 24px;
}

.markdown-preview blockquote {
  padding: 2px 0 2px 14px;
  border-left: 4px solid var(--accent);
  color: var(--muted);
}

.markdown-preview strong {
  color: var(--accent-strong);
}

.tag-line {
  justify-content: space-between;
  flex-wrap: wrap;
}

.tag-line label {
  min-width: min(100%, 360px);
  flex: 1;
}

#saveState {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--warm);
  font-size: 13px;
  font-weight: 850;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(21, 35, 31, 0.12);
  }

  .entry-list {
    max-height: 220px;
  }

  .workspace {
    padding: 18px;
  }
}

@media (max-width: 560px) {
  .sidebar {
    padding: 20px;
  }

  .brand {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .brand-mark {
    width: 44px;
    height: 44px;
    font-size: 21px;
  }

  .editor-card {
    padding: 18px;
  }

  .meta-row {
    align-items: stretch;
    flex-direction: column;
  }

  .meta-row label {
    width: 100%;
  }

  .title-field input {
    min-height: 54px;
  }

  .body-field {
    min-height: 300px;
  }
}
