:root {
  --bg: #f4f6fb;
  --card: #fff;
  --text: #1f2430;
  --muted: #5b6475;
  --border: #d9dee8;
  --accent: #1f5fbf;
  --accent-dark: #174a96;
  --code-bg: #f7f8fa;
  --ok: #1e7d4f;
  --danger: #b3261e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header, main {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 1rem;
}

header { padding-top: 2rem; }

h1 { margin: 0 0 0.5rem; font-size: 1.8rem; }
h2 { margin: 0; font-size: 1.2rem; }

.lead { color: var(--muted); margin: 0 0 1rem; }

.how {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
}
.how summary { cursor: pointer; font-weight: 600; }
.how ol { padding-left: 1.25rem; }
.how p { margin: 0.5rem 0; }

code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 0.25rem;
  font-size: 0.9em;
}

.memory, .card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.memory { border-left: 4px solid var(--accent); }

.memory-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

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

#brief {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.85rem;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--code-bg);
}

.memory-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.spacer { flex: 1; }
.toggle { display: flex; align-items: center; gap: 0.4rem; font-size: 0.95rem; }

button {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:hover { background: var(--accent-dark); }
button.secondary { background: #fff; color: var(--accent); }
button.secondary:hover { background: #eef3fc; }
button.danger { border-color: var(--danger); color: var(--danger); }
button.danger:hover { background: #fdeceb; }
button.copied { background: var(--ok); border-color: var(--ok); }

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}
.toc a {
  font-size: 0.85rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
}
.toc a:hover { border-color: var(--accent); color: var(--accent); }

.card { scroll-margin-top: 1rem; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.card h2 { font-size: 1.15rem; }
.card h2 .num { color: var(--muted); font-weight: 500; margin-right: 0.35rem; }
.desc { color: var(--muted); margin: 0.35rem 0 0.6rem; }

.tags { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.tag {
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: #eef3fc;
  color: var(--accent-dark);
}

.prompt-box {
  margin: 0;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.8rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
}
.prompt-box.expanded { max-height: none; }

.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
}
.link-btn:hover { background: none; text-decoration: underline; }
.hint { color: var(--muted); font-size: 0.8rem; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
#toast.show { opacity: 1; }

@media (max-width: 600px) {
  .card-head { flex-direction: column; }
  .memory-actions .spacer { display: none; }
}
