:root {
  --bg: #d8efc8;
  --bg-elev: #f4faef;
  --bg-sheet: #f7fbf4;
  --ink: #1d2a1b;
  --muted: #5c6e58;
  --line: #b7d0ad;
  --accent: #2f7d3a;
  --accent-2: #3d8b45;
  --danger: #b4453a;
  --shadow: 0 18px 40px rgba(40, 80, 40, 0.12);
  --radius: 16px;
  --font: "Figtree", system-ui, sans-serif;
  --serif: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 16px 72px;
}

.login-gate {
  position: relative;
  z-index: 40;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  border-radius: 20px;
}
.login-card h1 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 2.4rem;
  margin: 0 0 12px;
  text-align: center;
}
.login-card .primary { width: 100%; margin-top: 4px; }
.login-error { color: var(--danger); font-size: 0.95rem; font-weight: 600; margin: 0 0 10px; min-height: 1.2em; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.top-actions { display: flex; align-items: center; gap: 8px; }

.brand { display: flex; gap: 14px; align-items: center; flex: 1; min-width: 0; }
.quote-box {
  flex: 1;
  min-width: 160px;
  max-width: 480px;
  margin: 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--ink);
}
.mark {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: #f4faef;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.4rem;
}
.brand h1 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.65rem;
  margin: 0;
  letter-spacing: -0.02em;
}
.tag { margin: 0; color: var(--muted); font-size: 0.85rem; }

#search {
  width: 8.5rem;
  flex: 0 0 8.5rem;
  font-size: 0.78rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  padding: 4px 10px;
}

button, input, textarea { font: inherit; }
.primary, .ghost, .danger {
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 600;
}
.primary { background: var(--accent); color: #f4faef; }
.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.compact { padding: 4px 10px; font-size: 0.85rem; }
.hidden { display: none !important; }
.quiet { color: var(--muted); font-size: 0.85rem; margin: 8px 0 0; }

.status { color: var(--muted); font-size: 0.9rem; }

.workspace {
  display: grid;
  grid-template-columns: 260px 180px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.todo {
  position: sticky;
  top: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 240px;
  max-height: calc(100vh - 40px);
  overflow: auto;
}
.todo h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.2rem;
  margin: 0 0 10px;
}
.week {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.week:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.week-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 8px;
}
.week.past .week-label { color: var(--muted); font-weight: 600; }
.more-weeks { width: 100%; margin-top: 10px; }
.week-form { display: flex; gap: 6px; margin-bottom: 8px; }
#todo-form { display: flex; gap: 6px; margin-bottom: 10px; }
#todo-input, .week-form input {
  flex: 1;
  min-width: 0;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.85rem;
}
#todo-list, .todo-week-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cover-preview {
  width: 72px;
  height: 96px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 6px;
  display: block;
}
.card-tools {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.todo-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 8px;
  font-size: 0.88rem;
}
.todo-item.done .todo-text { text-decoration: line-through; color: var(--muted); }
.todo-item input[type="checkbox"] { margin-top: 3px; }
.todo-item .linkish { font-size: 0.7rem; }
.todo-text {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0;
  resize: none;
}

.kinds {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
}
.kind-btn {
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
}
.kind-btn:hover { background: rgba(47, 125, 58, 0.1); }
.kind-btn.active {
  background: var(--accent);
  color: #f4faef;
}
.pane {
  background: rgba(255, 255, 255, 0.28);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px 18px;
  min-height: 280px;
}
.fn-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.fn-head h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.25rem;
  margin: 0;
}
.fn-list { display: grid; gap: 8px; }
.card-wrap { display: grid; gap: 4px; justify-items: start; }
.card-edit { margin-left: 4px; }

.month-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.month-line::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: inherit;
}
.card:hover { border-color: var(--accent-2); }
.cover {
  width: 44px; height: 60px;
  border-radius: 6px;
  object-fit: cover;
  background: #cfe6c4;
}
.cover.placeholder {
  display: grid; place-items: center;
  color: var(--accent-2);
  font-family: var(--serif);
  font-size: 1.1rem;
}
.card h3 { margin: 0 0 2px; font-size: 0.98rem; }
.meta { color: var(--muted); font-size: 0.72rem; display: flex; gap: 6px; flex-wrap: wrap; }
.excerpt {
  margin: 6px 0 0;
  color: #33462f;
  font-size: 0.85rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.overlay {
  position: fixed; inset: 0;
  background: rgba(30, 50, 30, 0.45);
  display: grid;
  place-items: end center;
  z-index: 20;
  padding: 16px;
}
.sheet {
  background: var(--bg-sheet);
  width: min(560px, 100%);
  max-height: min(92vh, 860px);
  overflow: auto;
  border-radius: 20px 20px 12px 12px;
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  position: relative;
}
.sheet h2, .sheet h3 { font-family: var(--serif); font-weight: 500; margin: 0 0 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); margin-bottom: 12px; }
.field input, .field textarea, .comment-form textarea {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
}
.kind-row { display: flex; gap: 16px; margin-bottom: 14px; color: var(--muted); flex-wrap: wrap; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.icon-close {
  position: absolute; top: 12px; right: 12px;
  background: transparent; border: 0; color: var(--muted);
  font-size: 1.6rem; cursor: pointer;
}
.detail .lede { white-space: pre-wrap; }
.comments { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 16px; }
#comment-list { list-style: none; padding: 0; margin: 0 0 12px; }
#comment-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.comment-meta { color: var(--muted); font-size: 0.75rem; margin-bottom: 4px; display: flex; justify-content: space-between; }
.comment-form { display: grid; gap: 8px; }
.linkish {
  background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; font-size: 0.75rem;
}

@media (max-width: 1000px) {
  .workspace { grid-template-columns: 220px minmax(0, 1fr); }
  .kinds { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; position: static; }
}
@media (max-width: 760px) {
  .workspace { grid-template-columns: 1fr; }
  .todo, .kinds { position: static; max-height: none; }
}
@media (min-width: 720px) {
  .overlay { place-items: center; }
  .sheet { border-radius: 20px; }
}
