:root {
  --bg: #f4f1ea;
  --paper: #fffcf7;
  --ink: #1f1b16;
  --muted: #7a7368;
  --line: #e4ddd2;
  --today: #2f6f5e;
  --today-soft: #e4f2ec;
  --selected: #1f1b16;
  --danger: #a33b2b;
  --shadow: 0 10px 30px rgba(50, 40, 20, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

body {
  padding: 12px 12px calc(92px + env(safe-area-inset-bottom));
}

.app {
  width: min(480px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-title {
  margin: 0;
  min-width: 9.5em;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.icon-btn,
.ghost-btn,
.primary-btn,
.danger-btn {
  border: 0;
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  min-height: 40px;
  padding: 0 14px;
  font: inherit;
  cursor: pointer;
}

.icon-btn {
  width: 40px;
  padding: 0;
  font-size: 20px;
  box-shadow: var(--shadow);
}

.ghost-btn {
  background: transparent;
  color: var(--muted);
}

.calendar {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 14px 10px 12px;
  box-shadow: var(--shadow);
}

.weekdays,
.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.weekdays span {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding-bottom: 8px;
}

.day {
  appearance: none;
  border: 0;
  background: transparent;
  min-height: 48px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.day:disabled {
  visibility: hidden;
}

.day .num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 15px;
}

.day.is-today .num {
  background: var(--today-soft);
  color: var(--today);
  font-weight: 700;
}

.day.is-selected .num {
  background: var(--selected);
  color: #fff;
}

.day.is-today.is-selected .num {
  background: var(--today);
}

.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: transparent;
}

.day.has-entries .dot {
  background: var(--today);
}

.day.is-selected.has-entries .dot {
  background: rgba(255, 255, 255, 0.85);
}

.day-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 18px 6px 10px;
}

.day-header h2 {
  margin: 0;
  font-size: 18px;
}

.day-header .hint {
  color: var(--muted);
  font-size: 13px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 22px 16px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.entry {
  background: var(--paper);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.entry-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.time {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.entry-actions {
  display: flex;
  gap: 4px;
}

.entry-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.content {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  font-size: 16px;
}

.edit-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.edit-box textarea,
.edit-box input[type="time"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  background: #fff;
}

.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(244, 241, 234, 0.94);
  backdrop-filter: blur(10px);
}

.composer-inner {
  width: min(480px, 100%);
  margin: 0 auto;
  display: flex;
  gap: 8px;
}

.composer input {
  flex: 1;
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  padding: 0 16px;
  font: inherit;
  font-size: 16px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.primary-btn {
  background: var(--today);
  color: #fff;
  min-width: 48px;
  min-height: 48px;
  font-size: 22px;
  box-shadow: var(--shadow);
}

.danger-btn {
  background: #f8eae7;
  color: var(--danger);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 27, 22, 0.35);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}

.overlay.open {
  display: flex;
}

.sheet {
  width: min(480px, 100%);
  background: var(--paper);
  border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}

.sheet h3 {
  margin: 0 0 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
}

.field input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  font: inherit;
  font-size: 16px;
}

.export-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.export-actions button {
  border: 0;
  background: var(--bg);
  color: var(--ink);
  border-radius: 999px;
  min-height: 44px;
  font: inherit;
  cursor: pointer;
}

.export-actions .primary-btn {
  grid-column: 1 / -1;
  background: var(--today);
  color: #fff;
  font-size: 16px;
}

.banner {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8eae7;
  color: var(--danger);
  font-size: 13px;
}

.banner:empty {
  display: none;
}
