:root {
  --bg: #f3f0e8;
  --bg-soft: #eae4d6;
  --card: #fffdf8;
  --ink: #1c1917;
  --muted: #7a7368;
  --line: #e4dccb;
  --accent: #2f5d50;
  --accent-soft: #dce8e3;
  --warn: #b08968;
  --ok: #6a994e;
  --shadow: 0 10px 30px rgba(44, 36, 24, 0.06);
  --radius: 18px;
  --hour-h: 72px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161412;
    --bg-soft: #201c18;
    --card: #221e1a;
    --ink: #f4efe6;
    --muted: #a89f91;
    --line: #3a342c;
    --accent: #8fbfb0;
    --accent-soft: #24332e;
    --warn: #d4b48c;
    --ok: #98c47a;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  overscroll-behavior: none;
}

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

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(12px + var(--safe-top)) 16px calc(92px + var(--safe-bottom));
}

.brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.brand h1 {
  margin: 0;
  font-family: "Songti SC", "Source Han Serif SC", "Noto Serif SC", serif;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.date-nav .label {
  flex: 1;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}

.today-chip {
  height: 36px;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--accent);
  color: #fffdf8;
  font-size: 13px;
  font-weight: 600;
}

.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 12px;
}

.progress .bar {
  flex: 1;
  height: 6px;
  border-radius: 99px;
  background: var(--bg-soft);
  overflow: hidden;
}

.progress .bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.25s ease;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 14px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.card-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.meta {
  color: var(--muted);
  font-size: 12px;
}

.focus-row {
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.focus-row:first-of-type {
  border-top: 0;
}

.focus-num {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}

.focus-row input {
  width: 100%;
  border: 0;
  background: transparent;
  outline: none;
  padding: 8px 0;
  font-size: 16px;
}

.focus-row input::placeholder {
  color: #b4ab9d;
}

.check {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  display: grid;
  place-items: center;
  background: transparent;
}

.check.done {
  background: var(--accent);
  border-color: var(--accent);
  color: #fffdf8;
}

.check svg {
  width: 12px;
  height: 12px;
}

.now-card .title {
  font-size: 16px;
  font-weight: 650;
  margin: 0 0 4px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink);
  font-size: 12px;
  border: 1px solid transparent;
}

.chip.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

.timeline-wrap {
  position: relative;
}

.timeline-legend {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.timeline {
  position: relative;
  height: calc(24 * var(--hour-h));
  user-select: none;
  touch-action: pan-y;
}

.timeline.selecting {
  touch-action: none;
}

.hour {
  display: grid;
  grid-template-columns: 46px 1fr 36px;
  height: var(--hour-h);
}

.hour-label {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  padding-top: 0;
  transform: translateY(-6px);
}

.hour-track {
  border-top: 1px solid var(--line);
  background:
    linear-gradient(to bottom, transparent 50%, color-mix(in srgb, var(--line) 70%, transparent) 50%, color-mix(in srgb, var(--line) 70%, transparent) calc(50% + 1px), transparent calc(50% + 1px));
}

.hour.sleep .hour-track {
  background-color: color-mix(in srgb, var(--bg-soft) 70%, transparent);
}

.now-line {
  position: absolute;
  left: 46px;
  right: 36px;
  height: 2px;
  background: #c45c4a;
  z-index: 3;
  pointer-events: none;
}

.now-line::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #c45c4a;
}

.block {
  position: absolute;
  left: 50px;
  right: 40px;
  border-radius: 12px;
  padding: 8px 10px;
  color: #fffdf8;
  overflow: hidden;
  z-index: 2;
  box-shadow: 0 6px 16px rgba(47, 93, 80, 0.18);
}

.block.done {
  opacity: 0.55;
}

.block .b-title {
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.block .b-time,
.block .b-tag {
  font-size: 11px;
  opacity: 0.9;
}

.rail-check {
  position: absolute;
  right: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--card);
  z-index: 5;
  display: grid;
  place-items: center;
  color: var(--accent);
}

.rail-check.done {
  background: var(--accent);
  border-color: var(--accent);
  color: #fffdf8;
}

.rail-check svg {
  width: 12px;
  height: 12px;
}

.selection {
  position: absolute;
  left: 50px;
  right: 40px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  border: 1.5px dashed var(--accent);
  z-index: 4;
  pointer-events: none;
  display: none;
}

.selection.show {
  display: block;
}

.selection span {
  position: sticky;
  top: 8px;
  display: inline-block;
  margin: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fffdf8;
  font-size: 12px;
  font-weight: 650;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.day-cell {
  border-radius: 12px;
  padding: 8px 0;
  text-align: center;
  background: var(--bg-soft);
  border: 1px solid transparent;
}

.day-cell.today {
  border-color: var(--accent);
}

.day-cell .wd {
  font-size: 11px;
  color: var(--muted);
}

.day-cell .num {
  font-size: 14px;
  font-weight: 700;
  margin: 2px 0 6px;
}

.mini-bar {
  width: 8px;
  height: 28px;
  margin: 0 auto;
  border-radius: 99px;
  background: color-mix(in srgb, var(--accent) 18%, var(--bg));
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}

.mini-bar > span {
  display: block;
  width: 100%;
  background: var(--accent);
}

.note {
  width: 100%;
  min-height: 72px;
  border: 0;
  resize: vertical;
  background: transparent;
  outline: none;
  line-height: 1.55;
}

.month-weeks {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.week-card {
  width: 100%;
  text-align: left;
  padding: 12px;
  border-radius: 14px;
  background: var(--bg-soft);
  border: 1px solid transparent;
}

.week-card.current {
  border-color: var(--accent);
}

.week-card .wk-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.week-card .wk-name {
  font-size: 14px;
  font-weight: 650;
}

.week-card .wk-meta {
  font-size: 11px;
  color: var(--muted);
}

.week-card .wk-items {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.week-pills {
  display: flex;
  gap: 4px;
  margin-top: 10px;
}

.week-pills i {
  flex: 1;
  height: 5px;
  border-radius: 99px;
  background: var(--line);
}

.week-pills i.filled {
  background: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.week-pills i.done {
  background: var(--accent);
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 6px;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  z-index: 10;
}

.tab {
  height: 44px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.tab.active {
  background: var(--card);
  color: var(--accent);
  border: 1px solid var(--line);
}

.hidden {
  display: none !important;
}

.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 12, 0.38);
  z-index: 20;
  display: none;
}

.sheet-mask.show {
  display: block;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(110%);
  width: min(480px, 100%);
  background: var(--card);
  border-radius: 22px 22px 0 0;
  padding: 12px 16px calc(18px + var(--safe-bottom));
  z-index: 21;
  transition: transform 0.22s ease;
}

.sheet.show {
  transform: translateX(-50%) translateY(0);
}

.grabber {
  width: 36px;
  height: 4px;
  border-radius: 99px;
  background: var(--line);
  margin: 4px auto 12px;
}

.sheet h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input[type="text"],
.field select {
  width: 100%;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 0 12px;
  outline: none;
  font-size: 16px;
}

.times {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
}

.colors {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-dot {
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
}

.color-dot.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 8px;
  margin-top: 8px;
}

.btn {
  height: 44px;
  border-radius: 14px;
  font-weight: 650;
}

.btn.primary {
  background: var(--accent);
  color: #fffdf8;
}

.btn.ghost {
  background: var(--bg-soft);
}

.btn.danger {
  color: #b42318;
}

.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 14px;
}

.banner button {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.about p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: 12px;
}

.focus-row.done input {
  text-decoration: line-through;
  color: var(--muted);
}

.empty-timeline {
  position: absolute;
  left: 58px;
  right: 48px;
  top: 40%;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
  z-index: 1;
}
